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 IoTHubDeviceClient_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 IoTHubDeviceClient_... 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_DEVICE_CLIENT_LL_H
XinZhangMS 0:f7f1f0d76dd6 24 #define IOTHUB_DEVICE_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/macro_utils.h"
XinZhangMS 0:f7f1f0d76dd6 30 #include "azure_c_shared_utility/umock_c_prod.h"
XinZhangMS 0:f7f1f0d76dd6 31
XinZhangMS 0:f7f1f0d76dd6 32 #include "iothub_transport_ll.h"
XinZhangMS 0:f7f1f0d76dd6 33 #include "iothub_client_core_ll.h"
XinZhangMS 0:f7f1f0d76dd6 34
XinZhangMS 0:f7f1f0d76dd6 35 #ifdef __cplusplus
XinZhangMS 0:f7f1f0d76dd6 36 extern "C"
XinZhangMS 0:f7f1f0d76dd6 37 {
XinZhangMS 0:f7f1f0d76dd6 38 #endif
XinZhangMS 0:f7f1f0d76dd6 39
XinZhangMS 0:f7f1f0d76dd6 40 typedef struct IOTHUB_CLIENT_CORE_LL_HANDLE_DATA_TAG* IOTHUB_DEVICE_CLIENT_LL_HANDLE;
XinZhangMS 0:f7f1f0d76dd6 41
XinZhangMS 0:f7f1f0d76dd6 42
XinZhangMS 0:f7f1f0d76dd6 43 /**
XinZhangMS 0:f7f1f0d76dd6 44 * @brief Creates a IoT Hub client for communication with an existing
XinZhangMS 0:f7f1f0d76dd6 45 * IoT Hub using the specified connection string parameter.
XinZhangMS 0:f7f1f0d76dd6 46 *
XinZhangMS 0:f7f1f0d76dd6 47 * @param connectionString Pointer to a character string
XinZhangMS 0:f7f1f0d76dd6 48 * @param protocol Function pointer for protocol implementation
XinZhangMS 0:f7f1f0d76dd6 49 *
XinZhangMS 0:f7f1f0d76dd6 50 * Sample connection string:
XinZhangMS 0:f7f1f0d76dd6 51 * <blockquote>
XinZhangMS 0:f7f1f0d76dd6 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];SharedAccessKey=[Device key goes here];</pre>
XinZhangMS 0:f7f1f0d76dd6 53 * </blockquote>
XinZhangMS 0:f7f1f0d76dd6 54 *
XinZhangMS 0:f7f1f0d76dd6 55 * @return A non-NULL @c IOTHUB_DEVICE_CLIENT_LL_HANDLE value that is used when
XinZhangMS 0:f7f1f0d76dd6 56 * invoking other functions for IoT Hub client and @c NULL on failure.
XinZhangMS 0:f7f1f0d76dd6 57 */
XinZhangMS 0:f7f1f0d76dd6 58 MOCKABLE_FUNCTION(, IOTHUB_DEVICE_CLIENT_LL_HANDLE, IoTHubDeviceClient_LL_CreateFromConnectionString, const char*, connectionString, IOTHUB_CLIENT_TRANSPORT_PROVIDER, protocol);
XinZhangMS 0:f7f1f0d76dd6 59
XinZhangMS 0:f7f1f0d76dd6 60 /**
XinZhangMS 0:f7f1f0d76dd6 61 * @brief Creates a IoT Hub client for communication with an existing IoT
XinZhangMS 0:f7f1f0d76dd6 62 * Hub using the specified parameters.
XinZhangMS 0:f7f1f0d76dd6 63 *
XinZhangMS 0:f7f1f0d76dd6 64 * @param config Pointer to an @c IOTHUB_CLIENT_CONFIG structure
XinZhangMS 0:f7f1f0d76dd6 65 *
XinZhangMS 0:f7f1f0d76dd6 66 * The API does not allow sharing of a connection across multiple
XinZhangMS 0:f7f1f0d76dd6 67 * devices. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 68 *
XinZhangMS 0:f7f1f0d76dd6 69 * @return A non-NULL @c IOTHUB_DEVICE_CLIENT_LL_HANDLE value that is used when
XinZhangMS 0:f7f1f0d76dd6 70 * invoking other functions for IoT Hub client and @c NULL on failure.
XinZhangMS 0:f7f1f0d76dd6 71 */
XinZhangMS 0:f7f1f0d76dd6 72 MOCKABLE_FUNCTION(, IOTHUB_DEVICE_CLIENT_LL_HANDLE, IoTHubDeviceClient_LL_Create, const IOTHUB_CLIENT_CONFIG*, config);
XinZhangMS 0:f7f1f0d76dd6 73
XinZhangMS 0:f7f1f0d76dd6 74 /**
XinZhangMS 0:f7f1f0d76dd6 75 * @brief Creates a IoT Hub client for communication with an existing IoT
XinZhangMS 0:f7f1f0d76dd6 76 * Hub using an existing transport.
XinZhangMS 0:f7f1f0d76dd6 77 *
XinZhangMS 0:f7f1f0d76dd6 78 * @param config Pointer to an @c IOTHUB_CLIENT_DEVICE_CONFIG structure
XinZhangMS 0:f7f1f0d76dd6 79 *
XinZhangMS 0:f7f1f0d76dd6 80 * The API *allows* sharing of a connection across multiple
XinZhangMS 0:f7f1f0d76dd6 81 * devices. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 82 *
XinZhangMS 0:f7f1f0d76dd6 83 * @return A non-NULL @c IOTHUB_DEVICE_CLIENT_LL_HANDLE value that is used when
XinZhangMS 0:f7f1f0d76dd6 84 * invoking other functions for IoT Hub client and @c NULL on failure.
XinZhangMS 0:f7f1f0d76dd6 85 */
XinZhangMS 0:f7f1f0d76dd6 86 MOCKABLE_FUNCTION(, IOTHUB_DEVICE_CLIENT_LL_HANDLE, IoTHubDeviceClient_LL_CreateWithTransport, const IOTHUB_CLIENT_DEVICE_CONFIG*, config);
XinZhangMS 0:f7f1f0d76dd6 87
XinZhangMS 0:f7f1f0d76dd6 88 /**
XinZhangMS 0:f7f1f0d76dd6 89 * @brief Creates a IoT Hub client for communication with an existing IoT
XinZhangMS 0:f7f1f0d76dd6 90 * Hub using the device auth module.
XinZhangMS 0:f7f1f0d76dd6 91 *
XinZhangMS 0:f7f1f0d76dd6 92 * @param iothub_uri Pointer to an ioThub hostname received in the registration process
XinZhangMS 0:f7f1f0d76dd6 93 * @param device_id Pointer to the device Id of the device
XinZhangMS 0:f7f1f0d76dd6 94 * @param device_auth_handle A device auth handle used to generate the connection string
XinZhangMS 0:f7f1f0d76dd6 95 * @param protocol Function pointer for protocol implementation
XinZhangMS 0:f7f1f0d76dd6 96 *
XinZhangMS 0:f7f1f0d76dd6 97 * @return A non-NULL @c IOTHUB_DEVICE_CLIENT_LL_HANDLE value that is used when
XinZhangMS 0:f7f1f0d76dd6 98 * invoking other functions for IoT Hub client and @c NULL on failure.
XinZhangMS 0:f7f1f0d76dd6 99 */
XinZhangMS 0:f7f1f0d76dd6 100 MOCKABLE_FUNCTION(, IOTHUB_DEVICE_CLIENT_LL_HANDLE, IoTHubDeviceClient_LL_CreateFromDeviceAuth, const char*, iothub_uri, const char*, device_id, IOTHUB_CLIENT_TRANSPORT_PROVIDER, protocol);
XinZhangMS 0:f7f1f0d76dd6 101
XinZhangMS 0:f7f1f0d76dd6 102 /**
XinZhangMS 0:f7f1f0d76dd6 103 * @brief Disposes of resources allocated by the IoT Hub client. This is a
XinZhangMS 0:f7f1f0d76dd6 104 * blocking call.
XinZhangMS 0:f7f1f0d76dd6 105 *
XinZhangMS 0:f7f1f0d76dd6 106 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 107 */
XinZhangMS 0:f7f1f0d76dd6 108 MOCKABLE_FUNCTION(, void, IoTHubDeviceClient_LL_Destroy, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle);
XinZhangMS 0:f7f1f0d76dd6 109
XinZhangMS 0:f7f1f0d76dd6 110 /**
XinZhangMS 0:f7f1f0d76dd6 111 * @brief Asynchronous call to send the message specified by @p eventMessageHandle.
XinZhangMS 0:f7f1f0d76dd6 112 *
XinZhangMS 0:f7f1f0d76dd6 113 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 114 * @param eventMessageHandle The handle to an IoT Hub message.
XinZhangMS 0:f7f1f0d76dd6 115 * @param eventConfirmationCallback The callback specified by the device for receiving
XinZhangMS 0:f7f1f0d76dd6 116 * confirmation of the delivery of the IoT Hub message.
XinZhangMS 0:f7f1f0d76dd6 117 * This callback can be expected to invoke the
XinZhangMS 0:f7f1f0d76dd6 118 * ::IoTHubDeviceClient_LL_SendEventAsync function for the
XinZhangMS 0:f7f1f0d76dd6 119 * same message in an attempt to retry sending a failing
XinZhangMS 0:f7f1f0d76dd6 120 * message. The user can specify a @c NULL value here to
XinZhangMS 0:f7f1f0d76dd6 121 * indicate that no callback is required.
XinZhangMS 0:f7f1f0d76dd6 122 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 123 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 124 *
XinZhangMS 0:f7f1f0d76dd6 125 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 126 * the ::IoTHubDeviceClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 127 *
XinZhangMS 0:f7f1f0d76dd6 128 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 129 */
XinZhangMS 0:f7f1f0d76dd6 130 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_SendEventAsync, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_MESSAGE_HANDLE, eventMessageHandle, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK, eventConfirmationCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 131
XinZhangMS 0:f7f1f0d76dd6 132 /**
XinZhangMS 0:f7f1f0d76dd6 133 * @brief This function returns the current sending status for IoTHubClient.
XinZhangMS 0:f7f1f0d76dd6 134 *
XinZhangMS 0:f7f1f0d76dd6 135 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 136 * @param iotHubClientStatus The sending state is populated at the address pointed
XinZhangMS 0:f7f1f0d76dd6 137 * at by this parameter. The value will be set to
XinZhangMS 0:f7f1f0d76dd6 138 * @c IOTHUBCLIENT_SENDSTATUS_IDLE if there is currently
XinZhangMS 0:f7f1f0d76dd6 139 * no item to be sent and @c IOTHUBCLIENT_SENDSTATUS_BUSY
XinZhangMS 0:f7f1f0d76dd6 140 * if there are.
XinZhangMS 0:f7f1f0d76dd6 141 *
XinZhangMS 0:f7f1f0d76dd6 142 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 143 */
XinZhangMS 0:f7f1f0d76dd6 144 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_GetSendStatus, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_STATUS*, iotHubClientStatus);
XinZhangMS 0:f7f1f0d76dd6 145
XinZhangMS 0:f7f1f0d76dd6 146 /**
XinZhangMS 0:f7f1f0d76dd6 147 * @brief Sets up the message callback to be invoked when IoT Hub issues a
XinZhangMS 0:f7f1f0d76dd6 148 * message to the device. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 149 *
XinZhangMS 0:f7f1f0d76dd6 150 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 151 * @param messageCallback The callback specified by the device for receiving
XinZhangMS 0:f7f1f0d76dd6 152 * messages from IoT Hub.
XinZhangMS 0:f7f1f0d76dd6 153 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 154 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 155 *
XinZhangMS 0:f7f1f0d76dd6 156 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 157 * the ::IoTHubDeviceClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 158 *
XinZhangMS 0:f7f1f0d76dd6 159 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 160 */
XinZhangMS 0:f7f1f0d76dd6 161 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_SetMessageCallback, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC, messageCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 162
XinZhangMS 0:f7f1f0d76dd6 163 /**
XinZhangMS 0:f7f1f0d76dd6 164 * @brief Sets up the connection status callback to be invoked representing the status of
XinZhangMS 0:f7f1f0d76dd6 165 * the connection to IOT Hub. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 166 *
XinZhangMS 0:f7f1f0d76dd6 167 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 168 * @param connectionStatusCallback The callback specified by the device for receiving
XinZhangMS 0:f7f1f0d76dd6 169 * updates about the status of the connection to IoT Hub.
XinZhangMS 0:f7f1f0d76dd6 170 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 171 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 172 *
XinZhangMS 0:f7f1f0d76dd6 173 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 174 * the ::IoTHubDeviceClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 175 *
XinZhangMS 0:f7f1f0d76dd6 176 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 177 */
XinZhangMS 0:f7f1f0d76dd6 178 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_SetConnectionStatusCallback, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_CONNECTION_STATUS_CALLBACK, connectionStatusCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 179
XinZhangMS 0:f7f1f0d76dd6 180 /**
XinZhangMS 0:f7f1f0d76dd6 181 * @brief Sets up the connection status callback to be invoked representing the status of
XinZhangMS 0:f7f1f0d76dd6 182 * the connection to IOT Hub. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 183 *
XinZhangMS 0:f7f1f0d76dd6 184 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 185 * @param retryPolicy The policy to use to reconnect to IoT Hub when a
XinZhangMS 0:f7f1f0d76dd6 186 * connection drops.
XinZhangMS 0:f7f1f0d76dd6 187 * @param retryTimeoutLimitInSeconds Maximum amount of time(seconds) to attempt reconnection when a
XinZhangMS 0:f7f1f0d76dd6 188 * connection drops to IOT Hub.
XinZhangMS 0:f7f1f0d76dd6 189 *
XinZhangMS 0:f7f1f0d76dd6 190 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 191 * the ::IoTHubDeviceClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 192 *
XinZhangMS 0:f7f1f0d76dd6 193 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 194 */
XinZhangMS 0:f7f1f0d76dd6 195 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_SetRetryPolicy, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_RETRY_POLICY, retryPolicy, size_t, retryTimeoutLimitInSeconds);
XinZhangMS 0:f7f1f0d76dd6 196
XinZhangMS 0:f7f1f0d76dd6 197
XinZhangMS 0:f7f1f0d76dd6 198 /**
XinZhangMS 0:f7f1f0d76dd6 199 * @brief Sets up the connection status callback to be invoked representing the status of
XinZhangMS 0:f7f1f0d76dd6 200 * the connection to IOT Hub. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 201 *
XinZhangMS 0:f7f1f0d76dd6 202 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 203 * @param retryPolicy Out parameter containing the policy to use to reconnect to IoT Hub.
XinZhangMS 0:f7f1f0d76dd6 204 * @param retryTimeoutLimitInSeconds Out parameter containing maximum amount of time in seconds to attempt reconnection
XinZhangMS 0:f7f1f0d76dd6 205 to IOT Hub.
XinZhangMS 0:f7f1f0d76dd6 206 *
XinZhangMS 0:f7f1f0d76dd6 207 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 208 * the ::IoTHubDeviceClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 209 *
XinZhangMS 0:f7f1f0d76dd6 210 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 211 */
XinZhangMS 0:f7f1f0d76dd6 212 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_GetRetryPolicy, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_RETRY_POLICY*, retryPolicy, size_t*, retryTimeoutLimitInSeconds);
XinZhangMS 0:f7f1f0d76dd6 213
XinZhangMS 0:f7f1f0d76dd6 214 /**
XinZhangMS 0:f7f1f0d76dd6 215 * @brief This function returns in the out parameter @p lastMessageReceiveTime
XinZhangMS 0:f7f1f0d76dd6 216 * what was the value of the @c time function when the last message was
XinZhangMS 0:f7f1f0d76dd6 217 * received at the client.
XinZhangMS 0:f7f1f0d76dd6 218 *
XinZhangMS 0:f7f1f0d76dd6 219 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 220 * @param lastMessageReceiveTime Out parameter containing the value of @c time function
XinZhangMS 0:f7f1f0d76dd6 221 * when the last message was received.
XinZhangMS 0:f7f1f0d76dd6 222 *
XinZhangMS 0:f7f1f0d76dd6 223 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 224 */
XinZhangMS 0:f7f1f0d76dd6 225 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_GetLastMessageReceiveTime, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle, time_t*, lastMessageReceiveTime);
XinZhangMS 0:f7f1f0d76dd6 226
XinZhangMS 0:f7f1f0d76dd6 227 /**
XinZhangMS 0:f7f1f0d76dd6 228 * @brief This function is meant to be called by the user when work
XinZhangMS 0:f7f1f0d76dd6 229 * (sending/receiving) can be done by the IoTHubClient.
XinZhangMS 0:f7f1f0d76dd6 230 *
XinZhangMS 0:f7f1f0d76dd6 231 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 232 *
XinZhangMS 0:f7f1f0d76dd6 233 * All IoTHubClient interactions (in regards to network traffic
XinZhangMS 0:f7f1f0d76dd6 234 * and/or user level callbacks) are the effect of calling this
XinZhangMS 0:f7f1f0d76dd6 235 * function and they take place synchronously inside _DoWork.
XinZhangMS 0:f7f1f0d76dd6 236 */
XinZhangMS 0:f7f1f0d76dd6 237 MOCKABLE_FUNCTION(, void, IoTHubDeviceClient_LL_DoWork, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle);
XinZhangMS 0:f7f1f0d76dd6 238
XinZhangMS 0:f7f1f0d76dd6 239 /**
XinZhangMS 0:f7f1f0d76dd6 240 * @brief This API sets a runtime option identified by parameter @p optionName
XinZhangMS 0:f7f1f0d76dd6 241 * to a value pointed to by @p value. @p optionName and the data type
XinZhangMS 0:f7f1f0d76dd6 242 * @p value is pointing to are specific for every option.
XinZhangMS 0:f7f1f0d76dd6 243 *
XinZhangMS 0:f7f1f0d76dd6 244 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 245 * @param optionName Name of the option.
XinZhangMS 0:f7f1f0d76dd6 246 * @param value The value.
XinZhangMS 0:f7f1f0d76dd6 247 *
XinZhangMS 0:f7f1f0d76dd6 248 * The options that can be set via this API are:
XinZhangMS 0:f7f1f0d76dd6 249 * - @b timeout - the maximum time in milliseconds a communication is
XinZhangMS 0:f7f1f0d76dd6 250 * allowed to use. @p value is a pointer to an @c unsigned @c int with
XinZhangMS 0:f7f1f0d76dd6 251 * the timeout value in milliseconds. This is only supported for the HTTP
XinZhangMS 0:f7f1f0d76dd6 252 * protocol as of now. When the HTTP protocol uses CURL, the meaning of
XinZhangMS 0:f7f1f0d76dd6 253 * the parameter is <em>total request time</em>. When the HTTP protocol uses
XinZhangMS 0:f7f1f0d76dd6 254 * winhttp, the meaning is the same as the @c dwSendTimeout and
XinZhangMS 0:f7f1f0d76dd6 255 * @c dwReceiveTimeout parameters of the
XinZhangMS 0:f7f1f0d76dd6 256 * <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa384116(v=vs.85).aspx">
XinZhangMS 0:f7f1f0d76dd6 257 * WinHttpSetTimeouts</a> API.
XinZhangMS 0:f7f1f0d76dd6 258 * - @b CURLOPT_LOW_SPEED_LIMIT - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 259 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 260 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 261 * - @b CURLOPT_LOW_SPEED_TIME - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 262 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 263 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 264 * - @b CURLOPT_FORBID_REUSE - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 265 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 266 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 267 * - @b CURLOPT_FRESH_CONNECT - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 268 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 269 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 270 * - @b CURLOPT_VERBOSE - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 271 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 272 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 273 * - @b keepalive - available for MQTT protocol. Integer value that sets the
XinZhangMS 0:f7f1f0d76dd6 274 * interval in seconds when pings are sent to the server.
XinZhangMS 0:f7f1f0d76dd6 275 * - @b logtrace - available for MQTT protocol. Boolean value that turns on and
XinZhangMS 0:f7f1f0d76dd6 276 * off the diagnostic logging.
XinZhangMS 0:f7f1f0d76dd6 277 * - @b sas_token_lifetime - available for MQTT & AMQP protocol. size_t value that that determines the
XinZhangMS 0:f7f1f0d76dd6 278 * sas token timeout length.
XinZhangMS 0:f7f1f0d76dd6 279 *
XinZhangMS 0:f7f1f0d76dd6 280 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 281 */
XinZhangMS 0:f7f1f0d76dd6 282 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_SetOption, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle, const char*, optionName, const void*, value);
XinZhangMS 0:f7f1f0d76dd6 283
XinZhangMS 0:f7f1f0d76dd6 284 /**
XinZhangMS 0:f7f1f0d76dd6 285 * @brief This API specifies a call back to be used when the device receives a desired state update.
XinZhangMS 0:f7f1f0d76dd6 286 *
XinZhangMS 0:f7f1f0d76dd6 287 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 288 * @param deviceTwinCallback The callback specified by the device client to be used for updating
XinZhangMS 0:f7f1f0d76dd6 289 * the desired state. The callback will be called in response to patch
XinZhangMS 0:f7f1f0d76dd6 290 * request send by the IoTHub services. The payload will be passed to the
XinZhangMS 0:f7f1f0d76dd6 291 * callback, along with two version numbers:
XinZhangMS 0:f7f1f0d76dd6 292 * - Desired:
XinZhangMS 0:f7f1f0d76dd6 293 * - LastSeenReported:
XinZhangMS 0:f7f1f0d76dd6 294 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 295 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 296 *
XinZhangMS 0:f7f1f0d76dd6 297 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 298 * the ::IoTHubDeviceClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 299 *
XinZhangMS 0:f7f1f0d76dd6 300 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 301 */
XinZhangMS 0:f7f1f0d76dd6 302 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_SetDeviceTwinCallback, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_DEVICE_TWIN_CALLBACK, deviceTwinCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 303
XinZhangMS 0:f7f1f0d76dd6 304 /**
XinZhangMS 0:f7f1f0d76dd6 305 * @brief This API sneds a report of the device's properties and their current values.
XinZhangMS 0:f7f1f0d76dd6 306 *
XinZhangMS 0:f7f1f0d76dd6 307 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 308 * @param reportedState The current device property values to be 'reported' to the IoTHub.
XinZhangMS 0:f7f1f0d76dd6 309 * @param reportedStateCallback The callback specified by the device client to be called with the
XinZhangMS 0:f7f1f0d76dd6 310 * result of the transaction.
XinZhangMS 0:f7f1f0d76dd6 311 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 312 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 313 *
XinZhangMS 0:f7f1f0d76dd6 314 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 315 * the ::IoTHubDeviceClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 316 *
XinZhangMS 0:f7f1f0d76dd6 317 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 318 */
XinZhangMS 0:f7f1f0d76dd6 319 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_SendReportedState, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle, const unsigned char*, reportedState, size_t, size, IOTHUB_CLIENT_REPORTED_STATE_CALLBACK, reportedStateCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 320 /**
XinZhangMS 0:f7f1f0d76dd6 321 * @brief This API sets callback for async 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 inboundDeviceMethodCallback 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, IoTHubDeviceClient_LL_SetDeviceMethodCallback, IOTHUB_DEVICE_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 responses to a asnyc method callback identified the methodId.
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 methodId The methodId of the Device Method callback.
XinZhangMS 0:f7f1f0d76dd6 337 * @param response The response data for the method callback.
XinZhangMS 0:f7f1f0d76dd6 338 * @param response_size The size of the response data buffer.
XinZhangMS 0:f7f1f0d76dd6 339 * @param status_response The status response of the method callback.
XinZhangMS 0:f7f1f0d76dd6 340 *
XinZhangMS 0:f7f1f0d76dd6 341 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 342 */
XinZhangMS 0:f7f1f0d76dd6 343 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_DeviceMethodResponse, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle, METHOD_HANDLE, methodId, const unsigned char*, response, size_t, respSize, int, statusCode);
XinZhangMS 0:f7f1f0d76dd6 344
XinZhangMS 0:f7f1f0d76dd6 345 #ifndef DONT_USE_UPLOADTOBLOB
XinZhangMS 0:f7f1f0d76dd6 346 /**
XinZhangMS 0:f7f1f0d76dd6 347 * @brief This API uploads to Azure Storage the content pointed to by @p source having the size @p size
XinZhangMS 0:f7f1f0d76dd6 348 * under the blob name devicename/@pdestinationFileName
XinZhangMS 0:f7f1f0d76dd6 349 *
XinZhangMS 0:f7f1f0d76dd6 350 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 351 * @param destinationFileName name of the file.
XinZhangMS 0:f7f1f0d76dd6 352 * @param source pointer to the source for file content (can be NULL)
XinZhangMS 0:f7f1f0d76dd6 353 * @param size the size of the source in memory (if @p source is NULL then size needs to be 0).
XinZhangMS 0:f7f1f0d76dd6 354 *
XinZhangMS 0:f7f1f0d76dd6 355 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 356 */
XinZhangMS 0:f7f1f0d76dd6 357 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_UploadToBlob, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle, const char*, destinationFileName, const unsigned char*, source, size_t, size);
XinZhangMS 0:f7f1f0d76dd6 358
XinZhangMS 0:f7f1f0d76dd6 359 /**
XinZhangMS 0:f7f1f0d76dd6 360 * @brief This API uploads to Azure Storage the content provided block by block by @p getDataCallback
XinZhangMS 0:f7f1f0d76dd6 361 * under the blob name devicename/@pdestinationFileName
XinZhangMS 0:f7f1f0d76dd6 362 *
XinZhangMS 0:f7f1f0d76dd6 363 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 364 * @param destinationFileName name of the file.
XinZhangMS 0:f7f1f0d76dd6 365 * @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 366 * @param context Any data provided by the user to serve as context on getDataCallback.
XinZhangMS 0:f7f1f0d76dd6 367 *
XinZhangMS 0:f7f1f0d76dd6 368 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 369 */
XinZhangMS 0:f7f1f0d76dd6 370 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_UploadMultipleBlocksToBlob, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle, const char*, destinationFileName, IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK_EX, getDataCallbackEx, void*, context);
XinZhangMS 0:f7f1f0d76dd6 371
XinZhangMS 0:f7f1f0d76dd6 372 #endif /*DONT_USE_UPLOADTOBLOB*/
XinZhangMS 0:f7f1f0d76dd6 373
XinZhangMS 0:f7f1f0d76dd6 374 #ifdef __cplusplus
XinZhangMS 0:f7f1f0d76dd6 375 }
XinZhangMS 0:f7f1f0d76dd6 376 #endif
XinZhangMS 0:f7f1f0d76dd6 377
XinZhangMS 0:f7f1f0d76dd6 378 #endif /* IOTHUB_DEVICE_CLIENT_LL_H */