iv2go-simulator

0.11.0 • Public • Published

OSAA iV2GO Device Simulator

Prerequisites

You must have access to a working IoT Central application.

Installation

Clone the repository

git clone git@github.com:NordicodeApS/osaa-device-simulator.git

Change directory:

cd osaa-device-simulator

Install packages:

npm install

Start the watcher while developing:

npm run dev

Build:

npm run build

Symlink the binary (globally):

npm link

Usage

Run the following command to see a list of options:

iv2go-simulator --help

Example:

iv2go-simulator -d [device ID] -k [device key] -s [ID scope] -m [model ID] -i 30

Note: if you get a "permission denied" error, you might need to make the js file executable.
You can do this by running: chmod +x dist/index.js

Device key

The simulator connections to IoT Central by using the Shared access signature method.

The device key is specific for the device and is generated with the following console command:

az extension add --name azure-iot # if not already installed
az iot central device compute-device-key --primary-key <enrollment group primary key> --device-id <device ID>

You might need to install the Azure CLI for the command to work

The enrollment group primary key is the primary key of the Shared access signature of an enrollment group (also called Device connection group) that uses the SAS attestation type.

Read more: https://learn.microsoft.com/en-gb/azure/iot-central/core/concepts-device-authentication#sas-enrollment-group

Environment variables

If you find you're using the same values for idScope and modelId over and over again, or you don't want to compute device keys all the time, consider creating a .env file with some general values.

If you want to leave out the deviceKey option and instead generate a device key on-the-fly, add this variable:

DEVICE_GROUP_KEY=<enrollment group primary key>

You can also leave out the idScope and modelId options and instead add these variables:

DEVICE_ID_SCOPE=<ID scope>
DEVICE_MODEL_ID=<model ID>

If you add all the env variables above, you can launch a simulator simply by running:

iv2go-simulator -d [device ID]

Here is a list of all available environment variables and options:

Key Option Default Description
DEVICE_ID -d (empty) The device ID
DEVICE_KEY -k (empty) The computed device key (read more)
DEVICE_ID_SCOPE -s (empty)  ID scope
DEVICE_MODEL_ID -m (empty) Template model ID
DEVICE_GROUP_KEY (empty) Enrollment group primary key (read more)
INTERVAL -i 30 How often to send messages (in seconds)
DURATION -t 3600  Treatment duration
FLOWRATE -f 75 The flowrate in ml/h
LOOP -l false If the treatment should loop
-q false Suppress output

Build Docker image

docker build -t iv2go-simulator:<tag> .
docker tag iv2go-simulator:<tag> <registry-endpoint>/iv2go-simulator:<tag>
docker push <registry-endpoint>/iv2go-simulator:<tag>

Readme

Keywords

none

Package Sidebar

Install

npm i iv2go-simulator

Weekly Downloads

1

Version

0.11.0

License

MIT

Unpacked Size

70.8 kB

Total Files

21

Last publish

Collaborators

  • jezzdk