Atos-Research-and-Innovation / IoTagent-LoRaWAN

FIWARE IoT Agent for LoRaWAN protocol (with CayenneLpp and CBOR data models)
https://fiware-lorawan.readthedocs.io/en/latest/
Other
34 stars 40 forks source link

Update support for chirpstack with data_model: application_server #139

Closed hbrito-gtc closed 2 years ago

hbrito-gtc commented 2 years ago

When using ChirpStack (before loraserverio) as application_server "provider": "loraserver.io" , and use a payload format decoding done by the application server, this agent expect receive a message.object (See loraserveriorAppService.js), but Chirspack publish with name objectJSON (See https://www.chirpstack.io/application-server/integrations/events/)

The solution I have found is to set the payload marshaler on the Chirpstack application server as json_v3.

 # Payload marshaler.
  #
  # This defines how the MQTT payloads are encoded. Valid options are:
  # * protobuf:  Protobuf encoding
  # * json:      JSON encoding (easier for debugging, but less compact than 'protobuf')
  # * json_v3:   v3 JSON (will be removed in the next major release)
  marshaler="json_v3"

With json (change the object name to JSON object and also put the escape character "\" before the double quotes, then the agent failed:

"objectJSON":"{\"co2\":0.9581763626025936,\"humidity\":0.018713221139656417,\"temperature\":0.7916723090820832,\"vdd\":0.423553153885841}"

With json_v3:

"object":"co2":0.19809069547580238,"humidity":0.7625402814654507,"temperature":0.2960604545000967,"vdd":0.13733159253790328}}