f2c8d6e92d
* Store simulations using the storage adapter * Implement device bootstrap scenario: when a new device is created, mark it as a simulated device and report some properties like device type, messages schema, and initial location. * Remove dependency on IoT Hub manager and access IoT Hub directly * Refactor state machine to reduce complexity and reuse code * Add launch settings for Visual Studio * Remove env var used for the web service TCP port * Improve logging of exceptions to avoid log flooding * Fix messages format, to always use the “_unit” convention * Add JSON config checks |
||
---|---|---|
.github | ||
Services | ||
Services.Test | ||
SimulationAgent | ||
SimulationAgent.Test | ||
WebService | ||
WebService.Test | ||
scripts | ||
.gitattributes | ||
.gitignore | ||
.travis.yml | ||
CONTRIBUTING.md | ||
DEVELOPMENT.md | ||
LICENSE | ||
README.md | ||
device-simulation.sln | ||
device-simulation.sln.DotSettings | ||
version |
README.md
Device Simulation
This service allows to manage a pool of simulated devices, to test the end-to-end flow of device-to-cloud (D2C) telemetry, invoking cloud-to-device (C2D) commands, methods, etc.
The microservice provides a RESTful endpoint to set the simulation details, to start and stop the simulation, to add and remove virtual devices. The simulation is composed by a set of virtual devices, of different types, each sending telemetry and replying to method calls.
How to use the microservice
Quick demo using the public Docker image
After cloning the repository, follow these steps:
- Install Docker Compose: https://docs.docker.com/compose/install
- Create an instance of Azure IoT Hub
- Store the "IoT Hub Connection string" in the env-vars-setup script. For more information about environment variables, see the development notes.
- Using an HTTP client like Postman, use the RESTful API to create a simulation.
By default, Docker Compose will start the service using the sample device types defined in sample-volume:
- to load device types definitions from a different folder, edit the docker-compose.yml
- to add your custom simulations, add the JSON and Javascript files into the folder and restart the service. See the wiki for more information about device types and the API.
Working with Visual Studio
After cloning the repository, follow these steps:
-
Install Docker: https://docs.docker.com/engine/installation
-
Create an instance of Azure IoT Hub
-
Open the solution in Visual Studio
-
Either in Visual Studio or in your system, define the following environment variable:
PCS_IOTHUB_CONNSTRING
= {your Azure IoT Hub connection string}
For more information about environment variables, see the development notes.
-
In Visual Studio, start the WebService project
-
In Visual Studio, Start the SimulationAgent project
-
Using an HTTP client like Postman, use the RESTful API to create a simulation.