Connect LoPy LoRa with Semtech Board
I am trying to connect Semtech LoRa development board with LoPy. I am sending 9 bytes of payload from Semtech board each 2 seconds. Format of the packet that is sent from Semtech board is: first 4 bytes are unsigned int (used for packet ID), other 5 bytes are dummy.
I am able to receive packets on LoPy, but with following problems:
- Not able to receive each packet, but every second (packet loss is 50%)
- Able to extract packet ID properly only if reading first two bytes: _LORA_PKG_FORMAT = "H" (unsigned short int, 2 bytes). If I put _LORA_PKG_FORMAT = "I" (unsigned int, 4 bytes), it is decoded as garbage.
Code that I used for reception is given below:
from network import LoRa
_LORA_PKG_FORMAT = "I"
lora = LoRa(mode=LoRa.LORA,
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
rxBuf = s.recv(9)
if (len(rxBuf) > 0)
rxData = struct.unpack(_LORA_PKG_FORMAT, rxBuf)
Does anyone have an idea what should be done to receive each packet and to properly decode all four bytes?