In order to use this simulator, you must have created a Microsoft Azure IotHub. This can be done either via the portal.azure.com or through an ARM file. For this project, I created a resource group with a single iothub.
The program creates a deviceIds.json file which will include the deviceIds of the devices it creates. You can prepoluate this if desired. If the num_devices is greater than the number of deviceIds in the list, then the program will create them. Created devices will be named 'SimulatedDevice-' where UUID4 is a generated UUID.
The application uses Node.js and npm. Start at step 2 if you have them installed already.
-
Install Node.js (this will also install npm)
-
Go to the project folder in the terminal and install the required npm modules:
npm install
-
Generate an .env file containing the information that you used to register the device simulator in your IoT Platform organization (.env.example provided):
iot_hub_connection_string=<iothubconnectionstring> num_devices=<count_of_the_number_of_devices>
-
Start the application:
npm start
Requires: iothub-explorer and jq
List all devices:
iothub-explorer list
Query information about each device in the deviceIds.json file:
cat deviceIds.json | jq -r .[] | xargs -L 1 iothub-explorer info
Delete information about each device in the deviceIds.json file:
cat deviceIds.json | jq -r .[] | xargs -L 1 iothub-explorer delete
This sample code is licensed under Apache 2.0. Full license text is available in LICENSE.