A simple IoTHub sample using HTTP as transport
Dependencies: EthernetInterface NTPClient iothub_client iothub_http_transport mbed-rtos mbed wolfSSL serializer azure_c_shared_utility
This sample showcases the usage of Azure IoT client libraries with the HTTP transport for sending/receiving raw messages from an IoT Hub.
Diff: main.cpp
- Revision:
- 22:3acb69edee6b
- Parent:
- 17:3abbcd6aac9f
- Child:
- 23:39fcc72c3963
--- a/main.cpp Mon Jan 25 19:21:30 2016 -0800 +++ b/main.cpp Tue Jan 26 17:56:04 2016 -0800 @@ -5,56 +5,26 @@ #include "EthernetInterface.h" #include "simplesample_http.h" #include "NTPClient.h" - -int setupRealTime(void) -{ - int result; - - (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; -} +#include "azureiot_common/platform.h" int main(void) { - (void)printf("Initializing mbed specific things...\r\n"); + int result; + (void)printf("Initializing mbed specific things...\r\n"); - if (EthernetInterface::init()) + /* These are needed in order to initialize the time provider for Proton-C */ + mbed_log_init(); + mbedtime_init(); + + if ((result = platform_init()) != 0) { - (void)printf("Error initializing EthernetInterface.\r\n"); + (void)printf("Error initializing the platform: %d\r\n",result); return -1; } - if (setupRealTime() != 0) - { - (void)printf("Failed setting up real time clock\r\n"); - return -1; - } - simplesample_http_run(); + platform_deinit(); + return 0; }