V3 Payload decoder query

Hi All,
I have recently migrated from V2 where I had a gateway and a GPS end device running , This was fine with the device being visable on “Advanced maps”.
Now having migrated to V3 my device is no longer visable , and I think it it is the payload decoder ,
being honest , I copied and pasted the old decoder into the new decoder area.

Is that where I went wrong ? below is the decoder. Any help , greatly appreciated .

function Decoder(b, port) {

var lng = (b[0] | b[1]<<8 | b[2]<<16 | (b[2] & 0x80 ? 0xFF<<24 : 0)) / 10000;

var lat = (b[3] | b[4]<<8 | b[5]<<16 | (b[5] & 0x80 ? 0xFF<<24 : 0)) / 10000;

return {

location: {

longitude: lng,

latitude: lat

},

G7NSJ : "Seismet Test_Node "

};

}

Assuming this is not a stack question but actually related to TTN Mapper …

If you read the docs on the TTN Mapper website you’ll see that it’s not ready for v3 yet.

Ah, ok thanks for the info… I will sit back and keep an eye on it. Thanks again.

Having had the payload formatter and decoder working correctly on V2 (GPS Node showing on TTN mapper ) , now I have registered my GW to V3.
I have populated the V3 payload format fields with the decoder script that worked on V2 and added the “adapter” to the bottom of said script . The adapter was taken from
https://www.thethingsnetwork.org/community/munich/post/using-ttn-v2-payload-decode-functions-with-ttn-v3

The odd thing is a few weeks back the decoder worked on V3, however it now refuses to decode the payload.
Has anything changed in V3 recently that would produce this result or could it be I have some codeing wrong.
I can confirm the payload decoder alone works on V2 .

Any help would be greatly appreciated .

Yes, but hard to tell without any details on your code and not just the wrapper, which isn’t required as v3 actually supports v2 format as well.

Hi Nick,
Thanks for the prompt reply
Not sure what you mean about a “Wrapper” however here is my payload followed by the decoder script

4F9AFF650108342C35322E3436343600000000

 function Decoder(b, port) {


var lng = (b[0] | b[1]<<8 | b[2]<<16 | (b[2] & 0x80 ? 0xFF<<24 : 0)) / 10000;

var lat  = (b[3] | b[4]<<8 | b[5]<<16 | (b[5] & 0x80 ? 0xFF<<24 : 0)) / 10000;

return {

location: {

longitude: lng,

latitude: lat

},

Woodbank : "**Seismet** Test_Node "

};

}
function decodeUplink(input) {
  var data = input.bytes;
  var valid = true;

  if (typeof Decoder === "function") {
    data = Decoder(data, input.fPort);
  }

  if (typeof Converter === "function") {
    data = Converter(data, input.fPort);
  }

  if (typeof Validator === "function") {
    valid = Validator(data, input.fPort);
  }

  if (valid) {
    return {
      data: data
    };
  } else {
    return {
      data: {},
      errors: ["Invalid data received"]
    };
  }
}

The lower section below “Woodbank” is the adapter form the link in previous post , and I confirm when I fist set it up in V3 it did decode the payload.

Using the above payload and decoder only, and in the V2 stack it does decode ok ?

I suspect its down to my joining snippits together and relating to these things { and } .
I am not a coder but am trying to make sense of it all .

Best regards

Moderator Edit: Moved mouse to </> on toolbar to format code …

The extra code from the Munich blog - the one that wraps up the v2 code to make it v3 like.

That’s getting a bit old and is up there with the “I’m not good with Maths” grin. What level of coder do you have to be before you stop saying that?

Anyway, works for me, both with & without the “wrapper” - but I’d have expected it to break as how would it know which function to call? The v2 or the v3 one?

I get:

  "decoded_payload": {
    "Woodbank": "**Seismet** Test_Node ",
    "location": {
      "latitude": 52.4645,
      "longitude": -2.6033
    }
  }

so , are you saying that it decodes in V3 ?
which is what I am trying to get it to do (it works fine in V2 then also in V3 till it broke)

By saying I am not a coder,
I meant I cant write the code but when I see it written down some parts I understand which I suppose is how we all started ! Maybe ?

If you understand it there is nothing stopping you from trying to write it.

If you want to do these sorts of things, how much easier if you knew a bit of code, I mean, if super models can learn and, most importantly, are motivated to learn

Yes, that helps alot, thanks.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.