-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[BREAKING] Disable WiFi at boot by default #7902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 14 commits
ab16b8c
6310da8
330b229
68d338e
253bbc5
5ead6a2
b2a53b7
7756427
64ff4b0
2d4ca1d
8510670
1059beb
7fd4116
c15cb5d
9d7eb2e
227e557
eca1367
8b0d641
6d9ec26
8ecc7f0
8332c42
df8f8a7
20020c0
4e5abc6
2eb8bb1
da5966b
f0f1f55
77087f0
5d12aa2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,33 @@ persistent | |
|
||
WiFi.persistent(persistent) | ||
|
||
Starting from version 3 of this core, **persistence is disabled by default | ||
and WiFi does not anymore automatically fires up at boot** (see PR `#7902 <https://github.com/esp8266/Arduino/pull/7902>`__). | ||
|
||
Previously, SDK was automatically starting WiFi at boot. This was probably | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest highlighting here that the prior to v3 persistent was defaulted to true, and so the wifi creds were always stored to flash when the WiFi was configured, which could lead to a reduced life of the wifi config flash sector, and hence the entire ESP. Starting with v3, persistent defaults to false, so creds aren't stored by the SDK in the flash sector and hence don't survive across reboots. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @devyte I think this is not precisely correct. Settings that were once persisted, remain that way, so thereafter, |
||
intended for the Espressif AT FW which is interactive and preserves WiFi | ||
state accross reboots. This behavior is generally irrelevant with the | ||
Arduino API because sketches start with ``WiFi.begin()`` or | ||
``WiFi.softAP()``. | ||
|
||
This change is harmless with standard sketches: Calls to ``WiFi.mode()`` do | ||
enable radio as usual. It also smooths current spikes at boot and decreases | ||
DHCP stress. | ||
|
||
Legacy behavior can be restored by calling ``enableWiFiAtBootTime()`` from | ||
anywhere in the code (it is a weak void function intended to play with the | ||
linker). | ||
|
||
.. code:: cpp | ||
|
||
void setup () { | ||
#ifdef WIFI_IS_OFF_AT_BOOT | ||
enableWiFiAtBootTime(); // can be called from anywhere with the same effect | ||
#endif | ||
.... | ||
} | ||
|
||
When legacy behavior is restored thanks to this call, | ||
ESP8266 is able to reconnect to the last used WiFi network or establishes the same Access Point upon power up or reset. | ||
By default, these settings are written to specific sectors of flash memory every time they are changed in ``WiFi.begin(ssid, passphrase)`` or ``WiFi.softAP(ssid, passphrase, channel)``, and when ``WiFi.disconnect`` or ``WiFi.softAPdisconnect`` is invoked. | ||
Frequently calling these functions could cause wear on the flash memory (see issue `#1054 <https://github.com/esp8266/Arduino/issues/1054>`__). | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,6 +164,7 @@ WiFi Multi | |
Example: | ||
|
||
.. code:: cpp | ||
|
||
#include <ESP8266WiFiMulti.h> | ||
|
||
ESP8266WiFiMulti wifiMulti; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 starts asleep by default | ||
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. small side note / question, will test some time later today |
||
// wifi starts asleep by default | ||
wifi_fpm_do_wakeup(); | ||
wifi_fpm_close(); | ||
} | ||
|
||
bool ret = false; | ||
ETS_UART_INTR_DISABLE(); | ||
if(_persistent) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.