Currently I've got my own LoRaWAN network, with around 45 devices sending data with this payload: ID=D0001&T=23&H=60 where ID is the sensorId; T-Temperature; H - Humidity.
What steps do I have to make next to get context from my devices?
These are the steps that I've made:
1 - Installed IoT-Agent Ultralight
2 - Configured MQTT on the config.js file with my MQTT data
config.mqtt = {
host: 'HOST_NAME',
port: 1883,
protocol : mqtt
,
username: 'USERNAME',
password: 'PASSWORD',
retain: false,
retries: 5,
retryTime: 5,
keepalive: 0,
avoidLeadingSlash: false
};
3 - IoTAgent-ul (node bin/iot-agentul), getting this message: time=2020-12-01T10:44:48.197Z | lvl=INFO | corr=526cdc56-62b8-4791-b95d-f5110ca18b7e | trans=526cdc56-62b8-4791-b95d-f5110ca18b7e | op=IOTAUL.MQTT.Binding | from=n/a | srv=n/a | subsrv=n/a | msg=connected | comp=IoTAgent
It is unclear whether you need the IoT Agent for Ultralight or the IoT Agent for LoRaWAN. Ultralight is a payload syntax, the Ultralight IoT Agent supports HTTP, MQTT and AMPQ transports. LoRaWAN is a transport, it supports a couple of COAP protocols.
If you are really sending LoRa COAP messages then you'll need the LoRaWAN agent.
If you are using Ultralight over MQTT, then your message payload should look like this
ID|D0001|T|23|H|60
An Ultralight over MQTT Tutorial exists within the Step-by-Step Guide.
If you are using COAP over LoRaWAN, then your message payload would be a stream of base64
bytes coming from the LoRa gateway. The Things network tutorial describes the set-up.
If your payload literally is: ID=D0001&T=23&H=60
, you're going to need to create your own parser like the Custom IoT Agent Tutorial and follow the steps in altering the IoT Agent codebase.
Specifically, the flow of control with the HTTPBindings
parseData() function. The ulParser
would need to be re-written to accept your alternate syntax. It looks similar enough that all you'd need to do is:
if (payload) {
data = ulParser.parse(payload.replace(/&/g, "|").replace(/=/g, "|"));
}
(Even better if that could be done prior to sending to the Ultralight IoT Agent)
The advantage of re-using an existing IoT Agent (or writing a new one using the IoT Agent Node lib) is that functions such as the creation of entities and mapping of attributes is achieved using the existing code.