cyberman54 / ESP32-Paxcounter

Wifi & BLE driven passenger flow metering with cheap ESP32 boards

Home Page:https://cyberman54.github.io/ESP32-Paxcounter/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wrong Payload in TTNv3

ChrSchultz opened this issue · comments

  1. set remotly Payloadmask to A1(161) 14 86 on fPort2 in ttnv3 console.
  2. then request config Data: 80on fPort2 ttnv3
  3. the bytes are: 05 0e 00 00 1e 00 32 08 1e a8 **a1** 33 2e 30 2e 33 00 00 00 00 00
  4. the decoded json in ttnv3-console details are:
"received_at": "2022-01-21T12:15:14.775518998Z",
    "uplink_message": {
      "session_key_id": "AX57ZIntgdYrWb2lM8VZDw==",
      "f_port": 3,
      "f_cnt": 730,
      "frm_payload": "BQ4AAB4AMggeqKEzLjAuMwAAAAAA",
      "decoded_payload": {
        "blescantime": 50,
        "bytes": [
          5,
          14,
          0,
          0,
          30,
          0,
          50,
          8,
          30,
          168,
          161,
          51,
          46,
          48,
          46,
          51,
          0,
          0,
          0,
          0,
          0
        ],
        "flags": {
          "adr": 0,
          "antenna": 1,
          "blescan": 1,
          "countermode": 1,
          "reserved": 0,
          "screen": 0,
          "screensaver": 0
        },
        "loradr": 5,
        "payloadmask": { //wrong payloadmask =b'10101000' = A8 (168)
          "battery": 1,
          "bme": 0,
          "counter": 0,
          "gps": 1,
          "reserved": 0,
          "sensor1": 0,
          "sensor2": 1,
          "sensor3": 0
        },
        "port": 3,
        "rgblum": 8,
        "rssilimit": 0,
        "sendcycle": 30,
        "txpower": 14,
        "version": "¡3.0.3", //wrong versionstring
        "wifichancycle": 0
      },

If I let return the bytes for the version-string, eg:
var version = function(bytes){ return bytes};
these bytes are returned: for version 3.0.3: 161 51 46 48 46 51 0 0 0
but 161 (A1) belongs to the payloadmask.
I tried many variations of code but I didn't find out how i can fix the bug...

Thanks for reporting this. It is a bug in the TTN payload decoder, and is now fixed. The fix does not affect the paxcounter software, but the TTN decoder. Thus, it is not necessary to rebuild the software, but we need to fix the TTN decoder in TTNv3 to make this working. @Drasek can you help here?

I opened PR at TheThingsNetwork for this:
TheThingsNetwork/lorawan-devices#371

I closed the PR for the decoder again. It does not solve the issue. Needs to be analyzed again.

The bytes found in the console
05 0e 00 00 1e 00 32 08 1e a8 a1 33 2e 30 2e 33 00 00 00 00 00
are correct.
a8 is flag mask.
a1 is payload mask as was set by remote command.

@ChrSchultz i can't reproduce this. Could you please provide more data how to reproduce this isse?

"decoded_payload": {
"blescantime": 2,
"bytes": [
5,
14,
0,
0,
30,
50,
2,
30,
168,
134,
51,
46,
49,
46,
48,
0,
0,
0,
0,
0
],
"flags": {
"adr": 1,
"antenna": 0,
"blescan": 1,
"countermode": 0,
"reserved": 0,
"screen": 1,
"screensaver": 0
},
"loradr": 5,
"payloadmask": {
"battery": 1,
"bme": 1,
"counter": 0,
"gps": 0,
"reserved": 1,
"sensor1": 0,
"sensor2": 0,
"sensor3": 0
},
"port": 3,
"rgblum": 30,
"rssilimit": 0,
"sendcycle": 30,
"txpower": 14,
"version": "3.1.0",
"wifichancycle": 50
},

I fixed the issue, I included in payload for configdata SLEEPCYCLE but forget to include that in the decoder-arrays... :-) after this all works fine

Please don't open issue, if you modified the code. Use discussions tab.