RIoT2.Net.Node is a .NET 9 ASP.NET Core application that acts as an IoT node in the RIoT2 system. A node hosts and manages IoT devices, communicates with an orchestrator over MQTT, and dynamically loads device functionality from plugins.
- Dynamically loads device plugins at runtime from the
Plugins/directory. - Communicates with the orchestrator over MQTT (online messages, commands, configuration updates).
- Configures, starts, stops, and schedules devices.
- Exposes HTTP endpoints for node/plugin manifests and device status/configuration templates.
- Framework: .NET 9 (
net9.0) - App type: ASP.NET Core Minimal API
- Logging: Serilog (console + rolling file sink at
Logs/RIoT2.log) - JSON:
System.Text.Json(camelCase, case-insensitive, indented) - Core library:
RIoT2.Core
dotnet build dotnet run
If you want to work on the source code, clone the repository and run the following commands:
# restore dependencies
dotnet restore
# build the solution
dotnet build
# run the application
dotnet run --project src/RIoT2.Net.Node/RIoT2.Net.Node.csprojEnsure you have the .NET 9 SDK installed. Optionally, install an IDE such as Visual Studio 2022 (Windows) or Visual Studio Code (cross-platform).
To deploy the application, configure the environment and logging as needed, then publish the application:
# publish the application
dotnet publish --configuration Release
# navigate to the publish output directory
cd ./src/RIoT2.Net.Node/bin/Release/net9.0/publish
# run the application
dotnet RIoT2.Net.Node.dllAdjust the paths and settings based on your environment and requirements.
To build and run the application in a Docker container, use the following commands:
# build the Docker image
docker build -t riot2-net-node .
# run the Docker container
docker run -d --name riot2-net-node -p 80:80 -v /path/to/data:/app/Data -v /path/to/logs:/app/Logs riot2-net-nodeReplace /path/to/data and /path/to/logs with the desired paths on the host machine for persistent data and logs storage.
The application uses the following folders within the container:
/app/Data /app/Logs /app/Plugins
The project defines three build configurations: Debug, Release, and Local.
In
Debugbuilds, device configuration is loaded fromData/local.configuration.jsoninstead of waiting for an orchestrator command.
Node identity and connectivity are configured through environment variables:
| Environment Variable | Description |
|---|---|
RIOT2_NODE_ID |
Unique identifier for this node; also used as the MQTT client id. |
RIOT2_NODE_URL |
Base URL where the node's HTTP API is reachable. |
RIOT2_MQTT_IP |
Address of the MQTT broker. |
RIOT2_MQTT_USERNAME |
Username for MQTT authentication. |
RIOT2_MQTT_PASSWORD |
Password for MQTT authentication. |
| Method | Route | Description |
|---|---|---|
GET |
/api/node/manifest |
Returns the node manifest. |
GET |
/api/node/plugin/manifest |
Returns the plugin manifest. |
GET |
/api/device/status |
Returns status for each device with a known state. |
GET |
/api/device/configuration/templates |
Returns device configuration templates. |
Device functionality is provided by plugins — .dll files placed in the Plugins/ directory. Each plugin exposes a type implementing IDevicePlugin, which is discovered via reflection and initialized at startup. Plugin packages can also be downloaded from a URL supplied in the device configuration; a new package triggers a node restart to reload plugins.