You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[BREAKING] wifi: remove pseudo-modes for shutdown, expose ::[resumeFrom]shutdown() (#7956)
* wifi: remove pseudo-modes for shutdown
make shutdown and resumeFromShutdown public
removes extra code from the mode handler and include method description
in the docs
* typo
* dup
* typos
* reference only shutdown() & resumeFromShutdown()
prefer to have some specific function, don't simply chain into sleep
update examples and docs
* safeguard raw sdk config usage
Copy file name to clipboardExpand all lines: doc/esp8266wifi/generic-class.rst
+35-24
Original file line number
Diff line number
Diff line change
@@ -80,9 +80,6 @@ Once ``WiFi.persistent(false)`` is called, ``WiFi.begin``, ``WiFi.disconnect``,
80
80
mode
81
81
~~~~
82
82
83
-
Regular WiFi modes
84
-
__________________
85
-
86
83
.. code:: cpp
87
84
88
85
bool mode(WiFiMode_t m)
@@ -94,25 +91,6 @@ Switches to one of the regular WiFi modes, where ``m`` is one of:
94
91
- ``WIFI_AP``: switch to `Access Point (AP) <readme.rst#soft-access-point>`__ mode.
95
92
- ``WIFI_AP_STA``: enable both Station (STA) and Access Point (AP) mode.
96
93
97
-
Pseudo-modes
98
-
____________
99
-
100
-
.. code:: cpp
101
-
102
-
bool mode(WiFiMode_t m, WiFiState* state)
103
-
104
-
Used with the following pseudo-modes, where ``m`` is one of:
105
-
106
-
- ``WIFI_SHUTDOWN``: Fills in the provided ``WiFiState`` structure, switches to ``WIFI_OFF`` mode and puts WiFi into forced sleep, preserving energy.
107
-
- ``WIFI_RESUME``: Turns WiFi on and tries to re-establish the WiFi connection stored in the ``WiFiState`` structure.
108
-
109
-
These modes are used in low-power scenarios, e.g. where ESP.deepSleep is used between actions to preserve battery power.
110
-
111
-
It is the user's responsibility to preserve the WiFiState between ``WIFI_SHUTDOWN`` and ``WIFI_RESUME``, e.g. by storing it
112
-
in RTC user data and/or flash memory.
113
-
114
-
There is an example sketch `WiFiShutdown.ino <https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/examples/WiFiShutdown/WiFiShutdown.ino>`__ available in the examples folder of the ESP8266WiFi library.
115
-
116
94
getMode
117
95
~~~~~~~
118
96
@@ -199,6 +177,41 @@ getPhyMode
199
177
200
178
Gets the WiFi radio phy mode that is currently set.
201
179
180
+
forceSleepBegin
181
+
~~~~~~~~~~~~~~~
182
+
183
+
.. code:: cpp
184
+
185
+
bool forceSleepBegin (uint32 sleepUs=0)
186
+
187
+
Saves the currently set WiFi mode and starts forced modem sleep for the specified time (us)
188
+
189
+
forceSleepWake
190
+
~~~~~~~~~~~~~~
191
+
192
+
.. code:: cpp
193
+
194
+
bool forceSleepWake ()
195
+
196
+
Called after `forceSleepBegin()`. Restores the previous WiFi mode and attempts reconnection when STA was active.
197
+
198
+
shutdown and resumeFromShutdown
199
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
200
+
201
+
.. code:: cpp
202
+
203
+
bool shutdown (WiFiState& state)
204
+
bool shutdown (WiFiState& state, uint32 sleepUs)
205
+
bool resumeFromShutdown (WiFiState& state)
206
+
bool shutdownValidCRC (const WiFiState& state)
207
+
208
+
Stores the STA interface IP configuration in the specified ``state`` struct and calls ``forceSleepBegin(sleepUs)``.
209
+
Restores STA interface configuration from the ``state`` and calls ``forceSleepWake()``.
210
+
211
+
These methods are intended to be used in low-power scenarios, e.g. where ESP.deepSleep is used between actions to preserve battery power. It is the user's responsibility to preserve the WiFiState between ``shutdown()`` and ``resumeFromShutdown()`` by storing it in the RTC user data and/or flash memory.
212
+
213
+
See `WiFiShutdown.ino <https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/examples/WiFiShutdown/WiFiShutdown.ino>`__ for an example of usage.
214
+
202
215
Other Function Calls
203
216
~~~~~~~~~~~~~~~~~~~~
204
217
@@ -208,8 +221,6 @@ Other Function Calls
208
221
WiFiSleepType_t getSleepMode ()
209
222
bool enableSTA (bool enable)
210
223
bool enableAP (bool enable)
211
-
bool forceSleepBegin (uint32 sleepUs=0)
212
-
bool forceSleepWake ()
213
224
int hostByName (const char *aHostname, IPAddress &aResult)
0 commit comments