Skip to content

Commit 865476e

Browse files
committed
Last minute pybytes bugfixes
1 parent afa7b87 commit 865476e

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

esp32/frozen/Pybytes/_pybytes.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def connect(self):
222222
self.__config_updated = False
223223
self.__check_init()
224224

225-
if not self.__conf['network_preferences']:
225+
if not self.__conf.get('network_preferences'):
226226
print("network_preferences are empty, set it up in /flash/pybytes_config.json first") # noqa
227227

228228
for net in self.__conf['network_preferences']:
@@ -310,11 +310,10 @@ def set_config(
310310
if reconnect:
311311
self.reconnect()
312312

313-
def update_config(self, key=None, value=None, permanent=True, silent=False, reconnect=False):
314-
if key is None:
315-
raise ValueError('You need to either specify a key!')
316-
else:
317-
self.__conf[key].update(value)
313+
def update_config(self, key, value=None, permanent=True, silent=False, reconnect=False):
314+
if type(value) != list:
315+
raise ValueError('Value must be a list!')
316+
self.__conf[key].update(value)
318317
self.__config_updated = True
319318
if permanent: self.write_config(silent=silent)
320319
if reconnect:
@@ -444,8 +443,10 @@ def activate(self, activation_string):
444443
except:
445444
from _pybytes_config import PybytesConfig
446445
try:
447-
self.__conf = PybytesConfig().cli_config(activation_info=jstring)
448-
self.start()
446+
if self.__conf = PybytesConfig().cli_config(activation_info=jstring):
447+
self.start()
448+
else:
449+
print('Activation failed!')
449450
except Exception as ex:
450451
print('Activation failed! Please try again...')
451452
print_debug(1, ex)

esp32/frozen/Pybytes/_pybytes_connection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def connect_wifi(self, reconnect=True, check_interval=0.5, timeout=120):
139139
return False
140140
elif attempt == 3:
141141
print("Error connecting using WIFI: %s" % e)
142+
return False
142143

143144
self.__network_type = constants.__NETWORK_TYPE_WIFI
144145
print("WiFi connection established")

esp32/frozen/Pybytes/_pybytes_constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
available at https://www.pycom.io/opensource/licensing
77
'''
88

9-
import sys, pycom
9+
import sys
10+
import pycom
1011

1112

1213
class MQTTConstants:

esp32/frozen/Pybytes/_pybytes_library.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def pack_scan_info_message(self, lora):
138138
wifi_deinit = True
139139

140140
while not wifi_networks and scan_attempts < 5:
141-
wifi_networks = self.__pybytes_connection.wlan.scan()
141+
wifi_networks = self.__pybytes_connection.wlan.scan(type=WLAN.SCAN_PASSIVE)
142142
scan_attempts += 1
143143
print_debug(6, 'number of scanned wifi_networks: {}'.format(len(wifi_networks)))
144144
print_debug(6, 'scan_attempts: {}'.format(scan_attempts))

0 commit comments

Comments
 (0)