You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/iot-hub/iot-hub-python-python-c2d.md
+9-8Lines changed: 9 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ At the end of this tutorial, you run two Python console apps:
30
30
31
31
***SimulatedDevice.py**, a modified version of the app created in [Send telemetry from a device to an IoT hub](quickstart-send-telemetry-python.md), which connects to your IoT hub and receives cloud-to-device messages.
32
32
33
-
***SendCloudToDeviceMessage.py**, which sends a cloud-to-device message to the simulated device app through IoT Hub, and then receives its delivery acknowledgment.
33
+
***SendCloudToDeviceMessage.py**, which sends cloud-to-device messages to the simulated device app through IoT Hub.
@@ -54,8 +54,9 @@ In this section, you create a Python console app to simulate the device and rece
54
54
55
55
1. Add the following `import` statements and variables at the start of the **SimulatedDevice.py** file:
56
56
57
-
```python
57
+
```python
58
58
import threading
59
+
import time
59
60
from azure.iot.device import IoTHubDeviceClient
60
61
61
62
RECEIVED_MESSAGES = 0
@@ -117,13 +118,13 @@ In this section, you create a Python console app to simulate the device and rece
117
118
118
119
## Get the IoT hub connection string
119
120
120
-
In this article you create a backend service to send cloud-to-device messages through the IoT hub you created in [Send telemetry from a device to an IoT hub](quickstart-send-telemetry-python.md). To send cloud-to-device messages, your service needs the **service connect** permission. By default, every IoT Hub is created with a shared access policy named **service** that grants this permission.
121
+
In this article, you create a backend service to send cloud-to-device messages through the IoT hub you created in [Send telemetry from a device to an IoT hub](quickstart-send-telemetry-python.md). To send cloud-to-device messages, your service needs the **service connect** permission. By default, every IoT Hub is created with a shared access policy named **service** that grants this permission.
In this section, you create a Python console app that sends cloud-to-device messages to the simulated device app. You need the device ID of the device you added in the [Send telemetry from a device to an IoT hub](quickstart-send-telemetry-python.md) quickstart. You also need the the IoT hub connection string you copied previously in [Get the IoT hub connection string](#get-the-iot-hub-connection-string).
127
+
In this section, you create a Python console app that sends cloud-to-device messages to the simulated device app. You need the device ID of the device you added in the [Send telemetry from a device to an IoT hub](quickstart-send-telemetry-python.md) quickstart. You also need the IoT hub connection string you copied previously in [Get the IoT hub connection string](#get-the-iot-hub-connection-string).
127
128
128
129
1. In your working directory, open a command prompt and install the **Azure IoT Hub Service SDK for Python**.
129
130
@@ -212,19 +213,19 @@ You are now ready to run the applications.
212
213
python SimulatedDevice.py
213
214
```
214
215
215
-

216
+

216
217
217
218
1. Open a new command prompt in your working directory and run the following command to send cloud-to-device messages:
218
219
219
220
```shell
220
221
python SendCloudToDeviceMessage.py
221
222
```
222
223
223
-

224
+

0 commit comments