![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
IoT based security system that detects suspicious movements through a motion detector and alerts the user on their gmail. In the presence of motion sensed between 7 to 9 times, the Grove PIR sensor sends an input to the board which is connected to internet via Ethernet. The board publishes the sensor data on IBM IoT foundation, which is known as IBM Watson. The data is then sent to IBM Bluemix which provides real time analysis and the remote time data management and monitoring. For more information : https://developer.ibm.com/recipes/tutorials/mbed-c-client-library-for-ibm-iot-foundation/
Dependencies: C12832 EthernetInterface LM75B MMA7660 MQTT mbed-rtos mbed
Fork of IBMIoTClientEthernetExample by
Diff: main.cpp
- Revision:
- 12:8b480eb8a496
- Parent:
- 11:7a6df9a2dcdc
- Child:
- 13:85801e3b83d3
diff -r 7a6df9a2dcdc -r 8b480eb8a496 main.cpp --- a/main.cpp Tue Mar 10 08:24:52 2015 +0000 +++ b/main.cpp Thu Jul 09 14:35:57 2015 +0000 @@ -30,7 +30,7 @@ #include "rtos.h" // Update this to the next number *before* a commit -#define __APP_SW_REVISION__ "10" +#define __APP_SW_REVISION__ "11" // Configuration values needed to connect to IBM IoT Cloud #define ORG "quickstart" // For a registered connection, replace with your org @@ -250,11 +250,8 @@ while (connect(client, ipstack) != 0) { -#if defined(TARGET_K64F) - red(); -#else Thread red_thread(flashing_red); -#endif + int timeout = getConnTimeout(++retryAttempt); WARN("Retry attempt number %d waiting %d\n", retryAttempt, timeout); @@ -290,29 +287,7 @@ } -#if defined(TARGET_K64F) -int getUUID48(char* buf, int buflen) -{ - unsigned int UUID_LOC_WORD0 = 0x40048060; - unsigned int UUID_LOC_WORD1 = 0x4004805C; - - // Fetch word 0 - uint32_t word0 = *(uint32_t *)UUID_LOC_WORD0; - - // Fetch word 1 - // we only want bottom 16 bits of word1 (MAC bits 32-47) - // and bit 9 forced to 1, bit 8 forced to 0 - // Locally administered MAC, reduced conflicts - // http://en.wikipedia.org/wiki/MAC_address - uint32_t word1 = *(uint32_t *)UUID_LOC_WORD1; - word1 |= 0x00000200; - word1 &= 0x0000FEFF; - - int rc = snprintf(buf, buflen, "%4x%08x", word1, word0); // Device id must be in lower case - - return rc; -} -#else + char* getMac(EthernetInterface& eth, char* buf, int buflen) // Obtain MAC address { strncpy(buf, eth.getMACAddress(), buflen); @@ -322,7 +297,7 @@ memmove(pos, pos + 1, strlen(pos) + 1); return buf; } -#endif + void messageArrived(MQTT::MessageData& md) @@ -368,22 +343,14 @@ led2 = LED2_OFF; // K64F: turn off the main board LED displayMessage("Connecting"); -#if defined(TARGET_K64F) - yellow(); // Don't flash on the K64F, because starting a thread causes the EthernetInterface init call to hang -#else Thread yellow_thread(flashing_yellow); -#endif - + printf("connecting..."); MQTTEthernet ipstack; MQTT::Client<MQTTEthernet, Countdown, MQTT_MAX_PACKET_SIZE> client(ipstack); if (quickstartMode) { -#if defined(TARGET_K64F) - getUUID48(id, sizeof(id)); // getMac doesn't work on the K64F -#else getMac(ipstack.getEth(), id, sizeof(id)); -#endif } attemptConnect(&client, &ipstack);