Automatic formatting of GPS coordinates

I have a device transmitting GPS coordinates to TTN every 30 seconds. But when viewing the data being received and how it’s formatted, I see that the GPS coordinates are sometimes formatted differently. The ‘lat’ and ‘lon’ coordinates are wrapped in a ‘map’ object(?). But I’m not defining one in my decoder, and I wonder why this is happening and how I can disable it since I’m not sure the data will be handled correctly in my integrations.

image

image

Here’s my decoder:

function Decoder(bytes, port) {
  var lat = (bytes[2] << 16) | (bytes[1] << 8) | bytes[0];
  var long = (bytes[5] << 16) | (bytes[4] << 8) | bytes[3];
  
  var location = {};
  location.lat = ((lat - 900000) / 10000.0);
  location.lon = ((long - 1800000) / 10000.0);
  
  return {
    location: location,
    doorState: (bytes[6] & 0x01) ? "closed" : "open"
  };
}

Maybe you have a converter installed?

Nope, I have no converters added, only the decoder. Also, as you can see, it’s not consistent. It goes back and forth between those two formats from message to message.

You might want to review the fair access policy for TTN;

Fair Access Policy

I’m going to take a guess here that “map” does not refer to a representation of geography, but is rather a javascript construct.

The next guess would be that your code is (perhaps as a result of load sharing and a version change) running in two different execution environments which make different assumption of what operations are implicit and what are explicit. In one the map gets fully decomposed to nested json, in the other it gets dumped out as a string description.

(For example there was another recent complaint about changes in the javascript environment Buffer not defined any more?)

Although an ugly workaround, something simple you could probably due would be to flatten the structure, ie instead of having a “location” just have a “latitude” and “longitude” at the same level as “doorState”. You’d have to change the receiver too but consistency would seem more likely.

You’re absolutely right. Currently it’s a test project in our lab where we have our own gateway. But regardless I’ve increased the TX interval of the sensors to 10 minutes.

Aha, thanks a lot for the input. I wasn’t aware that what you’re saying was a possibility. We’re currently testing with both Azure and AWS, and as far as I can see the integrations are not affected by this, only how it’s presented in the TTN Data logger. The data is being handled regardless.

Yes, if it becomes a problem I think we could do this.

Thanks again.