Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 3024c89

Browse files
Xykoniwahdan88
authored andcommitted
Bugfixes
Fix Pybytes OTA update failure Add option to deinit active wifi connection when disabling wifi_on_boot
1 parent aae6c26 commit 3024c89

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

esp32/frozen/Pybytes/_OTA.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
import os
1919
from binascii import hexlify
2020

21+
try:
22+
from pybytes_debug import print_debug
23+
except:
24+
from _pybytes_debug import print_debug
25+
2126
# Try to get version number
2227
# try:
2328
# from OTA_VERSION import VERSION
@@ -225,14 +230,15 @@ def get_data(self, req, dest_path=None, hash=False, firmware=False):
225230

226231
# Get data from server
227232
result = s.recv(50)
233+
print_debug(4, "Result: {}".format(result))
228234

229235
start_writing = False
230236
while (len(result) > 0):
231237
# Ignore the HTTP headers
232238
if not start_writing:
233239
if "\r\n\r\n" in result:
234240
start_writing = True
235-
result = result.decode().split("\r\n\r\n")[1].encode()
241+
result = result.split(b'\r\n\r\n')[1]
236242

237243
if start_writing:
238244
if firmware:

esp32/frozen/Pybytes/_pybytes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(self, config, activation=False, autoconnect=False):
4747

4848
if not self.__activation:
4949
self.__conf = config
50-
pycom.wifi_on_boot(False)
50+
pycom.wifi_on_boot(False, True)
5151

5252
self.__check_dump_ca()
5353
try:

esp32/mods/modpycom.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
#include "modmachine.h"
4040
#include "esp32chipinfo.h"
41+
#include "modwlan.h"
4142

4243

4344
#include <string.h>
@@ -341,13 +342,18 @@ STATIC mp_obj_t mod_pycom_nvs_erase_all (void) {
341342
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_pycom_nvs_erase_all_obj, mod_pycom_nvs_erase_all);
342343

343344
STATIC mp_obj_t mod_pycom_wifi_on_boot (mp_uint_t n_args, const mp_obj_t *args) {
344-
if (n_args >= 1 ) {
345+
if (n_args == 0) {
346+
return mp_obj_new_bool(config_get_wifi_on_boot());
347+
}
348+
if (config_get_wifi_on_boot() != mp_obj_is_true(args[0])) {
345349
config_set_wifi_on_boot (mp_obj_is_true(args[0]));
346350
if (n_args > 1 && mp_obj_is_true(args[1])) {
347-
mptask_config_wifi(true);
351+
if (mp_obj_is_true(args[0])) {
352+
mptask_config_wifi(true);
353+
} else {
354+
wlan_deinit(NULL);
355+
}
348356
}
349-
} else {
350-
return mp_obj_new_bool(config_get_wifi_on_boot());
351357
}
352358
return mp_const_none;
353359
}

0 commit comments

Comments
 (0)