1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-16 00:43:00 +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

@ -31,6 +31,7 @@
#define CORE_HAS_UMM
#define WIFI_HAS_EVENT_CALLBACK
#define WIFI_IS_OFF_AT_BOOT
#include <stdlib.h> // malloc()
#include <stddef.h> // size_t
@ -104,6 +105,8 @@ uint64_t micros64(void);
void delay(unsigned long);
void delayMicroseconds(unsigned int us);
void enableWiFiAtBootTime (void) __attribute__((noinline));
#if defined(F_CPU) || defined(CORE_MOCK)
#ifdef __cplusplus
constexpr

View File

@ -332,7 +332,18 @@ extern "C" void app_entry (void)
extern "C" void preinit (void) __attribute__((weak));
extern "C" void preinit (void)
{
/* do nothing by default */
/* does nothing, kept for backward compatibility */
}
extern "C" void __disableWiFiAtBootTime (void) __attribute__((weak));
extern "C" void __disableWiFiAtBootTime (void)
{
// Starting from arduino core v3: wifi is disabled at boot time
// WiFi.begin() or WiFi.softAP() will wake WiFi up
wifi_set_opmode_current(0/*WIFI_OFF*/);
wifi_fpm_set_sleep_type(MODEM_SLEEP_T);
wifi_fpm_open();
wifi_fpm_do_sleep(0xFFFFFFF);
}
extern "C" void user_init(void) {
@ -365,6 +376,7 @@ extern "C" void user_init(void) {
umm_init_iram();
#endif
preinit(); // Prior to C++ Dynamic Init (not related to above init() ). Meant to be user redefinable.
__disableWiFiAtBootTime(); // default weak function disables WiFi
ets_task(loop_task,
LOOP_TASK_PRIORITY, s_loop_queue,

View File

@ -18,6 +18,7 @@ void esp_schedule();
void tune_timeshift64 (uint64_t now_us);
void disable_extra4k_at_link_time (void) __attribute__((noinline));
bool sntp_set_timezone_in_seconds(int32_t timezone);
void __disableWiFiAtBootTime (void) __attribute__((noinline));
void __real_system_restart_local() __attribute__((noreturn));
uint32_t sqrt32 (uint32_t n);
@ -34,6 +35,6 @@ using TrivialCB = std::function<void()>;
void settimeofday_cb (const BoolCB& cb);
void settimeofday_cb (const TrivialCB& cb);
#endif
#endif // __cplusplus
#endif // __COREDECLS_H