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 module) to communicate
XinZhangMS 0:f7f1f0d76dd6 6 * with an Azure IoTHub.
XinZhangMS 0:f7f1f0d76dd6 7 *
XinZhangMS 0:f7f1f0d76dd6 8 * @details IoTHubModuleClient_LL is a module that allows a user (usually a
XinZhangMS 0:f7f1f0d76dd6 9 * module) 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 IoTHubModuleClient_... 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_MODULE_CLIENT_LL_H
XinZhangMS 0:f7f1f0d76dd6 24 #define IOTHUB_MODULE_CLIENT_LL_H
XinZhangMS 0:f7f1f0d76dd6 25
XinZhangMS 0:f7f1f0d76dd6 26 #include <time.h>
XinZhangMS 0:f7f1f0d76dd6 27 #include "azure_c_shared_utility/macro_utils.h"
XinZhangMS 0:f7f1f0d76dd6 28 #include "azure_c_shared_utility/umock_c_prod.h"
XinZhangMS 0:f7f1f0d76dd6 29
XinZhangMS 0:f7f1f0d76dd6 30 #include "iothub_transport_ll.h"
XinZhangMS 0:f7f1f0d76dd6 31 #include "iothub_client_core_common.h"
XinZhangMS 0:f7f1f0d76dd6 32
XinZhangMS 0:f7f1f0d76dd6 33 #ifdef __cplusplus
XinZhangMS 0:f7f1f0d76dd6 34 extern "C"
XinZhangMS 0:f7f1f0d76dd6 35 {
XinZhangMS 0:f7f1f0d76dd6 36 #endif
XinZhangMS 0:f7f1f0d76dd6 37
XinZhangMS 0:f7f1f0d76dd6 38 typedef struct IOTHUB_MODULE_CLIENT_LL_HANDLE_DATA_TAG* IOTHUB_MODULE_CLIENT_LL_HANDLE;
XinZhangMS 0:f7f1f0d76dd6 39
XinZhangMS 0:f7f1f0d76dd6 40 #ifdef __cplusplus
XinZhangMS 0:f7f1f0d76dd6 41 }
XinZhangMS 0:f7f1f0d76dd6 42 #endif
XinZhangMS 0:f7f1f0d76dd6 43
XinZhangMS 0:f7f1f0d76dd6 44 #include <stddef.h>
XinZhangMS 0:f7f1f0d76dd6 45 #include <stdint.h>
XinZhangMS 0:f7f1f0d76dd6 46
XinZhangMS 0:f7f1f0d76dd6 47 #ifdef __cplusplus
XinZhangMS 0:f7f1f0d76dd6 48 extern "C"
XinZhangMS 0:f7f1f0d76dd6 49 {
XinZhangMS 0:f7f1f0d76dd6 50 #endif
XinZhangMS 0:f7f1f0d76dd6 51
XinZhangMS 0:f7f1f0d76dd6 52 /**
XinZhangMS 0:f7f1f0d76dd6 53 * @brief Creates a IoT Hub client for communication with an existing
XinZhangMS 0:f7f1f0d76dd6 54 * IoT Hub using the specified connection string parameter.
XinZhangMS 0:f7f1f0d76dd6 55 *
XinZhangMS 0:f7f1f0d76dd6 56 * @param connectionString Pointer to a character string
XinZhangMS 0:f7f1f0d76dd6 57 * @param protocol Function pointer for protocol implementation
XinZhangMS 0:f7f1f0d76dd6 58 *
XinZhangMS 0:f7f1f0d76dd6 59 * Sample connection string:
XinZhangMS 0:f7f1f0d76dd6 60 * <blockquote>
XinZhangMS 0:f7f1f0d76dd6 61 * <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];ModuleId=[Module ID goes here]</pre>
XinZhangMS 0:f7f1f0d76dd6 62 * </blockquote>
XinZhangMS 0:f7f1f0d76dd6 63 *
XinZhangMS 0:f7f1f0d76dd6 64 * @return A non-NULL @c IOTHUB_MODULE_CLIENT_LL_HANDLE value that is used when
XinZhangMS 0:f7f1f0d76dd6 65 * invoking other functions for IoT Hub client and @c NULL on failure.
XinZhangMS 0:f7f1f0d76dd6 66 */
XinZhangMS 0:f7f1f0d76dd6 67 MOCKABLE_FUNCTION(, IOTHUB_MODULE_CLIENT_LL_HANDLE, IoTHubModuleClient_LL_CreateFromConnectionString, const char*, connectionString, IOTHUB_CLIENT_TRANSPORT_PROVIDER, protocol);
XinZhangMS 0:f7f1f0d76dd6 68
XinZhangMS 0:f7f1f0d76dd6 69 /**
XinZhangMS 0:f7f1f0d76dd6 70 * @brief Disposes of resources allocated by the IoT Hub client. This is a
XinZhangMS 0:f7f1f0d76dd6 71 * blocking call.
XinZhangMS 0:f7f1f0d76dd6 72 *
XinZhangMS 0:f7f1f0d76dd6 73 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 74 */
XinZhangMS 0:f7f1f0d76dd6 75 MOCKABLE_FUNCTION(, void, IoTHubModuleClient_LL_Destroy, IOTHUB_MODULE_CLIENT_LL_HANDLE, iotHubModuleClientHandle);
XinZhangMS 0:f7f1f0d76dd6 76
XinZhangMS 0:f7f1f0d76dd6 77 /**
XinZhangMS 0:f7f1f0d76dd6 78 * @brief Asynchronous call to send the message specified by @p eventMessageHandle.
XinZhangMS 0:f7f1f0d76dd6 79 *
XinZhangMS 0:f7f1f0d76dd6 80 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 81 * @param eventMessageHandle The handle to an IoT Hub message.
XinZhangMS 0:f7f1f0d76dd6 82 * @param eventConfirmationCallback The callback specified by the module for receiving
XinZhangMS 0:f7f1f0d76dd6 83 * confirmation of the delivery of the IoT Hub message.
XinZhangMS 0:f7f1f0d76dd6 84 * This callback can be expected to invoke the
XinZhangMS 0:f7f1f0d76dd6 85 * ::IoTHubModuleClient_LL_SendEventAsync function for the
XinZhangMS 0:f7f1f0d76dd6 86 * same message in an attempt to retry sending a failing
XinZhangMS 0:f7f1f0d76dd6 87 * message. The user can specify a @c NULL value here to
XinZhangMS 0:f7f1f0d76dd6 88 * indicate that no callback is required.
XinZhangMS 0:f7f1f0d76dd6 89 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 90 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 91 *
XinZhangMS 0:f7f1f0d76dd6 92 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 93 * the ::IoTHubModuleClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 94 *
XinZhangMS 0:f7f1f0d76dd6 95 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 96 */
XinZhangMS 0:f7f1f0d76dd6 97 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_LL_SendEventAsync, IOTHUB_MODULE_CLIENT_LL_HANDLE, iotHubModuleClientHandle, IOTHUB_MESSAGE_HANDLE, eventMessageHandle, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK, eventConfirmationCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 98
XinZhangMS 0:f7f1f0d76dd6 99 /**
XinZhangMS 0:f7f1f0d76dd6 100 * @brief This function returns the current sending status for IoTHubClient.
XinZhangMS 0:f7f1f0d76dd6 101 *
XinZhangMS 0:f7f1f0d76dd6 102 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 103 * @param iotHubClientStatus The sending state is populated at the address pointed
XinZhangMS 0:f7f1f0d76dd6 104 * at by this parameter. The value will be set to
XinZhangMS 0:f7f1f0d76dd6 105 * @c IOTHUBCLIENT_SENDSTATUS_IDLE if there is currently
XinZhangMS 0:f7f1f0d76dd6 106 * no item to be sent and @c IOTHUBCLIENT_SENDSTATUS_BUSY
XinZhangMS 0:f7f1f0d76dd6 107 * if there are.
XinZhangMS 0:f7f1f0d76dd6 108 *
XinZhangMS 0:f7f1f0d76dd6 109 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 110 */
XinZhangMS 0:f7f1f0d76dd6 111 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_LL_GetSendStatus, IOTHUB_MODULE_CLIENT_LL_HANDLE, iotHubModuleClientHandle, IOTHUB_CLIENT_STATUS*, iotHubClientStatus);
XinZhangMS 0:f7f1f0d76dd6 112
XinZhangMS 0:f7f1f0d76dd6 113 /**
XinZhangMS 0:f7f1f0d76dd6 114 * @brief Sets up the message callback to be invoked when Edge issues a
XinZhangMS 0:f7f1f0d76dd6 115 * message to the module. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 116 *
XinZhangMS 0:f7f1f0d76dd6 117 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 118 * @param messageCallback The callback specified by the module for receiving
XinZhangMS 0:f7f1f0d76dd6 119 * messages from IoT Hub.
XinZhangMS 0:f7f1f0d76dd6 120 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 121 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 122 *
XinZhangMS 0:f7f1f0d76dd6 123 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 124 * the ::IoTHubModuleClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 125 *
XinZhangMS 0:f7f1f0d76dd6 126 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 127 */
XinZhangMS 0:f7f1f0d76dd6 128 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_LL_SetMessageCallback, IOTHUB_MODULE_CLIENT_LL_HANDLE, iotHubModuleClientHandle, IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC, messageCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 129
XinZhangMS 0:f7f1f0d76dd6 130 /**
XinZhangMS 0:f7f1f0d76dd6 131 * @brief Sets up the connection status callback to be invoked representing the status of
XinZhangMS 0:f7f1f0d76dd6 132 * the connection to IOT Hub. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 133 *
XinZhangMS 0:f7f1f0d76dd6 134 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 135 * @param connectionStatusCallback The callback specified by the module for receiving
XinZhangMS 0:f7f1f0d76dd6 136 * updates about the status of the connection to IoT Hub.
XinZhangMS 0:f7f1f0d76dd6 137 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 138 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 139 *
XinZhangMS 0:f7f1f0d76dd6 140 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 141 * the ::IoTHubModuleClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 142 *
XinZhangMS 0:f7f1f0d76dd6 143 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 144 */
XinZhangMS 0:f7f1f0d76dd6 145 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_LL_SetConnectionStatusCallback, IOTHUB_MODULE_CLIENT_LL_HANDLE, iotHubModuleClientHandle, IOTHUB_CLIENT_CONNECTION_STATUS_CALLBACK, connectionStatusCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 146
XinZhangMS 0:f7f1f0d76dd6 147 /**
XinZhangMS 0:f7f1f0d76dd6 148 * @brief Sets up the connection status callback to be invoked representing the status of
XinZhangMS 0:f7f1f0d76dd6 149 * the connection to IOT Hub. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 150 *
XinZhangMS 0:f7f1f0d76dd6 151 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 152 * @param retryPolicy The policy to use to reconnect to IoT Hub when a
XinZhangMS 0:f7f1f0d76dd6 153 * connection drops.
XinZhangMS 0:f7f1f0d76dd6 154 * @param retryTimeoutLimitInSeconds Maximum amount of time(seconds) to attempt reconnection when a
XinZhangMS 0:f7f1f0d76dd6 155 * connection drops to IOT Hub.
XinZhangMS 0:f7f1f0d76dd6 156 *
XinZhangMS 0:f7f1f0d76dd6 157 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 158 * the ::IoTHubModuleClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 159 *
XinZhangMS 0:f7f1f0d76dd6 160 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 161 */
XinZhangMS 0:f7f1f0d76dd6 162 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_LL_SetRetryPolicy, IOTHUB_MODULE_CLIENT_LL_HANDLE, iotHubModuleClientHandle, IOTHUB_CLIENT_RETRY_POLICY, retryPolicy, size_t, retryTimeoutLimitInSeconds);
XinZhangMS 0:f7f1f0d76dd6 163
XinZhangMS 0:f7f1f0d76dd6 164
XinZhangMS 0:f7f1f0d76dd6 165 /**
XinZhangMS 0:f7f1f0d76dd6 166 * @brief Sets up the connection status callback to be invoked representing the status of
XinZhangMS 0:f7f1f0d76dd6 167 * the connection to IOT Hub. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 168 *
XinZhangMS 0:f7f1f0d76dd6 169 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 170 * @param retryPolicy Out parameter containing the policy to use to reconnect to IoT Hub.
XinZhangMS 0:f7f1f0d76dd6 171 * @param retryTimeoutLimitInSeconds Out parameter containing maximum amount of time in seconds to attempt reconnection
XinZhangMS 0:f7f1f0d76dd6 172 to IOT Hub.
XinZhangMS 0:f7f1f0d76dd6 173 *
XinZhangMS 0:f7f1f0d76dd6 174 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 175 * the ::IoTHubModuleClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 176 *
XinZhangMS 0:f7f1f0d76dd6 177 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 178 */
XinZhangMS 0:f7f1f0d76dd6 179 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_LL_GetRetryPolicy, IOTHUB_MODULE_CLIENT_LL_HANDLE, iotHubModuleClientHandle, IOTHUB_CLIENT_RETRY_POLICY*, retryPolicy, size_t*, retryTimeoutLimitInSeconds);
XinZhangMS 0:f7f1f0d76dd6 180
XinZhangMS 0:f7f1f0d76dd6 181 /**
XinZhangMS 0:f7f1f0d76dd6 182 * @brief This function returns in the out parameter @p lastMessageReceiveTime
XinZhangMS 0:f7f1f0d76dd6 183 * what was the value of the @c time function when the last message was
XinZhangMS 0:f7f1f0d76dd6 184 * received at the client.
XinZhangMS 0:f7f1f0d76dd6 185 *
XinZhangMS 0:f7f1f0d76dd6 186 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 187 * @param lastMessageReceiveTime Out parameter containing the value of @c time function
XinZhangMS 0:f7f1f0d76dd6 188 * when the last message was received.
XinZhangMS 0:f7f1f0d76dd6 189 *
XinZhangMS 0:f7f1f0d76dd6 190 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 191 */
XinZhangMS 0:f7f1f0d76dd6 192 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_LL_GetLastMessageReceiveTime, IOTHUB_MODULE_CLIENT_LL_HANDLE, iotHubModuleClientHandle, time_t*, lastMessageReceiveTime);
XinZhangMS 0:f7f1f0d76dd6 193
XinZhangMS 0:f7f1f0d76dd6 194 /**
XinZhangMS 0:f7f1f0d76dd6 195 * @brief This function is meant to be called by the user when work
XinZhangMS 0:f7f1f0d76dd6 196 * (sending/receiving) can be done by the IoTHubClient.
XinZhangMS 0:f7f1f0d76dd6 197 *
XinZhangMS 0:f7f1f0d76dd6 198 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 199 *
XinZhangMS 0:f7f1f0d76dd6 200 * All IoTHubClient interactions (in regards to network traffic
XinZhangMS 0:f7f1f0d76dd6 201 * and/or user level callbacks) are the effect of calling this
XinZhangMS 0:f7f1f0d76dd6 202 * function and they take place synchronously inside _DoWork.
XinZhangMS 0:f7f1f0d76dd6 203 */
XinZhangMS 0:f7f1f0d76dd6 204 MOCKABLE_FUNCTION(, void, IoTHubModuleClient_LL_DoWork, IOTHUB_MODULE_CLIENT_LL_HANDLE, iotHubModuleClientHandle);
XinZhangMS 0:f7f1f0d76dd6 205
XinZhangMS 0:f7f1f0d76dd6 206 /**
XinZhangMS 0:f7f1f0d76dd6 207 * @brief This API sets a runtime option identified by parameter @p optionName
XinZhangMS 0:f7f1f0d76dd6 208 * to a value pointed to by @p value. @p optionName and the data type
XinZhangMS 0:f7f1f0d76dd6 209 * @p value is pointing to are specific for every option.
XinZhangMS 0:f7f1f0d76dd6 210 *
XinZhangMS 0:f7f1f0d76dd6 211 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 212 * @param optionName Name of the option.
XinZhangMS 0:f7f1f0d76dd6 213 * @param value The value.
XinZhangMS 0:f7f1f0d76dd6 214 *
XinZhangMS 0:f7f1f0d76dd6 215 * The options that can be set via this API are:
XinZhangMS 0:f7f1f0d76dd6 216 * - @b timeout - the maximum time in milliseconds a communication is
XinZhangMS 0:f7f1f0d76dd6 217 * allowed to use. @p value is a pointer to an @c unsigned @c int with
XinZhangMS 0:f7f1f0d76dd6 218 * the timeout value in milliseconds. This is only supported for the HTTP
XinZhangMS 0:f7f1f0d76dd6 219 * protocol as of now. When the HTTP protocol uses CURL, the meaning of
XinZhangMS 0:f7f1f0d76dd6 220 * the parameter is <em>total request time</em>. When the HTTP protocol uses
XinZhangMS 0:f7f1f0d76dd6 221 * winhttp, the meaning is the same as the @c dwSendTimeout and
XinZhangMS 0:f7f1f0d76dd6 222 * @c dwReceiveTimeout parameters of the
XinZhangMS 0:f7f1f0d76dd6 223 * <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa384116(v=vs.85).aspx">
XinZhangMS 0:f7f1f0d76dd6 224 * WinHttpSetTimeouts</a> API.
XinZhangMS 0:f7f1f0d76dd6 225 * - @b CURLOPT_LOW_SPEED_LIMIT - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 226 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 227 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 228 * - @b CURLOPT_LOW_SPEED_TIME - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 229 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 230 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 231 * - @b CURLOPT_FORBID_REUSE - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 232 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 233 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 234 * - @b CURLOPT_FRESH_CONNECT - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 235 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 236 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 237 * - @b CURLOPT_VERBOSE - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 238 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 239 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 240 * - @b keepalive - available for MQTT protocol. Integer value that sets the
XinZhangMS 0:f7f1f0d76dd6 241 * interval in seconds when pings are sent to the server.
XinZhangMS 0:f7f1f0d76dd6 242 * - @b logtrace - available for MQTT protocol. Boolean value that turns on and
XinZhangMS 0:f7f1f0d76dd6 243 * off the diagnostic logging.
XinZhangMS 0:f7f1f0d76dd6 244 * - @b sas_token_lifetime - available for MQTT & AMQP protocol. size_t value that that determines the
XinZhangMS 0:f7f1f0d76dd6 245 * sas token timeout length.
XinZhangMS 0:f7f1f0d76dd6 246 *
XinZhangMS 0:f7f1f0d76dd6 247 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 248 */
XinZhangMS 0:f7f1f0d76dd6 249 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_LL_SetOption, IOTHUB_MODULE_CLIENT_LL_HANDLE, iotHubModuleClientHandle, const char*, optionName, const void*, value);
XinZhangMS 0:f7f1f0d76dd6 250
XinZhangMS 0:f7f1f0d76dd6 251 /**
XinZhangMS 0:f7f1f0d76dd6 252 * @brief This API specifies a call back to be used when the module receives a desired state update.
XinZhangMS 0:f7f1f0d76dd6 253 *
XinZhangMS 0:f7f1f0d76dd6 254 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 255 * @param moduleTwinCallback The callback specified by the module client to be used for updating
XinZhangMS 0:f7f1f0d76dd6 256 * the desired state. The callback will be called in response to patch
XinZhangMS 0:f7f1f0d76dd6 257 * request send by the IoTHub services. The payload will be passed to the
XinZhangMS 0:f7f1f0d76dd6 258 * callback, along with two version numbers:
XinZhangMS 0:f7f1f0d76dd6 259 * - Desired:
XinZhangMS 0:f7f1f0d76dd6 260 * - LastSeenReported:
XinZhangMS 0:f7f1f0d76dd6 261 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 262 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 263 *
XinZhangMS 0:f7f1f0d76dd6 264 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 265 * the ::IoTHubModuleClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 266 *
XinZhangMS 0:f7f1f0d76dd6 267 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 268 */
XinZhangMS 0:f7f1f0d76dd6 269 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_LL_SetModuleTwinCallback, IOTHUB_MODULE_CLIENT_LL_HANDLE, iotHubModuleClientHandle, IOTHUB_CLIENT_DEVICE_TWIN_CALLBACK, moduleTwinCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 270
XinZhangMS 0:f7f1f0d76dd6 271 /**
XinZhangMS 0:f7f1f0d76dd6 272 * @brief This API sneds a report of the module's properties and their current values.
XinZhangMS 0:f7f1f0d76dd6 273 *
XinZhangMS 0:f7f1f0d76dd6 274 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 275 * @param reportedState The current module property values to be 'reported' to the IoTHub.
XinZhangMS 0:f7f1f0d76dd6 276 * @param reportedStateCallback The callback specified by the module client to be called with the
XinZhangMS 0:f7f1f0d76dd6 277 * result of the transaction.
XinZhangMS 0:f7f1f0d76dd6 278 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 279 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 280 *
XinZhangMS 0:f7f1f0d76dd6 281 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 282 * the ::IoTHubModuleClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 283 *
XinZhangMS 0:f7f1f0d76dd6 284 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 285 */
XinZhangMS 0:f7f1f0d76dd6 286 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_LL_SendReportedState, IOTHUB_MODULE_CLIENT_LL_HANDLE, iotHubModuleClientHandle, const unsigned char*, reportedState, size_t, size, IOTHUB_CLIENT_REPORTED_STATE_CALLBACK, reportedStateCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 287 /**
XinZhangMS 0:f7f1f0d76dd6 288 * @brief This API sets callback for async cloud to module method call.
XinZhangMS 0:f7f1f0d76dd6 289 *
XinZhangMS 0:f7f1f0d76dd6 290 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 291 * @param moduleMethodCallback The callback which will be called by IoTHub.
XinZhangMS 0:f7f1f0d76dd6 292 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 293 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 294 *
XinZhangMS 0:f7f1f0d76dd6 295 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 296 */
XinZhangMS 0:f7f1f0d76dd6 297 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_LL_SetModuleMethodCallback, IOTHUB_MODULE_CLIENT_LL_HANDLE, iotHubModuleClientHandle, IOTHUB_CLIENT_DEVICE_METHOD_CALLBACK_ASYNC, moduleMethodCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 298
XinZhangMS 0:f7f1f0d76dd6 299 /**
XinZhangMS 0:f7f1f0d76dd6 300 * @brief Asynchronous call to send the message specified by @p eventMessageHandle.
XinZhangMS 0:f7f1f0d76dd6 301 *
XinZhangMS 0:f7f1f0d76dd6 302 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 303 * @param eventMessageHandle The handle to an IoT Hub message.
XinZhangMS 0:f7f1f0d76dd6 304 * @param outputName The name of the queue to send the message to.
XinZhangMS 0:f7f1f0d76dd6 305 * @param eventConfirmationCallback The callback specified by the module for receiving
XinZhangMS 0:f7f1f0d76dd6 306 * confirmation of the delivery of the IoT Hub message.
XinZhangMS 0:f7f1f0d76dd6 307 * This callback can be expected to invoke the
XinZhangMS 0:f7f1f0d76dd6 308 * ::IoTHubClient_LL_SendEventAsync function for the
XinZhangMS 0:f7f1f0d76dd6 309 * same message in an attempt to retry sending a failing
XinZhangMS 0:f7f1f0d76dd6 310 * message. The user can specify a @c NULL value here to
XinZhangMS 0:f7f1f0d76dd6 311 * indicate that no callback is required.
XinZhangMS 0:f7f1f0d76dd6 312 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 313 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 314 *
XinZhangMS 0:f7f1f0d76dd6 315 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 316 * the ::IoTHubClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 317 *
XinZhangMS 0:f7f1f0d76dd6 318 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 319 */
XinZhangMS 0:f7f1f0d76dd6 320 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_LL_SendEventToOutputAsync, IOTHUB_MODULE_CLIENT_LL_HANDLE, iotHubModuleClientHandle, IOTHUB_MESSAGE_HANDLE, eventMessageHandle, const char*, outputName, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK, eventConfirmationCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 321
XinZhangMS 0:f7f1f0d76dd6 322 /**
XinZhangMS 0:f7f1f0d76dd6 323 * @brief This API sets callback for method call that is directed to specified 'inputName' queue (e.g. messages from IoTHubClient_SendEventToOutputAsync)
XinZhangMS 0:f7f1f0d76dd6 324 *
XinZhangMS 0:f7f1f0d76dd6 325 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 326 * @param inputName The name of the queue to listen on for this moduleMethodCallback/userContextCallback.
XinZhangMS 0:f7f1f0d76dd6 327 * @param eventHandlerCallback The callback which will be called by IoTHub.
XinZhangMS 0:f7f1f0d76dd6 328 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 329 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 330 *
XinZhangMS 0:f7f1f0d76dd6 331 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 332 */
XinZhangMS 0:f7f1f0d76dd6 333 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_LL_SetInputMessageCallback, IOTHUB_MODULE_CLIENT_LL_HANDLE, iotHubModuleClientHandle, const char*, inputName, IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC, eventHandlerCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 334
XinZhangMS 0:f7f1f0d76dd6 335 #ifdef USE_EDGE_MODULES
XinZhangMS 0:f7f1f0d76dd6 336
XinZhangMS 0:f7f1f0d76dd6 337 /**
XinZhangMS 0:f7f1f0d76dd6 338 * @brief This API creates a module handle based on environment variables set in the Edge runtime.
XinZhangMS 0:f7f1f0d76dd6 339 * NOTE: It is *ONLY* valid when the code is running in a container initiated by Edge.
XinZhangMS 0:f7f1f0d76dd6 340 *
XinZhangMS 0:f7f1f0d76dd6 341 * @param protocol Function pointer for protocol implementation
XinZhangMS 0:f7f1f0d76dd6 342 *
XinZhangMS 0:f7f1f0d76dd6 343 * @return A non-NULL @c IOTHUB_CLIENT_LL_HANDLE value that is used when
XinZhangMS 0:f7f1f0d76dd6 344 * invoking other functions for IoT Hub client and @c NULL on failure.
XinZhangMS 0:f7f1f0d76dd6 345 */
XinZhangMS 0:f7f1f0d76dd6 346 MOCKABLE_FUNCTION(, IOTHUB_MODULE_CLIENT_LL_HANDLE, IoTHubModuleClient_LL_CreateFromEnvironment, IOTHUB_CLIENT_TRANSPORT_PROVIDER, protocol);
XinZhangMS 0:f7f1f0d76dd6 347
XinZhangMS 0:f7f1f0d76dd6 348 /*
XinZhangMS 0:f7f1f0d76dd6 349 * @brief This API invokes a device method on a specified device
XinZhangMS 0:f7f1f0d76dd6 350 *
XinZhangMS 0:f7f1f0d76dd6 351 * @param iotHubModuleClientHandle The handle created by a call to a create function
XinZhangMS 0:f7f1f0d76dd6 352 * @param deviceId The device id of the device to invoke a method on
XinZhangMS 0:f7f1f0d76dd6 353 * @param methodName The name of the method
XinZhangMS 0:f7f1f0d76dd6 354 * @param methodPayload The method payload (in json format)
XinZhangMS 0:f7f1f0d76dd6 355 * @param timeout The time in seconds before a timeout occurs
XinZhangMS 0:f7f1f0d76dd6 356 * @param responseStatus This pointer will be filled with the response status after invoking the device method
XinZhangMS 0:f7f1f0d76dd6 357 * @param responsePayload This pointer will be filled with the response payload
XinZhangMS 0:f7f1f0d76dd6 358 * @param responsePayloadSize This pointer will be filled with the response payload size
XinZhangMS 0:f7f1f0d76dd6 359 *
XinZhangMS 0:f7f1f0d76dd6 360 * @return IOTHUB_CLIENT_OK upon success, or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 361 */
XinZhangMS 0:f7f1f0d76dd6 362 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_LL_DeviceMethodInvoke, IOTHUB_MODULE_CLIENT_LL_HANDLE, iotHubModuleClientHandle, const char*, deviceId, const char*, methodName, const char*, methodPayload, unsigned int, timeout, int*, responseStatus, unsigned char**, responsePayload, size_t*, responsePayloadSize);
XinZhangMS 0:f7f1f0d76dd6 363
XinZhangMS 0:f7f1f0d76dd6 364 /*
XinZhangMS 0:f7f1f0d76dd6 365 * @brief This API invokes a module method on a specified module
XinZhangMS 0:f7f1f0d76dd6 366 *
XinZhangMS 0:f7f1f0d76dd6 367 * @param iotHubModuleClientHandle The handle created by a call to a create function
XinZhangMS 0:f7f1f0d76dd6 368 * @param deviceId The device id of the device to invoke a method on
XinZhangMS 0:f7f1f0d76dd6 369 * @param moduleId The module id of the module to invoke a method on
XinZhangMS 0:f7f1f0d76dd6 370 * @param methodName The name of the method
XinZhangMS 0:f7f1f0d76dd6 371 * @param methodPayload The method payload (in json format)
XinZhangMS 0:f7f1f0d76dd6 372 * @param timeout The time in seconds before a timeout occurs
XinZhangMS 0:f7f1f0d76dd6 373 * @param responseStatus This pointer will be filled with the response status after invoking the module method
XinZhangMS 0:f7f1f0d76dd6 374 * @param responsePayload This pointer will be filled with the response payload
XinZhangMS 0:f7f1f0d76dd6 375 * @param responsePayloadSize This pointer will be filled with the response payload size
XinZhangMS 0:f7f1f0d76dd6 376 *
XinZhangMS 0:f7f1f0d76dd6 377 * @return IOTHUB_CLIENT_OK upon success, or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 378 */
XinZhangMS 0:f7f1f0d76dd6 379 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_LL_ModuleMethodInvoke, IOTHUB_MODULE_CLIENT_LL_HANDLE, iotHubModuleClientHandle, const char*, deviceId, const char*, moduleId, const char*, methodName, const char*, methodPayload, unsigned int, timeout, int*, responseStatus, unsigned char**, responsePayload, size_t*, responsePayloadSize);
XinZhangMS 0:f7f1f0d76dd6 380
XinZhangMS 0:f7f1f0d76dd6 381 #endif /*USE_EDGE_MODULES*/
XinZhangMS 0:f7f1f0d76dd6 382
XinZhangMS 0:f7f1f0d76dd6 383 #ifdef __cplusplus
XinZhangMS 0:f7f1f0d76dd6 384 }
XinZhangMS 0:f7f1f0d76dd6 385 #endif
XinZhangMS 0:f7f1f0d76dd6 386
XinZhangMS 0:f7f1f0d76dd6 387 #endif /* IOTHUB_MODULE_CLIENT_LL_H */