A simple IoTHub sample using AMQP as transport
Dependencies: EthernetInterface NTPClient iothub_amqp_transport iothub_client mbed-rtos mbed azure_c_shared_utility serializer wolfSSL azure_uamqp_c
This sample showcases the usage of Azure IoT client libraries with the AMQP transport for sending/receiving raw messages from an IoT Hub.
Diff: main.cpp
- Revision:
- 21:b8b8782d412f
- Parent:
- 16:b2c6de619743
- Child:
- 25:9cb9b0c15218
--- a/main.cpp Mon Jan 25 19:21:26 2016 -0800 +++ b/main.cpp Tue Jan 26 17:55:59 2016 -0800 @@ -7,68 +7,26 @@ #include "mbed/mbedtime.h" #include "simplesample_amqp.h" #include "NTPClient.h" - -int setupRealTime(void) -{ - int result; +#include "azureiot_common/platform.h" - (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) { + int result; (void)printf("Initializing mbed specific things...\r\n"); /* These are needed in order to initialize the time provider for Proton-C */ mbed_log_init(); mbedtime_init(); - if (EthernetInterface::init()) - { - (void)printf("Error initializing EthernetInterface.\r\n"); - return -1; - } - - if (setupRealTime() != 0) + if ((result = platform_init()) != 0) { - (void)printf("Failed setting up real time clock\r\n"); - return -1; - } - - if (EthernetInterface::connect()) - { - (void)printf("Error connecting EthernetInterface.\r\n"); + (void)printf("Error initializing the platform: %d\r\n",result); return -1; } simplesample_amqp_run(); - (void)EthernetInterface::disconnect(); - + platform_deinit(); return 0; }