Skip to content

Commit 4955602

Browse files
authored
Merge pull request #100760 from dominicbetts/pnp-build-updates
Update C build instructions
2 parents 604477f + e063a77 commit 4955602

File tree

2 files changed

+43
-10
lines changed

2 files changed

+43
-10
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ In this quickstart, you use the [Vcpkg](https://github.com/microsoft/vcpkg) libr
8282
8383
In this quickstart, you use an existing sample device capability model and associated interfaces.
8484
85-
1. Create a `pnp_app` directory in your local drive. You use this folder for the device model files and device code stub.
85+
1. Create a `pnp_app` folder in your local drive. You use this folder for the device model files and device code stub.
8686
87-
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.
87+
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 the files into the `pnp_app` folder.
8888
8989
> [!TIP]
9090
> To download a file from GitHub, navigate to the file, right-click on **Raw**, and then select **Save link as**.
@@ -106,7 +106,7 @@ Now that you have a DCM and its associated interfaces, you can generate the devi
106106
107107
1. Choose the **SampleDevice.capabilitymodel.json** file to use for generating the device code stub.
108108
109-
1. Enter the project name **sample_device**. This will be the name of your device application.
109+
1. Enter the project name **sample_device**. This is the name of your device application.
110110
111111
1. Choose **ANSI C** as your language.
112112
@@ -121,7 +121,7 @@ Now that you have a DCM and its associated interfaces, you can generate the devi
121121
122122
## Build and run the code
123123
124-
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.
124+
You use the Vcpkg package 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.
125125
126126
1. Create a `cmake` subdirectory in the `sample_device` folder, and navigate to that folder:
127127

articles/iot-pnp/tutorial-build-device-certification.md

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ To complete this tutorial, you need:
3030
- [Visual Studio Code](https://code.visualstudio.com/download)
3131
- [Azure IoT Tools for VS Code](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-tools) extension pack
3232

33-
You also need the IoT Plug and Play device that you create in the [Quickstart: Use a device capability model to create a device](quickstart-create-pnp-device-windows.md).
33+
You also need to complete the [Use a device capability model to create a device](quickstart-create-pnp-device-windows.md) quickstart for Windows. The quickstart shows you how to set up your development environment using Vcpkg and create a sample project.
3434

3535
## Store a capability model and interfaces
3636

@@ -102,20 +102,53 @@ To certify the device, it must enable provisioning through the [Azure IoT Device
102102
103103
1. Choose the DCM file you want to use to generate the device code stub.
104104
105-
1. Enter the project name, this is the name of your device application.
105+
1. Enter the project name, such as **sample_device**. This is the name of your device application.
106106
107107
1. Choose **ANSI C** as the language.
108108
109109
1. Choose **Via DPS (Device Provisioning Service) symmetric key** as connection method.
110110
111-
1. Choose **CMake Project on Windows** or **CMake Project on Linux** as project template depending on your device OS.
111+
1. Choose **CMake Project on Windows** as your project template.
112+
113+
1. Choose **Via Vcpkg** as the way to include the device SDK.
112114
113115
1. VS Code opens a new window with generated device code stub files.
114116
115-
1. After building the code, enter the DPS credentials (**DPS ID Scope**, **DPS Symmetric Key**, **Device Id**) as parameters for the application. To get the credentials from certification portal, see [Connect and test your IoT Plug and Play device](tutorial-certification-test.md#connect-and-discover-interfaces).
117+
## Build and run the code
116118
117-
```cmd/sh
118-
.\your_pnp_app.exe [DPS ID Scope] [DPS symmetric key] [device ID]
119+
You use the Vcpkg package 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.
120+
121+
1. Create a `cmake` subdirectory in the `sample_device` folder, and navigate to that folder:
122+
123+
```cmd
124+
mkdir cmake
125+
cd cmake
126+
```
127+
128+
1. Run the following commands to build the generated code stub (replacing the placeholder with the directory of your Vcpkg repo):
129+
130+
```cmd
131+
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"
132+
133+
cmake --build .
134+
```
135+
136+
> [!NOTE]
137+
> If you are using Visual Studio 2017 or 2015, you need to specify the CMake generator based on the build tools you are using:
138+
>```cmd
139+
># Either
140+
>cmake .. -G "Visual Studio 15 2017" -Duse_prov_client=ON -Dhsm_type_symm_key:BOOL=ON -DCMAKE_TOOLCHAIN_FILE="{directory of your Vcpkg repo}\scripts\buildsystems\vcpkg.cmake"
141+
># or
142+
>cmake .. -G "Visual Studio 14 2015" -Duse_prov_client=ON -Dhsm_type_symm_key:BOOL=ON -DCMAKE_TOOLCHAIN_FILE="{directory of your Vcpkg repo}\scripts\buildsystems\vcpkg.cmake"
143+
>```
144+
145+
> [!NOTE]
146+
> If cmake can't find your C++ compiler, you get build errors when you run the previous command. If that happens, try running this command at the [Visual Studio command prompt](https://docs.microsoft.com/dotnet/framework/tools/developer-command-prompt-for-vs).
147+
148+
1. After the build completes successfully, enter the DPS credentials (**DPS ID Scope**, **DPS Symmetric Key**, **Device Id**) as parameters for the application. To get the credentials from certification portal, see [Connect and test your IoT Plug and Play device](tutorial-certification-test.md#connect-and-discover-interfaces).
149+
150+
```cmd\sh
151+
.\Debug\sample_device.exe [Device ID] [DPS ID Scope] [DPS symmetric key]
119152
```
120153
121154
### Implement standard interfaces

0 commit comments

Comments
 (0)