TTN Node - link check does not work?

Ah, finally unpacked my The Things Node to test it myself :wink:

It seems you need to call ttn.linkCheck(interval) after you’ve joined. So, this works for me:

ttn.join(appEui, appKey);

// Set the time interval in seconds for the link check process to be triggered;
// 0 will disable the link check process. When the time interval expires, the
// next application packet that will be sent to the server will include also a
// link check MAC command in the LoRaWAN FOpts field.
uint16_t interval = 1;
ttn.linkCheck(interval); 

Of course, interval = 1 is just for testing.

This yields, e.g., 40DA22012601080002020A3B48DAB7EFC8B9A7461D249E being:

      ( FHDR = DevAddr[4] | FCtrl[1] | FCnt[2] | FOpts[0..15] )
     DevAddr = 260122DA (Big Endian)
       FCtrl = 01
        FCnt = 0008 (Big Endian)
       FOpts = 02

Here, FCtrl indicates that there’s 1 byte in FOpts:

And that one byte is a LinkCheckReq:

The response is, e.g., 60DA2201260307000210016C6E99E6, or:

      ( FHDR = DevAddr[4] | FCtrl[1] | FCnt[2] | FOpts[0..15] )
     DevAddr = 260122DA (Big Endian)
       FCtrl = 03
        FCnt = 0007 (Big Endian)
       FOpts = 021001

Here, the 0x02 in 021001 decodes to LinkCheckAns, along with:

So, 0x10 = margin = 16 dB, and 0x01 = gateway count = 1.

Enjoy :slight_smile:

3 Likes