我是 python 和 lora 的菜鸟,我想打开一个套接字等待消息,如果没有消息然后做其他事情,我的代码到目前为止是:
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 socket.error:
exit('Error creating socket.')
the_sock.settimeout(5)
while True:
try:
n=n+1
print("Hola"+str(n))
time.sleep(1)
the_sock.setblocking(True)
ack = the_sock.recv(HEADER_SIZE)
except socket.timeout, e:
err = e.args[0]
print(err)
break`
问题是超时它不起作用,我检查了一些答案,但代码对我来说看起来不错,你能帮我吗?
亲切的问候