update
This commit is contained in:
parent
9ac576d57b
commit
28cdd733bc
4
MQTT.py
4
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:
|
||||
# 重启机器
|
||||
|
|
4
ceshi.py
4
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
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue