From 5bef810dd34034cb9636b09ab2a75261297be754 Mon Sep 17 00:00:00 2001 From: Glenn Moloney Date: Fri, 19 May 2023 17:51:52 +1000 Subject: [PATCH 1/2] esp8266: WLAN.config('channel') to use wifi_get_channel(). Fixes Issue #11463: - WLAN.config('channel') returns incorrect channel for AP_IF if STA has connected to an external AP running on a different channel. - Same behaviour as for ESP32 from PR #8991. Signed-off-by: Glenn Moloney --- ports/esp8266/network_wlan.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ports/esp8266/network_wlan.c b/ports/esp8266/network_wlan.c index 348d7f6355..8b5f4c464b 100644 --- a/ports/esp8266/network_wlan.c +++ b/ports/esp8266/network_wlan.c @@ -476,8 +476,7 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs val = MP_OBJ_NEW_SMALL_INT(cfg.ap.authmode); break; case MP_QSTR_channel: - req_if = SOFTAP_IF; - val = MP_OBJ_NEW_SMALL_INT(cfg.ap.channel); + val = MP_OBJ_NEW_SMALL_INT(wifi_get_channel()); break; case MP_QSTR_hostname: case MP_QSTR_dhcp_hostname: { From df5f3c16815a51d237718b8e6b22d544731ffdbc Mon Sep 17 00:00:00 2001 From: Glenn Moloney Date: Mon, 26 Jun 2023 18:05:37 +1000 Subject: [PATCH 2/2] esp8266: WLAN.config(channel=x) to use wifi_set_channel(). Also permits channel option to be used for STA_IF interface. This provides compatibility with ESP32 code (esp. for espnow users). Signed-off-by: Glenn Moloney --- ports/esp8266/network_wlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/esp8266/network_wlan.c b/ports/esp8266/network_wlan.c index 8b5f4c464b..d55babeac6 100644 --- a/ports/esp8266/network_wlan.c +++ b/ports/esp8266/network_wlan.c @@ -395,8 +395,8 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs break; } case MP_QSTR_channel: { - req_if = SOFTAP_IF; cfg.ap.channel = mp_obj_get_int(kwargs->table[i].value); + error_check(wifi_set_channel(cfg.ap.channel), "can't set channel"); break; } case MP_QSTR_hostname: