From c049e62c874efcae34bbce9e01d4b9829217b0b1 Mon Sep 17 00:00:00 2001 From: Peng Li Date: Fri, 22 Jun 2018 16:26:16 +0800 Subject: [PATCH] fix mac address id --- mqtt-client.py | 4 +++- suanzi-support | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mqtt-client.py b/mqtt-client.py index cbc7cd4..59eff28 100644 --- a/mqtt-client.py +++ b/mqtt-client.py @@ -21,7 +21,9 @@ if __name__ == '__main__': def on_message(client, userdata, msg): print(msg.topic+" "+str(msg.payload)) if msg.topic == id + '-response': - print 'port is', str(msg.payload) + port = msg.payload + print 'port is', str(port) + print 'run ssh user@autossh.suanzi.ai -p ' + str(port) + ' to connect to ' + id + ' device' client = mqtt.Client() client.on_connect = on_connect diff --git a/suanzi-support b/suanzi-support index 8809b05..d016b06 100755 --- a/suanzi-support +++ b/suanzi-support @@ -67,7 +67,7 @@ class MyClient(mqtt.Client): if __name__ == '__main__': mac = hex(get_mac()) - id = os.getenv('USER') + '-' + '{:0>12}'.format(mac[2:13]) + id = os.getenv('USER') + '-' + '{:0>12}'.format(mac[2:-1]) print 'id is: ' , id client = MyClient(id) client.connect(MQTT_SERVER, MQTT_PORT, 60) -- 2.11.0