Required packages: nodejs, npm (prefered instalation via nvm):
Clone repository
Navigate to iot-worker folder
Install dependencies npm install
Copy .env.example
as .env, and modify its contents as in Configuration file section
Run command npm start
Execute command in project directory:
docker build -t supplier-listener-unique-worker .
Result should look like:
(...)
Successfully built IMAGE_ID
To run image execute (config.json and docker env as file or params are required):
docker run -i <place docker envs here> IMAGE_ID
If there is no env specified Unique Worker will stop execution.
All-in-one command which will build image and run it (ensure that path to config is correct):
docker run -i <place docker envs here> `docker build -q .`
Running from sources - It will expect .env & config.json in project folder.
Running in docker container - path to config.json file should be provided as described in this section, including rest of env specified as docker env file or parameters.
Redis server address
REDIS_HOST="127.0.0.1"
Redis server port
REDIS_PORT="6379"
Listens for an event in the Supplier's dApp and sends a command to the Supplier's IoT platform.
It consists of three elements:
Blockchain Worker - Parses blockchain transactions, supplies data for Iot Worker or Unique Worker.
IoT Worker - Builds requests to IoT server, uses data from queue supplied by Blockchain Worker or Unique Worker (filters unique data from many Blockchain Workers).
Unique Worker - Filters unique actions by transaction id between Blockchain Workers and Iot Workers.
Required packages: nodejs, npm (prefered instalation via nvm)
Clone repository
Navigate to blockchain-worker
folder
Install dependencies npm install
Copy .env.example
as .env, and modify its contents as in Configuration file section;
Run command npm start
Execute command in project directory:
docker build -t supplier-listener-blockchain-worker .
Result should look like:
(...)
Successfully built IMAGE_ID
To run image execute (docker env as file or params is required):
docker run -i <place docker envs here> IMAGE_ID
If there is no env specified Blockchain Worker will stop execution.
All-in-one command which will build image and run it (ensure that the path to config is correct).
docker run -i <place docker envs here> `docker build -q .`
Running from sources
- it will expect .env in project folder.
Running in docker container
- it will expect env specified as docker env file or parameters.
dApp monitored for action requests:
DAPP='3NBPqqjDH2eYmoHeXNPnHhLvA7D4UDQXQcx'
Functions called in dApp in order to make action on device (separated by "|"):
DAPP_FUNCS='deviceAction|deviceActionAs'
Url to node used for monitoring state of dApp:
NODE_URL='
https://nodes-testnet.wavesnodes.com
'
Number of blocks over parsed one higher values are safer but slower.
SAFETY_LEVEL=0
Checking interval for new transactions
CHECK_INTERVAL=1000
Blockchain updates extension port
NODE_GRPC_EVENTS_PORT='localhost:6881'
Grpc extension port
NODE_GRPC_PORT='10.0.0.7:6877'
Redis server address
REDIS_HOST="127.0.0.1"
Redis server port
REDIS_PORT="6379"
Required packages: nodejs, npm (prefered instalation via nvm)
Clone repository
Navigate to iot-worker
folder
Install dependencies npm install
Copy .env.example as .env, and modify its contents as in Configuration file section
Copy device config config.json.example
as config.jsonm
and modify it's contents as in Devices configuration file section
Run command npm start
Execute command in project directory:
docker build -t supplier-listener-iot-worker .
Result should look like:
(...)
Successfully built IMAGE_ID
To run image execute (config.json and docker env as file or params are required):
docker run -i -v `pwd`/.config.json:/app/config.json <place docker envs here> IMAGE_ID
When config.json
file is in another location, provide absolute path to it on left side of ":" (instead of `pwd`/config.json
, where pwd returns actual working directory, eg /user/home/xyz/listener/config.json
).
If there is no env specified, Iot Worker will stop execution.
All-in-one command which will build image and run it (ensure that path to config is correct)
docker run -i -v `pwd`/config.json:/app/config.json <place docker envs here> `docker build -q .`
Running from sources – It will expect .env
and config.json
in project folder.
Running in docker container - path to config.json
file should be provided as described in this section, including the rest of env specified as docker env file or parameters.
Token for IoT:
IOT_PLATFORM_TOKEN='abcdef...'
Url for sending command to devices where, for example {device_address} will be replaced with device's blockchain address (more variables are available as specified below)
IOT_PLATFORM_URL='http://localhost:3000/{device_address}/commands'
Method used for requests:
IOT_METHOD='POST'
Variables available for url/json
device_address
- blockchain address of device
action_name
- name of requested action (command)
key_id
- id of key asset
function_name
- name of used function
device_model
- type of device
Redis server address
REDIS_HOST="127.0.0.1"
Redis server port
REDIS_PORT="6379"
Devices configuration is defined in config.json in JSON format (remove comments before use).
"devices"
– array of supported devices
"supportedAction"
– array of supported action for device
"json"
- json for request
"jsonByAction"
- request json can be dependent on action:
"action"
- action to override json
"json"
- json to be used instead
Example of configuration: