Skip to content

Commit 325a7e2

Browse files
committed
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.
1 parent e4d90be commit 325a7e2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

ports/esp8266/modnetwork.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,20 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
410410
wifi_set_phy_mode(mp_obj_get_int(kwargs->table[i].value));
411411
break;
412412
}
413+
case MP_QSTR_auto_connect: {
414+
wifi_station_set_auto_connect(mp_obj_get_int(kwargs->table[i].value));
415+
break;
416+
}
417+
case MP_QSTR_reconnects: {
418+
req_if = STATION_IF;
419+
if (self->if_id == STATION_IF) {
420+
int reconnects = mp_obj_get_int(kwargs->table[i].value);
421+
// parameter reconnects == -1 means to retry forever.
422+
wifi_station_set_reconnect_policy((reconnects != 0));
423+
wifi_station_dhcpc_set_maxtry((reconnects == -1) ? 255 : reconnects);
424+
}
425+
break;
426+
}
413427
default:
414428
goto unknown;
415429
}
@@ -481,6 +495,11 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
481495
val = mp_obj_new_int(wifi_get_phy_mode());
482496
break;
483497
}
498+
case MP_QSTR_auto_connect: {
499+
val = (wifi_station_get_auto_connect() != 0)
500+
? mp_const_true : mp_const_false;
501+
break;
502+
}
484503
default:
485504
goto unknown;
486505
}

0 commit comments

Comments
 (0)
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