Skip to content

Commit ccf424f

Browse files
authored
Merge pull request #95533 from baanders/11-11-Pnp-Quickstart3
Pnp Quickstart 3
2 parents a977993 + bcb53ed commit ccf424f

File tree

2 files changed

+53
-61
lines changed

2 files changed

+53
-61
lines changed

articles/iot-pnp/quickstart-create-pnp-device-linux.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,23 @@ You can find your _company model repository connection string_ in the [Azure Cer
5454

5555
## Prepare an IoT hub
5656

57-
You need an Azure IoT hub in your Azure subscription to complete this quickstart. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
57+
You also need an Azure IoT hub in your Azure subscription to complete this quickstart. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin. If you don't have an IoT hub, there will be steps to create one below.
5858

5959
If you're using the Azure CLI locally, the `az` version should be **2.0.75** or later, the Azure Cloud Shell uses the latest version. Use the `az --version` command to check the version installed on your machine.
6060
61-
Add the Microsoft Azure IoT Extension for Azure CLI:
61+
Run the following command to add the Microsoft Azure IoT Extension for Azure CLI to your Cloud Shell instance:
6262
6363
```azurecli-interactive
6464
az extension add --name azure-cli-iot-ext
6565
```
6666
6767
The steps in this quickstart require version **0.8.5** or later of the extension. Use the `az extension list` command to check the version you have installed, and the `az extension update` command to update if necessary.
6868
69-
If don't have an IoT hub, create one using the following commands, replacing `{YourIoTHubName}` with a unique name of your choice. If you're running these commands locally, first sign in to your Azure subscription using `az login`. If you're running these commands in the Azure cloud shell, you're signed in automatically:
69+
If don't have an IoT hub, create one using the following commands, replacing `<YourIoTHubName>` with a unique name of your choice. If you're running these commands locally, first sign in to your Azure subscription using `az login`. If you're running these commands in the Azure cloud shell, you're signed in automatically:
7070
7171
```azurecli-interactive
7272
az group create --name pnpquickstarts_rg --location centralus
73-
az iot hub create --name {YourIoTHubName} \
73+
az iot hub create --name <YourIoTHubName> \
7474
--resource-group pnpquickstarts_rg --sku S1
7575
```
7676
@@ -79,23 +79,23 @@ The previous commands create a resource group called `pnpquickstarts_rg` and an
7979
> [!IMPORTANT]
8080
> During public preview, IoT Plug and Play features are only available on IoT hubs created in the **Central US**, **North Europe**, and **Japan East** regions.
8181
82-
Run the following command to create a device identity for a device called `mypnpdevice` in your IoT hub. Replace the `{YourIoTHubName}` placeholder with the name of your IoT hub:
82+
Run the following command to create a device identity in your IoT hub. Replace the **YourIoTHubName** and **YourDevice** placeholders with your actual names.
8383
8484
```azurecli-interactive
85-
az iot hub device-identity create --hub-name {YourIoTHubName} --device-id mypnpdevice
85+
az iot hub device-identity create --hub-name <YourIoTHubName> --device-id <YourDevice>
8686
```
8787
88-
Run the following commands to get the _device connection string_ for the device you just registered. You need this connection string later in this quickstart:
88+
Run the following commands to get the _device connection string_ for the device you just registered.
8989
9090
```azurecli-interactive
91-
az iot hub device-identity show-connection-string --hub-name {YourIoTHubName} --device-id mypnpdevice --output table
91+
az iot hub device-identity show-connection-string --hub-name <YourIoTHubName> --device-id <YourDevice> --output table
9292
```
9393
9494
## Author your model
9595
9696
In this quickstart, you use an existing sample device capability model and associated interfaces.
9797
98-
1. Create a `pnp_app` directory in your home directory. You use this folder for the device model files and device code stub.
98+
1. Create a `pnp_app` directory in your local drive. You use this folder for the device model files and device code stub.
9999
100100
```bash
101101
cd ~
@@ -110,34 +110,34 @@ In this quickstart, you use an existing sample device capability model and assoc
110110
curl -O -L https://raw.githubusercontent.com/Azure/IoTPlugandPlay/master/samples/EnvironmentalSensor.interface.json
111111
```
112112
113-
1. Open `pnp_app` folder with VS Code. You can view the files with intellisense:
113+
1. Open `pnp_app` folder with VS Code. You can view the files with IntelliSense:
114114
115115
![Device capability model](media/quickstart-create-pnp-device-linux/dcm.png)
116116
117117
1. In the files you downloaded, replace `<YOUR_COMPANY_NAME_HERE>` in the `@id` and `schema` fields with a unique value. Use only the characters a-z, A-Z, 0-9, and underscore. For more information, see [Digital Twin identifier format](https://github.com/Azure/IoTPlugandPlay/tree/master/DTDL#digital-twin-identifier-format).
118118
119119
## Generate the C code stub
120120
121-
Now you have a DCM and its associated interfaces, you can generate the device code that implements the model. To generate the C code stub in VS code:
121+
Now that you have a DCM and its associated interfaces, you can generate the device code that implements the model. To generate the C code stub in VS Code:
122122
123-
1. With the `pnp_app` folder open in VS code, use **Ctrl+Shift+P** to open the command palette, enter **IoT Plug and Play**, and select **Generate Device Code Stub**.
123+
1. With the `pnp_app` folder open in VS Code, use **Ctrl+Shift+P** to open the command palette, enter **IoT Plug and Play**, and select **Generate Device Code Stub**.
124124
125125
> [!NOTE]
126-
> The first time you use the IoT Plug and Play Code Generator utility, it takes a few seconds to download.
126+
> The first time you use the IoT Plug and Play Code Generator utility, it takes a few seconds to download and install automatically.
127127
128-
1. Choose the **SampleDevice.capabilitymodel.json** file to use to generate the device code stub.
128+
1. Choose the **SampleDevice.capabilitymodel.json** file to use for generating the device code stub.
129129
130-
1. Enter the project name **sample_device**, it will be the name of your device application.
130+
1. Enter the project name **sample_device**. This will be the name of your device application.
131131
132132
1. Choose **ANSI C** as your language.
133133
134134
1. Choose **Via IoT Hub device connection string** as connection method.
135135
136136
1. Choose **CMake Project on Linux** as your project template.
137137
138-
1. Choose **Via Source Code** as the way to include the SDK.
138+
1. Choose **Via Source Code** as the way to include the device SDK.
139139
140-
1. VS Code opens a new window with generated device code stub files.
140+
1. A new folder called **sample_device** is created in the same location as the DCM file, and in it are the generated device code stub files. VS Code opens a new window to display these.
141141
![Device code](media/quickstart-create-pnp-device-linux/device-code.png)
142142
143143
## Build and run the code
@@ -170,7 +170,7 @@ You use the device SDK source code to build the generated device code stub. The
170170
171171
```sh
172172
cd ~/pnp_app/sample_device/cmake
173-
./sample_device "{IoT Hub device connection string}"
173+
./sample_device "<device connection string>"
174174
```
175175
176176
1. The device application starts sending data to IoT Hub.
@@ -192,25 +192,25 @@ To validate the device code with the **az** CLI, you need to publish the files t
192192
> [!NOTE]
193193
> The connection string is only required the first time you connect to the repository.
194194
195-
1. In VS Code output window and notification, you can check the files have been published successfully.
195+
1. In VS Code output window and notification, you can check that the files have been published successfully.
196196
197197
> [!NOTE]
198198
> If you get errors on publishing the device model files, you can try use command **IoT Plug and Play: Sign out Model Repository** to sign out and go through the steps again.
199199
200200
### Use the Azure IoT CLI to validate the code
201201
202-
After the device client sample starts, you can check it's working with the Azure CLI.
202+
After the device client sample starts, you can check that it's working with the Azure CLI.
203203

204204
Use the following command to view the telemetry the sample device is sending. You may need to wait a minute or two before you see any telemetry in the output:
205205

206206
```azurecli-interactive
207-
az iot dt monitor-events --hub-name {your IoT hub} --device-id mypnpdevice
207+
az iot dt monitor-events --hub-name <YourIoTHubNme> --device-id <YourDevice>
208208
```
209209

210210
Use the following command to view all the properties sent by the device:
211211

212212
```azurecli-interactive
213-
az iot dt list-properties --device-id mypnpdevice --hub-name {Your IoT hub name} --source private --repo-login "{Your company model repository connection string}"
213+
az iot dt list-properties --device-id <YourDevice> --hub-name <YourIoTHubNme> --source private --repo-login "<Your company model repository connection string>"
214214
```
215215

216216
## Next steps
@@ -220,4 +220,4 @@ In this quickstart, you learned how to create an IoT Plug and Play device using
220220
To learn more about DCMs and how to create your own models, continue to the tutorial:
221221

222222
> [!div class="nextstepaction"]
223-
> [Tutorial: Create a test a device capability model using Visual Studio Code](tutorial-pnp-visual-studio-code.md)
223+
> [Tutorial: Create and test a device capability model using Visual Studio Code](tutorial-pnp-visual-studio-code.md)

articles/iot-pnp/quickstart-create-pnp-device.md

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Create an IoT Plug and Play Preview device | Microsoft Docs
2+
title: Create an IoT Plug and Play Preview device (Windows) | Microsoft Docs
33
description: Use a device capability model to generate device code. Then run the device code and see the device connect to your IoT Hub.
44
author: miagdp
55
ms.author: miag
@@ -45,43 +45,35 @@ You can find your _company model repository connection string_ in the [Azure Cer
4545

4646
## Prepare an IoT hub
4747

48-
You also need an Azure IoT hub in your Azure subscription to complete this quickstart. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
48+
You also need an Azure IoT hub in your Azure subscription to complete this quickstart. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin. If you don't have an IoT hub, follow [these instructions to create one](../iot-hub/iot-hub-create-using-cli.md).
4949

50-
> [!NOTE]
50+
> [!IMPORTANT]
5151
> During public preview, IoT Plug and Play features are only available on IoT hubs created in the **Central US**, **North Europe**, and **Japan East** regions.
5252
53-
Add the Microsoft Azure IoT Extension for Azure CLI:
53+
Run the following command to add the Microsoft Azure IoT Extension for Azure CLI to your Cloud Shell instance:
5454

5555
```azurecli-interactive
5656
az extension add --name azure-cli-iot-ext
5757
```
5858

59-
Run the following command to create the device identity in your IoT hub. Replace the **YourIoTHubName** and **YourDevice** placeholders with your actual names. If you don't have an IoT Hub, follow [these instructions to create one](../iot-hub/iot-hub-create-using-cli.md):
59+
Run the following command to create the device identity in your IoT hub. Replace the **YourIoTHubName** and **YourDevice** placeholders with your actual names.
6060

6161
```azurecli-interactive
62-
az iot hub device-identity create --hub-name [YourIoTHubName] --device-id [YourDevice]
62+
az iot hub device-identity create --hub-name <YourIoTHubName> --device-id <YourDevice>
6363
```
6464

65-
Run the following commands to get the _device connection string_ for the device you just registered:
65+
Run the following command to get the _device connection string_ for the device you just registered:
6666

6767
```azurecli-interactive
68-
az iot hub device-identity show-connection-string --hub-name [YourIoTHubName] --device-id [YourDevice] --output table
68+
az iot hub device-identity show-connection-string --hub-name <YourIoTHubName> --device-id <YourDevice> --output table
6969
```
7070

71-
Run the following commands to get the _IoT hub connection string_ for your hub:
71+
Run the following command to get the _IoT hub connection string_ for your hub:
7272

7373
```azurecli-interactive
74-
az iot hub show-connection-string --hub-name [YourIoTHubName] --output table
74+
az iot hub show-connection-string --hub-name <YourIoTHubName> --output table
7575
```
7676

77-
Make a note of the device connection string, which looks like:
78-
79-
```json
80-
HostName={YourIoTHubName}.azure-devices.net;DeviceId=MyCDevice;SharedAccessKey={YourSharedAccessKey}
81-
```
82-
83-
You'll use this value later in the quickstart.
84-
8577
## Prepare the development environment
8678

8779
### Get Azure IoT device SDK for C
@@ -113,9 +105,9 @@ In this quickstart, you prepare a development environment by installing the Azur
113105
114106
In this quickstart, you use an existing sample device capability model and associated interfaces.
115107
116-
1. Create a `pnp_app` directory in your local drive.
108+
1. Create a `pnp_app` directory in your local drive. You use this folder for the device model files and device code stub.
117109
118-
1. Download the [device capability model](https://github.com/Azure/IoTPlugandPlay/blob/master/samples/SampleDevice.capabilitymodel.json) and [interface sample](https://github.com/Azure/IoTPlugandPlay/blob/master/samples/EnvironmentalSensor.interface.json) and save files into `pnp_app` folder.
110+
1. Download the [device capability model and interface sample files](https://github.com/Azure/IoTPlugandPlay/blob/master/samples/SampleDevice.capabilitymodel.json) and [interface sample](https://github.com/Azure/IoTPlugandPlay/blob/master/samples/EnvironmentalSensor.interface.json) and save files into `pnp_app` folder.
119111
120112
> [!TIP]
121113
> To download a file from GitHub, navigate to the file, right-click on **Raw**, and then select **Save link as**.
@@ -130,29 +122,29 @@ In this quickstart, you use an existing sample device capability model and assoc
130122
131123
Now that you have a DCM and its associated interfaces, you can generate the device code that implements the model. To generate the C code stub in VS Code:
132124
133-
1. With the folder with DCM files open, use **Ctrl+Shift+P** to open the command palette, enter **IoT Plug and Play**, and select **Generate Device Code Stub**.
125+
1. With the `pnp_app` folder open in VS Code, use **Ctrl+Shift+P** to open the command palette, enter **IoT Plug and Play**, and select **Generate Device Code Stub**.
134126
135127
> [!NOTE]
136128
> The first time you use the IoT Plug and Play CodeGen CLI, it takes a few seconds to download and install automatically.
137129
138-
1. Choose the DCM file you want to use to generate the device code stub.
130+
1. Choose the **SampleDevice.capabilitymodel.json** file to use for generating the device code stub.
139131
140-
1. Enter the project name **sample_device**, it will be the name of your device application.
132+
1. Enter the project name **sample_device**. This will be the name of your device application.
141133
142134
1. Choose **ANSI C** as your language.
143135
144136
1. Choose **Via IoT Hub device connection string** as connection method.
145137
146-
1. Choose **CMake Project on Windows** as project template.
138+
1. Choose **CMake Project on Windows** as your project template.
147139
148140
1. Choose **Via Vcpkg** as way to include the device SDK.
149141
150142
1. A new folder called **sample_device** is created in the same location as the DCM file, and in it are the generated device code stub files. VS Code opens a new window to display these.
151143
![Device code](media/quickstart-create-pnp-device/device-code.png)
152144
153-
## Build the code
145+
## Build and run the code
154146
155-
You build the generated device code stub together with the device SDK. The application you build simulates a device that connects to an IoT hub. The application sends telemetry and properties and receives commands.
147+
You use the device SDK source code to build the generated device code stub. The application you build simulates a device that connects to an IoT hub. The application sends telemetry and properties and receives commands.
156148
157149
1. Create a `cmake` subdirectory in the `sample_device` folder, and navigate to that folder:
158150
@@ -164,7 +156,7 @@ You build the generated device code stub together with the device SDK. The appli
164156
1. Run the following commands to build the generated code stub (replacing the placeholder with the directory of your Vcpkg repo):
165157
166158
```cmd\sh
167-
cmake .. -G "Visual Studio 16 2019" -A Win32 -Duse_prov_client=ON -Dhsm_type_symm_key:BOOL=ON -DCMAKE_TOOLCHAIN_FILE="{directory of your Vcpkg repo}\scripts\buildsystems\vcpkg.cmake"
159+
cmake .. -G "Visual Studio 16 2019" -A Win32 -Duse_prov_client=ON -Dhsm_type_symm_key:BOOL=ON -DCMAKE_TOOLCHAIN_FILE="<directory of your Vcpkg repo>\scripts\buildsystems\vcpkg.cmake"
168160
169161
cmake --build .
170162
```
@@ -184,7 +176,7 @@ You build the generated device code stub together with the device SDK. The appli
184176
1. After the build completes successfully, run your application, passing the IoT hub device connection string as a parameter.
185177
186178
```cmd\sh
187-
.\Debug\sample_device.exe "[IoT Hub device connection string]"
179+
.\Debug\sample_device.exe "<device connection string>"
188180
```
189181
190182
1. The device application starts sending data to IoT Hub.
@@ -197,7 +189,7 @@ You build the generated device code stub together with the device SDK. The appli
197189
198190
To validate the device code with **Azure IoT Explorer**, you need to publish the files to the model repository.
199191
200-
1. With the folder with DCM files open in VS Code, use **Ctrl+Shift+P** to open the command palette, type and select **IoT Plug & Play: Submit files to Model Repository**.
192+
1. With the `pnp_app` folder open in VS Code, use **Ctrl+Shift+P** to open the command palette, type and select **IoT Plug & Play: Submit files to Model Repository**.
201193
202194
1. Select `SampleDevice.capabilitymodel.json` and `EnvironmentalSensor.interface.json` files.
203195
@@ -213,9 +205,9 @@ To validate the device code with **Azure IoT Explorer**, you need to publish the
213205
214206
### Use the Azure IoT explorer to validate the code
215207
216-
1. Open Azure IoT explorer, you see the **App configurations** page.
208+
1. Open Azure IoT explorer. You see the **App configurations** page.
217209
218-
1. Enter your IoT Hub connection string and click **Connect**.
210+
1. Enter your _IoT Hub connection string_ and select **Connect**.
219211
220212
1. After you connect, you see the device overview page.
221213
@@ -227,25 +219,25 @@ To validate the device code with **Azure IoT Explorer**, you need to publish the
227219
228220
1. Select the **Telemetry** page and hit _Start_ to view the telemetry data the device is sending.
229221
230-
1. Select the **Properties(non-writable)** page to view the non-writable properties reported by the device.
222+
1. Select the **Properties (non-writable)** page to view the non-writable properties reported by the device.
231223
232-
1. Select the **Properties(writable)** page to view the writable properties you can update.
224+
1. Select the **Properties (writable)** page to view the writable properties you can update.
233225
234226
1. Expand property **name**, update with a new name and select **Update writable property**.
235227
236-
1. To see the new name shows up in the **Reported Property** column, click the **Refresh** button on top of the page.
228+
1. To see the new name show up in the **Reported Property** column, select the **Refresh** button on top of the page.
237229
238-
1. Select the **Command** page to view all the commands the device supports.
230+
1. Select the **Commands** page to view all the commands the device supports.
239231
240232
1. Expand the **blink** command and set a new blink time interval. Select **Send command** to call the command on the device.
241233
242-
1. Go to the simulated device to verify that the command executed as expected.
234+
1. Go to the simulated device command prompt and read through the printed confirmation messages, to verify that the commands have executed as expected.
243235
244236
## Next steps
245237
246238
In this quickstart, you learned how to create an IoT Plug and Play device using a DCM.
247239
248-
To learn more about IoT Plug and Play, continue to the tutorial:
240+
To learn more about DCMs and how to create your own models, continue to the tutorial:
249241
250242
> [!div class="nextstepaction"]
251-
> [Create and test a device capability model using Visual Studio Code](tutorial-pnp-visual-studio-code.md)
243+
> [Tutorial: Create and test a device capability model using Visual Studio Code](tutorial-pnp-visual-studio-code.md)

0 commit comments

Comments
 (0)