How to extract Device Address from Payload ?
-
Hi everyone !
I need to know how to extract the device address from the payload ?
data = s.recv(64)
I use this one to receive data. Once the data is received, I have to extract the packet. Once extracting, I have to check with my list.
Sorry for posting this again, I am just confused with this.
Thank you in Advance.
-
@robert-hh Thank you so much ! I got the output.
-
@harish-kumar Actually it is the second to fifth byte in big endian format. So if you receive data from the socket, e.g.:
rx_data = lora_sock.recv(256) dev_addr = rx_data[1:5] print("Dev-Addr: ", ubinascii.hexlify(dev_addr))
-
@harish-kumar it should be hexlify(). I just try to verify my post.
-
@robert-hh you mean like once I get the data, I have to convert it and I have to compare ?
Is ubinascii.bin2hex() for extracting from payload ?If not, what is the command for extracting ?
-
@harish-kumar As far as I understand the LoRa Spec, the Dev address is contained in the first four bytes of the payload. You may extract it from there and use it for comparison. Depending on how your reference list is formatted, you may have to convert it, eg. with ubinascii.bin2hex().