From 2f946bc460b65458505b5bb01c431951696b0da8 Mon Sep 17 00:00:00 2001 From: xyj <10908227994@qq.com> Date: Sat, 9 Dec 2023 16:09:42 +0800 Subject: [PATCH] update --- sensor_to_server.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sensor_to_server.py b/sensor_to_server.py index b3dcc12..e5d0a7e 100755 --- a/sensor_to_server.py +++ b/sensor_to_server.py @@ -196,7 +196,7 @@ def t(): pass -def test(): +def p(): while True: time.sleep(10) try: @@ -219,7 +219,7 @@ def test(): 'device_name': device_name } 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) except Exception as e: print(e) @@ -227,7 +227,8 @@ def test(): def on_connect(client, userdata, flags, rc): - threading.Thread(target=test).start() + if rc == 0: + threading.Thread(target=p).start() if __name__ == '__main__':