fix mac address id
authorPeng Li <seudut@gmail.com>
Fri, 22 Jun 2018 08:26:16 +0000 (16:26 +0800)
committerPeng Li <seudut@gmail.com>
Fri, 22 Jun 2018 08:26:16 +0000 (16:26 +0800)
mqtt-client.py
suanzi-support

index cbc7cd4..59eff28 100644 (file)
@@ -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
index 8809b05..d016b06 100755 (executable)
@@ -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)