LoRa packet sniffer in LoPy?
-
Hi all,
I'm trying to debug some issues with a LoRa node (Dragino LSN50) not receiving any downlinks from my gateway (Mikrotik RBwAPR-2nD). I tested downlinks to my LoPy and that works fine, so I'm kind of guessing it may be a timing issue. Now I'd like to use my LoPy as a packet sniffer so that I can check the timings of the packets from the air. I would expect this to be possible from my LoPy, but looking around at the API documentation I'm not sure how.
The most basic test that I could come up with (with my very limited knowledge about LoRa) didn't yield anything:
from network import LoRa import socket lora = LoRa(mode=LoRa.LORA, public=True) lora.add_channel(0, frequency=864862500, dr_min=0, dr_max=5) lora.add_channel(1, frequency=865062500, dr_min=0, dr_max=5) lora.add_channel(2, frequency=865402500, dr_min=0, dr_max=5) lora.add_channel(3, frequency=865602500, dr_min=0, dr_max=5) lora.add_channel(4, frequency=865985000, dr_min=0, dr_max=5) lora.add_channel(5, frequency=866200000, dr_min=0, dr_max=5) lora.add_channel(6, frequency=866400000, dr_min=0, dr_max=5) lora.add_channel(7, frequency=866600000, dr_min=0, dr_max=5) s = socket.socket(socket.AF_LORA, socket.SOCK_RAW) s.setsockopt(socket.SOL_LORA, socket.SO_DR, 0) s.setblocking(True) while True: print(s.recv(1))
Does anyone have any experience with this?
Thanks,
Marten
-
@jcaron Thanks a lot for your help. However, I just found out that my gateway wasn't on the latest version of the firmware. Upgrading to v6.46.4 solved my problem. It seems like due to some reason TTN chooses to use RX1 for my LoPy and RX2 for my LSN50s. I'm guessing there was some kind of issue with the RX2 in the previous version of the firmware.
-
@martenjacobs The timing is weird... RX2 should be 2 seconds after TX, not 1, though with a one-second precision this is hard to tell. But indeed, listening on 869525000 at SF 9 should allow you to "catch" those.
Note that TTN uses SF9 rather than the default SF12 for RX2, so if the node uses OTAA it needs to correctly handle the MAC commands that tell it so (and correctly save that information across sleep periods and reboots -- that was an issue on early versions of the LoPy firmware). If the node uses ABP, you need to configure the node explicitly.
-
@jcaron said in LoRa packet sniffer in LoPy?:
This makes sniffing LoRaWAN difficult, as downlinks in RX1 are sent on the same channel and DR the uplink was sent, which is usually dynamic.
Right, that makes sense. However, in my case (no idea why) it seems the TTN is always using RX2 for these nodes
So that would mean only sniffing 869525000 Hz could already tell me something.
-
@martenjacobs Remember that a LoPy can only listen on one channel and DR at a time. If you use raw LoRa (as opposed to LoRaWAN) you'll have to specify the frequency, DR, bandwidth etc. you want to listen on.
This makes sniffing LoRaWAN difficult, as downlinks in RX1 are sent on the same channel and DR the uplink was sent, which is usually dynamic.