mcci-catena/arduino-lmic

The "Margin" field of the "DevStatusAns" command payload is wrongly encoded

frazar opened this issue · 3 comments

Tested with Arudino Mega 2560 connected to RFM95 module.

Add the following two lines to project_config/lmic_project_config.h:

#define LMIC_DEBUG_LEVEL 2
#define LMIC_PRINTF_TO Serial

After running a slightly modified version of the ttn-otaa sketch, this is the output on the Serial.

Serial connection enstablished.
RXMODE_RSSI
62657: engineUpdate, opmode=0x808
Packet queued
62708: EV_JOINING
62778: engineUpdate, opmode=0xc
273627: engineUpdate, opmode=0xc
273909: EV_TXSTART
273934: engineUpdate, opmode=0x88c
273992: TXMODE, freq=868100000, len=23, SF=7, BW=125, CR=4/5, IH=0
582073: setupRx1 txrxFlags 00 --> 01
start single rx: now-rxtime: 6
582161: RXMODE_SINGLE, freq=868100000, SF=7, BW=125, CR=4/5, IH=0
593337: EV_JOINED
netid: 0
devaddr: XXXXXXXX
artKey: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
nwkKey: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
593699: engineUpdate, opmode=0x808
594248: EV_TXSTART
594274: engineUpdate, opmode=0x888
594393: TXMODE, freq=868100000, len=19, SF=7, BW=125, CR=4/5, IH=0
653595: setupRx1 txrxFlags 0x1 --> 01
start single rx: now-rxtime: 4294967238
653657: RXMODE_SINGLE, freq=868100000, SF=7, BW=125, CR=4/5, IH=0
662938: process options (olen=0x6)
662975: LinkAdrReq: p1:52 chmap:0007 chpage:00 uprt:01 ans:87
663116: decodeFrame txrxFlags 0x1 --> 21
663333: Received downlink, window=RX1, port=-1, ack=0, txrxFlags=0x21
663705: EV_TXCOMPLETE (includes waiting for RX windows)
664010: engineUpdate, opmode=0x800
1289010: engineUpdate, opmode=0x808
1289466: EV_TXSTART
1289495: engineUpdate, opmode=0x888
1289554: TXMODE, freq=868300000, len=24, SF=7, BW=125, CR=4/5, IH=0
Packet queued
1349396: setupRx1 txrxFlags 0x21 --> 01
start single rx: now-rxtime: 4294967238
1349463: RXMODE_SINGLE, freq=868300000, SF=7, BW=125, CR=4/5, IH=0

Basically we can see that the Node is able to join the Lora network (593337: EV_JOINED), but fails to send the first uplink packet and keeps retrying.

Logging on the AWG ubuntu machine and checking the logs with journalctl -f -u loraserver I noticed the following lines appearing right after the node sends the "Packet queued" message:

Sep 24 20:20:15 ip-172-31-45-153 loraserver[18826]: time="2018-09-24T20:20:15Z" level=error msg="processing uplink frame error" data_base64=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX error="create uplink frame-log error: marshal phypayload error: lorawan: max value of Margin is 31"

I take it that this is not "The Things Network" as the network server? Definitely agree that this is a problem, but I need more context, as I've not seen this in my testing. (Need to figure out what additional test coverage is needed.)

Yes, sorry for not being clear enough. I'm using the LoRa Server software stack in a development environment.

OK, cool! Another test case.... Interesting to think about how one could do hardware-in-the-loop testing with this.

You will probably find that this version of the LMIC stack doesn't do a great job with MAC command responses. See issue #87 for details. TL;DR: it doesn't built the response as it's parsing the request, so things can go back out of order (or not at all).