iot-agent

module
v0.0.0-...-8c71cb1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2024 License: AGPL-3.0

README

iot-agent

A service that handles (decodes and converts) incoming data from multiple sources.

Design

flowchart LR
    mqtt-->handler
    converter--rabbitMQ-->iot-core
    facade--http-->iot-device-mgmt
    iot-device-mgmt--http-->decoder
    iot-device-mgmt--http-->converter
    subgraph app server
        mqtt
    end
    subgraph iot-agent
        handler--http-->api
        api-->facade
        decoder-->converter
    end 

Iot-Agent gets sensor uplink messages on subscribed mqtt-topics exposed by application servers. Messages are handled and POSTed to /api/v0/messages, which is an local http endpoint. Metadata about the sensor is fetched from iot-device-mgmt, this metadata contains information about which decoder to use to decode the message payload. The metadata also contains information about the converters to use for measurements.

Dependencies

Facades

Since application servers such as Chirpstack has different uplink payloads a facade is used to transform the specific payload into an internal format.

Chirpstack

Support for Chirpstack v3 payloads.

Netmore

Support for payloads from netmore

Decoders

Decoder implementations for sensors

Presence

Uses codec for Sensative

Qalcosonic

Decoder for Ambiductor Qalcosonic w1 water meters (w1e, w1t, w1h).

  • Volume (incl. timestamp)
  • Temperature (w1t)
  • Status (codes & messages)
Elsys
  • Temperature
  • ExternalTemperature
  • Vdd
  • CO2
  • Humidity
  • Light
  • Motion
  • Occupancy
  • DigitalInput
  • DigitalInputCounter

Depends on the Generic Javascript decoder

Enviot
  • Battery
  • Humidity
  • SensorStatus
  • SnowHeight
  • Temperature
Milesight
  • Temperature
  • Humidity
  • CO2
  • Battery
Senlab
  • Temperature
Sensative
  • BatteryLevel
  • Temperature
  • Humidity
  • DoorReport
  • DoorAlarm
  • Presence
Sensefarm
  • BatteryVoltage
  • Resistances
  • SoilMoistures
  • Temperature

Converters

Converters converts sensor data to lwm2m measurements.

AirQuality

urn:oma:lwm2m:ext:3428

Conductivity

urn:oma:lwm2m:ext:3327

DigitalInput

urn:oma:lwm2m:ext:3200

Distance

urn:oma:lwm2m:ext:3330

Humidity

urn:oma:lwm2m:ext:3304

Illuminance

urn:oma:lwm2m:ext:3301

PeopleCount

urn:oma:lwm2m:ext:3434

Presence

urn:oma:lwm2m:ext:3302

Pressure

urn:oma:lwm2m:ext:3323

Temperature

urn:oma:lwm2m:ext:3303

Watermeter

urn:oma:lwm2m:ext:3424

Build and test

Build

docker build -f deployments/Dockerfile -t diwise/iot-agent:latest .

Test

curl -X POST http://localhost:8080/api/v0/messages 
     -H "Content-Type: application/json"
     -d '{
            "deviceName": "mcg-ers-co2-01",
            "deviceProfileName": "ELSYS",
            "deviceProfileID": "0b765672",
            "devEUI": "a1b2c3d4e5f6",
            "data": "AQDuAhYEALIFAgYBxAcONA==",
            "object": {
                "co2": 452,
                "humidity": 22,
                "light": 178,
                "motion": 2,
                "temperature": 23.8,
                "vdd": 3636
            }
        }'

Configuration

Environment variables

"MQTT_DISABLED": "false", # enable/disable mqtt input 
"MQTT_HOST": "<broker hostname>",
"MQTT_PORT": "<broker port number>",
"MQTT_USER": "<username>",
"MQTT_PASSWORD": "<password>",
"MQTT_TOPIC_0": "topic-01/#", # configure mqtt topic names
"MQTT_TOPIC_1": "topic-02/#", # it is possible to specify multiple topics
...
"MQTT_TOPIC_n": "topic-n/#",
"RABBITMQ_HOST": "<rabbit mq hostname>",
"RABBITMQ_PORT": "5672",
"RABBITMQ_VHOST": "/",
"RABBITMQ_USER": "user",
"RABBITMQ_PASS": "bitnami",
"RABBITMQ_DISABLED": "false",
"DEV_MGMT_URL": "http://iot-device-mgmt:8080", 
"SERVICE_PORT": "<custom service port, default 8080>",
"MSG_FWD_ENDPOINT" : "http://iot-agent:8080/api/v0/messages",
"OAUTH2_TOKEN_URL": "http://keycloak:8080/realms/diwise-local/protocol/openid-connect/token",
"OAUTH2_CLIENT_ID": "diwise-devmgmt-api",
"OAUTH2_CLIENT_SECRET": "<client secret>",
"APPSERVER_FACADE": "<facade>" # configure application server, chirpstack (default) or netmore

CLI flags

none

Configuration files

none

iot-agent on diwise.github.io

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL