Skip to content

Commit a4ecdef

Browse files
committed
Preventing function lte_connect against entering PIN if it had been entered.
1 parent a50448a commit a4ecdef

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

LiveObjects/hal.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __init__(self, net_type):
6161
self._net_type = BoardsInterface.WIFI if net_type == BoardsInterface.DEFAULT_CARRIER else net_type
6262
self._carrier_capability = (BoardsInterface.WIFI, BoardsInterface.LTE)
6363
self._wifi_tls_capability = True
64-
self._lte_tls_capability = False
64+
self._lte_tls_capability = True
6565
self._mqtt_lib = super().mqtt_lib_import_str(self._lang)
6666
self._credentials = super().create_credentials(self._net_type)
6767

@@ -122,7 +122,7 @@ def __init__(self, net_type):
122122
self._lang = 'Python'
123123
self._net_type = BoardsInterface.EXISTING_NETWORK if net_type == BoardsInterface.DEFAULT_CARRIER else net_type
124124
self._carrier_capability = (BoardsInterface.EXISTING_NETWORK,)
125-
self._wifi_tls_capability = True
125+
self._existing_network_tls_capability = True
126126
self._mqtt_lib = super().mqtt_lib_import_str(self._lang)
127127
self._credentials = super().create_credentials(self._net_type)
128128

@@ -131,7 +131,7 @@ def network_connect(self):
131131
use_existing_network_connection()
132132

133133
def get_security_level(self):
134-
return LiveObjects.SSL if self._wifi_tls_capability else LiveObjects.NONE
134+
return LiveObjects.SSL if self._existing_network_tls_capability else LiveObjects.NONE
135135

136136

137137
class BoardsFactory:
@@ -187,9 +187,19 @@ def lte_connect(pin):
187187

188188
from network import LTE
189189

190+
def is_waiting_for_pin():
191+
if lte.send_at_cmd('AT+CPIN?').strip() == '+CPIN: SIM PIN\r\n\r\nOK':
192+
return True
193+
else:
194+
return False
195+
190196
lte = LTE()
191197
time.sleep(2)
192-
print("PIN", (lte.send_at_cmd('AT+CPIN="%s"' % pin)).strip())
198+
199+
if is_waiting_for_pin():
200+
print("PIN", (lte.send_at_cmd('AT+CPIN="%s"' % pin)).strip())
201+
else:
202+
print("PIN READY")
193203

194204
lte.attach()
195205
print("attaching... ", end='')

0 commit comments

Comments
 (0)