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 #ifndef IOTHUB_CLIENT_PRIVATE_H
markrad 3:c0556ff7b8e3 5 #define IOTHUB_CLIENT_PRIVATE_H
markrad 3:c0556ff7b8e3 6
markrad 3:c0556ff7b8e3 7 #include <signal.h>
markrad 3:c0556ff7b8e3 8
markrad 3:c0556ff7b8e3 9 #include "azure_c_shared_utility/macro_utils.h"
markrad 3:c0556ff7b8e3 10 #include "azure_c_shared_utility/crt_abstractions.h"
markrad 3:c0556ff7b8e3 11 #include "azure_c_shared_utility/doublylinkedlist.h"
markrad 3:c0556ff7b8e3 12 #include "azure_c_shared_utility/umock_c_prod.h"
markrad 3:c0556ff7b8e3 13 #include "azure_c_shared_utility/constbuffer.h"
markrad 3:c0556ff7b8e3 14
markrad 3:c0556ff7b8e3 15 #include "iothub_message.h"
markrad 3:c0556ff7b8e3 16 #include "iothub_client_ll.h"
markrad 3:c0556ff7b8e3 17 #include "azure_c_shared_utility/macro_utils.h"
markrad 3:c0556ff7b8e3 18 #include "azure_c_shared_utility/umock_c_prod.h"
markrad 3:c0556ff7b8e3 19
markrad 3:c0556ff7b8e3 20 #ifdef __cplusplus
markrad 3:c0556ff7b8e3 21 extern "C"
markrad 3:c0556ff7b8e3 22 {
markrad 3:c0556ff7b8e3 23 #endif
markrad 3:c0556ff7b8e3 24
markrad 3:c0556ff7b8e3 25 #define EVENT_ENDPOINT "/messages/events"
markrad 3:c0556ff7b8e3 26 #define MESSAGE_ENDPOINT "/messages/devicebound"
markrad 3:c0556ff7b8e3 27 #define MESSAGE_ENDPOINT_HTTP "/messages/devicebound"
markrad 3:c0556ff7b8e3 28 #define MESSAGE_ENDPOINT_HTTP_ETAG "/messages/devicebound/"
markrad 3:c0556ff7b8e3 29 #define CLIENT_DEVICE_TYPE_PREFIX "iothubclient"
markrad 3:c0556ff7b8e3 30 #define CLIENT_DEVICE_BACKSLASH "/"
markrad 3:c0556ff7b8e3 31 #define CBS_REPLY_TO "cbs"
markrad 3:c0556ff7b8e3 32 #define CBS_ENDPOINT "/$" CBS_REPLY_TO
markrad 3:c0556ff7b8e3 33 #define API_VERSION "?api-version=2016-11-14"
markrad 3:c0556ff7b8e3 34 #define REJECT_QUERY_PARAMETER "&reject"
markrad 3:c0556ff7b8e3 35
markrad 3:c0556ff7b8e3 36 MOCKABLE_FUNCTION(, void, IoTHubClient_LL_SendComplete, IOTHUB_CLIENT_LL_HANDLE, handle, PDLIST_ENTRY, completed, IOTHUB_CLIENT_CONFIRMATION_RESULT, result);
markrad 3:c0556ff7b8e3 37 MOCKABLE_FUNCTION(, void, IoTHubClient_LL_ReportedStateComplete, IOTHUB_CLIENT_LL_HANDLE, handle, uint32_t, item_id, int, status_code);
markrad 3:c0556ff7b8e3 38 MOCKABLE_FUNCTION(, IOTHUBMESSAGE_DISPOSITION_RESULT, IoTHubClient_LL_MessageCallback, IOTHUB_CLIENT_LL_HANDLE, handle, IOTHUB_MESSAGE_HANDLE, message);
markrad 3:c0556ff7b8e3 39 MOCKABLE_FUNCTION(, void, IoTHubClient_LL_RetrievePropertyComplete, IOTHUB_CLIENT_LL_HANDLE, handle, DEVICE_TWIN_UPDATE_STATE, update_state, const unsigned char*, payLoad, size_t, size);
markrad 3:c0556ff7b8e3 40 MOCKABLE_FUNCTION(, int, IoTHubClient_LL_DeviceMethodComplete, IOTHUB_CLIENT_LL_HANDLE, handle, const char*, method_name, const unsigned char*, payLoad, size_t, size, BUFFER_HANDLE, result_payload);
markrad 3:c0556ff7b8e3 41 MOCKABLE_FUNCTION(, void, IotHubClient_LL_ConnectionStatusCallBack, IOTHUB_CLIENT_LL_HANDLE, handle, IOTHUB_CLIENT_CONNECTION_STATUS, status, IOTHUB_CLIENT_CONNECTION_STATUS_REASON, reason);
markrad 3:c0556ff7b8e3 42 typedef struct IOTHUB_MESSAGE_LIST_TAG
markrad 3:c0556ff7b8e3 43 {
markrad 3:c0556ff7b8e3 44 IOTHUB_MESSAGE_HANDLE messageHandle;
markrad 3:c0556ff7b8e3 45 IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK callback;
markrad 3:c0556ff7b8e3 46 void* context;
markrad 3:c0556ff7b8e3 47 DLIST_ENTRY entry;
markrad 3:c0556ff7b8e3 48 uint64_t ms_timesOutAfter; /* a value of "0" means "no timeout", if the IOTHUBCLIENT_LL's handle tickcounter > msTimesOutAfer then the message shall timeout*/
markrad 3:c0556ff7b8e3 49 }IOTHUB_MESSAGE_LIST;
markrad 3:c0556ff7b8e3 50
markrad 3:c0556ff7b8e3 51 typedef struct IOTHUB_DEVICE_TWIN_TAG
markrad 3:c0556ff7b8e3 52 {
markrad 3:c0556ff7b8e3 53 uint32_t item_id;
markrad 3:c0556ff7b8e3 54 uint64_t ms_timesOutAfter; /* a value of "0" means "no timeout", if the IOTHUBCLIENT_LL's handle tickcounter > msTimesOutAfer then the message shall timeout*/
markrad 3:c0556ff7b8e3 55 IOTHUB_CLIENT_REPORTED_STATE_CALLBACK reported_state_callback;
markrad 3:c0556ff7b8e3 56 CONSTBUFFER_HANDLE report_data_handle;
markrad 3:c0556ff7b8e3 57 void* context;
markrad 3:c0556ff7b8e3 58 DLIST_ENTRY entry;
markrad 3:c0556ff7b8e3 59 } IOTHUB_DEVICE_TWIN;
markrad 3:c0556ff7b8e3 60 union IOTHUB_IDENTITY_INFO_TAG
markrad 3:c0556ff7b8e3 61 {
markrad 3:c0556ff7b8e3 62 IOTHUB_DEVICE_TWIN* device_twin;
markrad 3:c0556ff7b8e3 63 IOTHUB_MESSAGE_LIST* iothub_message;
markrad 3:c0556ff7b8e3 64 };
markrad 3:c0556ff7b8e3 65
markrad 3:c0556ff7b8e3 66
markrad 3:c0556ff7b8e3 67 #ifdef __cplusplus
markrad 3:c0556ff7b8e3 68 }
markrad 3:c0556ff7b8e3 69 #endif
markrad 3:c0556ff7b8e3 70
markrad 3:c0556ff7b8e3 71 #endif /* IOTHUB_CLIENT_PRIVATE_H */