examples/power_save: enable modem sleep and DFS by default

This commit is contained in:
Ivan Grokhotkov 2017-10-10 12:33:47 +08:00
parent 062be56c3c
commit f6ef536fe9
3 changed files with 20 additions and 1 deletions

View file

@ -14,7 +14,7 @@ config WIFI_PASSWORD
choice POWER_SAVE_MODE
prompt "power save mode"
default POWER_SAVE_NONE
default POWER_SAVE_MODEM
help
Power save mode for the esp32 to use.

View file

@ -17,6 +17,7 @@
#include "esp_wifi.h"
#include "esp_log.h"
#include "esp_event_loop.h"
#include "esp_pm.h"
#include "nvs_flash.h"
/*set the ssid and password via "make menuconfig"*/
@ -89,5 +90,17 @@ void app_main()
}
ESP_ERROR_CHECK( ret );
#if CONFIG_PM_ENABLE
// Configure dynamic frequency scaling: maximum frequency is set in sdkconfig,
// minimum frequency is XTAL.
rtc_cpu_freq_t max_freq;
rtc_clk_cpu_freq_from_mhz(CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ, &max_freq);
esp_pm_config_esp32_t pm_config = {
.max_cpu_freq = max_freq,
.min_cpu_freq = RTC_CPU_FREQ_XTAL
};
ESP_ERROR_CHECK( esp_pm_configure(&pm_config) );
#endif // CONFIG_PM_ENABLE
wifi_power_save();
}

View file

@ -0,0 +1,6 @@
# Use lower CPU frequency
CONFIG_ESP32_DEFAULT_CPU_FREQ_80=y
# Enable support for power management
CONFIG_PM_ENABLE=y
# Use RTC timer as reference
CONFIG_PM_USE_RTC_TIMER_REF=y