Simple sample that demonstrates reading the FXOS8700CQ accelerometer, convert the data to JSON and send to an Azure IoT Hub.

Dependencies:   azure_umqtt_c iothub_mqtt_transport mbed-rtos mbed wolfSSL Socket lwip-eth lwip-sys lwip

Committer:
markrad
Date:
Tue Apr 25 01:33:13 2017 +0000
Revision:
7:2564d95cbf81
Parent:
3:c0556ff7b8e3
Fix bug in NTP library. Clean up code some.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
markrad 3:c0556ff7b8e3 1 // Copyright (c) Microsoft. All rights reserved.
markrad 3:c0556ff7b8e3 2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
markrad 3:c0556ff7b8e3 3
markrad 3:c0556ff7b8e3 4 #include <stdlib.h>
markrad 3:c0556ff7b8e3 5 #ifdef _CRTDBG_MAP_ALLOC
markrad 3:c0556ff7b8e3 6 #include <crtdbg.h>
markrad 3:c0556ff7b8e3 7 #endif
markrad 3:c0556ff7b8e3 8 #include <stdarg.h>
markrad 3:c0556ff7b8e3 9 #include <stdio.h>
markrad 3:c0556ff7b8e3 10 #include "azure_c_shared_utility/xlogging.h"
markrad 3:c0556ff7b8e3 11
markrad 3:c0556ff7b8e3 12 void consolelogger_log(LOG_CATEGORY log_category, const char* file, const char* func, const int line, unsigned int options, const char* format, ...)
markrad 3:c0556ff7b8e3 13 {
markrad 3:c0556ff7b8e3 14 va_list args;
markrad 3:c0556ff7b8e3 15 va_start(args, format);
markrad 3:c0556ff7b8e3 16
markrad 3:c0556ff7b8e3 17 time_t t = time(NULL);
markrad 3:c0556ff7b8e3 18
markrad 3:c0556ff7b8e3 19 switch (log_category)
markrad 3:c0556ff7b8e3 20 {
markrad 3:c0556ff7b8e3 21 case LOG_INFO:
markrad 3:c0556ff7b8e3 22 (void)printf("Info: ");
markrad 3:c0556ff7b8e3 23 break;
markrad 3:c0556ff7b8e3 24 case LOG_ERROR:
markrad 3:c0556ff7b8e3 25 (void)printf("Error: Time:%.24s File:%s Func:%s Line:%d ", ctime(&t), file, func, line);
markrad 3:c0556ff7b8e3 26 break;
markrad 3:c0556ff7b8e3 27 default:
markrad 3:c0556ff7b8e3 28 break;
markrad 3:c0556ff7b8e3 29 }
markrad 3:c0556ff7b8e3 30
markrad 3:c0556ff7b8e3 31 (void)vprintf(format, args);
markrad 3:c0556ff7b8e3 32 va_end(args);
markrad 3:c0556ff7b8e3 33
markrad 3:c0556ff7b8e3 34 (void)log_category;
markrad 3:c0556ff7b8e3 35 if (options & LOG_LINE)
markrad 3:c0556ff7b8e3 36 {
markrad 3:c0556ff7b8e3 37 (void)printf("\r\n");
markrad 3:c0556ff7b8e3 38 }
markrad 3:c0556ff7b8e3 39 }