Remote monitoring IoTHub device sample Added real SHTx sensor to get temperature and humidity Added new command to set temperature scale change Removed "mock" commands to set temperature and humidity values It's configured to work on FRDM-K64F board

Dependencies:   EthernetInterface NTPClient SHTx iothub_amqp_transport iothub_client mbed-rtos mbed proton-c-mbed serializer wolfSSL

Fork of remote_monitoring by Azure IoT

main.cpp

Committer:
AzureIoTClient
Date:
2015-09-17
Revision:
5:0ac6b44084ed
Parent:
2:90e50410da9b
Child:
6:066c3ca4df78

File content as of revision 5:0ac6b44084ed:

// 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 "mbed/logging.h"
#include "mbed/mbedtime.h"
#include "asset_monitoring.h"
#include "NTPClient.h"

int setupRealTime(void)
{
	(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)
{
    (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;
	}

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

    asset_monitoring_run();

	(void)EthernetInterface::disconnect();

    return 0;
}