disk91 / WioLoRaWANFieldTester

85 stars 32 forks source link

strange GPS values when decoding on TTI #69

Closed t0mZ4 closed 1 year ago

t0mZ4 commented 1 year ago

Hi there

We are getting the following decode from the unit:

 "received_at": "2023-01-05T15:06:38.354426073Z",
    "uplink_message": {
      "session_key_id": "AYWCUAnqwpnFZHaPH6h2SQ==",
      "f_port": 1,
      "f_cnt": 29,
      "frm_payload": "AAAAAAAAAAAAAA==",
      "decoded_payload": {
        "accuracy": 0.5,
        "altitude": -1000,
        "hdop": 0,
        "latitude": 0.0000053,
        "longitude": 0.0000107,
        "sats": 0
      },

using this decoder

function Decoder(bytes, port) { 
  var 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;
}

are we doing something wrong?

disk91 commented 1 year ago

Decoding is good... the GPS position is just unknown, so it reports 0 to identify this. You can easily filter with the altitude (compared with a real position 0,0) Your GPS is indoor or not yet sync with sat or having a GPS signal precision too low ( red / orange bullet on the screen)