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