Identify count of devices connecting to Gateway

Hi
This may be deliberate-but I’d like to know from the logs of my test single channel gateway how many different devices are connecting to it (I intend to deploy into the local neighborhood, but want to see if its worthwhile).i can see this from the web console but not from the CLI of my gateway

journalctl -f -a -u dual_chan_pkt_fwd | grep freq
Nov 12 09:48:20 RPI3-2-LoraWAN-Gateway-Greystone dual_chan_pkt_fwd[1142]: rxpk update: {“rxpk”:[{“tmst”:2581672676,“freq”:868.3,“chan”:1,“rfch”:0,“stat”:1,“modu”:“LORA”,“datr”:“SF7BW125”,“codr”:“4/5”,“rssi”:-70,“lsnr”:9.0,“size”:21,“data”:“QPMSASYATwABQ/3uhD/IFdIpyXsZ”}]}
Nov 12 09:49:30 RPI3-2-LoraWAN-Gateway-Greystone dual_chan_pkt_fwd[1142]: rxpk update: {“rxpk”:[{“tmst”:2651682102,“freq”:868.3,“chan”:1,“rfch”:0,“stat”:1,“modu”:“LORA”,“datr”:“SF7BW125”,“codr”:“4/5”,“rssi”:-71,“lsnr”:9.0,“size”:21,“data”:“QPMSASYAVgABbCDLYt8/gJetAWBN”}]}

Is it possible to do this using the likes of journalctl -f -a -u dual_chan_pkt_fwd | grep freq ?

Cheers

cabs

The following is not really accurate, as a DevAddr is not unique, and you’d need to know each device’s secret NwkSKey to uniquely identify a device. But it’s a start:

  • Convert the Base64-encoded raw packet to a binary or hexadecimal representation, like QPMSASYATwABQ/3uhD/IFdIpyXsZ equals 40F3120126004F000143FDEE843FC815D229C97B19.
  • Take the first byte and see if that denoted an uplink.
  • If yes, take bytes 2 through 5 to get the DevAddr (LSB); F3120126 in the example above.
  • Count the unique occurrences of DevAddr.

As your gateway will forward any packet it receives, including plain LoRa that is not using LoRaWAN, and including packets for other operators, you might want to limit counting to a DevAddr that starts with 0x26 or 0x27 (in LSB look at the 4th byte of the DevAddr). A decoding library such as https://github.com/anthonykirby/lora-packet might help decoding the non-encrypted parts of the raw packet.

1 Like

Thank you very much, that sounds like I have something to work on!

Cheers

Cabs