Skip to content
This repository was archived by the owner on Apr 23, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@
"adm-zip": "^0.4.11",
"azure-arm-resource": "^3.1.0-preview",
"azure-arm-website": "^3.0.0-preview",
"azure-iot-device": "^1.7.1",
"azure-iot-device-amqp": "^1.7.1",
"azure-iot-device-http": "^1.7.1",
"azure-iot-device-mqtt": "^1.7.1",
"azure-iothub": "^1.2.3",
"body-parser": "^1.18.2",
"eventemitter2": "^5.0.0",
Expand Down
7 changes: 7 additions & 0 deletions resources/boardlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
"detailInfo": "Raspberry Pi",
"helpUrl": "https://www.raspberrypi.org/",
"exampleUrl": "https://raw.githubusercontent.com/VSChina/azureiotdevkit_tools/gallery/workbench-example-raspi.json"
},
{
"name": "Simulator",
"id": "simulator",
"detailInfo": "Simulate the connection between device and IoT hub",
"helpUrl": "https://github.com/Microsoft/vscode-iot-workbench",
"exampleUrl": "https://raw.githubusercontent.com/ab-sin-the/my-test-folder/master/simulator-example.json"
}
]
}
Empty file added resources/simulator/basic.js
Empty file.
8 changes: 8 additions & 0 deletions resources/simulator/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "iot-workbench-simulator",
"version": "0.1.0",
"main": "app.js",
"dependencies": {
"azure-iot-device-mqtt": "^1.4.3"
}
}
33 changes: 33 additions & 0 deletions resources/simulator/simple_iothub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const clientFromConnectionString = require('azure-iot-device-mqtt').clientFromConnectionString;
const Message = require('azure-iot-device').Message;
const connectionString = require('./config.json').connectionString;
const client = clientFromConnectionString(connectionString);

client.open(err => {
if (err) {
console.error('Could not connect: ' + err);
process.exit(1);
} else {
const data = {
topic: 'iot'
};
const message = new Message(JSON.stringify(data));

setInterval(() => {
client.sendEvent(message, err => {
if (err) {
console.warn('Send message to IoT Hub failed: ' + err.toString());
} else {
console.log('Message sent to IoT Hub.');
}
});
}, 2000);

client.on('message', msg => {
console.log(msg);
client.complete(msg, () => {
console.log('completed');
});
});
}
});
25 changes: 25 additions & 0 deletions resources/simulator/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"templates": [
{
"description": "",
"detail": "Create project with device only code.",
"label": "Device only",
"type": "Basic",
"sketch": "basic.js"
},
{
"description": "",
"detail": "Create project that connects to Azure IoT Hub, such as sending sensor data to cloud.",
"label": "With Azure IoT Hub",
"type": "IotHub",
"sketch": "simple_iothub.js"
},
{
"description": "",
"detail": "Create project that connects to Azure IoT Hub and processes device data further in Azure Functions.",
"label": "With Azure Functions",
"type": "AzureFunctions",
"sketch": "simple_iothub.js"
}
]
}
Loading