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.h
XinZhangMS 0:f7f1f0d76dd6 5 * @brief Extends the IoTHubCLient_LL module with additional features.
XinZhangMS 0:f7f1f0d76dd6 6 *
XinZhangMS 0:f7f1f0d76dd6 7 * @details IoTHubClient is a module that extends the IoTHubCLient_LL
XinZhangMS 0:f7f1f0d76dd6 8 * module with 2 features:
XinZhangMS 0:f7f1f0d76dd6 9 * - scheduling the work for the IoTHubCLient from a
XinZhangMS 0:f7f1f0d76dd6 10 * thread, so that the user does not need to create their
XinZhangMS 0:f7f1f0d76dd6 11 * own thread
XinZhangMS 0:f7f1f0d76dd6 12 * - thread-safe APIs
XinZhangMS 0:f7f1f0d76dd6 13 */
XinZhangMS 0:f7f1f0d76dd6 14
XinZhangMS 0:f7f1f0d76dd6 15 #ifndef IOTHUB_MODULE_CLIENT_H
XinZhangMS 0:f7f1f0d76dd6 16 #define IOTHUB_MODULE_CLIENT_H
XinZhangMS 0:f7f1f0d76dd6 17
XinZhangMS 0:f7f1f0d76dd6 18 #include <stddef.h>
XinZhangMS 0:f7f1f0d76dd6 19 #include <stdint.h>
XinZhangMS 0:f7f1f0d76dd6 20
XinZhangMS 0:f7f1f0d76dd6 21 #include "azure_c_shared_utility/umock_c_prod.h"
XinZhangMS 0:f7f1f0d76dd6 22 #include "iothub_transport_ll.h"
XinZhangMS 0:f7f1f0d76dd6 23 #include "iothub_client_core_ll.h"
XinZhangMS 0:f7f1f0d76dd6 24 #include "iothub_client_core.h"
XinZhangMS 0:f7f1f0d76dd6 25 #include "iothub_module_client_ll.h"
XinZhangMS 0:f7f1f0d76dd6 26
XinZhangMS 0:f7f1f0d76dd6 27 #ifndef IOTHUB_MODULE_CLIENT_INSTANCE_TYPE
XinZhangMS 0:f7f1f0d76dd6 28 typedef IOTHUB_CLIENT_CORE_HANDLE IOTHUB_MODULE_CLIENT_HANDLE;
XinZhangMS 0:f7f1f0d76dd6 29 #define IOTHUB_MODULE_CLIENT_INSTANCE_TYPE
XinZhangMS 0:f7f1f0d76dd6 30 #endif // IOTHUB_CLIENT_INSTANCE
XinZhangMS 0:f7f1f0d76dd6 31
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 /**
XinZhangMS 0:f7f1f0d76dd6 39 * @brief Creates a IoT Hub client for communication with an existing
XinZhangMS 0:f7f1f0d76dd6 40 * IoT Hub using the specified connection string parameter.
XinZhangMS 0:f7f1f0d76dd6 41 *
XinZhangMS 0:f7f1f0d76dd6 42 * @param connectionString Pointer to a character string
XinZhangMS 0:f7f1f0d76dd6 43 * @param protocol Function pointer for protocol implementation
XinZhangMS 0:f7f1f0d76dd6 44 *
XinZhangMS 0:f7f1f0d76dd6 45 * Sample connection string:
XinZhangMS 0:f7f1f0d76dd6 46 * <blockquote>
XinZhangMS 0:f7f1f0d76dd6 47 * <pre>HostName=[IoT Hub name goes here].[IoT Hub suffix goes here, e.g., private.azure-devices-int.net];DeviceId=[Device ID goes here];SharedAccessKey=[Device key goes here];ModuleId=[Module ID goes here]</pre>
XinZhangMS 0:f7f1f0d76dd6 48 * <pre>HostName=[IoT Hub name goes here].[IoT Hub suffix goes here, e.g., private.azure-devices-int.net];DeviceId=[Device ID goes here];SharedAccessSignature=SharedAccessSignature sr=[IoT Hub name goes here].[IoT Hub suffix goes here, e.g., private.azure-devices-int.net]/devices/[Device ID goes here]&sig=[SAS Token goes here]&se=[Expiry Time goes here];ModuleId=[Module ID goes here]</pre>
XinZhangMS 0:f7f1f0d76dd6 49 * </blockquote>
XinZhangMS 0:f7f1f0d76dd6 50 *
XinZhangMS 0:f7f1f0d76dd6 51 * @return A non-NULL @c IOTHUB_MODULE_CLIENT_HANDLE value that is used when
XinZhangMS 0:f7f1f0d76dd6 52 * invoking other functions for IoT Hub client and @c NULL on failure.
XinZhangMS 0:f7f1f0d76dd6 53 */
XinZhangMS 0:f7f1f0d76dd6 54 MOCKABLE_FUNCTION(, IOTHUB_MODULE_CLIENT_HANDLE, IoTHubModuleClient_CreateFromConnectionString, const char*, connectionString, IOTHUB_CLIENT_TRANSPORT_PROVIDER, protocol);
XinZhangMS 0:f7f1f0d76dd6 55
XinZhangMS 0:f7f1f0d76dd6 56 /**
XinZhangMS 0:f7f1f0d76dd6 57 * @brief Disposes of resources allocated by the IoT Hub client. This is a
XinZhangMS 0:f7f1f0d76dd6 58 * blocking call.
XinZhangMS 0:f7f1f0d76dd6 59 *
XinZhangMS 0:f7f1f0d76dd6 60 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 61 */
XinZhangMS 0:f7f1f0d76dd6 62 MOCKABLE_FUNCTION(, void, IoTHubModuleClient_Destroy, IOTHUB_MODULE_CLIENT_HANDLE, iotHubModuleClientHandle);
XinZhangMS 0:f7f1f0d76dd6 63
XinZhangMS 0:f7f1f0d76dd6 64 /**
XinZhangMS 0:f7f1f0d76dd6 65 * @brief Asynchronous call to send the message specified by @p eventMessageHandle.
XinZhangMS 0:f7f1f0d76dd6 66 *
XinZhangMS 0:f7f1f0d76dd6 67 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 68 * @param eventMessageHandle The handle to an IoT Hub message.
XinZhangMS 0:f7f1f0d76dd6 69 * @param eventConfirmationCallback The callback specified by the module for receiving
XinZhangMS 0:f7f1f0d76dd6 70 * confirmation of the delivery of the IoT Hub message.
XinZhangMS 0:f7f1f0d76dd6 71 * This callback can be expected to invoke the
XinZhangMS 0:f7f1f0d76dd6 72 * ::IoTHubModuleClient_SendEventAsync function for the
XinZhangMS 0:f7f1f0d76dd6 73 * same message in an attempt to retry sending a failing
XinZhangMS 0:f7f1f0d76dd6 74 * message. The user can specify a @c NULL value here to
XinZhangMS 0:f7f1f0d76dd6 75 * indicate that no callback is required.
XinZhangMS 0:f7f1f0d76dd6 76 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 77 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 78 *
XinZhangMS 0:f7f1f0d76dd6 79 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 80 * the ::IoTHubModuleClient_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 81 *
XinZhangMS 0:f7f1f0d76dd6 82 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 83 */
XinZhangMS 0:f7f1f0d76dd6 84 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_SendEventAsync, IOTHUB_MODULE_CLIENT_HANDLE, iotHubModuleClientHandle, IOTHUB_MESSAGE_HANDLE, eventMessageHandle, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK, eventConfirmationCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 85
XinZhangMS 0:f7f1f0d76dd6 86 /**
XinZhangMS 0:f7f1f0d76dd6 87 * @brief This function returns the current sending status for IoTHubClient.
XinZhangMS 0:f7f1f0d76dd6 88 *
XinZhangMS 0:f7f1f0d76dd6 89 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 90 * @param iotHubClientStatus The sending state is populated at the address pointed
XinZhangMS 0:f7f1f0d76dd6 91 * at by this parameter. The value will be set to
XinZhangMS 0:f7f1f0d76dd6 92 * @c IOTHUBCLIENT_SENDSTATUS_IDLE if there is currently
XinZhangMS 0:f7f1f0d76dd6 93 * no item to be sent and @c IOTHUBCLIENT_SENDSTATUS_BUSY
XinZhangMS 0:f7f1f0d76dd6 94 * if there are.
XinZhangMS 0:f7f1f0d76dd6 95 *
XinZhangMS 0:f7f1f0d76dd6 96 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 97 */
XinZhangMS 0:f7f1f0d76dd6 98 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_GetSendStatus, IOTHUB_MODULE_CLIENT_HANDLE, iotHubModuleClientHandle, IOTHUB_CLIENT_STATUS*, iotHubClientStatus);
XinZhangMS 0:f7f1f0d76dd6 99
XinZhangMS 0:f7f1f0d76dd6 100 /**
XinZhangMS 0:f7f1f0d76dd6 101 * @brief Sets up the message callback to be invoked when IoT Hub issues a
XinZhangMS 0:f7f1f0d76dd6 102 * message to the device. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 103 *
XinZhangMS 0:f7f1f0d76dd6 104 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 105 * @param messageCallback The callback specified by the device for receiving
XinZhangMS 0:f7f1f0d76dd6 106 * messages from IoT Hub.
XinZhangMS 0:f7f1f0d76dd6 107 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 108 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 109 *
XinZhangMS 0:f7f1f0d76dd6 110 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 111 * the ::IoTHubDeviceClient_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 112 *
XinZhangMS 0:f7f1f0d76dd6 113 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 114 */
XinZhangMS 0:f7f1f0d76dd6 115 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_SetMessageCallback, IOTHUB_MODULE_CLIENT_HANDLE, iotHubModuleClientHandle, IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC, messageCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 116
XinZhangMS 0:f7f1f0d76dd6 117 /**
XinZhangMS 0:f7f1f0d76dd6 118 * @brief Sets up the connection status callback to be invoked representing the status of
XinZhangMS 0:f7f1f0d76dd6 119 * the connection to IOT Hub. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 120 *
XinZhangMS 0:f7f1f0d76dd6 121 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 122 * @param connectionStatusCallback The callback specified by the module for receiving
XinZhangMS 0:f7f1f0d76dd6 123 * updates about the status of the connection to IoT Hub.
XinZhangMS 0:f7f1f0d76dd6 124 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 125 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 126 *
XinZhangMS 0:f7f1f0d76dd6 127 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 128 * the ::IoTHubModuleClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 129 *
XinZhangMS 0:f7f1f0d76dd6 130 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 131 */
XinZhangMS 0:f7f1f0d76dd6 132 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_SetConnectionStatusCallback, IOTHUB_MODULE_CLIENT_HANDLE, iotHubModuleClientHandle, IOTHUB_CLIENT_CONNECTION_STATUS_CALLBACK, connectionStatusCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 133
XinZhangMS 0:f7f1f0d76dd6 134 /**
XinZhangMS 0:f7f1f0d76dd6 135 * @brief Sets up the connection status callback to be invoked representing the status of
XinZhangMS 0:f7f1f0d76dd6 136 * the connection to IOT Hub. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 137 *
XinZhangMS 0:f7f1f0d76dd6 138 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 139 * @param retryPolicy The policy to use to reconnect to IoT Hub when a
XinZhangMS 0:f7f1f0d76dd6 140 * connection drops.
XinZhangMS 0:f7f1f0d76dd6 141 * @param retryTimeoutLimitInSeconds Maximum amount of time(seconds) to attempt reconnection when a
XinZhangMS 0:f7f1f0d76dd6 142 * connection drops to IOT Hub.
XinZhangMS 0:f7f1f0d76dd6 143 *
XinZhangMS 0:f7f1f0d76dd6 144 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 145 * the ::IoTHubModuleClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 146 *
XinZhangMS 0:f7f1f0d76dd6 147 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 148 */
XinZhangMS 0:f7f1f0d76dd6 149 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_SetRetryPolicy, IOTHUB_MODULE_CLIENT_HANDLE, iotHubModuleClientHandle, IOTHUB_CLIENT_RETRY_POLICY, retryPolicy, size_t, retryTimeoutLimitInSeconds);
XinZhangMS 0:f7f1f0d76dd6 150
XinZhangMS 0:f7f1f0d76dd6 151 /**
XinZhangMS 0:f7f1f0d76dd6 152 * @brief Sets up the connection status callback to be invoked representing the status of
XinZhangMS 0:f7f1f0d76dd6 153 * the connection to IOT Hub. This is a blocking call.
XinZhangMS 0:f7f1f0d76dd6 154 *
XinZhangMS 0:f7f1f0d76dd6 155 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 156 * @param retryPolicy Out parameter containing the policy to use to reconnect to IoT Hub.
XinZhangMS 0:f7f1f0d76dd6 157 * @param retryTimeoutLimitInSeconds Out parameter containing maximum amount of time in seconds to attempt reconnection
XinZhangMS 0:f7f1f0d76dd6 158 to IOT Hub.
XinZhangMS 0:f7f1f0d76dd6 159 *
XinZhangMS 0:f7f1f0d76dd6 160 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 161 * the ::IoTHubModuleClient_LL_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 162 *
XinZhangMS 0:f7f1f0d76dd6 163 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 164 */
XinZhangMS 0:f7f1f0d76dd6 165 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_GetRetryPolicy, IOTHUB_MODULE_CLIENT_HANDLE, iotHubModuleClientHandle, IOTHUB_CLIENT_RETRY_POLICY*, retryPolicy, size_t*, retryTimeoutLimitInSeconds);
XinZhangMS 0:f7f1f0d76dd6 166
XinZhangMS 0:f7f1f0d76dd6 167 /**
XinZhangMS 0:f7f1f0d76dd6 168 * @brief This function returns in the out parameter @p lastMessageReceiveTime
XinZhangMS 0:f7f1f0d76dd6 169 * what was the value of the @c time function when the last message was
XinZhangMS 0:f7f1f0d76dd6 170 * received at the client.
XinZhangMS 0:f7f1f0d76dd6 171 *
XinZhangMS 0:f7f1f0d76dd6 172 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 173 * @param lastMessageReceiveTime Out parameter containing the value of @c time function
XinZhangMS 0:f7f1f0d76dd6 174 * when the last message was received.
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, IoTHubModuleClient_GetLastMessageReceiveTime, IOTHUB_MODULE_CLIENT_HANDLE, iotHubModuleClientHandle, time_t*, lastMessageReceiveTime);
XinZhangMS 0:f7f1f0d76dd6 179
XinZhangMS 0:f7f1f0d76dd6 180 /**
XinZhangMS 0:f7f1f0d76dd6 181 * @brief This API sets a runtime option identified by parameter @p optionName
XinZhangMS 0:f7f1f0d76dd6 182 * to a value pointed to by @p value. @p optionName and the data type
XinZhangMS 0:f7f1f0d76dd6 183 * @p value is pointing to are specific for every option.
XinZhangMS 0:f7f1f0d76dd6 184 *
XinZhangMS 0:f7f1f0d76dd6 185 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 186 * @param optionName Name of the option.
XinZhangMS 0:f7f1f0d76dd6 187 * @param value The value.
XinZhangMS 0:f7f1f0d76dd6 188 *
XinZhangMS 0:f7f1f0d76dd6 189 * The options that can be set via this API are:
XinZhangMS 0:f7f1f0d76dd6 190 * - @b timeout - the maximum time in milliseconds a communication is
XinZhangMS 0:f7f1f0d76dd6 191 * allowed to use. @p value is a pointer to an @c unsigned @c int with
XinZhangMS 0:f7f1f0d76dd6 192 * the timeout value in milliseconds. This is only supported for the HTTP
XinZhangMS 0:f7f1f0d76dd6 193 * protocol as of now. When the HTTP protocol uses CURL, the meaning of
XinZhangMS 0:f7f1f0d76dd6 194 * the parameter is <em>total request time</em>. When the HTTP protocol uses
XinZhangMS 0:f7f1f0d76dd6 195 * winhttp, the meaning is the same as the @c dwSendTimeout and
XinZhangMS 0:f7f1f0d76dd6 196 * @c dwReceiveTimeout parameters of the
XinZhangMS 0:f7f1f0d76dd6 197 * <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa384116(v=vs.85).aspx">
XinZhangMS 0:f7f1f0d76dd6 198 * WinHttpSetTimeouts</a> API.
XinZhangMS 0:f7f1f0d76dd6 199 * - @b CURLOPT_LOW_SPEED_LIMIT - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 200 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 201 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 202 * - @b CURLOPT_LOW_SPEED_TIME - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 203 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 204 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 205 * - @b CURLOPT_FORBID_REUSE - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 206 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 207 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 208 * - @b CURLOPT_FRESH_CONNECT - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 209 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 210 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 211 * - @b CURLOPT_VERBOSE - only available for HTTP protocol and only
XinZhangMS 0:f7f1f0d76dd6 212 * when CURL is used. It has the same meaning as CURL's option with the same
XinZhangMS 0:f7f1f0d76dd6 213 * name. @p value is pointer to a long.
XinZhangMS 0:f7f1f0d76dd6 214 * - @b messageTimeout - the maximum time in milliseconds until a message
XinZhangMS 0:f7f1f0d76dd6 215 * is timeouted. The time starts at IoTHubModuleClient_SendEventAsync. By default,
XinZhangMS 0:f7f1f0d76dd6 216 * messages do not expire. @p is a pointer to a uint64_t
XinZhangMS 0:f7f1f0d76dd6 217 * - @b svc2cl_keep_alive_timeout_secs - the AMQP service side keep alive interval in seconds.
XinZhangMS 0:f7f1f0d76dd6 218 * After the connection established the client requests the server to set the
XinZhangMS 0:f7f1f0d76dd6 219 * keep alive interval for given time.
XinZhangMS 0:f7f1f0d76dd6 220 * If it is not set then the default 240 sec applies.
XinZhangMS 0:f7f1f0d76dd6 221 * If it is set to zero the server will not send keep alive messages to the client.
XinZhangMS 0:f7f1f0d76dd6 222 * - @b cl2svc_keep_alive_send_ratio - the AMQP client side keep alive interval in seconds.
XinZhangMS 0:f7f1f0d76dd6 223 * After the connection established the server requests the client to set the
XinZhangMS 0:f7f1f0d76dd6 224 * keep alive interval for given time.
XinZhangMS 0:f7f1f0d76dd6 225 * If it is not set then the default ratio of 1/2 is applied.
XinZhangMS 0:f7f1f0d76dd6 226 * The ratio has to be greater than 0.0 and equal to or less than 0.9
XinZhangMS 0:f7f1f0d76dd6 227
XinZhangMS 0:f7f1f0d76dd6 228 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 229 */
XinZhangMS 0:f7f1f0d76dd6 230 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_SetOption, IOTHUB_MODULE_CLIENT_HANDLE, iotHubModuleClientHandle, const char*, optionName, const void*, value);
XinZhangMS 0:f7f1f0d76dd6 231
XinZhangMS 0:f7f1f0d76dd6 232 /**
XinZhangMS 0:f7f1f0d76dd6 233 * @brief This API specifies a call back to be used when the module receives a state update.
XinZhangMS 0:f7f1f0d76dd6 234 *
XinZhangMS 0:f7f1f0d76dd6 235 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 236 * @param moduleTwinCallback The callback specified by the module client to be used for updating
XinZhangMS 0:f7f1f0d76dd6 237 * the desired state. The callback will be called in response to a
XinZhangMS 0:f7f1f0d76dd6 238 * request send by the IoTHub services. The payload will be passed to the
XinZhangMS 0:f7f1f0d76dd6 239 * callback, along with two version numbers:
XinZhangMS 0:f7f1f0d76dd6 240 * - Desired:
XinZhangMS 0:f7f1f0d76dd6 241 * - LastSeenReported:
XinZhangMS 0:f7f1f0d76dd6 242 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 243 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 244 *
XinZhangMS 0:f7f1f0d76dd6 245 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 246 * the ::IoTHubModuleClient_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 247 *
XinZhangMS 0:f7f1f0d76dd6 248 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 249 */
XinZhangMS 0:f7f1f0d76dd6 250 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_SetModuleTwinCallback, IOTHUB_MODULE_CLIENT_HANDLE, iotHubModuleClientHandle, IOTHUB_CLIENT_DEVICE_TWIN_CALLBACK, moduleTwinCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 251
XinZhangMS 0:f7f1f0d76dd6 252 /**
XinZhangMS 0:f7f1f0d76dd6 253 * @brief This API sends a report of the module's properties and their current values.
XinZhangMS 0:f7f1f0d76dd6 254 *
XinZhangMS 0:f7f1f0d76dd6 255 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 256 * @param reportedState The current module property values to be 'reported' to the IoTHub.
XinZhangMS 0:f7f1f0d76dd6 257 * @param reportedStateCallback The callback specified by the module client to be called with the
XinZhangMS 0:f7f1f0d76dd6 258 * result of the transaction.
XinZhangMS 0:f7f1f0d76dd6 259 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 260 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 261 *
XinZhangMS 0:f7f1f0d76dd6 262 * @b NOTE: The application behavior is undefined if the user calls
XinZhangMS 0:f7f1f0d76dd6 263 * the ::IoTHubModuleClient_Destroy function from within any callback.
XinZhangMS 0:f7f1f0d76dd6 264 *
XinZhangMS 0:f7f1f0d76dd6 265 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 266 */
XinZhangMS 0:f7f1f0d76dd6 267 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_SendReportedState, IOTHUB_MODULE_CLIENT_HANDLE, iotHubModuleClientHandle, const unsigned char*, reportedState, size_t, size, IOTHUB_CLIENT_REPORTED_STATE_CALLBACK, reportedStateCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 268
XinZhangMS 0:f7f1f0d76dd6 269 /**
XinZhangMS 0:f7f1f0d76dd6 270 * @brief This API sets callback for async cloud to module method call.
XinZhangMS 0:f7f1f0d76dd6 271 *
XinZhangMS 0:f7f1f0d76dd6 272 * @param iotHubClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 273 * @param methodCallback The callback which will be called by IoTHub.
XinZhangMS 0:f7f1f0d76dd6 274 * @param userContextCallback User specified context that will be provided to the
XinZhangMS 0:f7f1f0d76dd6 275 * callback. This can be @c NULL.
XinZhangMS 0:f7f1f0d76dd6 276 *
XinZhangMS 0:f7f1f0d76dd6 277 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 278 */
XinZhangMS 0:f7f1f0d76dd6 279 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_SetModuleMethodCallback, IOTHUB_MODULE_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_DEVICE_METHOD_CALLBACK_ASYNC, methodCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 280
XinZhangMS 0:f7f1f0d76dd6 281 /**
XinZhangMS 0:f7f1f0d76dd6 282 * @brief Asynchronous call to send the message specified by @p eventMessageHandle.
XinZhangMS 0:f7f1f0d76dd6 283 *
XinZhangMS 0:f7f1f0d76dd6 284 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 285 * @param eventMessageHandle The handle to an IoT Hub message.
XinZhangMS 0:f7f1f0d76dd6 286 * @param outputName The name of the queue to send the message to.
XinZhangMS 0:f7f1f0d76dd6 287 * @param eventConfirmationCallback The callback specified by the module for receiving
XinZhangMS 0:f7f1f0d76dd6 288 * confirmation of the delivery of the IoT Hub message.
XinZhangMS 0:f7f1f0d76dd6 289 * This callback can be expected to invoke the
XinZhangMS 0:f7f1f0d76dd6 290 * ::IoTHubClient_SendEventAsync function for the
XinZhangMS 0:f7f1f0d76dd6 291 * same message in an attempt to retry sending a failing
XinZhangMS 0:f7f1f0d76dd6 292 * message. The user can specify a @c NULL value here to
XinZhangMS 0:f7f1f0d76dd6 293 * indicate that no callback is required.
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 ::IoTHubClient_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, IoTHubModuleClient_SendEventToOutputAsync, IOTHUB_MODULE_CLIENT_HANDLE, iotHubModuleClientHandle, IOTHUB_MESSAGE_HANDLE, eventMessageHandle, const char*, outputName, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK, eventConfirmationCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 303
XinZhangMS 0:f7f1f0d76dd6 304
XinZhangMS 0:f7f1f0d76dd6 305 /**
XinZhangMS 0:f7f1f0d76dd6 306 * @brief This API sets callback for method call that is directed to specified 'inputName' queue (e.g. messages from IoTHubClient_SendEventToOutputAsync)
XinZhangMS 0:f7f1f0d76dd6 307 *
XinZhangMS 0:f7f1f0d76dd6 308 * @param iotHubModuleClientHandle The handle created by a call to the create function.
XinZhangMS 0:f7f1f0d76dd6 309 * @param inputName The name of the queue to listen on for this moduleMethodCallback/userContextCallback.
XinZhangMS 0:f7f1f0d76dd6 310 * @param eventHandlerCallback The callback which will be called by IoTHub.
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 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 315 */
XinZhangMS 0:f7f1f0d76dd6 316 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_SetInputMessageCallback, IOTHUB_MODULE_CLIENT_HANDLE, iotHubModuleClientHandle, const char*, inputName, IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC, eventHandlerCallback, void*, userContextCallback);
XinZhangMS 0:f7f1f0d76dd6 317
XinZhangMS 0:f7f1f0d76dd6 318 #ifdef USE_EDGE_MODULES
XinZhangMS 0:f7f1f0d76dd6 319 /**
XinZhangMS 0:f7f1f0d76dd6 320 * @brief This API creates a module handle based on environment variables set in the Edge runtime.
XinZhangMS 0:f7f1f0d76dd6 321 NOTE: It is *ONLY* valid when the code is running in a container initiated by Edge.
XinZhangMS 0:f7f1f0d76dd6 322 *
XinZhangMS 0:f7f1f0d76dd6 323 * @param protocol Function pointer for protocol implementation
XinZhangMS 0:f7f1f0d76dd6 324 *
XinZhangMS 0:f7f1f0d76dd6 325 * @return A non-NULL @c IOTHUB_CLIENT_LL_HANDLE value that is used when
XinZhangMS 0:f7f1f0d76dd6 326 * invoking other functions for IoT Hub client and @c NULL on failure.
XinZhangMS 0:f7f1f0d76dd6 327
XinZhangMS 0:f7f1f0d76dd6 328 */
XinZhangMS 0:f7f1f0d76dd6 329 MOCKABLE_FUNCTION(, IOTHUB_MODULE_CLIENT_HANDLE, IoTHubModuleClient_CreateFromEnvironment, IOTHUB_CLIENT_TRANSPORT_PROVIDER, protocol);
XinZhangMS 0:f7f1f0d76dd6 330
XinZhangMS 0:f7f1f0d76dd6 331 /*
XinZhangMS 0:f7f1f0d76dd6 332 * @brief This API invokes a device method on a specified device
XinZhangMS 0:f7f1f0d76dd6 333 *
XinZhangMS 0:f7f1f0d76dd6 334 * @param iotHubModuleClientHandle The handle created by a call to a create function
XinZhangMS 0:f7f1f0d76dd6 335 * @param deviceId The device id of the device to invoke a method on
XinZhangMS 0:f7f1f0d76dd6 336 * @param methodName The name of the method
XinZhangMS 0:f7f1f0d76dd6 337 * @param methodPayload The method payload (in json format)
XinZhangMS 0:f7f1f0d76dd6 338 * @param timeout The time in seconds before a timeout occurs
XinZhangMS 0:f7f1f0d76dd6 339 * @param responseStatus This pointer will be filled with the response status after invoking the device method
XinZhangMS 0:f7f1f0d76dd6 340 * @param responsePayload This pointer will be filled with the response payload
XinZhangMS 0:f7f1f0d76dd6 341 * @param responsePayloadSize This pointer will be filled with the response payload size
XinZhangMS 0:f7f1f0d76dd6 342 *
XinZhangMS 0:f7f1f0d76dd6 343 * @return IOTHUB_CLIENT_OK upon success, or an error code upon failure.
XinZhangMS 0:f7f1f0d76dd6 344 */
XinZhangMS 0:f7f1f0d76dd6 345 MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_DeviceMethodInvokeAsync, IOTHUB_MODULE_CLIENT_HANDLE, iotHubModuleClientHandle, const char*, deviceId, const char*, methodName, const char*, methodPayload, unsigned int, timeout, IOTHUB_METHOD_INVOKE_CALLBACK, methodInvokeCallback, void*, context);
XinZhangMS 0:f7f1f0d76dd6 346
XinZhangMS 0:f7f1f0d76dd6 347 /*
XinZhangMS 0:f7f1f0d76dd6 348 * @brief This API invokes a module method on a specified module
XinZhangMS 0:f7f1f0d76dd6 349 *
XinZhangMS 0:f7f1f0d76dd6 350 * @param iotHubModuleClientHandle The handle created by a call to a create function
XinZhangMS 0:f7f1f0d76dd6 351 * @param deviceId The device id of the device to invoke a method on
XinZhangMS 0:f7f1f0d76dd6 352 * @param moduleId The module id of the module 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 module 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_ModuleMethodInvokeAsync, IOTHUB_MODULE_CLIENT_HANDLE, iotHubModuleClientHandle, const char*, deviceId, const char*, moduleId, const char*, methodName, const char*, methodPayload, unsigned int, timeout, IOTHUB_METHOD_INVOKE_CALLBACK, methodInvokeCallback, void*, context);
XinZhangMS 0:f7f1f0d76dd6 363
XinZhangMS 0:f7f1f0d76dd6 364 #endif /*USE_EDGE_MODULES*/
XinZhangMS 0:f7f1f0d76dd6 365
XinZhangMS 0:f7f1f0d76dd6 366 #ifdef __cplusplus
XinZhangMS 0:f7f1f0d76dd6 367 }
XinZhangMS 0:f7f1f0d76dd6 368 #endif
XinZhangMS 0:f7f1f0d76dd6 369
XinZhangMS 0:f7f1f0d76dd6 370 #endif /* IOTHUB_MODULE_CLIENT_H */