diff --git a/MQTT.py b/MQTT.py index 7eb9bad..313196d 100644 --- a/MQTT.py +++ b/MQTT.py @@ -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)