Skip to content

Commit

Permalink
ESP32: Add wifi.sta_ps_mode: an option to control wifi power save mode
Browse files Browse the repository at this point in the history
CL: wifi: ESP32: Add wifi.sta_ps_mode: an option to control wifi power save mode
  • Loading branch information
rojer committed May 10, 2019
1 parent 968f20c commit 1de40f1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BasedOnStyle: Google
AllowShortFunctionsOnASingleLine: false
SpaceAfterCStyleCast: true
PointerBindsToType: false
DerivePointerBinding: false
1 change: 1 addition & 0 deletions mos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ conds:
apply:
config_schema:
- ["wifi.ap.keep_enabled", "b", true, {title: "Keep AP enabled when station is on"}]
- ["wifi.sta_ps_mode", "i", 0, {title: "Power save mode for station: 0 - none, 1 - min, 2 - max."}]
cdefs:
MGOS_WIFI_ENABLE_AP_STA: 1

Expand Down
10 changes: 7 additions & 3 deletions src/esp32/esp32_wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,14 @@ static esp_err_t esp32_wifi_ensure_start(void) {
goto out;
}
s_started = true;
wifi_ps_type_t ps_type = WIFI_PS_NONE;
esp_wifi_get_ps(&ps_type);
wifi_ps_type_t cur_ps_mode = WIFI_PS_NONE;
wifi_ps_type_t want_ps_mode = (wifi_ps_type_t) mgos_sys_config_get_wifi_sta_ps_mode();
esp_wifi_get_ps(&cur_ps_mode);
/* Workaround for https://github.com/espressif/esp-idf/issues/1942 */
if (ps_type != WIFI_PS_NONE) esp_wifi_set_ps(WIFI_PS_NONE);
if (cur_ps_mode != want_ps_mode) {
LOG(LL_DEBUG, ("WiFi PS %d -> %d", cur_ps_mode, want_ps_mode));
esp_wifi_set_ps(want_ps_mode);
}
}
out:
return r;
Expand Down

0 comments on commit 1de40f1

Please sign in to comment.