update
This commit is contained in:
parent
28cdd733bc
commit
24be9201aa
3
MQTT.py
3
MQTT.py
|
@ -13,6 +13,7 @@ def on_connect(client, userdata, flags, rc):
|
||||||
|
|
||||||
# Message receiving callback
|
# Message receiving callback
|
||||||
def on_message(client, userdata, msg):
|
def on_message(client, userdata, msg):
|
||||||
|
try:
|
||||||
data = json.loads(msg.payload.decode('utf-8'))["msg"]
|
data = json.loads(msg.payload.decode('utf-8'))["msg"]
|
||||||
if data == "push_stream":
|
if data == "push_stream":
|
||||||
# 启动推流视频
|
# 启动推流视频
|
||||||
|
@ -38,6 +39,8 @@ def on_message(client, userdata, msg):
|
||||||
else:
|
else:
|
||||||
# 错误类型
|
# 错误类型
|
||||||
client.publish('success', payload='No Such Type', qos=0)
|
client.publish('success', payload='No Such Type', qos=0)
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
times = 120
|
times = 120
|
||||||
|
|
|
@ -35,6 +35,7 @@ def t():
|
||||||
windspeed_send = bytes.fromhex(windspeed_send)
|
windspeed_send = bytes.fromhex(windspeed_send)
|
||||||
winddirection_send = bytes.fromhex(winddirection_send)
|
winddirection_send = bytes.fromhex(winddirection_send)
|
||||||
while True:
|
while True:
|
||||||
|
try:
|
||||||
# if ser.is_open:
|
# if ser.is_open:
|
||||||
ser.write(temp_send)
|
ser.write(temp_send)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
@ -187,6 +188,9 @@ def t():
|
||||||
t2 = LOT_DATA(**data)
|
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)
|
add(t2)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def on_connect(client, userdata, flags, rc):
|
def on_connect(client, userdata, flags, rc):
|
||||||
|
|
Loading…
Reference in New Issue