Decoder for Post in Loriot


Im trying to get my data send to Ubidots.
create a funtion inside ubidots using this link: Ubidots HTTPS - LoRaWAN Network Server Osprey (v7.x) - Documentation Hub
also use this link for the coding by ubidots: Integrate your LORIOT data with Ubidots using UbiFunctions | Ubidots Help Center
im stuck at decoder part.
My data are in hexadecimal. as in picture attached.
your help are greatly appreciated. Thanks

Hi @azrulasree,

Thank you for sharing your questions with the community. We’re glad to hear that you are using the Loriot + Ubidots integration. In order to help you, can you please let us know the following information:

  • Which device or devices are you connecting?
  • Can you please share the documentation regarding the device data frame and how the data should be decoded?
  • After running the UbiFunction from section 2 of the guide, which error or response are you obtaining?

Best,
-Isabel

Hi isabel.
This is a project on the Lorawan device.

End device: Smart City (Libelium).
Gateway: RAK 7249
Network Server: Loriot

I tried before this with the decoder below on TTN(I got example on github):
The example payload in hexadecimal will be by end device : 0102030405060708090A0B0C0D0E0F

function Decoder(bytes, port) {
var i = 0;

function nextFloat() {
// Sign-extend to 32 bits to support negative values, by shifting 24 bits
// (too far) to the left, followed by a sign-propagating right shift:
return (bytes[i++]<<24>>16 | bytes[i++]) / 100;
}

function nextMinMedianMax() {
return {
min: nextFloat(),
median: nextFloat(),
max: nextFloat()
}
}

return {
temperature: nextMinMedianMax(),
pressure: nextMinMedianMax(),
no2: nextMinMedianMax(),
battery: bytes[i++]
}
}


With this decoder, im able to get temperature, pressure, no2 and battery.
I did modified the decoder when putting inside ubidots’s funtion. But they might be something wrong as im not familiar with the coding.

And your last question. I dont get any error since no output being sent by Loriot.



note that no device created mean data not received from Loriot.

Hi @azrulasree,

Can you please check the logs of the UbiFunction, and sending us an image of the results and output, by following these steps:

  1. Go to DevicesFunctions
    image

  2. Refer to the control bar and select the logs icon as shown below to view the history of your Function’s executions:

  1. In the UbiFunction’s logs, you can confirm if the function is having an error while running and in which line of the code.

Now, we take a look to a Functions that we believe is the one you are using and the error seems to be is the following part of the code:

input = {
    bytes: bytes, // Buffer of bytes
    fport: port
    
    function nextFloat() {
    return (bytes[i++]<<24>>16 | bytes[i++]) / 100;}
    
    function nextMinMedianMax() {
    return {
      min: nextFloat(),
      median: nextFloat(),
      max: nextFloat()
      }
  }
}
  • There are missing commas on the properties definition.
  • The methods defined inside the object are not well structured. Please check the following documentation that might help you solve these issues.

I will be attentive to your response,
-Isabel

Hi, i did fix the syntax.

Now, when i open log. this is what I get.

I copied the log example.
2022-05-09T09:39:21.414625Z stdout: args: {“EUI”:“0004A30B00EEBF4E”,"_id":“6278e148845282d63416d908”,“ack”:false,“bat”:255,“cmd”:“gw”,“data”:“0102030405060708090a0b0c0d0e0f”,“dr”:“SF12 BW125 4/5”,“fcnt”:53230,“freq”:924200000,“gws”:[{“ant”:0,“gweui”:“AC1F09FFFF0141B4”,“lat”:0,“lon”:0,“rssi”:-25,“snr”:9,“time”:“2022-05-09T09:39:20.466941Z”,“ts”:1652089160470}],“port”:3,“seqno”:58023,“toa”:1646,“ts”:1652089160470}


Do I need to ask the manufacturer for the right decoder of the payload?