T
while (True):
recv_pkg = lora_sock.recv(512)
time.sleep(0.2)
if(len(recv_pkg) > 13):
print(recv_pkg)
recv_pkg_len = recv_pkg[12]
# unpack the message based on protocol definition
dest_addr, src_addr, pkg_len, msg = struct.unpack(_LORA_PKG_FORMAT % recv_pkg_len, recv_pkg)
if(dest_addr==SRC_ADDR):
ack_pkg = struct.pack(_LORA_ACK_FORMAT, src_addr, SRC_ADDR, 1, 200)
lora_sock.send(ack_pkg)
else:
print("Message lost")