update
This commit is contained in:
parent
95bca848c9
commit
d9db4ee8bd
13
MQTT.py
13
MQTT.py
|
@ -71,13 +71,12 @@ def exec_shutdown():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
client = mqtt.Client(client_id=device_name)
|
||||||
client = mqtt.Client(client_id=device_name)
|
client.username_pw_set("demo", "123456")
|
||||||
client.username_pw_set("demo", "123456")
|
# Specify callback function
|
||||||
# Specify callback function
|
client.on_connect = on_connect
|
||||||
client.on_connect = on_connect
|
# 尝试连接 MQTT 服务器
|
||||||
# 尝试连接 MQTT 服务器
|
while True:
|
||||||
while True:
|
|
||||||
try:
|
try:
|
||||||
# ceshi-mqtt.lihaink.cn
|
# ceshi-mqtt.lihaink.cn
|
||||||
client.connect('192.168.1.27', 1883)
|
client.connect('192.168.1.27', 1883)
|
||||||
|
|
|
@ -19,17 +19,16 @@ def on_disconnect(client, userdata, rc):
|
||||||
print("失败,执行本地存储")
|
print("失败,执行本地存储")
|
||||||
# subprocess.Popen(['/usr/bin/bash /home/pi/lot_manager/bash/stop_data_upload.sh'], shell=True)
|
# subprocess.Popen(['/usr/bin/bash /home/pi/lot_manager/bash/stop_data_upload.sh'], shell=True)
|
||||||
|
|
||||||
|
|
||||||
times = 3
|
times = 3
|
||||||
|
|
||||||
if __name__ == '__main__':
|
client = mqtt.Client(client_id=device_name)
|
||||||
client = mqtt.Client(client_id=device_name)
|
client.username_pw_set("demo", "123456")
|
||||||
client.username_pw_set("demo", "123456")
|
# Specify callback function
|
||||||
# Specify callback function
|
client.on_connect = on_connect
|
||||||
client.on_connect = on_connect
|
client.on_disconnect = on_disconnect
|
||||||
client.on_disconnect = on_disconnect
|
|
||||||
# 尝试连接 MQTT 服务器
|
# 尝试连接 MQTT 服务器
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
# ceshi-mqtt.lihaink.cn
|
# ceshi-mqtt.lihaink.cn
|
||||||
client.connect('192.168.1.27', 1883)
|
client.connect('192.168.1.27', 1883)
|
||||||
|
|
Loading…
Reference in New Issue