Skip to content

Commit 2005bcc

Browse files
authored
Merge pull request #96264 from dominicbetts/pnp-linux-vcpkg
Use vcpkg in Linux Quickstart
2 parents e0802d9 + f01745e commit 2005bcc

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

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

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,22 @@ Run the following commands to get the _device connection string_ for the device
9191
az iot hub device-identity show-connection-string --hub-name <YourIoTHubName> --device-id <YourDevice> --output table
9292
```
9393
94+
## Prepare the development environment
95+
96+
In this quickstart, you use the [Vcpkg](https://github.com/microsoft/vcpkg) library manager to install the Azure IoT C device SDK in your development environment.
97+
98+
Open a shell. Execute the following command to install Vcpkg:
99+
100+
```bash
101+
cd ~
102+
git clone https://github.com/microsoft/vcpkg
103+
cd vcpkg
104+
./bootstrap-vcpkg.sh
105+
./vcpkg install azure-iot-sdk-c[public-preview,use_prov_client]
106+
```
107+
108+
You should expect this operation to take several minutes to complete.
109+
94110
## Author your model
95111
96112
In this quickstart, you use an existing sample device capability model and associated interfaces.
@@ -135,7 +151,7 @@ Now that you have a DCM and its associated interfaces, you can generate the devi
135151
136152
1. Choose **CMake Project on Linux** as your project template.
137153
138-
1. Choose **Via Source Code** as the way to include the device SDK.
154+
1. Choose **Via Vcpkg** as the way to include the device SDK.
139155
140156
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.
141157
![Device code](media/quickstart-create-pnp-device-linux/device-code.png)
@@ -144,13 +160,6 @@ Now that you have a DCM and its associated interfaces, you can generate the devi
144160
145161
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.
146162
147-
1. Run the following commands to download the device SDK source code:
148-
149-
```bash
150-
cd ~/pnp_app/sample_device
151-
git clone https://github.com/Azure/azure-iot-sdk-c --recursive -b public-preview
152-
```
153-
154163
1. Create a **CMake** build folder for the **sample_device** application:
155164
156165
```bash
@@ -159,10 +168,10 @@ You use the device SDK source code to build the generated device code stub. The
159168
cd cmake
160169
```
161170
162-
1. Run CMake to build your app with the SDK:
171+
1. Run CMake to build your app with the SDK. The following command assumes you installed **vcpkg** in your home folder:
163172
164173
```bash
165-
cmake .. -Duse_prov_client=ON -Dhsm_type_symm_key:BOOL=ON -Dskip_samples:BOOL=ON
174+
cmake .. -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake -Duse_prov_client=ON -Dhsm_type_symm_key:BOOL=ON
166175
cmake --build .
167176
```
168177
@@ -212,6 +221,7 @@ Use the following command to view all the properties sent by the device:
212221
```azurecli-interactive
213222
az iot dt list-properties --device-id <YourDevice> --hub-name <YourIoTHubNme> --source private --repo-login "<YourCompanyModelRepositoryConnectionString>"
214223
```
224+
215225
[!INCLUDE [iot-pnp-clean-resources.md](../../includes/iot-pnp-clean-resources.md)]
216226

217227
## Next steps

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,11 @@ You can find your _company model repository connection string_ in the [Azure Cer
4747

4848
## Prepare the development environment
4949

50-
### Get Azure IoT device SDK for C
51-
52-
In this quickstart, you prepare a development environment by installing the Azure IoT C device SDK via [Vcpkg](https://github.com/microsoft/vcpkg).
50+
In this quickstart, you use the [Vcpkg](https://github.com/microsoft/vcpkg) library manager to install the Azure IoT C device SDK in your development environment.
5351

5452
1. Open a command prompt. Execute the following command to install Vcpkg:
5553

56-
```cmd/sh
54+
```cmd
5755
git clone https://github.com/Microsoft/vcpkg.git
5856
cd vcpkg
5957
@@ -62,13 +60,13 @@ In this quickstart, you prepare a development environment by installing the Azur
6260
6361
Then, to hook up user-wide [integration](https://github.com/microsoft/vcpkg/blob/master/docs/users/integration.md), run the following (note: requires admin on first use):
6462
65-
```cmd/sh
63+
```cmd
6664
.\vcpkg.exe integrate install
6765
```
6866
6967
1. Install Azure IoT C device SDK Vcpkg:
7068
71-
```cmd/sh
69+
```cmd
7270
.\vcpkg.exe install azure-iot-sdk-c[public-preview,use_prov_client]
7371
```
7472
@@ -108,7 +106,7 @@ Now that you have a DCM and its associated interfaces, you can generate the devi
108106
109107
1. Choose **CMake Project on Windows** as your project template.
110108
111-
1. Choose **Via Vcpkg** as way to include the device SDK.
109+
1. Choose **Via Vcpkg** as the way to include the device SDK.
112110
113111
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.
114112
![Device code](media/quickstart-create-pnp-device/device-code.png)
@@ -119,22 +117,22 @@ You use the device SDK source code to build the generated device code stub. The
119117
120118
1. Create a `cmake` subdirectory in the `sample_device` folder, and navigate to that folder:
121119
122-
```cmd\sh
120+
```cmd
123121
mkdir cmake
124122
cd cmake
125123
```
126124
127125
1. Run the following commands to build the generated code stub (replacing the placeholder with the directory of your Vcpkg repo):
128126
129-
```cmd\sh
127+
```cmd
130128
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"
131129
132130
cmake --build .
133131
```
134132
135133
> [!NOTE]
136134
> If you are using Visual Studio 2017 or 2015, you need to specify the CMake generator based on the build tools you are using:
137-
>```cmd\sh
135+
>```cmd
138136
># Either
139137
>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"
140138
># or
@@ -146,7 +144,7 @@ You use the device SDK source code to build the generated device code stub. The
146144
147145
1. After the build completes successfully, run your application, passing the IoT hub device connection string as a parameter.
148146
149-
```cmd\sh
147+
```cmd
150148
.\Debug\sample_device.exe "<device connection string>"
151149
```
152150

0 commit comments

Comments
 (0)