Last active
January 23, 2018 08:54
-
-
Save jindrichsirucek/5e6d7208d323e35231f8291810fa53f1 to your computer and use it in GitHub Desktop.
100% working example. It saves battery life greatly, but ESP can still operate (except wifi)..
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern "C" { | |
#include "user_interface.h" | |
} | |
void turnWifiOn() | |
{ | |
if(MAIN_DEBUG) DEBUG_OUTPUT.println(E("WiFi Radio: Turning ON")); | |
wifi_fpm_do_wakeup(); | |
wifi_fpm_close(); | |
wifi_set_opmode(STATION_MODE); | |
wifi_station_connect(); | |
yield(); | |
} | |
#define FPM_SLEEP_MAX_TIME 0xFFFFFFF | |
void turnWifiOff() | |
{ | |
if(MAIN_DEBUG) DEBUG_OUTPUT.println(E("Diconnecting client and wifi")); | |
// client.disconnect(); | |
wifi_station_disconnect(); | |
wifi_set_opmode(NULL_MODE); | |
wifi_set_sleep_type(MODEM_SLEEP_T); | |
wifi_fpm_open(); | |
wifi_fpm_do_sleep(FPM_SLEEP_MAX_TIME); | |
yield(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment