mirror of
https://github.com/esphome/esphome.git
synced 2026-05-23 11:16:52 +08:00
[wifi] Fix ESP8266 power_save_mode mapping (LIGHT/HIGH were swapped) (#15029)
This commit is contained in:
committed by
Jesse Hills
parent
12eed0d384
commit
3fe84eadef
@@ -92,13 +92,23 @@ bool WiFiComponent::wifi_mode_(optional<bool> sta, optional<bool> ap) {
|
||||
return ret;
|
||||
}
|
||||
bool WiFiComponent::wifi_apply_power_save_() {
|
||||
// ESP8266 sleep types have confusing names — LIGHT_SLEEP_T is the MORE aggressive mode.
|
||||
// SDK enum: NONE_SLEEP_T=0, LIGHT_SLEEP_T=1, MODEM_SLEEP_T=2
|
||||
// https://github.com/esp8266/Arduino/blob/3.1.2/tools/sdk/include/user_interface.h#L447-L451
|
||||
// Arduino ESP32 compat confirms: WIFI_PS_MIN_MODEM=MODEM_SLEEP, WIFI_PS_MAX_MODEM=LIGHT_SLEEP
|
||||
// https://github.com/esp8266/Arduino/blob/3.1.2/libraries/ESP8266WiFi/src/ESP8266WiFiType.h#L53-L55
|
||||
sleep_type_t power_save;
|
||||
switch (this->power_save_) {
|
||||
case WIFI_POWER_SAVE_LIGHT:
|
||||
power_save = LIGHT_SLEEP_T;
|
||||
// MODEM_SLEEP_T: only the WiFi modem sleeps between DTIM beacons, CPU stays active.
|
||||
// Matches ESP32's WIFI_PS_MIN_MODEM.
|
||||
power_save = MODEM_SLEEP_T;
|
||||
break;
|
||||
case WIFI_POWER_SAVE_HIGH:
|
||||
power_save = MODEM_SLEEP_T;
|
||||
// LIGHT_SLEEP_T: both WiFi modem AND CPU suspend between DTIM beacons.
|
||||
// Most aggressive — prevents TCP processing during sleep. Matches ESP32's WIFI_PS_MAX_MODEM.
|
||||
// See https://github.com/esphome/esphome/issues/14999
|
||||
power_save = LIGHT_SLEEP_T;
|
||||
break;
|
||||
case WIFI_POWER_SAVE_NONE:
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user