Sample code that showcases how to use IBMIoTF client library to connect the mbed LPC1768 or FRDM-K64F devices to the IBM Internet of Things Cloud service.
Dependencies: C12832 IBMIoTF LM75B MMA7660
Diff: src/Main.cpp
- Revision:
- 2:2fc985a92cda
- Parent:
- 1:e58533b6bc6b
- Child:
- 3:e7b2f56c4f3f
--- a/src/Main.cpp Fri Nov 06 15:16:46 2015 +0000 +++ b/src/Main.cpp Tue Jan 05 08:53:43 2016 +0000 @@ -60,9 +60,9 @@ joystickPos = "CENTRE"; // Set IoT Foundation connection parameters - char organization[11] = "quickstart"; // For a registered connection, replace with your org + char organization[11] = "hrcl78"; // For a registered connection, replace with your org char deviceType[9] = "SampleDT"; // For a registered connection, replace with your device type - char deviceId[15] = ""; // For a registered connection, replace with your device id + char deviceId[15] = "12345"; // For a registered connection, replace with your device id char method[6] = "token"; // Not required to change as IBM IoTF expects only "token" for now char token[9] = "password"; // For a registered connection, replace with your auth-token @@ -109,9 +109,21 @@ //Message is converted from datapoints into json format and then published status = client.publishEvent("blink", buf); + lcd.locate(0,0); lcd.printf("Publish status = %s",status?"true":"false"); - + + if(status == false) { + // Check if connection is lost and retry + int re_count = 0; + while(!client.isConnected()) { + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Reconnecting... %d", re_count++); + client.reConnect(); + wait(5.0); + } + } count = 0; } if (blink_interval == 0)