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:
Mon Jun 11 15:39:23 2018 -0700
Revision:
88:248736be106e
Parent:
86:a1352899ea45
Child:
89:a2ed767a532e
1.2.5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AzureIoTClient 16:deba40344375 1 // Copyright (c) Microsoft. All rights reserved.
AzureIoTClient 16:deba40344375 2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
AzureIoTClient 16:deba40344375 3
AzureIoTClient 16:deba40344375 4 #include <stdlib.h>
Azure.IoT Build 38:a05929a75111 5 #include <string.h>
AzureIoTClient 60:41648c4e7036 6 #include "azure_c_shared_utility/optimize_size.h"
Azure.IoT Build 38:a05929a75111 7 #include "azure_c_shared_utility/gballoc.h"
Azure.IoT Build 38:a05929a75111 8 #include "azure_c_shared_utility/string_tokenizer.h"
Azure.IoT Build 38:a05929a75111 9 #include "azure_c_shared_utility/doublylinkedlist.h"
Azure.IoT Build 45:54c11b1b1407 10 #include "azure_c_shared_utility/xlogging.h"
Azure.IoT Build 38:a05929a75111 11 #include "azure_c_shared_utility/tickcounter.h"
AzureIoTClient 53:1e5a1ca1f274 12 #include "azure_c_shared_utility/constbuffer.h"
AzureIoTClient 66:a419827cb051 13 #include "azure_c_shared_utility/platform.h"
AzureIoTClient 16:deba40344375 14
AzureIoTClient 88:248736be106e 15 #include "iothub_client_core_ll.h"
AzureIoTClient 88:248736be106e 16 #include "internal/iothub_client_authorization.h"
AzureIoTClient 16:deba40344375 17 #include "iothub_client_ll.h"
AzureIoTClient 61:8b85a4e797cf 18 #include "iothub_transport_ll.h"
AzureIoTClient 88:248736be106e 19 #include "iothub_device_client_ll.h"
AzureIoTClient 88:248736be106e 20 #include "internal/iothub_client_private.h"
AzureIoTClient 66:a419827cb051 21 #include "iothub_client_options.h"
AzureIoTClient 33:b372b0efcd20 22 #include "iothub_client_version.h"
AzureIoTClient 88:248736be106e 23 #include "internal/iothub_client_diagnostic.h"
AzureIoTClient 53:1e5a1ca1f274 24 #include <stdint.h>
AzureIoTClient 43:038d8511e817 25
AzureIoTClient 44:33dd78697616 26 #ifndef DONT_USE_UPLOADTOBLOB
AzureIoTClient 88:248736be106e 27 #include "internal/iothub_client_ll_uploadtoblob.h"
AzureIoTClient 43:038d8511e817 28 #endif
Azure.IoT Build 36:67300d5a4c1f 29
AzureIoTClient 88:248736be106e 30 IOTHUB_CLIENT_LL_HANDLE IoTHubClient_LL_CreateFromConnectionString(const char* connectionString, IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol)
AzureIoTClient 16:deba40344375 31 {
AzureIoTClient 88:248736be106e 32 return (IOTHUB_CLIENT_LL_HANDLE)IoTHubClientCore_LL_CreateFromConnectionString(connectionString, protocol);
AzureIoTClient 66:a419827cb051 33 }
AzureIoTClient 62:5a4cdacf5090 34
AzureIoTClient 88:248736be106e 35 IOTHUB_CLIENT_LL_HANDLE IoTHubClient_LL_Create(const IOTHUB_CLIENT_CONFIG* config)
AzureIoTClient 66:a419827cb051 36 {
AzureIoTClient 88:248736be106e 37 return (IOTHUB_CLIENT_LL_HANDLE)IoTHubClientCore_LL_Create(config);
AzureIoTClient 62:5a4cdacf5090 38 }
AzureIoTClient 62:5a4cdacf5090 39
AzureIoTClient 88:248736be106e 40 IOTHUB_CLIENT_LL_HANDLE IoTHubClient_LL_CreateWithTransport(const IOTHUB_CLIENT_DEVICE_CONFIG * config)
AzureIoTClient 53:1e5a1ca1f274 41 {
AzureIoTClient 88:248736be106e 42 return (IOTHUB_CLIENT_LL_HANDLE)IoTHubClientCore_LL_CreateWithTransport(config);
AzureIoTClient 53:1e5a1ca1f274 43 }
AzureIoTClient 53:1e5a1ca1f274 44
AzureIoTClient 75:86205ca63a59 45 IOTHUB_CLIENT_LL_HANDLE IoTHubClient_LL_CreateFromDeviceAuth(const char* iothub_uri, const char* device_id, IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol)
AzureIoTClient 75:86205ca63a59 46 {
AzureIoTClient 88:248736be106e 47 return (IOTHUB_CLIENT_LL_HANDLE)IoTHubClientCore_LL_CreateFromDeviceAuth(iothub_uri, device_id, protocol);
Azure.IoT Build 36:67300d5a4c1f 48 }
Azure.IoT Build 36:67300d5a4c1f 49
AzureIoTClient 16:deba40344375 50 void IoTHubClient_LL_Destroy(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle)
AzureIoTClient 16:deba40344375 51 {
AzureIoTClient 88:248736be106e 52 IoTHubClientCore_LL_Destroy((IOTHUB_CLIENT_CORE_LL_HANDLE)iotHubClientHandle);
Azure.IoT Build 36:67300d5a4c1f 53 }
Azure.IoT Build 36:67300d5a4c1f 54
AzureIoTClient 16:deba40344375 55 IOTHUB_CLIENT_RESULT IoTHubClient_LL_SendEventAsync(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, IOTHUB_MESSAGE_HANDLE eventMessageHandle, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK eventConfirmationCallback, void* userContextCallback)
AzureIoTClient 16:deba40344375 56 {
AzureIoTClient 88:248736be106e 57 return IoTHubClientCore_LL_SendEventAsync((IOTHUB_CLIENT_CORE_LL_HANDLE)iotHubClientHandle, eventMessageHandle, eventConfirmationCallback, userContextCallback);
AzureIoTClient 16:deba40344375 58 }
AzureIoTClient 16:deba40344375 59
AzureIoTClient 16:deba40344375 60 IOTHUB_CLIENT_RESULT IoTHubClient_LL_GetSendStatus(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, IOTHUB_CLIENT_STATUS *iotHubClientStatus)
AzureIoTClient 16:deba40344375 61 {
AzureIoTClient 88:248736be106e 62 return IoTHubClientCore_LL_GetSendStatus((IOTHUB_CLIENT_CORE_LL_HANDLE)iotHubClientHandle, iotHubClientStatus);
AzureIoTClient 53:1e5a1ca1f274 63 }
AzureIoTClient 53:1e5a1ca1f274 64
AzureIoTClient 88:248736be106e 65 IOTHUB_CLIENT_RESULT IoTHubClient_LL_SetMessageCallback(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC messageCallback, void* userContextCallback)
AzureIoTClient 16:deba40344375 66 {
AzureIoTClient 88:248736be106e 67 return IoTHubClientCore_LL_SetMessageCallback((IOTHUB_CLIENT_CORE_LL_HANDLE)iotHubClientHandle, messageCallback, userContextCallback);
AzureIoTClient 52:1cc3c6d07cad 68 }
AzureIoTClient 52:1cc3c6d07cad 69
AzureIoTClient 52:1cc3c6d07cad 70 IOTHUB_CLIENT_RESULT IoTHubClient_LL_SetConnectionStatusCallback(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, IOTHUB_CLIENT_CONNECTION_STATUS_CALLBACK connectionStatusCallback, void * userContextCallback)
AzureIoTClient 52:1cc3c6d07cad 71 {
AzureIoTClient 88:248736be106e 72 return IoTHubClientCore_LL_SetConnectionStatusCallback((IOTHUB_CLIENT_CORE_LL_HANDLE)iotHubClientHandle, connectionStatusCallback, userContextCallback);
AzureIoTClient 52:1cc3c6d07cad 73 }
AzureIoTClient 52:1cc3c6d07cad 74
AzureIoTClient 53:1e5a1ca1f274 75 IOTHUB_CLIENT_RESULT IoTHubClient_LL_SetRetryPolicy(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, IOTHUB_CLIENT_RETRY_POLICY retryPolicy, size_t retryTimeoutLimitInSeconds)
AzureIoTClient 52:1cc3c6d07cad 76 {
AzureIoTClient 88:248736be106e 77 return IoTHubClientCore_LL_SetRetryPolicy((IOTHUB_CLIENT_CORE_LL_HANDLE)iotHubClientHandle, retryPolicy, retryTimeoutLimitInSeconds);
AzureIoTClient 52:1cc3c6d07cad 78 }
AzureIoTClient 52:1cc3c6d07cad 79
AzureIoTClient 53:1e5a1ca1f274 80 IOTHUB_CLIENT_RESULT IoTHubClient_LL_GetRetryPolicy(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, IOTHUB_CLIENT_RETRY_POLICY* retryPolicy, size_t* retryTimeoutLimitInSeconds)
AzureIoTClient 52:1cc3c6d07cad 81 {
AzureIoTClient 88:248736be106e 82 return IoTHubClientCore_LL_GetRetryPolicy((IOTHUB_CLIENT_CORE_LL_HANDLE)iotHubClientHandle, retryPolicy, retryTimeoutLimitInSeconds);
AzureIoTClient 52:1cc3c6d07cad 83 }
AzureIoTClient 52:1cc3c6d07cad 84
AzureIoTClient 16:deba40344375 85 IOTHUB_CLIENT_RESULT IoTHubClient_LL_GetLastMessageReceiveTime(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, time_t* lastMessageReceiveTime)
AzureIoTClient 16:deba40344375 86 {
AzureIoTClient 88:248736be106e 87 return IoTHubClientCore_LL_GetLastMessageReceiveTime((IOTHUB_CLIENT_CORE_LL_HANDLE)iotHubClientHandle, lastMessageReceiveTime);
AzureIoTClient 88:248736be106e 88 }
AzureIoTClient 16:deba40344375 89
AzureIoTClient 88:248736be106e 90 void IoTHubClient_LL_DoWork(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle)
AzureIoTClient 88:248736be106e 91 {
AzureIoTClient 88:248736be106e 92 IoTHubClientCore_LL_DoWork((IOTHUB_CLIENT_CORE_LL_HANDLE)iotHubClientHandle);
AzureIoTClient 88:248736be106e 93 }
AzureIoTClient 16:deba40344375 94
AzureIoTClient 88:248736be106e 95 IOTHUB_CLIENT_RESULT IoTHubClient_LL_SetDeviceTwinCallback(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, IOTHUB_CLIENT_DEVICE_TWIN_CALLBACK deviceTwinCallback, void* userContextCallback)
AzureIoTClient 88:248736be106e 96 {
AzureIoTClient 88:248736be106e 97 return IoTHubClientCore_LL_SetDeviceTwinCallback((IOTHUB_CLIENT_CORE_LL_HANDLE)iotHubClientHandle, deviceTwinCallback, userContextCallback);
AzureIoTClient 16:deba40344375 98 }
AzureIoTClient 16:deba40344375 99
AzureIoTClient 16:deba40344375 100 IOTHUB_CLIENT_RESULT IoTHubClient_LL_SetOption(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, const char* optionName, const void* value)
AzureIoTClient 16:deba40344375 101 {
AzureIoTClient 88:248736be106e 102 return IoTHubClientCore_LL_SetOption((IOTHUB_CLIENT_CORE_LL_HANDLE)iotHubClientHandle, optionName, value);
AzureIoTClient 53:1e5a1ca1f274 103 }
AzureIoTClient 53:1e5a1ca1f274 104
AzureIoTClient 53:1e5a1ca1f274 105 IOTHUB_CLIENT_RESULT IoTHubClient_LL_SendReportedState(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, const unsigned char* reportedState, size_t size, IOTHUB_CLIENT_REPORTED_STATE_CALLBACK reportedStateCallback, void* userContextCallback)
AzureIoTClient 53:1e5a1ca1f274 106 {
AzureIoTClient 88:248736be106e 107 return IoTHubClientCore_LL_SendReportedState((IOTHUB_CLIENT_CORE_LL_HANDLE)iotHubClientHandle, reportedState, size, reportedStateCallback, userContextCallback);
AzureIoTClient 53:1e5a1ca1f274 108 }
AzureIoTClient 53:1e5a1ca1f274 109
AzureIoTClient 53:1e5a1ca1f274 110 IOTHUB_CLIENT_RESULT IoTHubClient_LL_SetDeviceMethodCallback(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, IOTHUB_CLIENT_DEVICE_METHOD_CALLBACK_ASYNC deviceMethodCallback, void* userContextCallback)
AzureIoTClient 53:1e5a1ca1f274 111 {
AzureIoTClient 88:248736be106e 112 return IoTHubClientCore_LL_SetDeviceMethodCallback((IOTHUB_CLIENT_CORE_LL_HANDLE)iotHubClientHandle, deviceMethodCallback, userContextCallback);
AzureIoTClient 53:1e5a1ca1f274 113 }
AzureIoTClient 53:1e5a1ca1f274 114
AzureIoTClient 55:59b527ab3452 115 IOTHUB_CLIENT_RESULT IoTHubClient_LL_SetDeviceMethodCallback_Ex(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, IOTHUB_CLIENT_INBOUND_DEVICE_METHOD_CALLBACK inboundDeviceMethodCallback, void* userContextCallback)
AzureIoTClient 55:59b527ab3452 116 {
AzureIoTClient 88:248736be106e 117 return IoTHubClientCore_LL_SetDeviceMethodCallback_Ex((IOTHUB_CLIENT_CORE_LL_HANDLE)iotHubClientHandle, inboundDeviceMethodCallback, userContextCallback);
AzureIoTClient 55:59b527ab3452 118 }
AzureIoTClient 55:59b527ab3452 119
AzureIoTClient 55:59b527ab3452 120 IOTHUB_CLIENT_RESULT IoTHubClient_LL_DeviceMethodResponse(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, METHOD_HANDLE methodId, const unsigned char* response, size_t response_size, int status_response)
AzureIoTClient 55:59b527ab3452 121 {
AzureIoTClient 88:248736be106e 122 return IoTHubClientCore_LL_DeviceMethodResponse((IOTHUB_CLIENT_CORE_LL_HANDLE)iotHubClientHandle, methodId, response, response_size, status_response);
AzureIoTClient 55:59b527ab3452 123 }
AzureIoTClient 55:59b527ab3452 124
AzureIoTClient 44:33dd78697616 125 #ifndef DONT_USE_UPLOADTOBLOB
AzureIoTClient 42:448eecc3676e 126 IOTHUB_CLIENT_RESULT IoTHubClient_LL_UploadToBlob(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, const char* destinationFileName, const unsigned char* source, size_t size)
AzureIoTClient 42:448eecc3676e 127 {
AzureIoTClient 88:248736be106e 128 return IoTHubClientCore_LL_UploadToBlob((IOTHUB_CLIENT_CORE_LL_HANDLE)iotHubClientHandle, destinationFileName, source, size);
AzureIoTClient 82:f94e6bed4495 129 }
AzureIoTClient 82:f94e6bed4495 130
AzureIoTClient 80:db5f5237bc95 131 IOTHUB_CLIENT_RESULT IoTHubClient_LL_UploadMultipleBlocksToBlob(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, const char* destinationFileName, IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK getDataCallback, void* context)
AzureIoTClient 80:db5f5237bc95 132 {
AzureIoTClient 88:248736be106e 133 return IoTHubClientCore_LL_UploadMultipleBlocksToBlob((IOTHUB_CLIENT_CORE_LL_HANDLE)iotHubClientHandle, destinationFileName, getDataCallback, context);
AzureIoTClient 80:db5f5237bc95 134 }
AzureIoTClient 80:db5f5237bc95 135
AzureIoTClient 82:f94e6bed4495 136 IOTHUB_CLIENT_RESULT IoTHubClient_LL_UploadMultipleBlocksToBlobEx(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, const char* destinationFileName, IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK_EX getDataCallbackEx, void* context)
AzureIoTClient 82:f94e6bed4495 137 {
AzureIoTClient 88:248736be106e 138 return IoTHubClientCore_LL_UploadMultipleBlocksToBlobEx((IOTHUB_CLIENT_CORE_LL_HANDLE)iotHubClientHandle, destinationFileName, getDataCallbackEx, context);
AzureIoTClient 82:f94e6bed4495 139 }
AzureIoTClient 82:f94e6bed4495 140
AzureIoTClient 88:248736be106e 141 #endif