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:
Fri Nov 03 13:18:25 2017 -0700
Revision:
78:74a8d3068204
Parent:
72:c737b53d7689
Child:
80:db5f5237bc95
1.1.27

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 /** @file iothub_client.h
AzureIoTClient 16:deba40344375 5 * @brief Extends the IoTHubCLient_LL module with additional features.
AzureIoTClient 16:deba40344375 6 *
AzureIoTClient 16:deba40344375 7 * @details IoTHubClient is a module that extends the IoTHubCLient_LL
AzureIoTClient 16:deba40344375 8 * module with 2 features:
AzureIoTClient 40:1a94db9139ea 9 * - scheduling the work for the IoTHubCLient from a
AzureIoTClient 16:deba40344375 10 * thread, so that the user does not need to create their
AzureIoTClient 16:deba40344375 11 * own thread
AzureIoTClient 16:deba40344375 12 * - thread-safe APIs
AzureIoTClient 16:deba40344375 13 */
AzureIoTClient 16:deba40344375 14
AzureIoTClient 16:deba40344375 15 #ifndef IOTHUB_CLIENT_H
AzureIoTClient 22:b8732db970af 16 #define IOTHUB_CLIENT_H
AzureIoTClient 16:deba40344375 17
Azure.IoT.Build 54:6dcad9019a64 18 #ifndef IOTHUB_CLIENT_INSTANCE_TYPE
Azure.IoT Build 37:18310e4d888d 19 typedef struct IOTHUB_CLIENT_INSTANCE_TAG* IOTHUB_CLIENT_HANDLE;
Azure.IoT.Build 54:6dcad9019a64 20 #define IOTHUB_CLIENT_INSTANCE_TYPE
Azure.IoT.Build 54:6dcad9019a64 21 #endif // IOTHUB_CLIENT_INSTANCE
AzureIoTClient 53:1e5a1ca1f274 22
AzureIoTClient 53:1e5a1ca1f274 23 #include "iothubtransport.h"
AzureIoTClient 53:1e5a1ca1f274 24 #include <stddef.h>
AzureIoTClient 53:1e5a1ca1f274 25 #include <stdint.h>
AzureIoTClient 53:1e5a1ca1f274 26
AzureIoTClient 16:deba40344375 27 #include "iothub_client_ll.h"
AzureIoTClient 53:1e5a1ca1f274 28 #include "azure_c_shared_utility/umock_c_prod.h"
AzureIoTClient 16:deba40344375 29
AzureIoTClient 16:deba40344375 30 #ifdef __cplusplus
AzureIoTClient 16:deba40344375 31 extern "C"
AzureIoTClient 16:deba40344375 32 {
AzureIoTClient 16:deba40344375 33 #endif
AzureIoTClient 16:deba40344375 34
AzureIoTClient 42:448eecc3676e 35 #define IOTHUB_CLIENT_FILE_UPLOAD_RESULT_VALUES \
Azure.IoT.Build 54:6dcad9019a64 36 FILE_UPLOAD_OK, \
AzureIoTClient 42:448eecc3676e 37 FILE_UPLOAD_ERROR
AzureIoTClient 42:448eecc3676e 38
AzureIoTClient 42:448eecc3676e 39 DEFINE_ENUM(IOTHUB_CLIENT_FILE_UPLOAD_RESULT, IOTHUB_CLIENT_FILE_UPLOAD_RESULT_VALUES)
AzureIoTClient 62:5a4cdacf5090 40 typedef void(*IOTHUB_CLIENT_FILE_UPLOAD_CALLBACK)(IOTHUB_CLIENT_FILE_UPLOAD_RESULT result, void* userContextCallback);
AzureIoTClient 16:deba40344375 41
AzureIoTClient 53:1e5a1ca1f274 42 /**
AzureIoTClient 53:1e5a1ca1f274 43 * @brief Creates a IoT Hub client for communication with an existing
AzureIoTClient 53:1e5a1ca1f274 44 * IoT Hub using the specified connection string parameter.
AzureIoTClient 53:1e5a1ca1f274 45 *
AzureIoTClient 53:1e5a1ca1f274 46 * @param connectionString Pointer to a character string
AzureIoTClient 53:1e5a1ca1f274 47 * @param protocol Function pointer for protocol implementation
AzureIoTClient 53:1e5a1ca1f274 48 *
AzureIoTClient 53:1e5a1ca1f274 49 * Sample connection string:
AzureIoTClient 53:1e5a1ca1f274 50 * <blockquote>
AzureIoTClient 53:1e5a1ca1f274 51 * <pre>HostName=[IoT Hub name goes here].[IoT Hub suffix goes here, e.g., private.azure-devices-int.net];DeviceId=[Device ID goes here];SharedAccessKey=[Device key goes here];</pre>
AzureIoTClient 53:1e5a1ca1f274 52 * <pre>HostName=[IoT Hub name goes here].[IoT Hub suffix goes here, e.g., private.azure-devices-int.net];DeviceId=[Device ID goes here];SharedAccessSignature=SharedAccessSignature sr=[IoT Hub name goes here].[IoT Hub suffix goes here, e.g., private.azure-devices-int.net]/devices/[Device ID goes here]&sig=[SAS Token goes here]&se=[Expiry Time goes here];</pre>
AzureIoTClient 53:1e5a1ca1f274 53 * </blockquote>
AzureIoTClient 53:1e5a1ca1f274 54 *
AzureIoTClient 53:1e5a1ca1f274 55 * @return A non-NULL @c IOTHUB_CLIENT_HANDLE value that is used when
AzureIoTClient 53:1e5a1ca1f274 56 * invoking other functions for IoT Hub client and @c NULL on failure.
AzureIoTClient 53:1e5a1ca1f274 57 */
AzureIoTClient 53:1e5a1ca1f274 58 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_HANDLE, IoTHubClient_CreateFromConnectionString, const char*, connectionString, IOTHUB_CLIENT_TRANSPORT_PROVIDER, protocol);
AzureIoTClient 16:deba40344375 59
AzureIoTClient 53:1e5a1ca1f274 60 /**
AzureIoTClient 53:1e5a1ca1f274 61 * @brief Creates a IoT Hub client for communication with an existing IoT
AzureIoTClient 53:1e5a1ca1f274 62 * Hub using the specified parameters.
AzureIoTClient 53:1e5a1ca1f274 63 *
AzureIoTClient 53:1e5a1ca1f274 64 * @param config Pointer to an @c IOTHUB_CLIENT_CONFIG structure
AzureIoTClient 53:1e5a1ca1f274 65 *
AzureIoTClient 53:1e5a1ca1f274 66 * The API does not allow sharing of a connection across multiple
AzureIoTClient 53:1e5a1ca1f274 67 * devices. This is a blocking call.
AzureIoTClient 53:1e5a1ca1f274 68 *
AzureIoTClient 53:1e5a1ca1f274 69 * @return A non-NULL @c IOTHUB_CLIENT_HANDLE value that is used when
AzureIoTClient 53:1e5a1ca1f274 70 * invoking other functions for IoT Hub client and @c NULL on failure.
AzureIoTClient 53:1e5a1ca1f274 71 */
AzureIoTClient 53:1e5a1ca1f274 72 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_HANDLE, IoTHubClient_Create, const IOTHUB_CLIENT_CONFIG*, config);
AzureIoTClient 16:deba40344375 73
AzureIoTClient 53:1e5a1ca1f274 74 /**
AzureIoTClient 53:1e5a1ca1f274 75 * @brief Creates a IoT Hub client for communication with an existing IoT
AzureIoTClient 53:1e5a1ca1f274 76 * Hub using the specified parameters.
AzureIoTClient 53:1e5a1ca1f274 77 *
AzureIoTClient 53:1e5a1ca1f274 78 * @param transportHandle TRANSPORT_HANDLE which represents a connection.
AzureIoTClient 53:1e5a1ca1f274 79 * @param config Pointer to an @c IOTHUB_CLIENT_CONFIG structure
AzureIoTClient 53:1e5a1ca1f274 80 *
AzureIoTClient 53:1e5a1ca1f274 81 * The API allows sharing of a connection across multiple
AzureIoTClient 53:1e5a1ca1f274 82 * devices. This is a blocking call.
AzureIoTClient 53:1e5a1ca1f274 83 *
AzureIoTClient 53:1e5a1ca1f274 84 * @return A non-NULL @c IOTHUB_CLIENT_HANDLE value that is used when
AzureIoTClient 53:1e5a1ca1f274 85 * invoking other functions for IoT Hub client and @c NULL on failure.
AzureIoTClient 53:1e5a1ca1f274 86 */
AzureIoTClient 53:1e5a1ca1f274 87 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_HANDLE, IoTHubClient_CreateWithTransport, TRANSPORT_HANDLE, transportHandle, const IOTHUB_CLIENT_CONFIG*, config);
Azure.IoT Build 37:18310e4d888d 88
AzureIoTClient 53:1e5a1ca1f274 89 /**
AzureIoTClient 78:74a8d3068204 90 * @brief Creates a IoT Hub client for communication with an existing IoT
AzureIoTClient 78:74a8d3068204 91 * Hub using the device auth module.
AzureIoTClient 78:74a8d3068204 92 *
AzureIoTClient 78:74a8d3068204 93 * @param iothub_uri Pointer to an ioThub hostname received in the registration process
AzureIoTClient 78:74a8d3068204 94 * @param device_id Pointer to the device Id of the device
AzureIoTClient 78:74a8d3068204 95 * @param protocol Function pointer for protocol implementation
AzureIoTClient 78:74a8d3068204 96 *
AzureIoTClient 78:74a8d3068204 97 * @return A non-NULL @c IOTHUB_CLIENT_LL_HANDLE value that is used when
AzureIoTClient 78:74a8d3068204 98 * invoking other functions for IoT Hub client and @c NULL on failure.
AzureIoTClient 78:74a8d3068204 99 */
AzureIoTClient 78:74a8d3068204 100 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_HANDLE, IoTHubClient_CreateFromDeviceAuth, const char*, iothub_uri, const char*, device_id, IOTHUB_CLIENT_TRANSPORT_PROVIDER, protocol);
AzureIoTClient 78:74a8d3068204 101
AzureIoTClient 78:74a8d3068204 102 /**
AzureIoTClient 53:1e5a1ca1f274 103 * @brief Disposes of resources allocated by the IoT Hub client. This is a
AzureIoTClient 53:1e5a1ca1f274 104 * blocking call.
AzureIoTClient 53:1e5a1ca1f274 105 *
AzureIoTClient 53:1e5a1ca1f274 106 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 53:1e5a1ca1f274 107 */
AzureIoTClient 53:1e5a1ca1f274 108 MOCKABLE_FUNCTION(, void, IoTHubClient_Destroy, IOTHUB_CLIENT_HANDLE, iotHubClientHandle);
AzureIoTClient 16:deba40344375 109
AzureIoTClient 53:1e5a1ca1f274 110 /**
AzureIoTClient 53:1e5a1ca1f274 111 * @brief Asynchronous call to send the message specified by @p eventMessageHandle.
AzureIoTClient 53:1e5a1ca1f274 112 *
AzureIoTClient 53:1e5a1ca1f274 113 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 53:1e5a1ca1f274 114 * @param eventMessageHandle The handle to an IoT Hub message.
AzureIoTClient 53:1e5a1ca1f274 115 * @param eventConfirmationCallback The callback specified by the device for receiving
AzureIoTClient 53:1e5a1ca1f274 116 * confirmation of the delivery of the IoT Hub message.
AzureIoTClient 53:1e5a1ca1f274 117 * This callback can be expected to invoke the
AzureIoTClient 53:1e5a1ca1f274 118 * ::IoTHubClient_SendEventAsync function for the
AzureIoTClient 53:1e5a1ca1f274 119 * same message in an attempt to retry sending a failing
AzureIoTClient 53:1e5a1ca1f274 120 * message. The user can specify a @c NULL value here to
AzureIoTClient 53:1e5a1ca1f274 121 * indicate that no callback is required.
AzureIoTClient 53:1e5a1ca1f274 122 * @param userContextCallback User specified context that will be provided to the
AzureIoTClient 53:1e5a1ca1f274 123 * callback. This can be @c NULL.
AzureIoTClient 53:1e5a1ca1f274 124 *
AzureIoTClient 53:1e5a1ca1f274 125 * @b NOTE: The application behavior is undefined if the user calls
AzureIoTClient 53:1e5a1ca1f274 126 * the ::IoTHubClient_Destroy function from within any callback.
AzureIoTClient 53:1e5a1ca1f274 127 *
AzureIoTClient 53:1e5a1ca1f274 128 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 53:1e5a1ca1f274 129 */
AzureIoTClient 53:1e5a1ca1f274 130 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SendEventAsync, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_MESSAGE_HANDLE, eventMessageHandle, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK, eventConfirmationCallback, void*, userContextCallback);
AzureIoTClient 16:deba40344375 131
AzureIoTClient 53:1e5a1ca1f274 132 /**
AzureIoTClient 53:1e5a1ca1f274 133 * @brief This function returns the current sending status for IoTHubClient.
AzureIoTClient 53:1e5a1ca1f274 134 *
AzureIoTClient 53:1e5a1ca1f274 135 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 53:1e5a1ca1f274 136 * @param iotHubClientStatus The sending state is populated at the address pointed
AzureIoTClient 53:1e5a1ca1f274 137 * at by this parameter. The value will be set to
AzureIoTClient 53:1e5a1ca1f274 138 * @c IOTHUBCLIENT_SENDSTATUS_IDLE if there is currently
AzureIoTClient 53:1e5a1ca1f274 139 * no item to be sent and @c IOTHUBCLIENT_SENDSTATUS_BUSY
AzureIoTClient 53:1e5a1ca1f274 140 * if there are.
AzureIoTClient 53:1e5a1ca1f274 141 *
AzureIoTClient 53:1e5a1ca1f274 142 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 53:1e5a1ca1f274 143 */
AzureIoTClient 53:1e5a1ca1f274 144 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_GetSendStatus, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_STATUS*, iotHubClientStatus);
AzureIoTClient 16:deba40344375 145
AzureIoTClient 53:1e5a1ca1f274 146 /**
AzureIoTClient 53:1e5a1ca1f274 147 * @brief Sets up the message callback to be invoked when IoT Hub issues a
AzureIoTClient 53:1e5a1ca1f274 148 * message to the device. This is a blocking call.
AzureIoTClient 53:1e5a1ca1f274 149 *
AzureIoTClient 53:1e5a1ca1f274 150 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 53:1e5a1ca1f274 151 * @param messageCallback The callback specified by the device for receiving
AzureIoTClient 53:1e5a1ca1f274 152 * messages from IoT Hub.
AzureIoTClient 53:1e5a1ca1f274 153 * @param userContextCallback User specified context that will be provided to the
AzureIoTClient 53:1e5a1ca1f274 154 * callback. This can be @c NULL.
AzureIoTClient 53:1e5a1ca1f274 155 *
AzureIoTClient 53:1e5a1ca1f274 156 * @b NOTE: The application behavior is undefined if the user calls
AzureIoTClient 53:1e5a1ca1f274 157 * the ::IoTHubClient_Destroy function from within any callback.
AzureIoTClient 53:1e5a1ca1f274 158 *
AzureIoTClient 53:1e5a1ca1f274 159 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 53:1e5a1ca1f274 160 */
AzureIoTClient 53:1e5a1ca1f274 161 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SetMessageCallback, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC, messageCallback, void*, userContextCallback);
AzureIoTClient 16:deba40344375 162
AzureIoTClient 52:1cc3c6d07cad 163 /**
AzureIoTClient 52:1cc3c6d07cad 164 * @brief Sets up the connection status callback to be invoked representing the status of
AzureIoTClient 52:1cc3c6d07cad 165 * the connection to IOT Hub. This is a blocking call.
AzureIoTClient 52:1cc3c6d07cad 166 *
AzureIoTClient 52:1cc3c6d07cad 167 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 52:1cc3c6d07cad 168 * @param connectionStatusCallback The callback specified by the device for receiving
AzureIoTClient 52:1cc3c6d07cad 169 * updates about the status of the connection to IoT Hub.
AzureIoTClient 52:1cc3c6d07cad 170 * @param userContextCallback User specified context that will be provided to the
AzureIoTClient 52:1cc3c6d07cad 171 * callback. This can be @c NULL.
AzureIoTClient 52:1cc3c6d07cad 172 *
AzureIoTClient 52:1cc3c6d07cad 173 * @b NOTE: The application behavior is undefined if the user calls
AzureIoTClient 52:1cc3c6d07cad 174 * the ::IoTHubClient_LL_Destroy function from within any callback.
AzureIoTClient 52:1cc3c6d07cad 175 *
AzureIoTClient 52:1cc3c6d07cad 176 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 52:1cc3c6d07cad 177 */
AzureIoTClient 53:1e5a1ca1f274 178 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SetConnectionStatusCallback, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_CONNECTION_STATUS_CALLBACK, connectionStatusCallback, void*, userContextCallback);
AzureIoTClient 52:1cc3c6d07cad 179
AzureIoTClient 52:1cc3c6d07cad 180 /**
AzureIoTClient 52:1cc3c6d07cad 181 * @brief Sets up the connection status callback to be invoked representing the status of
AzureIoTClient 52:1cc3c6d07cad 182 * the connection to IOT Hub. This is a blocking call.
AzureIoTClient 52:1cc3c6d07cad 183 *
AzureIoTClient 52:1cc3c6d07cad 184 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 52:1cc3c6d07cad 185 * @param retryPolicy The policy to use to reconnect to IoT Hub when a
AzureIoTClient 52:1cc3c6d07cad 186 * connection drops.
AzureIoTClient 53:1e5a1ca1f274 187 * @param retryTimeoutLimitInSeconds Maximum amount of time(seconds) to attempt reconnection when a
AzureIoTClient 52:1cc3c6d07cad 188 * connection drops to IOT Hub.
AzureIoTClient 52:1cc3c6d07cad 189 *
AzureIoTClient 52:1cc3c6d07cad 190 * @b NOTE: The application behavior is undefined if the user calls
AzureIoTClient 52:1cc3c6d07cad 191 * the ::IoTHubClient_LL_Destroy function from within any callback.
AzureIoTClient 52:1cc3c6d07cad 192 *
AzureIoTClient 52:1cc3c6d07cad 193 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 52:1cc3c6d07cad 194 */
AzureIoTClient 53:1e5a1ca1f274 195 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SetRetryPolicy, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_RETRY_POLICY, retryPolicy, size_t, retryTimeoutLimitInSeconds);
AzureIoTClient 52:1cc3c6d07cad 196
AzureIoTClient 52:1cc3c6d07cad 197 /**
AzureIoTClient 52:1cc3c6d07cad 198 * @brief Sets up the connection status callback to be invoked representing the status of
AzureIoTClient 52:1cc3c6d07cad 199 * the connection to IOT Hub. This is a blocking call.
AzureIoTClient 52:1cc3c6d07cad 200 *
AzureIoTClient 52:1cc3c6d07cad 201 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 52:1cc3c6d07cad 202 * @param retryPolicy Out parameter containing the policy to use to reconnect to IoT Hub.
AzureIoTClient 53:1e5a1ca1f274 203 * @param retryTimeoutLimitInSeconds Out parameter containing maximum amount of time in seconds to attempt reconnection
AzureIoTClient 52:1cc3c6d07cad 204 to IOT Hub.
AzureIoTClient 52:1cc3c6d07cad 205 *
AzureIoTClient 52:1cc3c6d07cad 206 * @b NOTE: The application behavior is undefined if the user calls
AzureIoTClient 52:1cc3c6d07cad 207 * the ::IoTHubClient_LL_Destroy function from within any callback.
AzureIoTClient 52:1cc3c6d07cad 208 *
AzureIoTClient 52:1cc3c6d07cad 209 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 52:1cc3c6d07cad 210 */
AzureIoTClient 53:1e5a1ca1f274 211 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_GetRetryPolicy, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_RETRY_POLICY*, retryPolicy, size_t*, retryTimeoutLimitInSeconds);
AzureIoTClient 52:1cc3c6d07cad 212
AzureIoTClient 53:1e5a1ca1f274 213 /**
AzureIoTClient 53:1e5a1ca1f274 214 * @brief This function returns in the out parameter @p lastMessageReceiveTime
AzureIoTClient 53:1e5a1ca1f274 215 * what was the value of the @c time function when the last message was
AzureIoTClient 53:1e5a1ca1f274 216 * received at the client.
AzureIoTClient 53:1e5a1ca1f274 217 *
AzureIoTClient 53:1e5a1ca1f274 218 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 53:1e5a1ca1f274 219 * @param lastMessageReceiveTime Out parameter containing the value of @c time function
AzureIoTClient 53:1e5a1ca1f274 220 * when the last message was received.
AzureIoTClient 53:1e5a1ca1f274 221 *
AzureIoTClient 53:1e5a1ca1f274 222 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 53:1e5a1ca1f274 223 */
AzureIoTClient 53:1e5a1ca1f274 224 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_GetLastMessageReceiveTime, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, time_t*, lastMessageReceiveTime);
AzureIoTClient 16:deba40344375 225
AzureIoTClient 53:1e5a1ca1f274 226 /**
AzureIoTClient 53:1e5a1ca1f274 227 * @brief This API sets a runtime option identified by parameter @p optionName
AzureIoTClient 53:1e5a1ca1f274 228 * to a value pointed to by @p value. @p optionName and the data type
AzureIoTClient 53:1e5a1ca1f274 229 * @p value is pointing to are specific for every option.
AzureIoTClient 53:1e5a1ca1f274 230 *
AzureIoTClient 53:1e5a1ca1f274 231 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 53:1e5a1ca1f274 232 * @param optionName Name of the option.
AzureIoTClient 53:1e5a1ca1f274 233 * @param value The value.
AzureIoTClient 53:1e5a1ca1f274 234 *
AzureIoTClient 53:1e5a1ca1f274 235 * The options that can be set via this API are:
AzureIoTClient 53:1e5a1ca1f274 236 * - @b timeout - the maximum time in milliseconds a communication is
AzureIoTClient 53:1e5a1ca1f274 237 * allowed to use. @p value is a pointer to an @c unsigned @c int with
AzureIoTClient 53:1e5a1ca1f274 238 * the timeout value in milliseconds. This is only supported for the HTTP
AzureIoTClient 53:1e5a1ca1f274 239 * protocol as of now. When the HTTP protocol uses CURL, the meaning of
AzureIoTClient 53:1e5a1ca1f274 240 * the parameter is <em>total request time</em>. When the HTTP protocol uses
AzureIoTClient 53:1e5a1ca1f274 241 * winhttp, the meaning is the same as the @c dwSendTimeout and
AzureIoTClient 53:1e5a1ca1f274 242 * @c dwReceiveTimeout parameters of the
AzureIoTClient 53:1e5a1ca1f274 243 * <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa384116(v=vs.85).aspx">
AzureIoTClient 53:1e5a1ca1f274 244 * WinHttpSetTimeouts</a> API.
AzureIoTClient 53:1e5a1ca1f274 245 * - @b CURLOPT_LOW_SPEED_LIMIT - only available for HTTP protocol and only
AzureIoTClient 53:1e5a1ca1f274 246 * when CURL is used. It has the same meaning as CURL's option with the same
AzureIoTClient 53:1e5a1ca1f274 247 * name. @p value is pointer to a long.
AzureIoTClient 53:1e5a1ca1f274 248 * - @b CURLOPT_LOW_SPEED_TIME - only available for HTTP protocol and only
AzureIoTClient 53:1e5a1ca1f274 249 * when CURL is used. It has the same meaning as CURL's option with the same
AzureIoTClient 53:1e5a1ca1f274 250 * name. @p value is pointer to a long.
AzureIoTClient 53:1e5a1ca1f274 251 * - @b CURLOPT_FORBID_REUSE - only available for HTTP protocol and only
AzureIoTClient 53:1e5a1ca1f274 252 * when CURL is used. It has the same meaning as CURL's option with the same
AzureIoTClient 53:1e5a1ca1f274 253 * name. @p value is pointer to a long.
AzureIoTClient 53:1e5a1ca1f274 254 * - @b CURLOPT_FRESH_CONNECT - only available for HTTP protocol and only
AzureIoTClient 53:1e5a1ca1f274 255 * when CURL is used. It has the same meaning as CURL's option with the same
AzureIoTClient 53:1e5a1ca1f274 256 * name. @p value is pointer to a long.
AzureIoTClient 53:1e5a1ca1f274 257 * - @b CURLOPT_VERBOSE - only available for HTTP protocol and only
AzureIoTClient 53:1e5a1ca1f274 258 * when CURL is used. It has the same meaning as CURL's option with the same
AzureIoTClient 53:1e5a1ca1f274 259 * name. @p value is pointer to a long.
AzureIoTClient 53:1e5a1ca1f274 260 * - @b messageTimeout - the maximum time in milliseconds until a message
AzureIoTClient 53:1e5a1ca1f274 261 * is timeouted. The time starts at IoTHubClient_SendEventAsync. By default,
AzureIoTClient 53:1e5a1ca1f274 262 * messages do not expire. @p is a pointer to a uint64_t
AzureIoTClient 72:c737b53d7689 263 * - @b c2d_keep_alive_freq_secs - the AMQP C2D keep alive interval in seconds.
AzureIoTClient 72:c737b53d7689 264 * After the connection established the client requests the server to set the
AzureIoTClient 72:c737b53d7689 265 * keep alive interval for given time.
AzureIoTClient 72:c737b53d7689 266 * If it is not set then the default 240 sec applies.
AzureIoTClient 72:c737b53d7689 267 * If it is set to zero the server will not send keep alive messages to the client.
AzureIoTClient 53:1e5a1ca1f274 268 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 53:1e5a1ca1f274 269 */
AzureIoTClient 53:1e5a1ca1f274 270 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SetOption, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, const char*, optionName, const void*, value);
AzureIoTClient 53:1e5a1ca1f274 271
AzureIoTClient 53:1e5a1ca1f274 272 /**
AzureIoTClient 53:1e5a1ca1f274 273 * @brief This API specifies a call back to be used when the device receives a state update.
AzureIoTClient 53:1e5a1ca1f274 274 *
AzureIoTClient 53:1e5a1ca1f274 275 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 53:1e5a1ca1f274 276 * @param deviceTwinCallback The callback specified by the device client to be used for updating
AzureIoTClient 53:1e5a1ca1f274 277 * the desired state. The callback will be called in response to a
AzureIoTClient 53:1e5a1ca1f274 278 * request send by the IoTHub services. The payload will be passed to the
AzureIoTClient 53:1e5a1ca1f274 279 * callback, along with two version numbers:
AzureIoTClient 53:1e5a1ca1f274 280 * - Desired:
AzureIoTClient 53:1e5a1ca1f274 281 * - LastSeenReported:
AzureIoTClient 53:1e5a1ca1f274 282 * @param userContextCallback User specified context that will be provided to the
AzureIoTClient 53:1e5a1ca1f274 283 * callback. This can be @c NULL.
AzureIoTClient 53:1e5a1ca1f274 284 *
AzureIoTClient 53:1e5a1ca1f274 285 * @b NOTE: The application behavior is undefined if the user calls
AzureIoTClient 53:1e5a1ca1f274 286 * the ::IoTHubClient_Destroy function from within any callback.
AzureIoTClient 53:1e5a1ca1f274 287 *
AzureIoTClient 53:1e5a1ca1f274 288 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 53:1e5a1ca1f274 289 */
AzureIoTClient 53:1e5a1ca1f274 290 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SetDeviceTwinCallback, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_DEVICE_TWIN_CALLBACK, deviceTwinCallback, void*, userContextCallback);
AzureIoTClient 53:1e5a1ca1f274 291
AzureIoTClient 53:1e5a1ca1f274 292 /**
AzureIoTClient 53:1e5a1ca1f274 293 * @brief This API sends a report of the device's properties and their current values.
AzureIoTClient 53:1e5a1ca1f274 294 *
AzureIoTClient 53:1e5a1ca1f274 295 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 53:1e5a1ca1f274 296 * @param reportedState The current device property values to be 'reported' to the IoTHub.
AzureIoTClient 53:1e5a1ca1f274 297 * @param reportedStateCallback The callback specified by the device client to be called with the
AzureIoTClient 53:1e5a1ca1f274 298 * result of the transaction.
AzureIoTClient 53:1e5a1ca1f274 299 * @param userContextCallback User specified context that will be provided to the
AzureIoTClient 53:1e5a1ca1f274 300 * callback. This can be @c NULL.
AzureIoTClient 53:1e5a1ca1f274 301 *
AzureIoTClient 53:1e5a1ca1f274 302 * @b NOTE: The application behavior is undefined if the user calls
AzureIoTClient 53:1e5a1ca1f274 303 * the ::IoTHubClient_Destroy function from within any callback.
AzureIoTClient 53:1e5a1ca1f274 304 *
AzureIoTClient 53:1e5a1ca1f274 305 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 53:1e5a1ca1f274 306 */
AzureIoTClient 53:1e5a1ca1f274 307 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SendReportedState, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, const unsigned char*, reportedState, size_t, size, IOTHUB_CLIENT_REPORTED_STATE_CALLBACK, reportedStateCallback, void*, userContextCallback);
AzureIoTClient 53:1e5a1ca1f274 308
AzureIoTClient 53:1e5a1ca1f274 309 /**
AzureIoTClient 53:1e5a1ca1f274 310 * @brief This API sets callback for cloud to device method call.
AzureIoTClient 53:1e5a1ca1f274 311 *
AzureIoTClient 53:1e5a1ca1f274 312 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 53:1e5a1ca1f274 313 * @param deviceMethodCallback The callback which will be called by IoTHub.
AzureIoTClient 53:1e5a1ca1f274 314 * @param userContextCallback User specified context that will be provided to the
AzureIoTClient 53:1e5a1ca1f274 315 * callback. This can be @c NULL.
AzureIoTClient 53:1e5a1ca1f274 316 *
AzureIoTClient 53:1e5a1ca1f274 317 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 53:1e5a1ca1f274 318 */
AzureIoTClient 53:1e5a1ca1f274 319 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SetDeviceMethodCallback, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_DEVICE_METHOD_CALLBACK_ASYNC, deviceMethodCallback, void*, userContextCallback);
AzureIoTClient 43:038d8511e817 320
AzureIoTClient 55:59b527ab3452 321 /**
AzureIoTClient 55:59b527ab3452 322 * @brief This API sets callback for async cloud to device method call.
AzureIoTClient 55:59b527ab3452 323 *
AzureIoTClient 55:59b527ab3452 324 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 55:59b527ab3452 325 * @param inboundDeviceMethodCallback The callback which will be called by IoTHub.
AzureIoTClient 55:59b527ab3452 326 * @param userContextCallback User specified context that will be provided to the
AzureIoTClient 55:59b527ab3452 327 * callback. This can be @c NULL.
AzureIoTClient 55:59b527ab3452 328 *
AzureIoTClient 55:59b527ab3452 329 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 55:59b527ab3452 330 */
AzureIoTClient 55:59b527ab3452 331 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SetDeviceMethodCallback_Ex, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_INBOUND_DEVICE_METHOD_CALLBACK, inboundDeviceMethodCallback, void*, userContextCallback);
AzureIoTClient 55:59b527ab3452 332
AzureIoTClient 55:59b527ab3452 333 /**
AzureIoTClient 55:59b527ab3452 334 * @brief This API responses to a asnyc method callback identified the methodId.
AzureIoTClient 55:59b527ab3452 335 *
AzureIoTClient 55:59b527ab3452 336 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 55:59b527ab3452 337 * @param methodId The methodId of the Device Method callback.
AzureIoTClient 55:59b527ab3452 338 * @param response The response data for the method callback.
AzureIoTClient 55:59b527ab3452 339 * @param response_size The size of the response data buffer.
AzureIoTClient 55:59b527ab3452 340 * @param status_response The status response of the method callback.
AzureIoTClient 55:59b527ab3452 341 *
AzureIoTClient 55:59b527ab3452 342 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 55:59b527ab3452 343 */
AzureIoTClient 55:59b527ab3452 344 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_DeviceMethodResponse, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, METHOD_HANDLE, methodId, const unsigned char*, response, size_t, response_size, int, statusCode);
AzureIoTClient 55:59b527ab3452 345
AzureIoTClient 44:33dd78697616 346 #ifndef DONT_USE_UPLOADTOBLOB
AzureIoTClient 42:448eecc3676e 347 /**
AzureIoTClient 42:448eecc3676e 348 * @brief IoTHubClient_UploadToBlobAsync uploads data from memory to a file in Azure Blob Storage.
AzureIoTClient 42:448eecc3676e 349 *
AzureIoTClient 42:448eecc3676e 350 * @param iotHubClientHandle The handle created by a call to the IoTHubClient_Create function.
AzureIoTClient 42:448eecc3676e 351 * @param destinationFileName The name of the file to be created in Azure Blob Storage.
AzureIoTClient 42:448eecc3676e 352 * @param source The source of data.
AzureIoTClient 42:448eecc3676e 353 * @param size The size of data.
AzureIoTClient 42:448eecc3676e 354 * @param iotHubClientFileUploadCallback A callback to be invoked when the file upload operation has finished.
AzureIoTClient 42:448eecc3676e 355 * @param context A user-provided context to be passed to the file upload callback.
AzureIoTClient 42:448eecc3676e 356 *
AzureIoTClient 42:448eecc3676e 357 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 42:448eecc3676e 358 */
AzureIoTClient 53:1e5a1ca1f274 359 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_UploadToBlobAsync, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, const char*, destinationFileName, const unsigned char*, source, size_t, size, IOTHUB_CLIENT_FILE_UPLOAD_CALLBACK, iotHubClientFileUploadCallback, void*, context);
AzureIoTClient 43:038d8511e817 360 #endif
AzureIoTClient 16:deba40344375 361 #ifdef __cplusplus
AzureIoTClient 16:deba40344375 362 }
AzureIoTClient 16:deba40344375 363 #endif
AzureIoTClient 16:deba40344375 364
AzureIoTClient 16:deba40344375 365 #endif /* IOTHUB_CLIENT_H */