WioLoRaWANFieldTester icon indicating copy to clipboard operation
WioLoRaWANFieldTester copied to clipboard

TTN webhook configuration for WioLoRaWANFieldTester

Open ffries opened this issue 2 years ago • 2 comments

Dear community,

Thank you for working on WioLoRaWANFieldTester. I am a newbie in LoRaWAN, so pardon my ignorance.

I purchased a WioLoRaWANFieldTester field tester with battery from seeed. i am only interested in TTN, not Helium.

After reinstalling firmware and setting GPS to 9600bds, I could register on my TTN Gateway and GPS worked. After long hours of testing I cannot upload any information.

I followed the instructions on the wiki, unfortunately, I don't understand how to set-up TTN payload formatters. I followed the instructions on the wiki without adding any formatters, unfortunately it replies "impossible to decode data". So I need to decode data ...

I found this webhook code and used it:

function Decoder(bytes, port) { 
  var decoded = {};
  
  if ( port != 1 ) return decoded;
  
  var lonSign = (bytes[0]>>7) & 0x01 ? -1 : 1;
  var latSign = (bytes[0]>>6) & 0x01 ? -1 : 1;
  
  var encLat = ((bytes[0] & 0x3f)<<17)+
               (bytes[1]<<9)+
               (bytes[2]<<1)+
               (bytes[3]>>7);

  var encLon = ((bytes[3] & 0x7f)<<16)+
               (bytes[4]<<8)+
               bytes[5];
  
  var hdop = bytes[8]/10;
  var sats = bytes[9];
  
  const maxHdop = 2;
  const minSats = 5;
  
  if ((hdop < maxHdop) && (sats >= minSats)) {
    // Send only acceptable quality of position to mappers
    decoded.latitude = latSign * (encLat * 108 + 53) / 10000000;
    decoded.longitude = lonSign * (encLon * 215 + 107) / 10000000;  
    decoded.altitude = ((bytes[6]<<8)+bytes[7])-1000;
    decoded.accuracy = (hdop*5+5)/10
    decoded.hdop = hdop;
    decoded.sats = sats;
  } else {
    decoded.error = "Need more GPS precision (hdop must be <"+maxHdop+
      " & sats must be >= "+minSats+") current hdop: "+hdop+" & sats:"+sats;
  }

  return decoded;
}

Also I wonder whether it is possible to use an experimental project in TTN Mapper for TTN. Can I integrate directly wih TTN Mapper and not disk91. With the above script "decoded_payload": {}, so data never reaches TNT Mapper.

Please advise:

  1. Which TTN payload is needed ? Is the above webhook correct ?
  2. Can I upload directly to TNT mapper or should I use your backend?

Kind regards, Ffries

ffries avatar Apr 09 '23 19:04 ffries

The project, when connected to the backend dev.disk91.com automatically pushes the data to ttnmapper. For the rest, read the setup guide for TTN

disk91 avatar Apr 10 '23 17:04 disk91

Thanks, closing the issue.

ffries avatar Apr 12 '23 12:04 ffries