Skip to content

Commit 86c0884

Browse files
authored
Documentation cleanup (Azure#1726)
Miscellaneous documentation cleanup: * Document SetOption should be used right after handle creation, not at arbitrary times. * Document that `timeout` parameter isn't respected during device/module method calls. * Document that CreateFromEnvironment API for creating handles inside IoT Edge containers requires MQTT protocol. * Fixup some doxygen warnings.
1 parent 26d8aed commit 86c0884

File tree

13 files changed

+103
-61
lines changed

13 files changed

+103
-61
lines changed

doc/Iothub_sdk_options.md

+11-17
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
This document describes how you can set options for the Azure IoT Hub and Device Provisioning Service (DPS) client connections.
44

5-
- [Example Code for Setting an Option](#set_option)
6-
- [Common Transport Options](#general_options)
7-
- [IoT Hub Device and Module Client Options](#IotHub_options)
8-
- [MQTT, AMQP, and HTTP Specific Protocol Options](#protocol_specific_options)
9-
- [Device Provisioning Service (DPS) Client Options](#provisioning_option)
10-
- [File Upload Options](#upload-options)
11-
12-
<a name="set_option"></a>
5+
- [Example Code for Setting an Option](#Example-Code-for-Setting-an-Option)
6+
- [When to Set Options](#When-to-Set-Options)
7+
- [Common Transport Options](#Common-Transport-Options)
8+
- [IoT Hub Device and Module Client Options](#IoT-Hub-Device-and-Module-Client-Options)
9+
- [MQTT, AMQP, and HTTP Specific Protocol Options](#MQTT,-AMQP,-and-HTTP-Specific-Protocol-Options)
10+
- [Device Provisioning Service (DPS) Client Options](#Device-Provisioning-Service-(DPS)-Client-Options)
11+
- [File Upload Options](#File-Upload-Options)
1312

1413
## Example Code for Setting an Option
1514

@@ -45,7 +44,10 @@ http_proxy.port = PROXY_PORT;
4544
Prov_Device_LL_SetOption(handle, OPTION_HTTP_PROXY, &http_proxy);
4645
```
4746

48-
<a name="general_options"></a>
47+
## When to Set Options
48+
49+
You should set the options you need right after creating your IoT Hub device or module handle. Setting most options after the connection has been initiated may be silently ignored or applied much later. Many of these are used at connection initiation time itself.
50+
4951

5052
## Common Transport Options
5153
You can use the options below for the IoT Hub Device Client, the IoT Hub Module Client, and for the Device Provisioning Client. These options are declared in [shared_util_options.h][shared-util-options-h].
@@ -63,8 +65,6 @@ You can use the options below for the IoT Hub Device Client, the IoT Hub Module
6365
| `"tls_version"` | OPTION_TLS_VERSION | int* | TLS version to use for openssl, 10 for version 1.0, 11 for version 1.1, 12 for version 1.2. (**DEPRECATED**: TLS 1.0 and 1.1 are not secure and should not be used. This option is included only for backward compatibility.)
6466

6567

66-
<a name="IotHub_options"></a>
67-
6868
## IoT Hub Device and Module Client Options
6969
You can use the options below for IoT Hub connections. These options are declared in [iothub_client_options.h][iothub-client-options-h].
7070

@@ -84,8 +84,6 @@ You may also use [common transport options](#general_options) options.
8484
| `"do_work_freq_ms"` | OPTION_DO_WORK_FREQUENCY_IN_MS | [tickcounter_ms_t *][tick-counter-header] | Specifies how frequently the worker thread spun by the convenience layer will wake up, in milliseconds. The default is 1 millisecond. The maximum allowable value is 100. (Convenience layer APIs only)
8585

8686

87-
<a name="protocol_specific_options"></a>
88-
8987
## MQTT, AMQP, and HTTP Specific Protocol Options
9088

9189
Some options are only supported by a given protocol (e.g. MQTT, AMQP, HTTP). These are declared in [iothub_client_options.h][iothub-client-options-h].
@@ -115,8 +113,6 @@ Some options are only supported by a given protocol (e.g. MQTT, AMQP, HTTP). Th
115113
| `"MinimumPollingTime"` | OPTION_MIN_POLLING_TIME | unsigned int* | Minimum time in seconds allowed between 2 consecutive GET issues to the service
116114
| `"timeout"` | OPTION_HTTP_TIMEOUT | long* | When using curl the amount of time before the request times out, defaults to 242 seconds.
117115

118-
<a name="provisioning_option"></a>
119-
120116
## Device Provisioning Service (DPS) Client Options
121117

122118
You can use the options below to configure the DPS client. These are defined in [prov_device_ll_client.h][provisioning-device-ll-client-options-h] except for `PROV_OPTION_DO_WORK_FREQUENCY_IN_MS` which is defined in [prov_device_client.h][provisioning-device-client-options-h].
@@ -130,8 +126,6 @@ You may also use [common transport options](#general_options).
130126
| `"provisioning_timeout"` | PROV_OPTION_TIMEOUT | long* | Maximum time to allow DPS to complete, in seconds.
131127
| `"do_work_freq_ms"` | PROV_OPTION_DO_WORK_FREQUENCY_IN_MS | uint16_t * | Specifies how frequently the worker thread spun by the convenience layer will wake up, in milliseconds. The default is 1 millisecond. (Convenience layer APIs only)
132128

133-
<a name="upload-options"></a>
134-
135129
## File Upload Options
136130

137131
When you upload files to Azure with APIs like `IoTHubDeviceClient_LL_UploadToBlob`, most of the options described above are silently ignored. This is even though these APIs use the same IoT Hub handle as used for telemetry, device methods, and device twin. The reason the options are different is because the underlying transport is implemented differently for uploads.

iothub_client/inc/iothub_device_client.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,15 @@ extern "C"
111111
* @param eventConfirmationCallback The callback specified by the device for receiving
112112
* confirmation of the delivery of the IoT Hub message.
113113
* This callback can be expected to invoke the
114-
* ::IoTHubDeviceClient_SendEventAsync function for the
114+
* IoTHubDeviceClient_SendEventAsync function for the
115115
* same message in an attempt to retry sending a failing
116116
* message. The user can specify a @c NULL value here to
117117
* indicate that no callback is required.
118118
* @param userContextCallback User specified context that will be provided to the
119119
* callback. This can be @c NULL.
120120
*
121121
* @b NOTE: The application behavior is undefined if the user calls
122-
* the ::IoTHubDeviceClient_Destroy function from within any callback.
122+
* the IoTHubDeviceClient_Destroy function from within any callback.
123123
* @remarks
124124
* The IOTHUB_MESSAGE_HANDLE instance provided as argument is copied by the function,
125125
* so this argument can be destroyed by the calling application right after IoTHubDeviceClient_SendEventAsync returns.
@@ -155,7 +155,7 @@ extern "C"
155155
* callback. This can be @c NULL.
156156
*
157157
* @b NOTE: The application behavior is undefined if the user calls
158-
* the ::IoTHubDeviceClient_Destroy function from within any callback.
158+
* the IoTHubDeviceClient_Destroy function from within any callback.
159159
*
160160
* @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
161161
*/
@@ -172,7 +172,7 @@ extern "C"
172172
* callback. This can be @c NULL.
173173
*
174174
* @b NOTE: The application behavior is undefined if the user calls
175-
* the ::IoTHubDeviceClient_Destroy function from within any callback.
175+
* the IoTHubDeviceClient_Destroy function from within any callback.
176176
*
177177
* @remark Callback specified will not receive connection status change notifications for upload connections created with IoTHubDeviceClient_UploadToBlob or IoTHubDeviceClient_UploadMultipleBlocksToBlob.
178178
*
@@ -191,7 +191,7 @@ extern "C"
191191
* connection drops to IOT Hub.
192192
*
193193
* @b NOTE: The application behavior is undefined if the user calls
194-
* the ::IoTHubDeviceClient_Destroy function from within any callback.
194+
* the IoTHubDeviceClient_Destroy function from within any callback.
195195
*
196196
* @remark Uploads initiated by IoTHubDeviceClient_UploadToBlob or IoTHubDeviceClient_UploadMultipleBlocksToBlob do not have automatic retries and do not honor the retryPolicy settings.
197197
*
@@ -209,7 +209,7 @@ extern "C"
209209
* to IOT Hub.
210210
*
211211
* @b NOTE: The application behavior is undefined if the user calls
212-
* the ::IoTHubDeviceClient_Destroy function from within any callback.
212+
* the IoTHubDeviceClient_Destroy function from within any callback.
213213
*
214214
* @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
215215
*/
@@ -257,7 +257,7 @@ extern "C"
257257
* callback. This can be @c NULL.
258258
*
259259
* @b NOTE: The application behavior is undefined if the user calls
260-
* the ::IoTHubDeviceClient_Destroy function from within any callback.
260+
* the IoTHubDeviceClient_Destroy function from within any callback.
261261
*
262262
* @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
263263
*/
@@ -274,7 +274,7 @@ extern "C"
274274
* callback. This can be @c NULL.
275275
*
276276
* @b NOTE: The application behavior is undefined if the user calls
277-
* the ::IoTHubDeviceClient_Destroy function from within any callback.
277+
* the IoTHubDeviceClient_Destroy function from within any callback.
278278
*
279279
* @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
280280
*/
@@ -290,7 +290,7 @@ extern "C"
290290
* callback. This can be @c NULL.
291291
*
292292
* @b NOTE: The application behavior is undefined if the user calls
293-
* the ::IoTHubDeviceClient_Destroy function from within any callback.
293+
* the IoTHubDeviceClient_Destroy function from within any callback.
294294
*
295295
* @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
296296
*/

iothub_client/inc/iothub_device_client_ll.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,15 @@ typedef struct IOTHUB_CLIENT_CORE_LL_HANDLE_DATA_TAG* IOTHUB_DEVICE_CLIENT_LL_HA
115115
* @param eventConfirmationCallback The callback specified by the device for receiving
116116
* confirmation of the delivery of the IoT Hub message.
117117
* This callback can be expected to invoke the
118-
* ::IoTHubDeviceClient_LL_SendEventAsync function for the
118+
* IoTHubDeviceClient_LL_SendEventAsync function for the
119119
* same message in an attempt to retry sending a failing
120120
* message. The user can specify a @c NULL value here to
121121
* indicate that no callback is required.
122122
* @param userContextCallback User specified context that will be provided to the
123123
* callback. This can be @c NULL.
124124
*
125125
* @b NOTE: The application behavior is undefined if the user calls
126-
* the ::IoTHubDeviceClient_LL_Destroy function from within any callback.
126+
* the IoTHubDeviceClient_LL_Destroy function from within any callback.
127127
* @remarks
128128
* The IOTHUB_MESSAGE_HANDLE instance provided as argument is copied by the function,
129129
* so this argument can be destroyed by the calling application right after IoTHubDeviceClient_LL_SendEventAsync returns.
@@ -159,7 +159,7 @@ typedef struct IOTHUB_CLIENT_CORE_LL_HANDLE_DATA_TAG* IOTHUB_DEVICE_CLIENT_LL_HA
159159
* callback. This can be @c NULL.
160160
*
161161
* @b NOTE: The application behavior is undefined if the user calls
162-
* the ::IoTHubDeviceClient_LL_Destroy function from within any callback.
162+
* the IoTHubDeviceClient_LL_Destroy function from within any callback.
163163
*
164164
* @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
165165
*/
@@ -176,7 +176,7 @@ typedef struct IOTHUB_CLIENT_CORE_LL_HANDLE_DATA_TAG* IOTHUB_DEVICE_CLIENT_LL_HA
176176
* callback. This can be @c NULL.
177177
*
178178
* @b NOTE: The application behavior is undefined if the user calls
179-
* the ::IoTHubDeviceClient_LL_Destroy function from within any callback.
179+
* the IoTHubDeviceClient_LL_Destroy function from within any callback.
180180
*
181181
* @remark Callback specified will not receive connection status change notifications for upload connections created with IoTHubDeviceClient_LL_UploadToBlob or IoTHubDeviceClient_LL_UploadMultipleBlocksToBlob.
182182
*
@@ -195,7 +195,7 @@ typedef struct IOTHUB_CLIENT_CORE_LL_HANDLE_DATA_TAG* IOTHUB_DEVICE_CLIENT_LL_HA
195195
* connection drops to IOT Hub.
196196
*
197197
* @b NOTE: The application behavior is undefined if the user calls
198-
* the ::IoTHubDeviceClient_LL_Destroy function from within any callback.
198+
* the IoTHubDeviceClient_LL_Destroy function from within any callback.
199199
*
200200
* @remark Uploads initiated by IoTHubDeviceClient_LL_UploadToBlob or IoTHubDeviceClient_LL_UploadMultipleBlocksToBlob do not have automatic retries and do not honor the retryPolicy settings.
201201
*
@@ -214,7 +214,7 @@ typedef struct IOTHUB_CLIENT_CORE_LL_HANDLE_DATA_TAG* IOTHUB_DEVICE_CLIENT_LL_HA
214214
to IOT Hub.
215215
*
216216
* @b NOTE: The application behavior is undefined if the user calls
217-
* the ::IoTHubDeviceClient_LL_Destroy function from within any callback.
217+
* the IoTHubDeviceClient_LL_Destroy function from within any callback.
218218
*
219219
* @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
220220
*/
@@ -276,7 +276,7 @@ typedef struct IOTHUB_CLIENT_CORE_LL_HANDLE_DATA_TAG* IOTHUB_DEVICE_CLIENT_LL_HA
276276
* callback. This can be @c NULL.
277277
*
278278
* @b NOTE: The application behavior is undefined if the user calls
279-
* the ::IoTHubDeviceClient_LL_Destroy function from within any callback.
279+
* the IoTHubDeviceClient_LL_Destroy function from within any callback.
280280
*
281281
* @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
282282
*/
@@ -293,7 +293,7 @@ typedef struct IOTHUB_CLIENT_CORE_LL_HANDLE_DATA_TAG* IOTHUB_DEVICE_CLIENT_LL_HA
293293
* callback. This can be @c NULL.
294294
*
295295
* @b NOTE: The application behavior is undefined if the user calls
296-
* the ::IoTHubDeviceClient_LL_Destroy function from within any callback.
296+
* the IoTHubDeviceClient_LL_Destroy function from within any callback.
297297
*
298298
* @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
299299
*/
@@ -308,7 +308,7 @@ typedef struct IOTHUB_CLIENT_CORE_LL_HANDLE_DATA_TAG* IOTHUB_DEVICE_CLIENT_LL_HA
308308
* callback. This can be @c NULL.
309309
*
310310
* @b NOTE: The application behavior is undefined if the user calls
311-
* the ::IoTHubClient_LL_Destroy function from within any callback.
311+
* the IoTHubClient_LL_Destroy function from within any callback.
312312
*
313313
* @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
314314
*/

iothub_client/inc/iothub_module_client.h

+15-6
Original file line numberDiff line numberDiff line change
@@ -301,24 +301,29 @@ extern "C"
301301
#ifdef USE_EDGE_MODULES
302302
/**
303303
* @brief This API creates a module handle based on environment variables set in the Edge runtime.
304-
NOTE: It is *ONLY* valid when the code is running in a container initiated by Edge.
304+
* NOTE: It is *ONLY* valid when the code is running in a container initiated by Edge.
305305
*
306-
* @param protocol Function pointer for protocol implementation
306+
*
307+
* @param protocol Function pointer for protocol implementation. This *MUST* be MQTT_Protocol.
308+
*
309+
* @remarks The protocol parameter MUST be set to MQTT_Protocol. Using other values will cause undefined behavior.
307310
*
308311
* @return A non-NULL @c IOTHUB_MODULE_CLIENT_HANDLE value that is used when
309312
* invoking other functions for IoT Hub client and @c NULL on failure.
310-
311313
*/
312314
MOCKABLE_FUNCTION(, IOTHUB_MODULE_CLIENT_HANDLE, IoTHubModuleClient_CreateFromEnvironment, IOTHUB_CLIENT_TRANSPORT_PROVIDER, protocol);
313315

314-
/*
316+
/**
315317
* @brief This API invokes a device method on a specified device
316318
*
317319
* @param iotHubModuleClientHandle The handle created by a call to a create function
318320
* @param deviceId The device id of the device to invoke a method on
319321
* @param methodName The name of the method
320322
* @param methodPayload The method payload (in json format)
321-
* @param timeout The time in seconds before a timeout occurs
323+
*
324+
* @warning The timeout parameter is ignored. See https://github.com/Azure/azure-iot-sdk-c/issues/1378.
325+
* The timeout used will be the default for IoT Edge.
326+
*
322327
* @param responseStatus This pointer will be filled with the response status after invoking the device method
323328
* @param responsePayload This pointer will be filled with the response payload
324329
* @param responsePayloadSize This pointer will be filled with the response payload size
@@ -327,7 +332,7 @@ extern "C"
327332
*/
328333
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);
329334

330-
/*
335+
/**
331336
* @brief This API invokes a module method on a specified module
332337
*
333338
* @param iotHubModuleClientHandle The handle created by a call to a create function
@@ -336,6 +341,10 @@ extern "C"
336341
* @param methodName The name of the method
337342
* @param methodPayload The method payload (in json format)
338343
* @param timeout The time in seconds before a timeout occurs
344+
*
345+
* @warning The timeout parameter is ignored. See https://github.com/Azure/azure-iot-sdk-c/issues/1378.
346+
* The timeout used will be the default for IoT Edge.
347+
*
339348
* @param responseStatus This pointer will be filled with the response status after invoking the module method
340349
* @param responsePayload This pointer will be filled with the response payload
341350
* @param responsePayloadSize This pointer will be filled with the response payload size

0 commit comments

Comments
 (0)