add codespace support (#1726)
This commit is contained in:
Родитель
28d9079515
Коммит
5de954f909
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"image": "aziotbld/embedded-codespace",
|
||||||
|
"postCreateCommand": "chmod +x /workspaces/azure-sdk-for-c/.devcontainer/post_build.sh && /workspaces/azure-sdk-for-c/.devcontainer/post_build.sh",
|
||||||
|
"extensions": ["webfreak.debug", "ms-vscode.cpptools" ]
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
cd /workspaces/azure-sdk-for-c
|
||||||
|
mkdir .vscode
|
||||||
|
cp ./.vscode-config/codespaces-launch.json ./.vscode/launch.json
|
||||||
|
cp ./.vscode-config/codespaces-tasks.json ./.vscode/tasks.json
|
||||||
|
|
||||||
|
mkdir cert
|
||||||
|
cd cert
|
||||||
|
|
||||||
|
openssl ecparam -out device_ec_key.pem -name prime256v1 -genkey
|
||||||
|
openssl req -new -days 30 -nodes -x509 -key device_ec_key.pem -out device_ec_cert.pem -subj "/CN=paho-sample-device1"
|
||||||
|
openssl x509 -noout -text -in device_ec_cert.pem
|
||||||
|
|
||||||
|
rm -f device_cert_store.pem
|
||||||
|
cat device_ec_cert.pem device_ec_key.pem > device_cert_store.pem
|
||||||
|
|
||||||
|
openssl x509 -noout -fingerprint -in device_ec_cert.pem | sed 's/://g'| sed 's/\(SHA1 Fingerprint=\)//g' | tee fingerprint.txt
|
|
@ -322,3 +322,6 @@ fingerprint.txt
|
||||||
|
|
||||||
# vcpkg
|
# vcpkg
|
||||||
/vcpkg
|
/vcpkg
|
||||||
|
|
||||||
|
# Cert
|
||||||
|
/cert
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"id": "device_id",
|
||||||
|
"description": "Device ID",
|
||||||
|
"type": "promptString"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "hostname",
|
||||||
|
"description": "IoT Hub Hostname",
|
||||||
|
"type": "promptString"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "IoT Telemetry",
|
||||||
|
"type": "gdb",
|
||||||
|
"request": "launch",
|
||||||
|
"env": {
|
||||||
|
"AZ_IOT_HUB_DEVICE_ID": "${input:device_id}",
|
||||||
|
"AZ_IOT_HUB_HOSTNAME": "${input:hostname}",
|
||||||
|
"AZ_IOT_DEVICE_X509_CERT_PEM_FILE_PATH": "/workspaces/azure-sdk-for-c/cert/device_cert_store.pem"
|
||||||
|
},
|
||||||
|
"target": "./build/sdk/samples/iot/paho_iot_hub_telemetry_sample",
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"preLaunchTask": "build"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "IoT C2D",
|
||||||
|
"type": "gdb",
|
||||||
|
"request": "launch",
|
||||||
|
"env": {
|
||||||
|
"AZ_IOT_HUB_DEVICE_ID": "${input:device_id}",
|
||||||
|
"AZ_IOT_HUB_HOSTNAME": "${input:hostname}",
|
||||||
|
"AZ_IOT_DEVICE_X509_CERT_PEM_FILE_PATH": "/workspaces/azure-sdk-for-c/cert/device_cert_store.pem"
|
||||||
|
},
|
||||||
|
"target": "./build/sdk/samples/iot/paho_iot_hub_c2d_sample",
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"preLaunchTask": "build"
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "IoT Methods",
|
||||||
|
"type": "gdb",
|
||||||
|
"request": "launch",
|
||||||
|
"env": {
|
||||||
|
"AZ_IOT_HUB_DEVICE_ID": "${input:device_id}",
|
||||||
|
"AZ_IOT_HUB_HOSTNAME": "${input:hostname}",
|
||||||
|
"AZ_IOT_DEVICE_X509_CERT_PEM_FILE_PATH": "/workspaces/azure-sdk-for-c/cert/device_cert_store.pem"
|
||||||
|
},
|
||||||
|
"target": "./build/sdk/samples/iot/paho_iot_hub_methods_sample",
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"preLaunchTask": "build"
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "IoT Twin",
|
||||||
|
"type": "gdb",
|
||||||
|
"request": "launch",
|
||||||
|
"env": {
|
||||||
|
"AZ_IOT_HUB_DEVICE_ID": "${input:device_id}",
|
||||||
|
"AZ_IOT_HUB_HOSTNAME": "${input:hostname}",
|
||||||
|
"AZ_IOT_DEVICE_X509_CERT_PEM_FILE_PATH": "/workspaces/azure-sdk-for-c/cert/device_cert_store.pem"
|
||||||
|
},
|
||||||
|
"target": "./build/sdk/samples/iot/paho_iot_hub_twin_sample",
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"preLaunchTask": "build"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "mkdir -p build && cd build && rm -rf * && cmake -DTRANSPORT_PAHO=ON -DCMAKE_BUILD_TYPE=Debug .. && cmake --build ."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -5,6 +5,7 @@
|
||||||
- [Azure IoT Samples](#azure-iot-samples)
|
- [Azure IoT Samples](#azure-iot-samples)
|
||||||
- [Table of Contents](#table-of-contents)
|
- [Table of Contents](#table-of-contents)
|
||||||
- [Introduction](#introduction)
|
- [Introduction](#introduction)
|
||||||
|
- [Github Codespaces](#github-codespaces)
|
||||||
- [Prerequisites](#prerequisites)
|
- [Prerequisites](#prerequisites)
|
||||||
- [Getting Started](#getting-started)
|
- [Getting Started](#getting-started)
|
||||||
- [Create an Authenticated Device](#create-an-authenticated-device)
|
- [Create an Authenticated Device](#create-an-authenticated-device)
|
||||||
|
@ -56,6 +57,21 @@ More detailed step-by-step guides on how to run an IoT Hub Client sample from sc
|
||||||
|
|
||||||
To view scenario-focused examples using the API calls, please view the Azure IoT Client [introductory examples](https://github.com/Azure/azure-sdk-for-c/blob/master/sdk/docs/iot/README.md#examples). General [coding patterns](https://github.com/Azure/azure-sdk-for-c/blob/master/sdk/docs/iot/coding_patterns.md) that are MQTT stack agnostic are also available to view.
|
To view scenario-focused examples using the API calls, please view the Azure IoT Client [introductory examples](https://github.com/Azure/azure-sdk-for-c/blob/master/sdk/docs/iot/README.md#examples). General [coding patterns](https://github.com/Azure/azure-sdk-for-c/blob/master/sdk/docs/iot/coding_patterns.md) that are MQTT stack agnostic are also available to view.
|
||||||
|
|
||||||
|
## Github Codespaces
|
||||||
|
|
||||||
|
You can use Github Codespaces to be up and running quickly! Here are the steps to follow (assuming you already have an IoT Hub set up).
|
||||||
|
|
||||||
|
1. Select the "Open with Codespaces" prompt on Github and then "New codespace".
|
||||||
|
![codespace](./docs/img/codespace.png)
|
||||||
|
1. Once the Codespace is open, all required build tools, extensions, and debugging tools will be setup for you.
|
||||||
|
1. Hit Control-Shift-B on your keyboard to build the SDK and samples.
|
||||||
|
1. Navigate to the `cert/` directory and find the fingerprint for the certificate that was generated for you.
|
||||||
|
1. In the Azure IoT Hub portal, add a device using Self-Signed Cert authentication. Paste the fingerprint in for Primary and Secondary. Add the device.
|
||||||
|
1. Back in the Codespace, navigate to the "Run" tab on the left side (arrow with a bug).
|
||||||
|
1. Select any of the samples and hit the green run button.
|
||||||
|
1. Paste you Device ID and IoT Hub Hostname in the prompts that pop up. Hit enter and the sample should be running!
|
||||||
|
1. Note you can use the device explorer to monitor/interact with the samples.
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
To run the samples, ensure you have the following programs and tools installed on your system:
|
To run the samples, ensure you have the following programs and tools installed on your system:
|
||||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 78 KiB |
Загрузка…
Ссылка в новой задаче