Skip to content

Commit 05a782e

Browse files
committed
Update of 'get_client_id()' in hal.py in order to individualize client_id by adding MAC address for Linux and Windows.
1 parent 8095d31 commit 05a782e

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

LiveObjects/hal.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# This software is distributed under the terms and conditions of the 'MIT'
55
# license which can be found in the file 'LICENSE.md' in this package distribution
66

7-
import os
87
import time
98
import sys
109

@@ -29,7 +28,7 @@ def get_apikey(self):
2928
return self._credentials.get_apikey()
3029

3130
def get_client_id(self):
32-
return self.get_lang_str() + 'MQTT'
31+
pass
3332

3433
def get_lang_str(self):
3534
lang_dict = {BoardsInterface.PYTHON: 'Python',
@@ -76,6 +75,9 @@ def get_security_level(self):
7675
if self._net_type == BoardsInterface.WIFI:
7776
return LiveObjects.SSL if self._wifi_tls_capability else LiveObjects.NONE
7877

78+
def get_client_id(self):
79+
return self.get_lang_str() + 'MQTT'
80+
7981

8082
class GPy(BoardsInterface):
8183
def __init__(self, net_type):
@@ -101,6 +103,8 @@ def get_security_level(self):
101103
elif self._net_type == BoardsInterface.LTE:
102104
return LiveObjects.SSL if self._lte_tls_capability else LiveObjects.NONE
103105

106+
def get_client_id(self):
107+
return self.get_lang_str() + 'MQTT'
104108

105109
class Esp8266(BoardsInterface):
106110
def __init__(self, net_type):
@@ -117,6 +121,9 @@ def connect(self):
117121
def get_security_level(self):
118122
return LiveObjects.SSL if self._wifi_tls_capability else LiveObjects.NONE
119123

124+
def get_client_id(self):
125+
return self.get_lang_str() + 'MQTT'
126+
120127

121128
class Win32(BoardsInterface):
122129
def __init__(self, net_type):
@@ -141,6 +148,10 @@ def get_store_cert_filename(self):
141148
print("[ERROR] U have missing library 'python-certifi-win32'")
142149
sys.exit()
143150

151+
def get_client_id(self):
152+
import uuid
153+
return self.get_lang_str() + 'MQTT_' + (''.join(['{:02x}'.format((uuid.getnode() >> ele) & 0xff) for ele in range(0,8*6,8)][::-1]))
154+
144155

145156
class Esp32(BoardsInterface):
146157
def __init__(self, net_type):
@@ -157,6 +168,9 @@ def connect(self):
157168
def get_security_level(self):
158169
return LiveObjects.SSL if self._wifi_tls_capability else LiveObjects.NONE
159170

171+
def get_client_id(self):
172+
return self.get_lang_str() + 'MQTT'
173+
160174

161175
class Linux(BoardsInterface):
162176
def __init__(self, net_type):
@@ -177,6 +191,10 @@ def get_security_level(self):
177191
def get_store_cert_filename(self):
178192
return self._cert_store_filename
179193

194+
def get_client_id(self):
195+
import uuid
196+
return self.get_lang_str() + 'MQTT_' + (''.join(['{:02x}'.format((uuid.getnode() >> ele) & 0xff) for ele in range(0,8*6,8)][::-1]))
197+
180198

181199
class BoardsFactory:
182200

0 commit comments

Comments
 (0)