@@ -52,6 +52,7 @@ extern "C" void esp_yield();
52
52
53
53
bool ESP8266WiFiGenericClass::_persistent = true ;
54
54
WiFiEventCb ESP8266WiFiGenericClass::_cbEvent = NULL ;
55
+ WiFiMode_t ESP8266WiFiGenericClass::_forceSleepLastMode = WIFI_OFF;
55
56
56
57
ESP8266WiFiGenericClass::ESP8266WiFiGenericClass () {
57
58
wifi_set_event_handler_cb ((wifi_event_handler_cb_t ) &ESP8266WiFiGenericClass::_eventCallback);
@@ -128,7 +129,7 @@ WiFiPhyMode_t ESP8266WiFiGenericClass::getPhyMode() {
128
129
* set the output power of WiFi
129
130
* @param dBm max: +20.5dBm min: 0dBm
130
131
*/
131
- void ESP8266WiFiGenericClass::setOutputPower (float_t dBm) {
132
+ void ESP8266WiFiGenericClass::setOutputPower (float dBm) {
132
133
133
134
if (dBm > 20.5 ) {
134
135
dBm = 20.5 ;
@@ -223,7 +224,43 @@ bool ESP8266WiFiGenericClass::enableAP(bool enable){
223
224
}
224
225
225
226
227
+ /* *
228
+ * Disable WiFi for x us when value is not 0
229
+ * @param sleep_time_in_us
230
+ * @return ok
231
+ */
232
+ bool ESP8266WiFiGenericClass::forceSleepBegin (uint32 sleepUs) {
233
+ _forceSleepLastMode = getMode ();
234
+ if (!mode (WIFI_OFF)) {
235
+ return false ;
236
+ }
237
+
238
+ if (sleepUs == 0 ) {
239
+ sleepUs = 0xFFFFFFF ;
240
+ }
241
+
242
+ wifi_fpm_set_sleep_type (MODEM_SLEEP_T);
243
+ wifi_fpm_open ();
244
+ return (wifi_fpm_do_sleep (sleepUs) == 0 );
245
+ }
226
246
247
+ /* *
248
+ * wake up WiFi Modem
249
+ * @return ok
250
+ */
251
+ bool ESP8266WiFiGenericClass::forceSleepWake () {
252
+ wifi_fpm_do_wakeup ();
253
+ wifi_fpm_close ();
254
+
255
+ // restore last mode
256
+ if (mode (_forceSleepLastMode)) {
257
+ if ((_forceSleepLastMode & WIFI_STA) != 0 ){
258
+ wifi_station_connect ();
259
+ }
260
+ return true ;
261
+ }
262
+ return false ;
263
+ }
227
264
228
265
229
266
// -----------------------------------------------------------------------------------------------------------------------
0 commit comments