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.

main.cpp

Committer:
AzureIoTClient
Date:
2015-09-16
Revision:
5:0bec07661dde
Parent:
3:bca772fcee7e
Child:
6:c035e0e00f92

File content as of revision 5:0bec07661dde:

// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#include <stdio.h>
#include "EthernetInterface.h"
#include "simplesample_http.h"
#include "NTPClient.h"

void 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");
}

int main(void)
{
	(void)printf("Initializing mbed specific things...\r\n");

	if (EthernetInterface::init())
	{
		(void)printf("Error initializing EthernetInterface.\r\n");
		return -1;
	}

    if (setupRealTime() != 0)
    {
         (void)printf("Failed setting up real time clock\r\n");
         return -1;
    }

    simplesample_http_run();

	return 0;
}