Skip to content

Commit 659e5a5

Browse files
committed
Changes in way of creation credentials regarding type of network (EXISTING, WIFI, LTE)
1 parent 11e6c3c commit 659e5a5

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

LiveObjects/credentials.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@
33
#
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
6-
class Credentials:
6+
import LiveObjects
7+
78

8-
NONE = 1
9-
WIFI = 2
10-
LTE = 3
9+
class Credentials:
1110

12-
def __init__(self, net_type=NONE):
11+
def __init__(self, net_type):
1312
self._apikey = <APIKEY>
1413

15-
if net_type == Credentials.WIFI:
14+
if net_type == LiveObjects.BoardsInterface.WIFI:
1615
self._wifi_ssid = <WIFI_SSID>
1716
self._wifi_password = <WIFI PASS>
18-
elif net_type == Credentials.LTE:
17+
elif net_type == LiveObjects.BoardsInterface.LTE:
1918
self._pin = <PIN>
2019
self._apn = <APN_NAME>
2120

LiveObjects/hal.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313
class BoardsInterface:
1414

15+
EXISTING = 1
16+
WIFI = 2
17+
LTE = 3
18+
1519
@staticmethod
1620
def create_credentials(mode):
1721
return LiveObjects.Credentials(mode)
@@ -50,7 +54,7 @@ def __init__(self):
5054
self._wifi_tls_capability = True
5155
self._lte_tls_capability = True
5256
self._mqtt_lib = super().mqtt_lib_import_str(self._lang)
53-
self._credentials = super().create_credentials(LiveObjects.Credentials.WIFI)
57+
self._credentials = super().create_credentials(BoardsInterface.WIFI)
5458

5559
def network_connect(self):
5660
pycom_wifi_connect(self._credentials.get_wifi_creds()['ssid'], self._credentials.get_wifi_creds()['password'])
@@ -62,7 +66,7 @@ def __init__(self):
6266
self._wifi_tls_capability = False
6367
self._wifi_lte_capability = False
6468
self._mqtt_lib = super().mqtt_lib_import_str(self._lang)
65-
self._credentials = super().create_credentials(LiveObjects.Credentials.WIFI)
69+
self._credentials = super().create_credentials(BoardsInterface.WIFI)
6670

6771
def network_connect(self):
6872
wifi_connect(self._credentials.get_wifi_creds()['ssid'], self._credentials.get_wifi_creds()['password'])
@@ -78,7 +82,7 @@ def __init__(self):
7882
self._wifi_tls_capability = True
7983
self._wifi_lte_capability = False
8084
self._mqtt_lib = super().mqtt_lib_import_str(self._lang)
81-
self._credentials = super().create_credentials(LiveObjects.Credentials.WIFI)
85+
self._credentials = super().create_credentials(BoardsInterface.WIFI)
8286

8387
def network_connect(self):
8488
wifi_connect(self._credentials.get_wifi_creds()['ssid'], self._credentials.get_wifi_creds()['password'])
@@ -90,7 +94,7 @@ def __init__(self):
9094
self._wifi_tls_capability = True
9195
self._wifi_lte_capability = False
9296
self._mqtt_lib = super().mqtt_lib_import_str(self._lang)
93-
self._credentials = super().create_credentials(LiveObjects.Credentials.NONE)
97+
self._credentials = super().create_credentials(BoardsInterface.EXISTING)
9498

9599
def network_connect(self):
96100
use_existing_network_connection()

0 commit comments

Comments
 (0)