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 Oct 04 09:15:49 2018 -0700
Revision:
93:7c0bbb86b167
Parent:
92:97148cf9aa2a
1.2.10

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