Skip to content

Commit 3e1dd5a

Browse files
committed
Edits
1 parent 1a527d7 commit 3e1dd5a

5 files changed

+27
-16
lines changed

articles/iot-hub/how-to-device-management.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ This article shows you how a back-end app and a device app can work together to
3636
3737
## Prerequisites
3838

39-
* **An IoT hub**
39+
* An IoT hub
4040

41-
* **A registered device**
41+
* A registered device
4242

43-
* If your application uses the MQTT protocol, make sure that **port 8883** is open in your firewall. The MQTT protocol communicates over port 8883. This port may be blocked in some corporate and educational network environments. For more information and ways to work around this issue, see [Connecting to IoT Hub (MQTT)](../iot/iot-mqtt-connect-to-iot-hub.md#connecting-to-iot-hub).
43+
* If your application uses the MQTT protocol, make sure that port 8883 is open in your firewall. The MQTT protocol communicates over port 8883. This port may be blocked in some corporate and educational network environments. For more information and ways to work around this issue, see [Connecting to IoT Hub (MQTT)](../iot/iot-mqtt-connect-to-iot-hub.md#connecting-to-iot-hub).
4444

4545
:::zone pivot="programming-language-csharp"
4646

includes/iot-hub-howto-device-management-dotnet.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.date: 11/25/2024
1111
ms.custom: mqtt, devx-track-csharp, devx-track-dotnet
1212
---
1313

14-
* Requires Visual Studio.
14+
* Requires Visual Studio
1515

1616
## Overview
1717

includes/iot-hub-howto-device-management-java.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ To connect to a device:
5858

5959
### Create a direct method callback listener
6060

61-
Call [subscribeToMethods](https://azure.github.io/azure-iot-sdk-java/master/device/com/microsoft/azure/sdk/iot/device/InternalClient.html#subscribeToMethods-com.microsoft.azure.sdk.iot.device.twin.MethodCallback-java.lang.Object-int-) to initialize a direct method callback listener. `subscribeToMethods` listens for incoming direct methods until the connection is terminated. The method name and payload is received for each direct method call.
61+
Use [subscribeToMethods](https://azure.github.io/azure-iot-sdk-java/master/device/com/microsoft/azure/sdk/iot/device/InternalClient.html#subscribeToMethods-com.microsoft.azure.sdk.iot.device.twin.MethodCallback-java.lang.Object-int-) to initialize a direct method callback listener. `subscribeToMethods` listens for incoming direct methods until the connection is terminated. The method name and payload is received for each direct method call.
6262

6363
For example:
6464

@@ -86,6 +86,17 @@ This section describes how to initiate a remote reboot on a device using a direc
8686

8787
The `ServiceClient` [DeviceMethod](/java/api/com.microsoft.azure.sdk.iot.service.devicetwin.devicemethod) class contains methods that services can use to access device twins.
8888

89+
### Service import statements
90+
91+
Use the following service import statements to access the Azure IoT SDK for Java.
92+
93+
```java
94+
import com.microsoft.azure.sdk.iot.service.jobs.DirectMethodsJobOptions;
95+
import com.microsoft.azure.sdk.iot.service.methods.DirectMethodRequestOptions;
96+
import com.microsoft.azure.sdk.iot.service.methods.DirectMethodsClient;
97+
import com.microsoft.azure.sdk.iot.service.methods.DirectMethodResponse;
98+
```
99+
89100
### Connect to IoT hub
90101

91102
You can connect a backend service to IoT Hub using the following methods:
@@ -116,11 +127,11 @@ DeviceMethod methodClient = new DeviceMethod(iotHubConnectionString);
116127

117128
### Invoke a method on a device
118129

119-
Call [invoke](/java/api/com.microsoft.azure.sdk.iot.service.devicetwin.devicemethod?#method-details) to invoke a method on a device and return the result status.
130+
Call [DeviceMethod.invoke](/java/api/com.microsoft.azure.sdk.iot.service.devicetwin.devicemethod?#method-details) to invoke a method on a device and return the result status.
120131

121-
This example calls the "reboot" method to initiate a reboot on the device. The "reboot" method is mapped to a listener on the device as described in the **Create a direct method callback listener** section of this article.
132+
The `invoke` payload parameter is optional. Use `null` if there is no payload supplied. The payload parameter can take different data forms including string, byte array, and HashMap. For examples, see [Direct Method Tests](https://github.com/Azure/azure-iot-sdk-java/blob/main/iot-e2e-tests/common/src/test/java/tests/integration/com/microsoft/azure/sdk/iot/iothub/methods/DirectMethodsTests.java).
122133

123-
The payload parameter is optional. Use `null` if there is no payload supplied. The payload parameter can take different data forms including string, byte array, and HashMap. For examples, see [Direct Method Tests](https://github.com/Azure/azure-iot-sdk-java/blob/main/iot-e2e-tests/common/src/test/java/tests/integration/com/microsoft/azure/sdk/iot/iothub/methods/DirectMethodsTests.java).
134+
This example calls the "reboot" method to initiate a reboot on the device. The "reboot" method is mapped to a listener on the device as described in the **Create a direct method callback listener** section of this article.
124135

125136
For example:
126137

includes/iot-hub-howto-device-management-node.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ client.open(function(err) {
101101

102102
### Create a direct method callback
103103

104-
Call [onDeviceMethod](/javascript/api/azure-iot-device/client?#azure-iot-device-client-ondevicemethod) to create a handler function or coroutine that is called when a direct method is received. The listener is associated with a method name keyword, such as "reboot". The method name can be used in an IoT Hub or backend application to trigger the callback method on the device.
104+
Call [onDeviceMethod](/javascript/api/azure-iot-device/client?#azure-iot-device-client-ondevicemethod) to create a callback handler function or coroutine that is called when a direct method is received. The listener is associated with a method name keyword, such as "reboot". The method name can be used in an IoT Hub or backend application to trigger the callback method on the device.
105105

106106
The callback handler function should call `send` to send a response acknowledgement message to the calling application.
107107

108-
This example sets up a direct method handler named `onReboot`.
108+
This example sets up a direct method handler named `onReboot` that is called when the "reboot" direct method name is used.
109109

110110
```javascript
111111
client.onDeviceMethod('reboot', onReboot);
@@ -175,7 +175,9 @@ var client = Client.fromConnectionString(connectionString);
175175

176176
### Invoke a method on a device
177177

178-
Use [invokeDeviceMethod](/javascript/api/azure-iothub/client?#azure-iothub-client-invokedevicemethod) to invoke a direct method by name on a device. The method name parameter identifies the direct method. The method name is "reboot" in the examples within this article.
178+
Use [invokeDeviceMethod](/javascript/api/azure-iothub/client?#azure-iothub-client-invokedevicemethod) to invoke a direct method by name on a device. The method name parameter identifies the direct method.
179+
180+
This example calls the "reboot" method to initiate a reboot on the device. The "reboot" method is mapped to a callback handler function on the device as described in the **Create a direct method callback** section of this article.
179181

180182
```javascript
181183
var startRebootDevice = function(deviceToReboot) {

includes/iot-hub-howto-device-management-python.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.date: 11/25/2024
1111
ms.custom: mqtt, devx-track-python, py-fresh-zinc
1212
---
1313

14-
* **Python SDK** - [Python version 3.7 or later](https://www.python.org/downloads/) is recommended. Make sure to use the 32-bit or 64-bit installation as required by your setup. When prompted during the installation, make sure to add Python to your platform-specific environment variable.
14+
* Python SDK - [Python version 3.7 or later](https://www.python.org/downloads/) is recommended. Make sure to use the 32-bit or 64-bit installation as required by your setup. When prompted during the installation, make sure to add Python to your platform-specific environment variable.
1515

1616
## Overview
1717

@@ -50,7 +50,7 @@ from azure.iot.device import IoTHubDeviceClient, MethodResponse
5050

5151
The [IoTHubDeviceClient](/python/api/azure-iot-device/azure.iot.device.iothubdeviceclient) class contains methods that can be used to work with direct methods.
5252

53-
Call [create_from_connection_string](/python/api/azure-iot-device/azure.iot.device.iothubdeviceclient?#azure-iot-device-iothubdeviceclient-create-from-connection-string) to connect an application to a device using a device connection string.
53+
Use [create_from_connection_string](/python/api/azure-iot-device/azure.iot.device.iothubdeviceclient?#azure-iot-device-iothubdeviceclient-create-from-connection-string) to connect an application to a device using a device connection string.
5454

5555
```python
5656
# substitute the device connection string in conn_str
@@ -61,14 +61,12 @@ device_client = IoTHubDeviceClient.create_from_connection_string(conn_str)
6161

6262
### Create a direct method callback
6363

64-
Call [on_method_request_received](/python/api/azure-iot-device/azure.iot.device.iothubdeviceclient?#azure-iot-device-iothubdeviceclient-on-method-request-received) to create a handler function or coroutine that is called when a direct method is received. The listener is associated with a method name keyword, such as "reboot". The method name can be used in an IoT Hub or backend application to trigger the callback method on the device.
64+
Use [on_method_request_received](/python/api/azure-iot-device/azure.iot.device.iothubdeviceclient?#azure-iot-device-iothubdeviceclient-on-method-request-received) to create a handler function or coroutine that is called when a direct method is received. The listener is associated with a method name keyword, such as "reboot". The method name can be used in an IoT Hub or backend application to trigger the callback method on the device.
6565

6666
The handler function should call [MethodResponse](/python/api/azure-iot-device/azure.iot.device.methodresponse) to send a response acknowledgement to the calling application.
6767

6868
This example sets up a direct method handler named `method_request_handler`.
6969

70-
For example:
71-
7270
```python
7371
try:
7472
# Attach the handler to the client

0 commit comments

Comments
 (0)