diff --git a/MQTT.py b/MQTT.py index 29ddd8e..c943430 100644 --- a/MQTT.py +++ b/MQTT.py @@ -30,7 +30,7 @@ def on_message(client, userdata, msg): # print("验证通过") import os # device_name = os.environ['device_name'] - # client.publish('error', payload=device_name, qos=0) + client.publish('error', payload=device_name, qos=0) # client.publish('success', payload='验证通过', qos=0) try: origin_data = json.loads(msg.payload.decode('utf-8')) @@ -69,8 +69,9 @@ times = 120 def exec_shutdown(): pass - +import os if __name__ == '__main__': + device_name = os.environ.get('device_name') while True: try: client = mqtt.Client(client_id='s')