Xin Zhang / azure-iot-c-sdk-f767zi

Dependents:   samplemqtt

Committer:
XinZhangMS
Date:
Thu Aug 23 06:52:14 2018 +0000
Revision:
0:f7f1f0d76dd6
azure-c-sdk for mbed os supporting NUCLEO_F767ZI

Who changed what in which revision?

UserRevisionLine numberNew contents of line
XinZhangMS 0:f7f1f0d76dd6 1 // Copyright (c) Microsoft. All rights reserved.
XinZhangMS 0:f7f1f0d76dd6 2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
XinZhangMS 0:f7f1f0d76dd6 3
XinZhangMS 0:f7f1f0d76dd6 4 /** @file iothub_client_ll.h
XinZhangMS 0:f7f1f0d76dd6 5 * @brief APIs that allow a user (usually a device) to communicate
XinZhangMS 0:f7f1f0d76dd6 6 * with an Azure IoTHub.
XinZhangMS 0:f7f1f0d76dd6 7 *
XinZhangMS 0:f7f1f0d76dd6 8 * @details IoTHubClient_LL is a module that allows a user (usually a
XinZhangMS 0:f7f1f0d76dd6 9 * device) to communicate with an Azure IoTHub. It can send events
XinZhangMS 0:f7f1f0d76dd6 10 * and receive messages. At any given moment in time there can only
XinZhangMS 0:f7f1f0d76dd6 11 * be at most 1 message callback function.
XinZhangMS 0:f7f1f0d76dd6 12 *
XinZhangMS 0:f7f1f0d76dd6 13 * This API surface contains a set of APIs that allows the user to
XinZhangMS 0:f7f1f0d76dd6 14 * interact with the lower layer portion of the IoTHubClient. These APIs
XinZhangMS 0:f7f1f0d76dd6 15 * contain @c _LL_ in their name, but retain the same functionality like the
XinZhangMS 0:f7f1f0d76dd6 16 * @c IoTHubClient_... APIs, with one difference. If the @c _LL_ APIs are
XinZhangMS 0:f7f1f0d76dd6 17 * used then the user is responsible for scheduling when the actual work done
XinZhangMS 0:f7f1f0d76dd6 18 * by the IoTHubClient happens (when the data is sent/received on/from the wire).
XinZhangMS 0:f7f1f0d76dd6 19 * This is useful for constrained devices where spinning a separate thread is
XinZhangMS 0:f7f1f0d76dd6 20 * often not desired.
XinZhangMS 0:f7f1f0d76dd6 21 */
XinZhangMS 0:f7f1f0d76dd6 22
XinZhangMS 0:f7f1f0d76dd6 23 #ifndef IOTHUB_CLIENT_LL_H
XinZhangMS 0:f7f1f0d76dd6 24 #define IOTHUB_CLIENT_LL_H
XinZhangMS 0:f7f1f0d76dd6 25
XinZhangMS 0:f7f1f0d76dd6 26 #include <stddef.h>
XinZhangMS 0:f7f1f0d76dd6 27 #include <stdint.h>
XinZhangMS 0:f7f1f0d76dd6 28
XinZhangMS 0:f7f1f0d76dd6 29 #include "azure_c_shared_utility/umock_c_prod.h"
XinZhangMS 0:f7f1f0d76dd6 30
XinZhangMS 0:f7f1f0d76dd6 31 #include "iothub_transport_ll.h"
XinZhangMS 0:f7f1f0d76dd6 32 #include "iothub_client_core_ll.h"
XinZhangMS 0:f7f1f0d76dd6 33
XinZhangMS 0:f7f1f0d76dd6 34 #ifdef __cplusplus
XinZhangMS 0:f7f1f0d76dd6 35 extern "C"
XinZhangMS 0:f7f1f0d76dd6 36 {
XinZhangMS 0:f7f1f0d76dd6 37 #endif
XinZhangMS 0:f7f1f0d76dd6 38
XinZhangMS 0:f7f1f0d76dd6 39 typedef struct IOTHUB_CLIENT_CORE_LL_HANDLE_DATA_TAG* IOTHUB_CLIENT_LL_HANDLE;
XinZhangMS 0:f7f1f0d76dd6 40
XinZhangMS 0:f7f1f0d76dd6 41
XinZhangMS 0:f7f1f0d76dd6 42 /**
XinZhangMS 0:f7f1f0d76dd6 43 * @brief Creates a IoT Hub client for communication with an existing
XinZhangMS 0:f7f1f0d76dd6 44 * IoT Hub using the specified connection string parameter.
XinZhangMS 0:f7f1f0d76dd6 45 *
XinZhangMS 0:f7f1f0d76dd6 46 * @param connectionString Pointer to a character string
XinZhangMS 0:f7f1f0d76dd6 47 * @param protocol Function pointer for protocol implementation
XinZhangMS 0:f7f1f0d76dd6 48 *
XinZhangMS 0:f7f1f0d76dd6 49 * Sample connection string:
XinZhangMS 0:f7f1f0d76dd6 50 * <blockquote>
XinZhangMS 0:f7f1f0d76dd6 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>
XinZhangMS 0:f7f1f0d76dd6 52 * </blockquote>
XinZhangMS 0:f7f1f0d76dd6 53 *
XinZhangMS 0:f7f1f0d76dd6 54 * @return A non-NULL @c IOTHUB_CLIENT_LL_HANDLE value that is used when
XinZhangMS 0:f7f1f0d76dd6 55 * invoking other functions for IoT Hub client and @c NULL on failure.
XinZhangMS 0:f7f1f0d76dd6 56 */
XinZhangMS 0:f7f1f0d76dd6 57 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_LL_HANDLE, IoTHubClient_LL_CreateFromConnectionString, const char*, connectionString, IOTHUB_CLIENT_TRANSPORT_PROVIDER, protocol);
XinZhangMS 0:f7f1f0d76dd6 58
XinZhangMS 0:f7f1f0d76dd6 59 /**
XinZhangMS 0:f7f1f0d76dd6 60 * @brief Creates a IoT Hub client for communication with an existing IoT
XinZhangMS 0:f7f1f0d76dd6 61 * Hub using the specified parameters.
XinZhangMS 0:f7f1f0d76dd6 62 *
XinZhangMS 0:f7f1f0d76dd6 63 * @param config Pointer to an @c IOTHUB_CLIENT_CONFIG structure
XinZhangMS 0:f7f1f0d76dd6 64 *
XinZhangMS 0:f7f1f0d76dd6 65 * The API does not allow sharing of a connection across multiple
XinZhangMS 0:f7f1f0d76dd6 66 * devices. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 67 *
XinZhangMS 0:f7f1f0d76dd6 68 * @return A non-NULL @c IOTHUB_CLIENT_LL_HANDLE value that is used when
XinZhangMS 0:f7f1f0d76dd6 69 * invoking other functions for IoT Hub client and @c NULL on failure.
XinZhangMS 0:f7f1f0d76dd6 70 */
XinZhangMS 0:f7f1f0d76dd6 71 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_LL_HANDLE, IoTHubClient_LL_Create, const IOTHUB_CLIENT_CONFIG*, config);
XinZhangMS 0:f7f1f0d76dd6 72
XinZhangMS 0:f7f1f0d76dd6 73 /**
XinZhangMS 0:f7f1f0d76dd6 74 * @brief Creates a IoT Hub client for communication with an existing IoT
XinZhangMS 0:f7f1f0d76dd6 75 * Hub using an existing transport.
XinZhangMS 0:f7f1f0d76dd6 76 *
XinZhangMS 0:f7f1f0d76dd6 77 * @param config Pointer to an @c IOTHUB_CLIENT_DEVICE_CONFIG structure
XinZhangMS 0:f7f1f0d76dd6 78 *
XinZhangMS 0:f7f1f0d76dd6 79 * The API *allows* sharing of a connection across multiple
XinZhangMS 0:f7f1f0d76dd6 80 * devices. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 81 *
XinZhangMS 0:f7f1f0d76dd6 82 * @return A non-NULL @c IOTHUB_CLIENT_LL_HANDLE value that is used when
XinZhangMS 0:f7f1f0d76dd6 83 * invoking other functions for IoT Hub client and @c NULL on failure.
XinZhangMS 0:f7f1f0d76dd6 84 */
XinZhangMS 0:f7f1f0d76dd6 85 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_LL_HANDLE, IoTHubClient_LL_CreateWithTransport, const IOTHUB_CLIENT_DEVICE_CONFIG*, config);
XinZhangMS 0:f7f1f0d76dd6 86
XinZhangMS 0:f7f1f0d76dd6 87 /**
XinZhangMS 0:f7f1f0d76dd6 88 * @brief Creates a IoT Hub client for communication with an existing IoT
XinZhangMS 0:f7f1f0d76dd6 89 * Hub using the device auth module.
XinZhangMS 0:f7f1f0d76dd6 90 *
XinZhangMS 0:f7f1f0d76dd6 91 * @param iothub_uri Pointer to an ioThub hostname received in the registration process
XinZhangMS 0:f7f1f0d76dd6 92 * @param device_id Pointer to the device Id of the device
XinZhangMS 0:f7f1f0d76dd6 93 * @param device_auth_handle a device auth handle used to generate the connection string
XinZhangMS 0:f7f1f0d76dd6 94 * @param protocol Function pointer for protocol implementation
XinZhangMS 0:f7f1f0d76dd6 95 *
XinZhangMS 0:f7f1f0d76dd6 96 * @return A non-NULL @c IOTHUB_CLIENT_LL_HANDLE value that is used when
XinZhangMS 0:f7f1f0d76dd6 97 * invoking other functions for IoT Hub client and @c NULL on failure.
XinZhangMS 0:f7f1f0d76dd6 98 */
XinZhangMS 0:f7f1f0d76dd6 99 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_LL_HANDLE, IoTHubClient_LL_CreateFromDeviceAuth, const char*, iothub_uri, const char*, device_id, IOTHUB_CLIENT_TRANSPORT_PROVIDER, protocol);
XinZhangMS 0:f7f1f0d76dd6 100
XinZhangMS 0:f7f1f0d76dd6 101 /**
XinZhangMS 0:f7f1f0d76dd6 102 * @brief Disposes of resources allocated by the IoT Hub client. This is a
XinZhangMS 0:f7f1f0d76dd6 103 * blocking call.
XinZhangMS 0:f7f1f0d76dd6 104 *
XinZhangMS 0:f7f1f0d76dd6 105 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 106 */
XinZhangMS 0:f7f1f0d76dd6 107 MOCKABLE_FUNCTION(, void, IoTHubClient_LL_Destroy, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle);
XinZhangMS 0:f7f1f0d76dd6 108
XinZhangMS 0:f7f1f0d76dd6 109 /**
XinZhangMS 0:f7f1f0d76dd6 110 * @brief Asynchronous call to send the message specified by @p eventMessageHandle.
XinZhangMS 0:f7f1f0d76dd6 111 *
XinZhangMS 0:f7f1f0d76dd6 112 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 113 * @param eventMessageHandle The handle to an IoT Hub message.
XinZhangMS 0:f7f1f0d76dd6 114 * @param eventConfirmationCallback The callback specified by the device for receiving
XinZhangMS 0:f7f1f0d76dd6 115 * confirmation of the delivery of the IoT Hub message.
XinZhangMS 0:f7f1f0d76dd6 116 * This callback can be expected to invoke the
XinZhangMS 0:f7f1f0d76dd6 117 * ::IoTHubClient_LL_SendEventAsync function for the
XinZhangMS 0:f7f1f0d76dd6 118 * same message in an attempt to retry sending a failing
XinZhangMS 0:f7f1f0d76dd6 119 * message. The user can specify a @c NULL value here to
XinZhangMS 0:f7f1f0d76dd6 120 * indicate that no callback is required.
XinZhangMS 0:f7f1f0d76dd6 121 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 122 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 123 *
XinZhangMS 0:f7f1f0d76dd6 124 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 125 * the ::IoTHubClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 126 *
XinZhangMS 0:f7f1f0d76dd6 127 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 128 */
XinZhangMS 0:f7f1f0d76dd6 129 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_SendEventAsync, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_MESSAGE_HANDLE, eventMessageHandle, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK, eventConfirmationCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 130
XinZhangMS 0:f7f1f0d76dd6 131 /**
XinZhangMS 0:f7f1f0d76dd6 132 * @brief This function returns the current sending status for IoTHubClient.
XinZhangMS 0:f7f1f0d76dd6 133 *
XinZhangMS 0:f7f1f0d76dd6 134 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 135 * @param iotHubClientStatus The sending state is populated at the address pointed
XinZhangMS 0:f7f1f0d76dd6 136 * at by this parameter. The value will be set to
XinZhangMS 0:f7f1f0d76dd6 137 * @c IOTHUBCLIENT_SENDSTATUS_IDLE if there is currently
XinZhangMS 0:f7f1f0d76dd6 138 * no item to be sent and @c IOTHUBCLIENT_SENDSTATUS_BUSY
XinZhangMS 0:f7f1f0d76dd6 139 * if there are.
XinZhangMS 0:f7f1f0d76dd6 140 *
XinZhangMS 0:f7f1f0d76dd6 141 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 142 */
XinZhangMS 0:f7f1f0d76dd6 143 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_GetSendStatus, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_STATUS*, iotHubClientStatus);
XinZhangMS 0:f7f1f0d76dd6 144
XinZhangMS 0:f7f1f0d76dd6 145 /**
XinZhangMS 0:f7f1f0d76dd6 146 * @brief Sets up the message callback to be invoked when IoT Hub issues a
XinZhangMS 0:f7f1f0d76dd6 147 * message to the device. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 148 *
XinZhangMS 0:f7f1f0d76dd6 149 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 150 * @param messageCallback The callback specified by the device for receiving
XinZhangMS 0:f7f1f0d76dd6 151 * messages from IoT Hub.
XinZhangMS 0:f7f1f0d76dd6 152 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 153 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 154 *
XinZhangMS 0:f7f1f0d76dd6 155 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 156 * the ::IoTHubClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 157 *
XinZhangMS 0:f7f1f0d76dd6 158 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 159 */
XinZhangMS 0:f7f1f0d76dd6 160 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_SetMessageCallback, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC, messageCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 161
XinZhangMS 0:f7f1f0d76dd6 162 /**
XinZhangMS 0:f7f1f0d76dd6 163 * @brief Sets up the connection status callback to be invoked representing the status of
XinZhangMS 0:f7f1f0d76dd6 164 * the connection to IOT Hub. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 165 *
XinZhangMS 0:f7f1f0d76dd6 166 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 167 * @param connectionStatusCallback The callback specified by the device for receiving
XinZhangMS 0:f7f1f0d76dd6 168 * updates about the status of the connection to IoT Hub.
XinZhangMS 0:f7f1f0d76dd6 169 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 170 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 171 *
XinZhangMS 0:f7f1f0d76dd6 172 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 173 * the ::IoTHubClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 174 *
XinZhangMS 0:f7f1f0d76dd6 175 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 176 */
XinZhangMS 0:f7f1f0d76dd6 177 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_SetConnectionStatusCallback, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_CONNECTION_STATUS_CALLBACK, connectionStatusCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 178
XinZhangMS 0:f7f1f0d76dd6 179 /**
XinZhangMS 0:f7f1f0d76dd6 180 * @brief Sets up the connection status callback to be invoked representing the status of
XinZhangMS 0:f7f1f0d76dd6 181 * the connection to IOT Hub. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 182 *
XinZhangMS 0:f7f1f0d76dd6 183 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 184 * @param retryPolicy The policy to use to reconnect to IoT Hub when a
XinZhangMS 0:f7f1f0d76dd6 185 * connection drops.
XinZhangMS 0:f7f1f0d76dd6 186 * @param retryTimeoutLimitInSeconds Maximum amount of time(seconds) to attempt reconnection when a
XinZhangMS 0:f7f1f0d76dd6 187 * connection drops to IOT Hub.
XinZhangMS 0:f7f1f0d76dd6 188 *
XinZhangMS 0:f7f1f0d76dd6 189 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 190 * the ::IoTHubClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 191 *
XinZhangMS 0:f7f1f0d76dd6 192 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 193 */
XinZhangMS 0:f7f1f0d76dd6 194 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_SetRetryPolicy, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_RETRY_POLICY, retryPolicy, size_t, retryTimeoutLimitInSeconds);
XinZhangMS 0:f7f1f0d76dd6 195
XinZhangMS 0:f7f1f0d76dd6 196
XinZhangMS 0:f7f1f0d76dd6 197 /**
XinZhangMS 0:f7f1f0d76dd6 198 * @brief Sets up the connection status callback to be invoked representing the status of
XinZhangMS 0:f7f1f0d76dd6 199 * the connection to IOT Hub. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 200 *
XinZhangMS 0:f7f1f0d76dd6 201 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 202 * @param retryPolicy Out parameter containing the policy to use to reconnect to IoT Hub.
XinZhangMS 0:f7f1f0d76dd6 203 * @param retryTimeoutLimitInSeconds Out parameter containing maximum amount of time in seconds to attempt reconnection
XinZhangMS 0:f7f1f0d76dd6 204 to IOT Hub.
XinZhangMS 0:f7f1f0d76dd6 205 *
XinZhangMS 0:f7f1f0d76dd6 206 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 207 * the ::IoTHubClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 208 *
XinZhangMS 0:f7f1f0d76dd6 209 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 210 */
XinZhangMS 0:f7f1f0d76dd6 211 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_GetRetryPolicy, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_RETRY_POLICY*, retryPolicy, size_t*, retryTimeoutLimitInSeconds);
XinZhangMS 0:f7f1f0d76dd6 212
XinZhangMS 0:f7f1f0d76dd6 213 /**
XinZhangMS 0:f7f1f0d76dd6 214 * @brief This function returns in the out parameter @p lastMessageReceiveTime
XinZhangMS 0:f7f1f0d76dd6 215 * what was the value of the @c time function when the last message was
XinZhangMS 0:f7f1f0d76dd6 216 * received at the client.
XinZhangMS 0:f7f1f0d76dd6 217 *
XinZhangMS 0:f7f1f0d76dd6 218 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 219 * @param lastMessageReceiveTime Out parameter containing the value of @c time function
XinZhangMS 0:f7f1f0d76dd6 220 * when the last message was received.
XinZhangMS 0:f7f1f0d76dd6 221 *
XinZhangMS 0:f7f1f0d76dd6 222 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 223 */
XinZhangMS 0:f7f1f0d76dd6 224 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_GetLastMessageReceiveTime, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, time_t*, lastMessageReceiveTime);
XinZhangMS 0:f7f1f0d76dd6 225
XinZhangMS 0:f7f1f0d76dd6 226 /**
XinZhangMS 0:f7f1f0d76dd6 227 * @brief This function is meant to be called by the user when work
XinZhangMS 0:f7f1f0d76dd6 228 * (sending/receiving) can be done by the IoTHubClient.
XinZhangMS 0:f7f1f0d76dd6 229 *
XinZhangMS 0:f7f1f0d76dd6 230 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 231 *
XinZhangMS 0:f7f1f0d76dd6 232 * All IoTHubClient interactions (in regards to network traffic
XinZhangMS 0:f7f1f0d76dd6 233 * and/or user level callbacks) are the effect of calling this
XinZhangMS 0:f7f1f0d76dd6 234 * function and they take place synchronously inside _DoWork.
XinZhangMS 0:f7f1f0d76dd6 235 */
XinZhangMS 0:f7f1f0d76dd6 236 MOCKABLE_FUNCTION(, void, IoTHubClient_LL_DoWork, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle);
XinZhangMS 0:f7f1f0d76dd6 237
XinZhangMS 0:f7f1f0d76dd6 238 /**
XinZhangMS 0:f7f1f0d76dd6 239 * @brief This API sets a runtime option identified by parameter @p optionName
XinZhangMS 0:f7f1f0d76dd6 240 * to a value pointed to by @p value. @p optionName and the data type
XinZhangMS 0:f7f1f0d76dd6 241 * @p value is pointing to are specific for every option.
XinZhangMS 0:f7f1f0d76dd6 242 *
XinZhangMS 0:f7f1f0d76dd6 243 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 244 * @param optionName Name of the option.
XinZhangMS 0:f7f1f0d76dd6 245 * @param value The value.
XinZhangMS 0:f7f1f0d76dd6 246 *
XinZhangMS 0:f7f1f0d76dd6 247 * The options that can be set via this API are:
XinZhangMS 0:f7f1f0d76dd6 248 * - @b timeout - the maximum time in milliseconds a communication is
XinZhangMS 0:f7f1f0d76dd6 249 * allowed to use. @p value is a pointer to an @c unsigned @c int with
XinZhangMS 0:f7f1f0d76dd6 250 * the timeout value in milliseconds. This is only supported for the HTTP
XinZhangMS 0:f7f1f0d76dd6 251 * protocol as of now. When the HTTP protocol uses CURL, the meaning of
XinZhangMS 0:f7f1f0d76dd6 252 * the parameter is <em>total request time</em>. When the HTTP protocol uses
XinZhangMS 0:f7f1f0d76dd6 253 * winhttp, the meaning is the same as the @c dwSendTimeout and
XinZhangMS 0:f7f1f0d76dd6 254 * @c dwReceiveTimeout parameters of the
XinZhangMS 0:f7f1f0d76dd6 255 * <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa384116(v=vs.85).aspx">
XinZhangMS 0:f7f1f0d76dd6 256 * WinHttpSetTimeouts</a> API.
XinZhangMS 0:f7f1f0d76dd6 257 * - @b CURLOPT_LOW_SPEED_LIMIT - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 258 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 259 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 260 * - @b CURLOPT_LOW_SPEED_TIME - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 261 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 262 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 263 * - @b CURLOPT_FORBID_REUSE - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 264 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 265 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 266 * - @b CURLOPT_FRESH_CONNECT - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 267 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 268 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 269 * - @b CURLOPT_VERBOSE - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 270 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 271 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 272 * - @b keepalive - available for MQTT protocol. Integer value that sets the
XinZhangMS 0:f7f1f0d76dd6 273 * interval in seconds when pings are sent to the server.
XinZhangMS 0:f7f1f0d76dd6 274 * - @b logtrace - available for MQTT protocol. Boolean value that turns on and
XinZhangMS 0:f7f1f0d76dd6 275 * off the diagnostic logging.
XinZhangMS 0:f7f1f0d76dd6 276 * - @b sas_token_lifetime - available for MQTT & AMQP protocol. size_t value that that determines the
XinZhangMS 0:f7f1f0d76dd6 277 * sas token timeout length.
XinZhangMS 0:f7f1f0d76dd6 278 *
XinZhangMS 0:f7f1f0d76dd6 279 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 280 */
XinZhangMS 0:f7f1f0d76dd6 281 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_SetOption, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, const char*, optionName, const void*, value);
XinZhangMS 0:f7f1f0d76dd6 282
XinZhangMS 0:f7f1f0d76dd6 283 /**
XinZhangMS 0:f7f1f0d76dd6 284 * @brief This API specifies a call back to be used when the device receives a desired state update.
XinZhangMS 0:f7f1f0d76dd6 285 *
XinZhangMS 0:f7f1f0d76dd6 286 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 287 * @param deviceTwinCallback The callback specified by the device client to be used for updating
XinZhangMS 0:f7f1f0d76dd6 288 * the desired state. The callback will be called in response to patch
XinZhangMS 0:f7f1f0d76dd6 289 * request send by the IoTHub services. The payload will be passed to the
XinZhangMS 0:f7f1f0d76dd6 290 * callback, along with two version numbers:
XinZhangMS 0:f7f1f0d76dd6 291 * - Desired:
XinZhangMS 0:f7f1f0d76dd6 292 * - LastSeenReported:
XinZhangMS 0:f7f1f0d76dd6 293 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 294 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 295 *
XinZhangMS 0:f7f1f0d76dd6 296 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 297 * the ::IoTHubClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 298 *
XinZhangMS 0:f7f1f0d76dd6 299 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 300 */
XinZhangMS 0:f7f1f0d76dd6 301 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_SetDeviceTwinCallback, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_DEVICE_TWIN_CALLBACK, deviceTwinCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 302
XinZhangMS 0:f7f1f0d76dd6 303 /**
XinZhangMS 0:f7f1f0d76dd6 304 * @brief This API sneds a report of the device's properties and their current values.
XinZhangMS 0:f7f1f0d76dd6 305 *
XinZhangMS 0:f7f1f0d76dd6 306 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 307 * @param reportedState The current device property values to be 'reported' to the IoTHub.
XinZhangMS 0:f7f1f0d76dd6 308 * @param reportedStateCallback The callback specified by the device client to be called with the
XinZhangMS 0:f7f1f0d76dd6 309 * result of the transaction.
XinZhangMS 0:f7f1f0d76dd6 310 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 311 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 312 *
XinZhangMS 0:f7f1f0d76dd6 313 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 314 * the ::IoTHubClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 315 *
XinZhangMS 0:f7f1f0d76dd6 316 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 317 */
XinZhangMS 0:f7f1f0d76dd6 318 MOCKABLE_FUNCTION(, 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);
XinZhangMS 0:f7f1f0d76dd6 319
XinZhangMS 0:f7f1f0d76dd6 320 /**
XinZhangMS 0:f7f1f0d76dd6 321 * @brief This API sets callback for cloud to device method call.
XinZhangMS 0:f7f1f0d76dd6 322 *
XinZhangMS 0:f7f1f0d76dd6 323 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 324 * @param deviceMethodCallback The callback which will be called by IoTHub.
XinZhangMS 0:f7f1f0d76dd6 325 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 326 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 327 *
XinZhangMS 0:f7f1f0d76dd6 328 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 329 */
XinZhangMS 0:f7f1f0d76dd6 330 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_SetDeviceMethodCallback, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_DEVICE_METHOD_CALLBACK_ASYNC, deviceMethodCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 331
XinZhangMS 0:f7f1f0d76dd6 332 /**
XinZhangMS 0:f7f1f0d76dd6 333 * @brief This API sets callback for async cloud to device method call.
XinZhangMS 0:f7f1f0d76dd6 334 *
XinZhangMS 0:f7f1f0d76dd6 335 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 336 * @param inboundDeviceMethodCallback The callback which will be called by IoTHub.
XinZhangMS 0:f7f1f0d76dd6 337 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 338 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 339 *
XinZhangMS 0:f7f1f0d76dd6 340 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 341 */
XinZhangMS 0:f7f1f0d76dd6 342 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_SetDeviceMethodCallback_Ex, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_INBOUND_DEVICE_METHOD_CALLBACK, inboundDeviceMethodCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 343
XinZhangMS 0:f7f1f0d76dd6 344 /**
XinZhangMS 0:f7f1f0d76dd6 345 * @brief This API responses to a asnyc method callback identified the methodId.
XinZhangMS 0:f7f1f0d76dd6 346 *
XinZhangMS 0:f7f1f0d76dd6 347 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 348 * @param methodId The methodId of the Device Method callback.
XinZhangMS 0:f7f1f0d76dd6 349 * @param response The response data for the method callback.
XinZhangMS 0:f7f1f0d76dd6 350 * @param response_size The size of the response data buffer.
XinZhangMS 0:f7f1f0d76dd6 351 * @param status_response The status response of the method callback.
XinZhangMS 0:f7f1f0d76dd6 352 *
XinZhangMS 0:f7f1f0d76dd6 353 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 354 */
XinZhangMS 0:f7f1f0d76dd6 355 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_DeviceMethodResponse, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, METHOD_HANDLE, methodId, const unsigned char*, response, size_t, respSize, int, statusCode);
XinZhangMS 0:f7f1f0d76dd6 356
XinZhangMS 0:f7f1f0d76dd6 357 #ifndef DONT_USE_UPLOADTOBLOB
XinZhangMS 0:f7f1f0d76dd6 358 /**
XinZhangMS 0:f7f1f0d76dd6 359 * @brief This API uploads to Azure Storage the content pointed to by @p source having the size @p size
XinZhangMS 0:f7f1f0d76dd6 360 * under the blob name devicename/@pdestinationFileName
XinZhangMS 0:f7f1f0d76dd6 361 *
XinZhangMS 0:f7f1f0d76dd6 362 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 363 * @param destinationFileName name of the file.
XinZhangMS 0:f7f1f0d76dd6 364 * @param source pointer to the source for file content (can be NULL)
XinZhangMS 0:f7f1f0d76dd6 365 * @param size the size of the source in memory (if @p source is NULL then size needs to be 0).
XinZhangMS 0:f7f1f0d76dd6 366 *
XinZhangMS 0:f7f1f0d76dd6 367 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 368 */
XinZhangMS 0:f7f1f0d76dd6 369 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_UploadToBlob, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, const char*, destinationFileName, const unsigned char*, source, size_t, size);
XinZhangMS 0:f7f1f0d76dd6 370
XinZhangMS 0:f7f1f0d76dd6 371 /**
XinZhangMS 0:f7f1f0d76dd6 372 ** DEPRECATED: Use IoTHubClient_LL_UploadMultipleBlocksToBlobAsyncEx instead **
XinZhangMS 0:f7f1f0d76dd6 373 * @brief This API uploads to Azure Storage the content provided block by block by @p getDataCallback
XinZhangMS 0:f7f1f0d76dd6 374 * under the blob name devicename/@pdestinationFileName
XinZhangMS 0:f7f1f0d76dd6 375 *
XinZhangMS 0:f7f1f0d76dd6 376 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 377 * @param destinationFileName name of the file.
XinZhangMS 0:f7f1f0d76dd6 378 * @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.
XinZhangMS 0:f7f1f0d76dd6 379 * @param context Any data provided by the user to serve as context on getDataCallback.
XinZhangMS 0:f7f1f0d76dd6 380 *
XinZhangMS 0:f7f1f0d76dd6 381 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 382 ** DEPRECATED: Use IoTHubClient_LL_UploadMultipleBlocksToBlobAsyncEx instead **
XinZhangMS 0:f7f1f0d76dd6 383 */
XinZhangMS 0:f7f1f0d76dd6 384 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_UploadMultipleBlocksToBlob, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, const char*, destinationFileName, IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK, getDataCallback, void*, context);
XinZhangMS 0:f7f1f0d76dd6 385
XinZhangMS 0:f7f1f0d76dd6 386 /**
XinZhangMS 0:f7f1f0d76dd6 387 * @brief This API uploads to Azure Storage the content provided block by block by @p getDataCallback
XinZhangMS 0:f7f1f0d76dd6 388 * under the blob name devicename/@pdestinationFileName
XinZhangMS 0:f7f1f0d76dd6 389 *
XinZhangMS 0:f7f1f0d76dd6 390 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 391 * @param destinationFileName name of the file.
XinZhangMS 0:f7f1f0d76dd6 392 * @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.
XinZhangMS 0:f7f1f0d76dd6 393 * @param context Any data provided by the user to serve as context on getDataCallback.
XinZhangMS 0:f7f1f0d76dd6 394 *
XinZhangMS 0:f7f1f0d76dd6 395 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 396 */
XinZhangMS 0:f7f1f0d76dd6 397 MOCKABLE_FUNCTION(, 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);
XinZhangMS 0:f7f1f0d76dd6 398
XinZhangMS 0:f7f1f0d76dd6 399 #endif /*DONT_USE_UPLOADTOBLOB*/
XinZhangMS 0:f7f1f0d76dd6 400
XinZhangMS 0:f7f1f0d76dd6 401 #ifdef __cplusplus
XinZhangMS 0:f7f1f0d76dd6 402 }
XinZhangMS 0:f7f1f0d76dd6 403 #endif
XinZhangMS 0:f7f1f0d76dd6 404
XinZhangMS 0:f7f1f0d76dd6 405 #endif /* IOTHUB_CLIENT_LL_H */