mirror of https://github.com/arendst/Tasmota.git
Change sleep command
Change command sleep from restart after change to not restart after change (#3554)
This commit is contained in:
parent
5977bd37e1
commit
ae6fcd4d60
|
@ -4,6 +4,7 @@
|
|||
* Add GPIO options ButtonXn, SwitchXn and CounterXn to select INPUT mode instead of INPUT_PULLUP (#2525)
|
||||
* Fix OtaMagic when file path contains a dash (-) (#3563)
|
||||
* Fix EnergyReset3 (#2723)
|
||||
* Change command sleep from restart after change to not restart after change (#3554)
|
||||
*
|
||||
* 6.1.1.8
|
||||
* Fix MQTT reconnection detection when using TasmotaMqtt library (#3558)
|
||||
|
|
|
@ -562,9 +562,9 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
else if (CMND_SLEEP == command_code) {
|
||||
if ((payload >= 0) && (payload < 251)) {
|
||||
if ((!Settings.sleep && payload) || (Settings.sleep && !payload)) restart_flag = 2;
|
||||
Settings.sleep = payload;
|
||||
sleep = payload;
|
||||
WiFiSetSleepMode();
|
||||
}
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE_UNIT_NVALUE_UNIT, command, sleep, (Settings.flag.value_units) ? " " D_UNIT_MILLISECOND : "", Settings.sleep, (Settings.flag.value_units) ? " " D_UNIT_MILLISECOND : "");
|
||||
}
|
||||
|
|
|
@ -1079,6 +1079,28 @@ void WifiConfig(uint8_t type)
|
|||
}
|
||||
}
|
||||
|
||||
void WiFiSetSleepMode()
|
||||
{
|
||||
/* Excerpt from the esp8266 non os sdk api reference (v2.2.1):
|
||||
* Sets sleep type for power saving. Set WIFI_NONE_SLEEP to disable power saving.
|
||||
* - Default mode: WIFI_MODEM_SLEEP.
|
||||
* - In order to lower the power comsumption, ESP8266 changes the TCP timer
|
||||
* tick from 250ms to 3s in WIFI_LIGHT_SLEEP mode, which leads to increased timeout for
|
||||
* TCP timer. Therefore, the WIFI_MODEM_SLEEP or deep-sleep mode should be used
|
||||
* where there is a requirement for the accurancy of the TCP timer.
|
||||
*/
|
||||
|
||||
#ifndef ARDUINO_ESP8266_RELEASE_2_4_1 // See https://github.com/arendst/Sonoff-Tasmota/issues/2559 - Sleep bug in SDK
|
||||
|
||||
if (sleep) {
|
||||
WiFi.setSleepMode(WIFI_LIGHT_SLEEP); // Allow light sleep during idle times
|
||||
} else {
|
||||
WiFi.setSleepMode(WIFI_MODEM_SLEEP); // Diable sleep (Esp8288/Arduino core and sdk default)
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void WifiBegin(uint8_t flag)
|
||||
{
|
||||
const char kWifiPhyMode[] = " BGN";
|
||||
|
@ -1095,9 +1117,7 @@ void WifiBegin(uint8_t flag)
|
|||
WiFi.disconnect(true); // Delete SDK wifi config
|
||||
delay(200);
|
||||
WiFi.mode(WIFI_STA); // Disable AP mode
|
||||
#ifndef ARDUINO_ESP8266_RELEASE_2_4_1 // See https://github.com/arendst/Sonoff-Tasmota/issues/2559 - Sleep bug
|
||||
if (Settings.sleep) { WiFi.setSleepMode(WIFI_LIGHT_SLEEP); } // Allow light sleep during idle times
|
||||
#endif
|
||||
WiFiSetSleepMode();
|
||||
// if (WiFi.getPhyMode() != WIFI_PHY_MODE_11N) { WiFi.setPhyMode(WIFI_PHY_MODE_11N); }
|
||||
if (!WiFi.getAutoConnect()) { WiFi.setAutoConnect(true); }
|
||||
// WiFi.setAutoReconnect(true);
|
||||
|
|
Loading…
Reference in New Issue