From ed31c7dc8f8cb630e36b89753aa769d01bdb2dbd Mon Sep 17 00:00:00 2001 From: Bill Sideris Date: Mon, 15 May 2023 22:38:59 +0300 Subject: [PATCH 1/2] Await down on stop_station --- ports/raspberrypi/common-hal/wifi/Radio.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ports/raspberrypi/common-hal/wifi/Radio.c b/ports/raspberrypi/common-hal/wifi/Radio.c index 12674a499b9c..76375ad2fcc4 100644 --- a/ports/raspberrypi/common-hal/wifi/Radio.c +++ b/ports/raspberrypi/common-hal/wifi/Radio.c @@ -161,7 +161,15 @@ void common_hal_wifi_radio_stop_station(wifi_radio_obj_t *self) { // (by tcpip_link_status). However since ap disconnection isn't working // either, this is not an issue. cyw43_wifi_leave(&cyw43_state, CYW43_ITF_AP); - + size_t timeout_ms = (size_t)MICROPY_FLOAT_C_FUN(ceil)(500); + uint64_t start = port_get_raw_ticks(NULL); + uint64_t deadline = start + timeout_ms; + while (port_get_raw_ticks(NULL) < deadline && (cyw43_tcpip_link_status(&cyw43_state, CYW43_ITF_STA) != CYW43_LINK_DOWN)) { + RUN_BACKGROUND_TASKS; + if (mp_hal_is_interrupted()) { + break; + } + } bindings_cyw43_wifi_enforce_pm(); } From 95c1d849d391a1e66b62f7481843b39b968240a8 Mon Sep 17 00:00:00 2001 From: Bill Sideris Date: Tue, 16 May 2023 04:47:44 +0300 Subject: [PATCH 2/2] Just 500 Co-authored-by: Dan Halbert --- ports/raspberrypi/common-hal/wifi/Radio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/raspberrypi/common-hal/wifi/Radio.c b/ports/raspberrypi/common-hal/wifi/Radio.c index 76375ad2fcc4..aa603f1be301 100644 --- a/ports/raspberrypi/common-hal/wifi/Radio.c +++ b/ports/raspberrypi/common-hal/wifi/Radio.c @@ -161,7 +161,7 @@ void common_hal_wifi_radio_stop_station(wifi_radio_obj_t *self) { // (by tcpip_link_status). However since ap disconnection isn't working // either, this is not an issue. cyw43_wifi_leave(&cyw43_state, CYW43_ITF_AP); - size_t timeout_ms = (size_t)MICROPY_FLOAT_C_FUN(ceil)(500); + const size_t timeout_ms = 500; uint64_t start = port_get_raw_ticks(NULL); uint64_t deadline = start + timeout_ms; while (port_get_raw_ticks(NULL) < deadline && (cyw43_tcpip_link_status(&cyw43_state, CYW43_ITF_STA) != CYW43_LINK_DOWN)) {