Microsoft Azure IoTHub client libraries

Dependents:   sht15_remote_monitoring RobotArmDemo iothub_client_sample_amqp f767zi_mqtt ... more

This library implements the Microsoft Azure IoTHub client library. The code is replicated from https://github.com/Azure/azure-iot-sdks

Committer:
AzureIoTClient
Date:
Thu Jul 12 18:09:13 2018 -0700
Revision:
91:bbf806070c5f
Parent:
89:a2ed767a532e
Child:
92:97148cf9aa2a
1.2.8

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AzureIoTClient 88:248736be106e 1 // Copyright (c) Microsoft. All rights reserved.
AzureIoTClient 88:248736be106e 2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
AzureIoTClient 88:248736be106e 3
AzureIoTClient 88:248736be106e 4 #ifndef IOTHUB_CLIENT_PRIVATE_H
AzureIoTClient 88:248736be106e 5 #define IOTHUB_CLIENT_PRIVATE_H
AzureIoTClient 88:248736be106e 6
AzureIoTClient 88:248736be106e 7 #include <stdbool.h>
AzureIoTClient 88:248736be106e 8 #include <signal.h>
AzureIoTClient 88:248736be106e 9
AzureIoTClient 88:248736be106e 10 #include "azure_c_shared_utility/constbuffer.h"
AzureIoTClient 88:248736be106e 11 #include "azure_c_shared_utility/crt_abstractions.h"
AzureIoTClient 88:248736be106e 12 #include "azure_c_shared_utility/doublylinkedlist.h"
AzureIoTClient 88:248736be106e 13 #include "azure_c_shared_utility/macro_utils.h"
AzureIoTClient 88:248736be106e 14 #include "azure_c_shared_utility/tickcounter.h"
AzureIoTClient 88:248736be106e 15 #include "azure_c_shared_utility/umock_c_prod.h"
AzureIoTClient 88:248736be106e 16
AzureIoTClient 88:248736be106e 17 #include "iothub_message.h"
AzureIoTClient 88:248736be106e 18 #include "iothub_client_core_ll.h"
AzureIoTClient 88:248736be106e 19 #include "internal/iothub_transport_ll_private.h"
AzureIoTClient 88:248736be106e 20 #include "internal/iothubtransport.h"
AzureIoTClient 88:248736be106e 21
AzureIoTClient 91:bbf806070c5f 22 #ifdef USE_EDGE_MODULES
AzureIoTClient 91:bbf806070c5f 23 #include "internal/iothub_client_edge.h"
AzureIoTClient 91:bbf806070c5f 24 #endif
AzureIoTClient 91:bbf806070c5f 25
AzureIoTClient 88:248736be106e 26 #ifdef __cplusplus
AzureIoTClient 88:248736be106e 27 extern "C"
AzureIoTClient 88:248736be106e 28 {
AzureIoTClient 88:248736be106e 29 #endif
AzureIoTClient 88:248736be106e 30
AzureIoTClient 88:248736be106e 31 #define EVENT_ENDPOINT "/messages/events"
AzureIoTClient 88:248736be106e 32 #define MESSAGE_ENDPOINT "/messages/devicebound"
AzureIoTClient 88:248736be106e 33 #define MESSAGE_ENDPOINT_HTTP "/messages/devicebound"
AzureIoTClient 88:248736be106e 34 #define MESSAGE_ENDPOINT_HTTP_ETAG "/messages/devicebound/"
AzureIoTClient 88:248736be106e 35 #define CLIENT_DEVICE_TYPE_PREFIX "iothubclient"
AzureIoTClient 88:248736be106e 36 #define CLIENT_DEVICE_BACKSLASH "/"
AzureIoTClient 88:248736be106e 37 #define CBS_REPLY_TO "cbs"
AzureIoTClient 88:248736be106e 38 #define CBS_ENDPOINT "/$" CBS_REPLY_TO
AzureIoTClient 88:248736be106e 39 #define API_VERSION "?api-version=2016-11-14"
AzureIoTClient 88:248736be106e 40 #define REJECT_QUERY_PARAMETER "&reject"
AzureIoTClient 88:248736be106e 41
AzureIoTClient 88:248736be106e 42 typedef bool(*IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC_EX)(MESSAGE_CALLBACK_INFO* messageData, void* userContextCallback);
AzureIoTClient 88:248736be106e 43
AzureIoTClient 88:248736be106e 44 MOCKABLE_FUNCTION(, void, IoTHubClientCore_LL_SendComplete, IOTHUB_CLIENT_CORE_LL_HANDLE, handle, PDLIST_ENTRY, completed, IOTHUB_CLIENT_CONFIRMATION_RESULT, result);
AzureIoTClient 88:248736be106e 45 MOCKABLE_FUNCTION(, void, IoTHubClientCore_LL_ReportedStateComplete, IOTHUB_CLIENT_CORE_LL_HANDLE, handle, uint32_t, item_id, int, status_code);
AzureIoTClient 88:248736be106e 46 MOCKABLE_FUNCTION(, bool, IoTHubClientCore_LL_MessageCallback, IOTHUB_CLIENT_CORE_LL_HANDLE, handle, MESSAGE_CALLBACK_INFO*, message_data);
AzureIoTClient 88:248736be106e 47 MOCKABLE_FUNCTION(, void, IoTHubClientCore_LL_RetrievePropertyComplete, IOTHUB_CLIENT_CORE_LL_HANDLE, handle, DEVICE_TWIN_UPDATE_STATE, update_state, const unsigned char*, payLoad, size_t, size);
AzureIoTClient 88:248736be106e 48 MOCKABLE_FUNCTION(, int, IoTHubClientCore_LL_DeviceMethodComplete, IOTHUB_CLIENT_CORE_LL_HANDLE, handle, const char*, method_name, const unsigned char*, payLoad, size_t, size, METHOD_HANDLE, response_id);
AzureIoTClient 88:248736be106e 49 MOCKABLE_FUNCTION(, void, IoTHubClientCore_LL_ConnectionStatusCallBack, IOTHUB_CLIENT_CORE_LL_HANDLE, handle, IOTHUB_CLIENT_CONNECTION_STATUS, status, IOTHUB_CLIENT_CONNECTION_STATUS_REASON, reason);
AzureIoTClient 88:248736be106e 50 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClientCore_LL_SetMessageCallback_Ex, IOTHUB_CLIENT_CORE_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC_EX, messageCallback, void*, userContextCallback);
AzureIoTClient 88:248736be106e 51 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClientCore_LL_SendMessageDisposition, IOTHUB_CLIENT_CORE_LL_HANDLE, iotHubClientHandle, MESSAGE_CALLBACK_INFO*, messageData, IOTHUBMESSAGE_DISPOSITION_RESULT, disposition);
AzureIoTClient 88:248736be106e 52 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClientCore_LL_GetOption, IOTHUB_CLIENT_CORE_LL_HANDLE, iotHubClientHandle, const char*, optionName, void**, value);
AzureIoTClient 89:a2ed767a532e 53 MOCKABLE_FUNCTION(, bool, IoTHubClientCore_LL_MessageCallbackFromInput, IOTHUB_CLIENT_CORE_LL_HANDLE, handle, MESSAGE_CALLBACK_INFO*, message_data);
AzureIoTClient 89:a2ed767a532e 54 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClientCore_LL_SetInputMessageCallbackEx, IOTHUB_CLIENT_CORE_LL_HANDLE, iotHubClientHandle, const char*, inputName, IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC_EX, eventHandlerCallbackEx, void *, userContextCallback, size_t, userContextCallbackLength);
AzureIoTClient 88:248736be106e 55
AzureIoTClient 91:bbf806070c5f 56 #ifdef USE_EDGE_MODULES
AzureIoTClient 91:bbf806070c5f 57 /* (Should be replaced after iothub_client refactor)*/
AzureIoTClient 91:bbf806070c5f 58 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_EDGE_HANDLE, IoTHubClientCore_LL_GetEdgeHandle, IOTHUB_CLIENT_CORE_LL_HANDLE, iotHubClientHandle);
AzureIoTClient 91:bbf806070c5f 59 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClientCore_LL_GenericMethodInvoke, IOTHUB_CLIENT_CORE_LL_HANDLE, iotHubClientHandle, const char*, deviceId, const char*, moduleId, const char*, methodName, const char*, methodPayload, unsigned int, timeout, int*, responseStatus, unsigned char**, responsePayload, size_t*, responsePayloadSize);
AzureIoTClient 91:bbf806070c5f 60 #endif
AzureIoTClient 91:bbf806070c5f 61
AzureIoTClient 88:248736be106e 62 typedef struct IOTHUB_MESSAGE_LIST_TAG
AzureIoTClient 88:248736be106e 63 {
AzureIoTClient 88:248736be106e 64 IOTHUB_MESSAGE_HANDLE messageHandle;
AzureIoTClient 88:248736be106e 65 IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK callback;
AzureIoTClient 88:248736be106e 66 void* context;
AzureIoTClient 88:248736be106e 67 DLIST_ENTRY entry;
AzureIoTClient 88:248736be106e 68 tickcounter_ms_t ms_timesOutAfter; /* a value of "0" means "no timeout", if the IOTHUBCLIENT_LL's handle tickcounter > msTimesOutAfer then the message shall timeout*/
AzureIoTClient 88:248736be106e 69 }IOTHUB_MESSAGE_LIST;
AzureIoTClient 88:248736be106e 70
AzureIoTClient 88:248736be106e 71 typedef struct IOTHUB_DEVICE_TWIN_TAG
AzureIoTClient 88:248736be106e 72 {
AzureIoTClient 88:248736be106e 73 uint32_t item_id;
AzureIoTClient 88:248736be106e 74 tickcounter_ms_t ms_timesOutAfter; /* a value of "0" means "no timeout", if the IOTHUBCLIENT_LL's handle tickcounter > msTimesOutAfer then the message shall timeout*/
AzureIoTClient 88:248736be106e 75 IOTHUB_CLIENT_REPORTED_STATE_CALLBACK reported_state_callback;
AzureIoTClient 88:248736be106e 76 CONSTBUFFER_HANDLE report_data_handle;
AzureIoTClient 88:248736be106e 77 void* context;
AzureIoTClient 88:248736be106e 78 DLIST_ENTRY entry;
AzureIoTClient 88:248736be106e 79 IOTHUB_CLIENT_CORE_LL_HANDLE client_handle;
AzureIoTClient 88:248736be106e 80 IOTHUB_DEVICE_HANDLE device_handle;
AzureIoTClient 88:248736be106e 81 } IOTHUB_DEVICE_TWIN;
AzureIoTClient 88:248736be106e 82
AzureIoTClient 88:248736be106e 83 union IOTHUB_IDENTITY_INFO_TAG
AzureIoTClient 88:248736be106e 84 {
AzureIoTClient 88:248736be106e 85 IOTHUB_DEVICE_TWIN* device_twin;
AzureIoTClient 88:248736be106e 86 IOTHUB_MESSAGE_LIST* iothub_message;
AzureIoTClient 88:248736be106e 87 };
AzureIoTClient 88:248736be106e 88
AzureIoTClient 88:248736be106e 89 #ifdef __cplusplus
AzureIoTClient 88:248736be106e 90 }
AzureIoTClient 88:248736be106e 91 #endif
AzureIoTClient 88:248736be106e 92
AzureIoTClient 88:248736be106e 93 #endif /* IOTHUB_CLIENT_PRIVATE_H */