IoT Example
Dependencies: C12832 LM75B MMA7660 MQTT mbed-rtos mbed
Fork of IBMIoTClientEthernetExample by
Diff: main.cpp
- Revision:
- 6:1a37fe371ee0
- Parent:
- 5:fe907e2e0d6c
- Child:
- 7:2fb7a98b559c
--- a/main.cpp Thu Aug 21 12:42:19 2014 +0000 +++ b/main.cpp Wed Sep 24 21:47:40 2014 +0000 @@ -231,6 +231,12 @@ { int retryAttempt = 0; connected = false; + + // make sure a cable is connected before starting to connect + while (!linkStatus()) { + wait(1.0f); + WARN("Ethernet link not present. Check cable connection\n"); + } while (connect(client, ipstack) != 0) { @@ -373,6 +379,12 @@ int count = 0; while (true) { + if (!linkStatus()) { + NVIC_SystemReset(); + // if ipstack and client were on the heap we could deconstruct and goto a label where they are constructed + // or maybe just add the proper members to do this disconnect and call attemptConnect(...) + } + if (++count == 100) { // Publish a message every second if (publish(&client, &ipstack) != 0)