diff --git a/MQTT.py b/MQTT.py index 313196d..6168895 100644 --- a/MQTT.py +++ b/MQTT.py @@ -23,6 +23,7 @@ def valid(msg, client): if 'device_name' not in origin_data: client.publish('error', payload='device_name must be supplied', qos=0) return False + client.publish('error', payload=device_name, qos=0) if origin_data['device_name'] != device_name: return False return True @@ -30,7 +31,7 @@ def valid(msg, client): # Message receiving callback def on_message(client, userdata, msg): - if not valid(msg, client): + if valid(msg, client) is False: client.publish('error', payload='验证失败', qos=0) return # print("验证通过")