This commit is contained in:
xyj 2023-12-07 18:34:52 +08:00
parent bee6cae883
commit 25ba5058f7
1 changed files with 5 additions and 6 deletions

11
MQTT.py
View File

@ -30,11 +30,11 @@ def valid(msg, client):
# Message receiving callback
def on_message(client, userdata, msg):
# if not valid(msg, client):
# # print("验证失败")
# return
# # print("验证通过")
# client.publish('error', payload='通过', qos=0)
if not valid(msg, client):
client.publish('error', payload='验证失败', qos=0)
return
# print("验证通过")
client.publish('success', payload='验证通过', qos=0)
try:
origin_data = json.loads(msg.payload.decode('utf-8'))
data = origin_data["msg"]
@ -59,7 +59,6 @@ def on_message(client, userdata, msg):
elif data == "status":
# 查看运行状态
get_status(client)
client.publish('error', payload='No Such Type2', qos=0)
else:
# 错误类型
client.publish('error', payload='No Such Type', qos=0)