Skip to content

Commit bfcb627

Browse files
committed
Adding Windows client support
1 parent 7fa9211 commit bfcb627

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

LiveObjects/Connection.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(self, debug=True):
4242
elif self.mode == LiveObjects.BoardsInterface.MICROPYTHON:
4343
from umqttrobust import MQTTClient
4444
except ImportError:
45-
print("[ERROR] U have missing libraries Paho-mqtt(for Python) or umqttrobust(for uPython)")
45+
print("[ERROR] U have missing libraries 'Paho-mqtt' (for Python) or 'umqttrobust' (for uPython)")
4646
sys.exit()
4747

4848
self.__port = self.__board.get_security_level()
@@ -116,6 +116,15 @@ def connect(self):
116116
self.__mqtt.on_message = self.__onMessage
117117
if self.__port == SSL:
118118
filename = "/etc/ssl/certs/ca-certificates.crt"
119+
120+
if self.__board.get_os_id() == LiveObjects.BoardsInterface.WINDOWS:
121+
try:
122+
import certifi
123+
filename = certifi.where()
124+
except ImportError:
125+
print("[ERROR] U have missing library 'python-certifi-win32'")
126+
sys.exit()
127+
119128
self.__mqtt.tls_set(filename)
120129
self.__mqtt.connect(self.__server, self.__port, 60)
121130
self.__mqtt.loop_start()

LiveObjects/hal.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,23 @@ def get_security_level(self):
104104

105105

106106
class Win32(BoardsInterface):
107-
pass
107+
def __init__(self, net_type):
108+
self._lang_id = BoardsInterface.PYTHON
109+
self._os_id = BoardsInterface.WINDOWS
110+
self._net_type = BoardsInterface.EXISTING_NETWORK if net_type == BoardsInterface.DEFAULT_CARRIER else net_type
111+
self._carrier_capability = (BoardsInterface.EXISTING_NETWORK,)
112+
self._existing_network_tls_capability = True
113+
self._credentials = super().create_credentials(self._net_type)
114+
115+
def connect(self):
116+
super().check_network_capabilities(self._net_type)
117+
use_existing_network_connection()
118+
119+
def get_security_level(self):
120+
return LiveObjects.SSL if self._existing_network_tls_capability else LiveObjects.NONE
121+
122+
def get_os_id(self):
123+
return self._os_id
108124

109125

110126
class Esp32(BoardsInterface):

0 commit comments

Comments
 (0)