mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-13 02:22:55 +03:00
[BREAKING] Disable WiFi at boot by default (#7902)
* Disable WiFi at boot by default * +define WIFI_IS_OFF_AT_BOOT * remove now useless example * mv enableWiFiAtBootTime() to core_esp8266_features.h * sync with master * per @earlephilhower review: a file was missing * doc * WiFi persistence is now false by default * fix doc * ditto * doc: remove sphinx warnings (fix links and formatting) * fix link name * fix doc * legacy: restore persistence * undeprecate preinit() * move force modem up to when mode has changed (per @mcspr review) * do not wake up from sleep when mode if OFF * fix doc per review
This commit is contained in:
@ -83,7 +83,7 @@ struct WiFiEventHandlerOpaque
|
||||
|
||||
static std::list<WiFiEventHandler> sCbEventList;
|
||||
|
||||
bool ESP8266WiFiGenericClass::_persistent = true;
|
||||
bool ESP8266WiFiGenericClass::_persistent = false;
|
||||
WiFiMode_t ESP8266WiFiGenericClass::_forceSleepLastMode = WIFI_OFF;
|
||||
|
||||
ESP8266WiFiGenericClass::ESP8266WiFiGenericClass()
|
||||
@ -418,12 +418,6 @@ bool ESP8266WiFiGenericClass::mode(WiFiMode_t m, WiFiState* state) {
|
||||
DEBUG_WIFI("core: state is useless without SHUTDOWN or RESUME\n");
|
||||
}
|
||||
|
||||
if (wifi_fpm_get_sleep_type() != NONE_SLEEP_T) {
|
||||
// wifi may have been put asleep by ESP8266WiFiGenericClass::preinitWiFiOff
|
||||
wifi_fpm_do_wakeup();
|
||||
wifi_fpm_close();
|
||||
}
|
||||
|
||||
if(_persistent){
|
||||
if(wifi_get_opmode() == (uint8) m && wifi_get_opmode_default() == (uint8) m){
|
||||
return true;
|
||||
@ -432,6 +426,12 @@ bool ESP8266WiFiGenericClass::mode(WiFiMode_t m, WiFiState* state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m != WIFI_OFF && wifi_fpm_get_sleep_type() != NONE_SLEEP_T) {
|
||||
// wifi starts asleep by default
|
||||
wifi_fpm_do_wakeup();
|
||||
wifi_fpm_close();
|
||||
}
|
||||
|
||||
bool ret = false;
|
||||
ETS_UART_INTR_DISABLE();
|
||||
if(_persistent) {
|
||||
@ -855,25 +855,7 @@ bool ESP8266WiFiGenericClass::resumeFromShutdown (WiFiState* state)
|
||||
return true;
|
||||
}
|
||||
|
||||
//meant to be called from user-defined ::preinit()
|
||||
void ESP8266WiFiGenericClass::preinitWiFiOff () {
|
||||
// https://github.com/esp8266/Arduino/issues/2111#issuecomment-224251391
|
||||
// WiFi.persistent(false);
|
||||
// WiFi.mode(WIFI_OFF);
|
||||
// WiFi.forceSleepBegin();
|
||||
|
||||
//WiFi.mode(WIFI_OFF) equivalent:
|
||||
// datasheet:
|
||||
// Set Wi-Fi working mode to Station mode, SoftAP
|
||||
// or Station + SoftAP, and do not update flash
|
||||
// (not persistent)
|
||||
wifi_set_opmode_current(WIFI_OFF);
|
||||
|
||||
//WiFi.forceSleepBegin(/*default*/0) equivalent:
|
||||
// sleep forever until wifi_fpm_do_wakeup() is called
|
||||
wifi_fpm_set_sleep_type(MODEM_SLEEP_T);
|
||||
wifi_fpm_open();
|
||||
wifi_fpm_do_sleep(0xFFFFFFF);
|
||||
|
||||
// use WiFi.forceSleepWake() to wake WiFi up
|
||||
// It was meant to be called from user-defined ::preinit()
|
||||
// It is now deprecated by enableWiFiAtBootTime() and __disableWiFiAtBootTime()
|
||||
}
|
||||
|
Reference in New Issue
Block a user