From 4d8ece6847477353d60237b377adb449ed707331 Mon Sep 17 00:00:00 2001 From: xyj <10908227994@qq.com> Date: Tue, 5 Dec 2023 17:00:32 +0800 Subject: [PATCH] update --- ceshi.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ceshi.py b/ceshi.py index 59a2a86..e675dcd 100644 --- a/ceshi.py +++ b/ceshi.py @@ -16,26 +16,26 @@ def on_connect(client, userdata, flags, rc): global times if rc == 0: print("连接成功,执行数据推送和本地存储") - subprocess.Popen(["supervisorctl stop sensor_to_local && supervisorctl start sensor_to_server"], shell=True) + subprocess.Popen(['/usr/bin/bash start_data_upload'], shell=True) times = 3 def on_connect_fail(client, userdata): print("失败,执行本地存储") - subprocess.Popen(["supervisorctl stop sensor_to_server && supervisorctl start sensor_to_local"], shell=True) + subprocess.Popen(['/usr/bin/bash stop_data_upload'], shell=True) times = 3 if __name__ == '__main__': while True: try: - client = mqtt.Client(transport="websockets") + client = mqtt.Client() client.username_pw_set("demo", "123456") # Specify callback function client.on_connect = on_connect client.on_connect_fail = on_connect_fail # Establish a connection - client.connect('ceshi-mqtt.lihaink.cn', 8083) + client.connect('ceshi-mqtt.lihaink.cn', 1883) # Publish a message client.loop_forever() except Exception as e: