Temperature sensor anomaly IoTHub sample
Dependencies: C12832 EthernetInterface LM75B NTPClient iothub_client iothub_http_transport mbed-rtos mbed serializer wolfSSL azure_c_shared_utility
This sample showcases the usage of Azure IoT client libraries to build an application sample that uploads temperature data and reacts to an alert for a temperature anomaly sent by a cloud service.
Diff: main.cpp
- Revision:
- 5:4afe2073d473
- Parent:
- 4:b0b512a80572
- Child:
- 6:315d04ac34d3
--- a/main.cpp Thu Sep 17 00:03:37 2015 -0700 +++ b/main.cpp Thu Sep 17 00:15:07 2015 -0700 @@ -240,30 +240,34 @@ } } - -void setupRealTime(void) +int setupRealTime(void) { - (void)printf("setupRealTime begin\r\n"); - if (EthernetInterface::connect()) - { - (void)printf("Error initializing EthernetInterface.\r\n"); - } - else - { - (void)printf("setupRealTime NTP begin\r\n"); - NTPClient ntp; - if (ntp.setTime("0.pool.ntp.org") != 0) - { - (void)printf("Failed setting time.\r\n"); - } - else - { - (void)printf("set time correctly!\r\n"); - } - (void)printf("setupRealTime NTP end\r\n"); - EthernetInterface::disconnect(); - } - (void)printf("setupRealTime end\r\n"); + (void)printf("setupRealTime begin\r\n"); + if (EthernetInterface::connect()) + { + (void)printf("Error initializing EthernetInterface.\r\n"); + result = __LINE__; + } + else + { + (void)printf("setupRealTime NTP begin\r\n"); + NTPClient ntp; + if (ntp.setTime("0.pool.ntp.org") != 0) + { + (void)printf("Failed setting time.\r\n"); + result = __LINE__; + } + else + { + (void)printf("set time correctly!\r\n"); + result = 0; + } + (void)printf("setupRealTime NTP end\r\n"); + EthernetInterface::disconnect(); + } + (void)printf("setupRealTime end\r\n"); + + return result; } int main(void)