This commit is contained in:
xyj 2023-12-09 16:09:42 +08:00
parent 3107d92359
commit 2f946bc460
1 changed files with 4 additions and 3 deletions

View File

@ -196,7 +196,7 @@ def t():
pass pass
def test(): def p():
while True: while True:
time.sleep(10) time.sleep(10)
try: try:
@ -219,7 +219,7 @@ def test():
'device_name': device_name 'device_name': device_name
} }
t2 = LOT_DATA(**data) t2 = LOT_DATA(**data)
# client.publish('demo', payload=json.dumps(data, ensure_ascii=False), qos=0) client.publish('demo', payload=json.dumps(data, ensure_ascii=False), qos=0)
add(t2) add(t2)
except Exception as e: except Exception as e:
print(e) print(e)
@ -227,7 +227,8 @@ def test():
def on_connect(client, userdata, flags, rc): def on_connect(client, userdata, flags, rc):
threading.Thread(target=test).start() if rc == 0:
threading.Thread(target=p).start()
if __name__ == '__main__': if __name__ == '__main__':