1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-12 01:53:07 +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:
david gauchard
2021-04-09 23:01:11 +02:00
committed by GitHub
parent da6ec83b5f
commit 1cc6960a55
22 changed files with 107 additions and 142 deletions

View File

@ -42,6 +42,33 @@ persistent
WiFi.persistent(persistent)
Starting from version 3 of this core, **persistence is disabled by default
and WiFi does not start automatically at boot** (see PR `#7902 <https://github.com/esp8266/Arduino/pull/7902>`__).
Previously, SDK was automatically starting WiFi at boot. This was probably
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>`__).