diff --git a/CHANGELOG.md b/CHANGELOG.md index c4eb29802..e7e207f17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file. ### Changed - Force initial default state ``SetOption57 1`` to scan wifi network every 44 minutes for strongest signal (#10395) +- Command ``Sleep 0`` removes any sleep from wifi modem except when ESP32 BLE is active ## [9.2.0.2] 20210105 ### Added diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 5981c4022..b3f8e38a0 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -96,6 +96,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Replaced RA8876 GPIO selection from ``SPI CS`` by ``RA8876 CS`` ### Changed +- Command ``Sleep 0`` removes any sleep from wifi modem except when ESP32 BLE is active - Logging from heap to stack freeing 700 bytes RAM - Disabled ``USE_LIGHT`` light support for ZBBridge saving 17.6kB [#10374](https://github.com/arendst/Tasmota/issues/10374) - Force initial default state ``SetOption57 1`` to scan wifi network every 44 minutes for strongest signal [#10395](https://github.com/arendst/Tasmota/issues/10395) diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 0866d3f84..1c5e32474 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -967,8 +967,9 @@ void CmndSetoption(void) bitWrite(Settings.flag5.data, pindex, XdrvMailbox.payload); switch (pindex) { case 1: // SetOption115 - Enable ESP32 MI32 - Settings.flag3.sleep_normal = 1; // SetOption60 - Enable normal sleep instead of dynamic sleep - TasmotaGlobal.restart_flag = 2; + if (0 == XdrvMailbox.payload) { + TasmotaGlobal.restart_flag = 2; + } break; } } diff --git a/tasmota/support_wifi.ino b/tasmota/support_wifi.ino index b281b0c51..2b5101174 100644 --- a/tasmota/support_wifi.ino +++ b/tasmota/support_wifi.ino @@ -160,15 +160,14 @@ void WiFiSetSleepMode(void) WiFi.setSleepMode(WIFI_MODEM_SLEEP); // Disable sleep (Esp8288/Arduino core and sdk default) } */ - if (TasmotaGlobal.sleep && Settings.flag3.sleep_normal) { // SetOption60 - Enable normal sleep instead of dynamic sleep - WiFi.setSleepMode(WIFI_LIGHT_SLEEP); // Allow light sleep during idle times - } else { -#ifdef ESP8266 - if (0 == TasmotaGlobal.sleep) { + if (0 == TasmotaGlobal.sleep) { + if (!TasmotaGlobal.wifi_stay_asleep) { WiFi.setSleepMode(WIFI_NONE_SLEEP); // Disable sleep - } else -#endif - { + } + } else { + if (Settings.flag3.sleep_normal) { // SetOption60 - Enable normal sleep instead of dynamic sleep + WiFi.setSleepMode(WIFI_LIGHT_SLEEP); // Allow light sleep during idle times + } else { WiFi.setSleepMode(WIFI_MODEM_SLEEP); // Sleep (Esp8288/Arduino core and sdk default) } } diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 36511aa9e..2407e61b1 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -125,6 +125,7 @@ struct { bool skip_light_fade; // Temporarily skip light fading bool restart_halt; // Do not restart but stay in wait loop bool module_changed; // Indicate module changed since last restart + bool wifi_stay_asleep; // Allow sleep only incase of ESP32 BLE StateBitfield global_state; // Global states (currently Wifi and Mqtt) (8 bits) uint8_t spi_enabled; // SPI configured diff --git a/tasmota/xsns_52_ibeacon.ino b/tasmota/xsns_52_ibeacon.ino index 731189827..723446700 100755 --- a/tasmota/xsns_52_ibeacon.ino +++ b/tasmota/xsns_52_ibeacon.ino @@ -279,16 +279,13 @@ void ESP32Init() { if (TasmotaGlobal.global_state.wifi_down) { return; } + TasmotaGlobal.wifi_stay_asleep = true; if (WiFi.getSleep() == false) { - if (0 == Settings.flag3.sleep_normal) { - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: About to restart to put WiFi modem in sleep mode"),"BLE"); - Settings.flag3.sleep_normal = 1; // SetOption60 - Enable normal sleep instead of dynamic sleep - TasmotaGlobal.restart_flag = 2; - } - return; + AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Put WiFi modem in sleep mode"),"BLE"); + WiFi.setSleep(true); // Sleep } - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Initializing Blueetooth..."),"BLE"); + AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Initializing Bluetooth..."),"BLE"); if (!ESP32BLE.mode.init) { NimBLEDevice::init(""); diff --git a/tasmota/xsns_62_MI_ESP32.ino b/tasmota/xsns_62_MI_ESP32.ino index 9e9c70dc5..689b5a72a 100644 --- a/tasmota/xsns_62_MI_ESP32.ino +++ b/tasmota/xsns_62_MI_ESP32.ino @@ -589,17 +589,17 @@ int MI32_decryptPacket(char *_buf, uint16_t _bufSize, uint32_t _type){ MI32_ReverseMAC(packet->MAC); uint8_t _bindkey[16] = {0x0}; bool foundNoKey = true; - AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: search key for MAC: %02x %02x %02x %02x %02x %02x"), packet->MAC[0], packet->MAC[1], packet->MAC[2], packet->MAC[3], packet->MAC[4], packet->MAC[5]); + AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Search key for MAC: %02x %02x %02x %02x %02x %02x"), packet->MAC[0], packet->MAC[1], packet->MAC[2], packet->MAC[3], packet->MAC[4], packet->MAC[5]); for(uint32_t i=0; iMAC,MIBLEbindKeys[i].MAC,sizeof(packet->MAC))==0){ memcpy(_bindkey,MIBLEbindKeys[i].key,sizeof(_bindkey)); - AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: decryption Key found")); + AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Decryption Key found")); foundNoKey = false; break; } } if(foundNoKey){ - AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: no Key found !!")); + AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: No Key found !!")); return -2; } @@ -619,7 +619,7 @@ int MI32_decryptPacket(char *_buf, uint16_t _bufSize, uint32_t _type){ ret = br_ccm_check_tag(&ctx, &tag); - AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: Err:%i, Decrypted : %02x %02x %02x %02x %02x "), ret, packet->payload[1],packet->payload[2],packet->payload[3],packet->payload[4],packet->payload[5]); + AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Err:%i, Decrypted : %02x %02x %02x %02x %02x "), ret, packet->payload[1],packet->payload[2],packet->payload[3],packet->payload[4],packet->payload[5]); return ret-1; } #endif // USE_MI_DECRYPTION @@ -660,7 +660,7 @@ uint32_t MIBLEgetSensorSlot(uint8_t (&_MAC)[6], uint16_t _type, uint8_t counter) bool _success = false; for (uint32_t i=0;i19) { - AddLog_P(LOG_LEVEL_INFO,PSTR("MI32: Scan buffer full")); + AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Scan buffer full")); MI32.state.beaconScanCounter = 1; return; } for(auto _scanResult : MIBLEscanResult){ if(memcmp(addr,_scanResult.MAC,6)==0){ - // AddLog_P(LOG_LEVEL_INFO,PSTR("MI32: known device")); + // AddLog_P(LOG_LEVEL_INFO,PSTR("M32: known device")); return; } } @@ -1585,12 +1582,12 @@ void MI32addBeacon(uint8_t index, char* data){ _new.time = 0; if(memcmp(_empty,_new.MAC,6) == 0){ _new.active = false; - AddLog_P(LOG_LEVEL_INFO,PSTR("MI32: beacon%u deactivated"), index); + AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Beacon%u deactivated"), index); } else{ _new.active = true; MI32.mode.activeBeacon = 1; - AddLog_P(LOG_LEVEL_INFO,PSTR("MI32: beacon added with MAC: %s"), _MAC); + AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Beacon added with MAC: %s"), _MAC); } } @@ -1845,7 +1842,7 @@ void CmndMi32Time(void) { if (XdrvMailbox.data_len > 0) { if (MIBLEsensors.size() > XdrvMailbox.payload) { if ((LYWSD02 == MIBLEsensors[XdrvMailbox.payload].type) || (MHOC303 == MIBLEsensors[XdrvMailbox.payload].type)) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("MI32: will set Time")); + AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Will set Time")); MI32.state.sensor = XdrvMailbox.payload; MI32.mode.canScan = 0; MI32.mode.canConnect = 0; @@ -1875,7 +1872,7 @@ void CmndMi32Unit(void) { if (XdrvMailbox.data_len > 0) { if (MIBLEsensors.size() > XdrvMailbox.payload) { if ((LYWSD02 == MIBLEsensors[XdrvMailbox.payload].type) || (MHOC303 == MIBLEsensors[XdrvMailbox.payload].type)) { - AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: will set Unit")); + AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Will set Unit")); MI32.state.sensor = XdrvMailbox.payload; MI32.mode.canScan = 0; MI32.mode.canConnect = 0; @@ -1925,11 +1922,11 @@ void CmndMi32Block(void){ switch (XdrvMailbox.index) { case 0: MIBLEBlockList.clear(); - // AddLog_P(LOG_LEVEL_INFO,PSTR("MI32: size of ilist: %u"), MIBLEBlockList.size()); - ResponseCmndIdxChar(PSTR("block list cleared")); + // AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Size of ilist: %u"), MIBLEBlockList.size()); + ResponseCmndIdxChar(PSTR("Block list cleared")); break; case 1: - ResponseCmndIdxChar(PSTR("show block list")); + ResponseCmndIdxChar(PSTR("Show block list")); break; } } @@ -1955,7 +1952,7 @@ void CmndMi32Block(void){ ResponseCmndIdxChar(XdrvMailbox.data); MI32removeMIBLEsensor(_MACasBytes.buf); } - // AddLog_P(LOG_LEVEL_INFO,PSTR("MI32: size of ilist: %u"), MIBLEBlockList.size()); + // AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Size of ilist: %u"), MIBLEBlockList.size()); break; } }