Moved to Eclipse at https://github.com/eclipse-thingweb/test-things
Collection of IoT device simulators that can be used for testing and exploration purposes of different protocols and other Web of Things mechanisms. The devices are implemented via various programming languages and frameworks. The protocols you can currently test are:
- HTTP
- CoAP
- MQTT
- Modbus (not fully working)
The project has several dependencies. Currently, JavaScript and Python are used for simulating different devices. Every device has its own dependencies and they should be handled individually, without influencing other device codebases. For that reason, npm is used for JS code, and poetry is used for Python code to run the scripts and handle the dependencies.
For testing, the JavaScript testing framework mocha is used. Therefore, the tests are written in JavaScript.
Every Thing should have its Thing Model and Thing Description validation test.
Thing Model validation test should be put under Thing's main directory and named tm.test.json
.
Thing Description validation test should be put under the protocol and programming language/framework's test directory and named td.test.json
.
For Thing Description validation test, the device should boot up and to understand the device booted up without any error, a message "ThingIsReady"
is expected to be prompted to the console by the device.
If you are going to add a different protocol for an existing Thing:
- Create a directory such as
<your_protocol>/<your_programming_language/your_framework>/
. - Create your project files and write your code inside this directory.
- If you are adding a new programming language, please use a tidy dependency management tool for the programming language. Otherwise use already used tools and frameworks not to overcomplicate the project.
- Create your
test/
directory under your Thing's directory and add your test files there.
If you are going to add a different programming language/framework for an existing protocol:
- Create a directory such as
<existing_protocol>/<your_programming_language/your_framework>/
. - Create your project files and write your code inside this directory.
- Please use a tidy dependency management tool for the programming language/framework. Otherwise use already used tools and frameworks not to overcomplicate the project.
If you are going to add a completely new Thing:
- Create a directory such as
things/<your_thing_name>/
. - Add your Thing Model under the previously created directory and name it such as
<your_thing_name>.tm.json
. - Follow the steps above to add your protocol and programming language/framework.
Calculator is a simple device, which has a read-only result
variable and depending on the action selected by the user, it adds or subtracts user input from the result
.
There is also a read-only lastChange
variable, which indicates the last time result
variable has changed.
Additionally, the device publishes an event, when result
is changed.
- HTTP
- JavaScript Express framework
- Python Flask framework
- CoAP
- JavaScript
- MQTT
- JavaScript
- Modbus
- JavaScript (WIP)
You can start the devices inside a container, for that running docker-compose up
at the root directory builds and runs the containers.
For custom configuration, take a look at the Dockerfile
of each device or docker-compose.yml.
For running the things separately, using their Dockerfile
's, docker build -t <image-tag> -f ./Dockerfile ../../
command must be used to give the context to be able to copy tm.json
into the container.
For Node.js-based devices, we use npm workspaces, and running npm install
at the root directory installs all the packages needed for every device.
After packages are installed, running node main.js
runs the Thing.
For port configuration, running either node main.js -p 1000
or node main.js --port 1000
starts the thing on port 1000.