From 7588abad321ecb609096b1361688fb68e78d8492 Mon Sep 17 00:00:00 2001 From: Bill Sideris Date: Wed, 6 Sep 2023 16:58:12 +0300 Subject: [PATCH 1/5] stop_station when no wifi-reconnect --- supervisor/shared/web_workflow/web_workflow.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/supervisor/shared/web_workflow/web_workflow.c b/supervisor/shared/web_workflow/web_workflow.c index 2a8133a562..33e72aa08d 100644 --- a/supervisor/shared/web_workflow/web_workflow.c +++ b/supervisor/shared/web_workflow/web_workflow.c @@ -266,6 +266,9 @@ bool supervisor_start_web_workflow(bool reload) { os_getenv_err_t result = common_hal_os_getenv_str("CIRCUITPY_WIFI_SSID", ssid, sizeof(ssid)); if (result != GETENV_OK) { + #if CIRCUITPY_CYW43 + common_hal_wifi_radio_stop_station(&common_hal_wifi_radio_obj); + #endif return false; } @@ -274,6 +277,10 @@ bool supervisor_start_web_workflow(bool reload) { // if password is unspecified, assume an open network password[0] = '\0'; } else if (result != GETENV_OK) { + #if CIRCUITPY_CYW43 + common_hal_wifi_radio_stop_station(&common_hal_wifi_radio_obj); + #endif + return false; } From ed4c510d8f0baa219a2cb4c153d6b233b37a7458 Mon Sep 17 00:00:00 2001 From: Bill Sideris Date: Wed, 6 Sep 2023 17:00:06 +0300 Subject: [PATCH 2/5] Remove a space --- supervisor/shared/web_workflow/web_workflow.c | 1 - 1 file changed, 1 deletion(-) diff --git a/supervisor/shared/web_workflow/web_workflow.c b/supervisor/shared/web_workflow/web_workflow.c index 33e72aa08d..04a02b8628 100644 --- a/supervisor/shared/web_workflow/web_workflow.c +++ b/supervisor/shared/web_workflow/web_workflow.c @@ -280,7 +280,6 @@ bool supervisor_start_web_workflow(bool reload) { #if CIRCUITPY_CYW43 common_hal_wifi_radio_stop_station(&common_hal_wifi_radio_obj); #endif - return false; } From 7258f7b4a048f83efbba32137fd6c49ef5a6b3d2 Mon Sep 17 00:00:00 2001 From: Bill Sideris Date: Thu, 28 Sep 2023 14:47:39 +0300 Subject: [PATCH 3/5] Revert "Remove a space" This reverts commit ed4c510d8f0baa219a2cb4c153d6b233b37a7458. --- supervisor/shared/web_workflow/web_workflow.c | 1 + 1 file changed, 1 insertion(+) diff --git a/supervisor/shared/web_workflow/web_workflow.c b/supervisor/shared/web_workflow/web_workflow.c index ce94fb4609..937e3acb4c 100644 --- a/supervisor/shared/web_workflow/web_workflow.c +++ b/supervisor/shared/web_workflow/web_workflow.c @@ -280,6 +280,7 @@ bool supervisor_start_web_workflow(bool reload) { #if CIRCUITPY_CYW43 common_hal_wifi_radio_stop_station(&common_hal_wifi_radio_obj); #endif + return false; } From 8c3715667571af896f723bfe8e63ce6906679592 Mon Sep 17 00:00:00 2001 From: Bill Sideris Date: Thu, 28 Sep 2023 14:47:43 +0300 Subject: [PATCH 4/5] Revert "stop_station when no wifi-reconnect" This reverts commit 7588abad321ecb609096b1361688fb68e78d8492. --- supervisor/shared/web_workflow/web_workflow.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/supervisor/shared/web_workflow/web_workflow.c b/supervisor/shared/web_workflow/web_workflow.c index 937e3acb4c..ecf83b8bcb 100644 --- a/supervisor/shared/web_workflow/web_workflow.c +++ b/supervisor/shared/web_workflow/web_workflow.c @@ -266,9 +266,6 @@ bool supervisor_start_web_workflow(bool reload) { os_getenv_err_t result = common_hal_os_getenv_str("CIRCUITPY_WIFI_SSID", ssid, sizeof(ssid)); if (result != GETENV_OK) { - #if CIRCUITPY_CYW43 - common_hal_wifi_radio_stop_station(&common_hal_wifi_radio_obj); - #endif return false; } @@ -277,10 +274,6 @@ bool supervisor_start_web_workflow(bool reload) { // if password is unspecified, assume an open network password[0] = '\0'; } else if (result != GETENV_OK) { - #if CIRCUITPY_CYW43 - common_hal_wifi_radio_stop_station(&common_hal_wifi_radio_obj); - #endif - return false; } From c3cf7c089491f697e669899b003b061fade826cc Mon Sep 17 00:00:00 2001 From: Bill Sideris Date: Thu, 28 Sep 2023 17:53:40 +0300 Subject: [PATCH 5/5] wifi_reset --- ports/raspberrypi/common-hal/wifi/Radio.c | 7 ++++++- ports/raspberrypi/common-hal/wifi/__init__.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ports/raspberrypi/common-hal/wifi/Radio.c b/ports/raspberrypi/common-hal/wifi/Radio.c index 1508b764a2..ffccd4faf8 100644 --- a/ports/raspberrypi/common-hal/wifi/Radio.c +++ b/ports/raspberrypi/common-hal/wifi/Radio.c @@ -75,8 +75,13 @@ bool common_hal_wifi_radio_get_enabled(wifi_radio_obj_t *self) { } void common_hal_wifi_radio_set_enabled(wifi_radio_obj_t *self, bool enabled) { - self->enabled = enabled; // TODO: Actually enable and disable the WiFi module at this point. + if (self->enabled && !enabled) { + common_hal_wifi_radio_stop_station(self); + common_hal_wifi_radio_stop_ap(self); + } + self->enabled = enabled; + } mp_obj_t common_hal_wifi_radio_get_hostname(wifi_radio_obj_t *self) { diff --git a/ports/raspberrypi/common-hal/wifi/__init__.c b/ports/raspberrypi/common-hal/wifi/__init__.c index 91a45e8d92..63f09fc774 100644 --- a/ports/raspberrypi/common-hal/wifi/__init__.c +++ b/ports/raspberrypi/common-hal/wifi/__init__.c @@ -71,7 +71,7 @@ void common_hal_wifi_init(bool user_initiated) { void wifi_user_reset(void) { if (wifi_user_initiated) { - // wifi_reset(); + wifi_reset(); wifi_user_initiated = false; } } @@ -83,7 +83,7 @@ void wifi_reset(void) { // the cyw43 wifi chip is not reset due to https://github.com/raspberrypi/pico-sdk/issues/980 common_hal_wifi_monitor_deinit(MP_STATE_VM(wifi_monitor_singleton)); common_hal_wifi_radio_obj.current_scan = NULL; - // common_hal_wifi_radio_set_enabled(radio, false); + common_hal_wifi_radio_set_enabled(&common_hal_wifi_radio_obj, false); supervisor_workflow_request_background(); }