From 28cdd733bc95cce385caae6741d6b154cecda96d Mon Sep 17 00:00:00 2001 From: xyj <10908227994@qq.com> Date: Thu, 7 Dec 2023 09:20:44 +0800 Subject: [PATCH] update --- MQTT.py | 4 ++-- ceshi.py | 4 ++-- sensor_to_server.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/MQTT.py b/MQTT.py index 18ba250..b3732c7 100644 --- a/MQTT.py +++ b/MQTT.py @@ -48,7 +48,6 @@ def exec_shutdown(): if __name__ == '__main__': - while True: try: client = mqtt.Client(client_id='device1') @@ -58,10 +57,11 @@ if __name__ == '__main__': client.on_message = on_message # Establish a connection # ceshi-mqtt.lihaink.cn - client.connect('ceshi-mqtt.lihaink.cn', 1883) + client.connect('192.168.1.27', 1883) # Publish a message client.loop_forever() except: + print("等待30秒连接") time.sleep(30) if times == 0: # 重启机器 diff --git a/ceshi.py b/ceshi.py index c9ae694..f0cc69c 100644 --- a/ceshi.py +++ b/ceshi.py @@ -35,11 +35,11 @@ if __name__ == '__main__': client.on_connect = on_connect client.on_connect_fail = on_connect_fail # Establish a connection - client.connect('ceshi-mqtt.lihaink.cn', 1883) + client.connect('192.168.1.27', 1883) # Publish a message client.loop_forever() except Exception as e: - # print("等待5秒重新连接客户端") + print("等待5秒重新连接客户端") time.sleep(5) if times != 0: times -= 1 diff --git a/sensor_to_server.py b/sensor_to_server.py index 8b3ad73..37f275e 100644 --- a/sensor_to_server.py +++ b/sensor_to_server.py @@ -200,6 +200,6 @@ if __name__ == '__main__': client.on_connect = on_connect # Establish a connection # ceshi-mqtt.lihaink.cn - client.connect('ceshi-mqtt.lihaink.cn', 1883) + client.connect('192.168.1.27', 1883) # Publish a message client.loop_forever()