Lopy LoRa socket timeout
-
Hi, I’m noob with python and lora, I want to open a socket wait for a message, if there is no message then do something else, my code so far is:
from network import LoRa import socket import machine import time import binascii import network n = 0 try: the_sock = socket.socket(socket.AF_LORA, socket.SOCK_RAW) except: exit('Error creating socket.') the_sock.settimeout(5) while True: try: n+=1 print("Hola"+str(n)) the_sock.setblocking(True) ack = the_sock.recv(64) except socket.timeout, e: err = e.args[0] print(err) break`
The problem is that the timeout it’s not working, I’ve checked some answers but the code looks good to me, can you help me please?
Kind Regards
-
@livius Thank you so much!!! that's exactly what I needed
-
@ahelllycan
change this tothe_sock.settimeout(5) ack = the_sock.recv(64)
setblocking is only shortcut for timeout
if you settimeout first and then setblocking you change timeout to nonesummary
settimeout(None)
==setblocking(True)
settimeout(0)
==setblocking(False)
settimeout(5)
--- no equivalent in setblocking