From 02a68820567a5d4ee652433e8336e4176b95f34e Mon Sep 17 00:00:00 2001 From: glenn20 Date: Sat, 6 Aug 2022 19:04:56 +1000 Subject: [PATCH] espnow: ESP8266: Add auto_connect & reconnects option to WLAN.config(). Adds: - WLAN.config(auto_connect=False) to stop the ESP8266 from automatically connecting to wifi networks after bootup. - WLAN.config(reconnects=X) to limit the number of times to attempt to reconnect after becoming disconnected from a wifi access point. --- ports/esp8266/network_wlan.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ports/esp8266/network_wlan.c b/ports/esp8266/network_wlan.c index 4ab4a9a0024f2..32ca3f9da9847 100644 --- a/ports/esp8266/network_wlan.c +++ b/ports/esp8266/network_wlan.c @@ -423,6 +423,20 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs wifi_set_sleep_type(mp_obj_get_int(kwargs->table[i].value)); break; } + case MP_QSTR_auto_connect: { + wifi_station_set_auto_connect(mp_obj_is_true(kwargs->table[i].value)); + break; + } + case MP_QSTR_reconnects: { + req_if = STATION_IF; + if (self->if_id == STATION_IF) { + int reconnects = mp_obj_get_int(kwargs->table[i].value); + // parameter reconnects == -1 means to retry forever. + wifi_station_set_reconnect_policy((reconnects != 0)); + wifi_station_dhcpc_set_maxtry((reconnects == -1) ? 255 : reconnects); + } + break; + } default: goto unknown; } @@ -494,6 +508,10 @@ 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(wifi_get_sleep_type()); break; } + case MP_QSTR_auto_connect: { + val = mp_obj_new_bool(wifi_station_get_auto_connect()); + break; + } default: goto unknown; } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy