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.
pull/9460/head
glenn20 2022-08-06 19:04:56 +10:00
rodzic 1093dea709
commit 02a6882056
1 zmienionych plików z 18 dodań i 0 usunięć

Wyświetl plik

@ -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;
}