Skip to content

Commit 02a6882

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 1093dea commit 02a6882

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

ports/esp8266/network_wlan.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,20 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
423423
wifi_set_sleep_type(mp_obj_get_int(kwargs->table[i].value));
424424
break;
425425
}
426+
case MP_QSTR_auto_connect: {
427+
wifi_station_set_auto_connect(mp_obj_is_true(kwargs->table[i].value));
428+
break;
429+
}
430+
case MP_QSTR_reconnects: {
431+
req_if = STATION_IF;
432+
if (self->if_id == STATION_IF) {
433+
int reconnects = mp_obj_get_int(kwargs->table[i].value);
434+
// parameter reconnects == -1 means to retry forever.
435+
wifi_station_set_reconnect_policy((reconnects != 0));
436+
wifi_station_dhcpc_set_maxtry((reconnects == -1) ? 255 : reconnects);
437+
}
438+
break;
439+
}
426440
default:
427441
goto unknown;
428442
}
@@ -494,6 +508,10 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
494508
val = MP_OBJ_NEW_SMALL_INT(wifi_get_sleep_type());
495509
break;
496510
}
511+
case MP_QSTR_auto_connect: {
512+
val = mp_obj_new_bool(wifi_station_get_auto_connect());
513+
break;
514+
}
497515
default:
498516
goto unknown;
499517
}

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