Skip to content

Commit 2ef855a

Browse files
committed
Edits
1 parent 158fa74 commit 2ef855a

4 files changed

+19
-10
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ To invoke a direct method on a device through IoT Hub, your service needs the **
158158

159159
As a parameter to `CreateFromConnectionString`, supply the **service** shared access policy. For more information about shared access policies, see [Control access to IoT Hub with shared access signatures](/azure/iot-hub/authenticate-authorize-sas).
160160

161-
[!INCLUDE [iot-authentication-service-connection-string.md](iot-authentication-service-connection-string.md)]
162-
163161
```csharp
164162
ServiceClient serviceClient;
165163
string connectionString = "{IoT hub service shared access policy connection string}";
@@ -177,10 +175,10 @@ To invoke a method on a device:
177175
1. Create a [CloudToDeviceMethod](/dotnet/api/microsoft.azure.devices.cloudtodevicemethod) object. Pass the device direct method name as a parameter.
178176
1. Call [InvokeDeviceMethodAsync](/dotnet/api/microsoft.azure.devices.serviceclient.invokedevicemethodasync?#microsoft-azure-devices-serviceclient-invokedevicemethodasync(system-string-microsoft-azure-devices-cloudtodevicemethod-system-threading-cancellationtoken)) to invoke the method on the device.
179177

180-
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](#create-a-direct-method-callback) section of this article.
178+
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](#create-a-direct-method-callback-listener) section of this article.
181179

182180
```csharp
183-
static string targetDevice = "myDeviceId";
181+
string targetDevice = "myDeviceId";
184182
CloudToDeviceMethod method = new CloudToDeviceMethod("reboot");
185183
method.ResponseTimeout = TimeSpan.FromSeconds(30);
186184

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ This section describes how to use device application code to create a direct met
2525

2626
### Device import statement
2727

28-
Use the following device import statement to access the Azure IoT SDK for Java.
28+
Use the following device import statements to access the Azure IoT SDK for Java.
2929

3030
```java
3131
import com.microsoft.azure.sdk.iot.device.*;
32+
import com.microsoft.azure.sdk.iot.device.exceptions.IotHubClientException;
33+
import com.microsoft.azure.sdk.iot.device.twin.DirectMethodPayload;
34+
import com.microsoft.azure.sdk.iot.device.twin.DirectMethodResponse;
35+
import com.microsoft.azure.sdk.iot.device.twin.MethodCallback;
36+
import com.microsoft.azure.sdk.iot.device.transport.IotHubConnectionStatus;
37+
import com.microsoft.azure.sdk.iot.device.twin.SubscriptionAcknowledgedCallback;
3238
```
3339

3440
### Connect to a device
@@ -60,6 +66,8 @@ To connect to a device:
6066

6167
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.
6268

69+
The listener should call [DirectMethodResponse](/java/api/com.microsoft.azure.sdk.iot.device.twin.directmethodresponse) to send a method response acknowledgment to the calling application.
70+
6371
For example:
6472

6573
```java

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.date: 11/25/2024
1111
ms.custom: mqtt, devx-track-js
1212
---
1313

14-
* Requires Node.js version 10.0.x or later.
14+
* Requires Node.js version 10.0.x or later
1515

1616
## Overview
1717

@@ -111,7 +111,7 @@ This example sets up a direct method handler named `onReboot` that is called whe
111111
client.onDeviceMethod('reboot', onReboot);
112112
```
113113

114-
In this example, the `onReboot` callback method implements the direct method on the device. The code is executed when the "reboot" direct method is called from a service application.
114+
In this example, the `onReboot` callback method implements the direct method on the device. The code is executed when the "reboot" direct method is called from a service application. The function calls `send` to send a response acknowledgment message to the calling application.
115115

116116
```javascript
117117
var onReboot = function(request, response) {

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ device_client = IoTHubDeviceClient.create_from_connection_string(conn_str)
6363

6464
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

66-
The handler function should call [MethodResponse](/python/api/azure-iot-device/azure.iot.device.methodresponse) to send a response acknowledgment to the calling application.
66+
The handler function should create a [MethodResponse](/python/api/azure-iot-device/azure.iot.device.methodresponse) and pass it to [send_method_response](/python/api/azure-iot-device/azure.iot.device.iothubdeviceclient?#azure-iot-device-iothubdeviceclient-send-method-response) to send a direct method response acknowledgment to the calling application.
6767

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

@@ -76,7 +76,7 @@ except:
7676
client.shutdown()
7777
```
7878

79-
In this example, the `method_request_handler` callback method implements the direct method on the device. The code is executed when the "rebootDevice" direct method is called from a service application. The method calls `MethodResponse` to send a response acknowledgment to the calling application.
79+
In this example, the `method_request_handler` callback method implements the direct method on the device. The code is executed when the "rebootDevice" direct method is called from a service application. The method calls `send_method_response` to send a direct method response acknowledgment to the calling application.
8080

8181
```python
8282
# Define the handler for method requests
@@ -189,4 +189,7 @@ except Exception as ex:
189189

190190
### SDK service samples
191191

192-
The Azure IoT SDK for Python provides a working sample of a service app that handles direct method tasks. For more information, see [Service helper sync](https://github.com/Azure/azure-iot-sdk-python/blob/e75d1c2026eab939d5d31097fd0c22924c53abf8/dev_utils/dev_utils/service_helper_sync.py).
192+
The Azure IoT SDK for Python provides working samples of service apps that handle direct method tasks. For more information, see:
193+
194+
* [Service helper sync](https://github.com/Azure/azure-iot-sdk-python/blob/e75d1c2026eab939d5d31097fd0c22924c53abf8/dev_utils/dev_utils/service_helper_sync.py)
195+
* [Service operations](https://github.com/Azure/azure-iot-sdk-python/blob/e75d1c2026eab939d5d31097fd0c22924c53abf8/tests/e2e/provisioning_e2e/iothubservice20180630/operations/service_operations.py)

0 commit comments

Comments
 (0)