mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 04:36:31 +00:00
v5.12.0c - Fix hold time action and wifi
5.12.0c * Fix intermittent exception when dns lookup is used while sleep is enabled * Fix 5.4.0 regression turning off single press after button hold during 4x hold time * Fix possible wifi connection problem by erasing sdk configuration parameters
This commit is contained in:
parent
4c75873027
commit
ac848572c9
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,3 +4,5 @@
|
|||||||
.gcc-flags.json
|
.gcc-flags.json
|
||||||
.vscode
|
.vscode
|
||||||
sonoff/user_config_override.h
|
sonoff/user_config_override.h
|
||||||
|
.vscode/c_cpp_properties.json
|
||||||
|
.vscode/launch.json
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
## Sonoff-Tasmota
|
## Sonoff-Tasmota
|
||||||
Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE.
|
Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE.
|
||||||
|
|
||||||
Current version is **5.12.0b** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
|
Current version is **5.12.0c** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
|
||||||
|
|
||||||
### ATTENTION All versions
|
### ATTENTION All versions
|
||||||
|
|
||||||
|
36
lib/readme.txt
Normal file
36
lib/readme.txt
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
This directory is intended for the project specific (private) libraries.
|
||||||
|
PlatformIO will compile them to static libraries and link to executable file.
|
||||||
|
|
||||||
|
The source code of each library should be placed in separate directory, like
|
||||||
|
"lib/private_lib/[here are source files]".
|
||||||
|
|
||||||
|
For example, see how can be organized `Foo` and `Bar` libraries:
|
||||||
|
|
||||||
|
|--lib
|
||||||
|
| |--Bar
|
||||||
|
| | |--docs
|
||||||
|
| | |--examples
|
||||||
|
| | |--src
|
||||||
|
| | |- Bar.c
|
||||||
|
| | |- Bar.h
|
||||||
|
| |--Foo
|
||||||
|
| | |- Foo.c
|
||||||
|
| | |- Foo.h
|
||||||
|
| |- readme.txt --> THIS FILE
|
||||||
|
|- platformio.ini
|
||||||
|
|--src
|
||||||
|
|- main.c
|
||||||
|
|
||||||
|
Then in `src/main.c` you should use:
|
||||||
|
|
||||||
|
#include <Foo.h>
|
||||||
|
#include <Bar.h>
|
||||||
|
|
||||||
|
// rest H/C/CPP code
|
||||||
|
|
||||||
|
PlatformIO will find your libraries automatically, configure preprocessor's
|
||||||
|
include paths and build them.
|
||||||
|
|
||||||
|
More information about PlatformIO Library Dependency Finder
|
||||||
|
- http://docs.platformio.org/page/librarymanager/ldf.html
|
@ -1,5 +1,7 @@
|
|||||||
/* 5.12.0c
|
/* 5.12.0c
|
||||||
* Fix intermittent exception when dns lookup is used while sleep is enabled
|
* Fix intermittent exception when dns lookup is used while sleep is enabled
|
||||||
|
* Fix 5.4.0 regression turning off single press after button hold during 4x hold time
|
||||||
|
* Fix possible wifi connection problem by erasing sdk configuration parameters
|
||||||
*
|
*
|
||||||
* 5.12.0b
|
* 5.12.0b
|
||||||
* Add serial debug info
|
* Add serial debug info
|
||||||
|
@ -185,14 +185,11 @@ void SetFlashModeDout()
|
|||||||
eboot_command_read(&ebcmd);
|
eboot_command_read(&ebcmd);
|
||||||
address = ebcmd.args[0];
|
address = ebcmd.args[0];
|
||||||
_buffer = new uint8_t[FLASH_SECTOR_SIZE];
|
_buffer = new uint8_t[FLASH_SECTOR_SIZE];
|
||||||
if (SPI_FLASH_RESULT_OK == spi_flash_read(address, (uint32_t*)_buffer, FLASH_SECTOR_SIZE)) {
|
|
||||||
|
if (ESP.flashRead(address, (uint32_t*)_buffer, FLASH_SECTOR_SIZE)) {
|
||||||
if (_buffer[2] != 3) { // DOUT
|
if (_buffer[2] != 3) { // DOUT
|
||||||
_buffer[2] = 3;
|
_buffer[2] = 3;
|
||||||
noInterrupts();
|
if (ESP.flashEraseSector(address / FLASH_SECTOR_SIZE)) ESP.flashWrite(address, (uint32_t*)_buffer, FLASH_SECTOR_SIZE);
|
||||||
if (SPI_FLASH_RESULT_OK == spi_flash_erase_sector(address / FLASH_SECTOR_SIZE)) {
|
|
||||||
spi_flash_write(address, (uint32_t*)_buffer, FLASH_SECTOR_SIZE);
|
|
||||||
}
|
|
||||||
interrupts();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete[] _buffer;
|
delete[] _buffer;
|
||||||
@ -256,15 +253,11 @@ void SettingsSave(byte rotate)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Settings.save_flag++;
|
Settings.save_flag++;
|
||||||
noInterrupts();
|
ESP.flashEraseSector(settings_location);
|
||||||
spi_flash_erase_sector(settings_location);
|
ESP.flashWrite(settings_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(SYSCFG));
|
||||||
spi_flash_write(settings_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(SYSCFG));
|
|
||||||
interrupts();
|
|
||||||
if (!stop_flash_rotate && rotate) {
|
if (!stop_flash_rotate && rotate) {
|
||||||
for (byte i = 1; i < CFG_ROTATES; i++) {
|
for (byte i = 1; i < CFG_ROTATES; i++) {
|
||||||
noInterrupts();
|
ESP.flashEraseSector(settings_location -i); // Delete previous configurations by resetting to 0xFF
|
||||||
spi_flash_erase_sector(settings_location -i); // Delete previous configurations by resetting to 0xFF
|
|
||||||
interrupts();
|
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,10 +282,8 @@ void SettingsLoad()
|
|||||||
settings_location = SETTINGS_LOCATION +1;
|
settings_location = SETTINGS_LOCATION +1;
|
||||||
for (byte i = 0; i < CFG_ROTATES; i++) {
|
for (byte i = 0; i < CFG_ROTATES; i++) {
|
||||||
settings_location--;
|
settings_location--;
|
||||||
noInterrupts();
|
ESP.flashRead(settings_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(SYSCFG));
|
||||||
spi_flash_read(settings_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(SYSCFG));
|
ESP.flashRead((settings_location -1) * SPI_FLASH_SEC_SIZE, (uint32*)&_SettingsH, sizeof(SYSCFGH));
|
||||||
spi_flash_read((settings_location -1) * SPI_FLASH_SEC_SIZE, (uint32*)&_SettingsH, sizeof(SYSCFGH));
|
|
||||||
interrupts();
|
|
||||||
|
|
||||||
// snprintf_P(log_data, sizeof(log_data), PSTR("Cnfg: Check at %X with count %d and holder %X"), settings_location -1, _SettingsH.save_flag, _SettingsH.cfg_holder);
|
// snprintf_P(log_data, sizeof(log_data), PSTR("Cnfg: Check at %X with count %d and holder %X"), settings_location -1, _SettingsH.save_flag, _SettingsH.cfg_holder);
|
||||||
// AddLog(LOG_LEVEL_DEBUG);
|
// AddLog(LOG_LEVEL_DEBUG);
|
||||||
@ -307,15 +298,10 @@ void SettingsLoad()
|
|||||||
AddLog(LOG_LEVEL_DEBUG);
|
AddLog(LOG_LEVEL_DEBUG);
|
||||||
if (Settings.cfg_holder != CFG_HOLDER) {
|
if (Settings.cfg_holder != CFG_HOLDER) {
|
||||||
// Auto upgrade
|
// Auto upgrade
|
||||||
noInterrupts();
|
ESP.flashRead((SETTINGS_LOCATION_3) * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(SYSCFG));
|
||||||
spi_flash_read((SETTINGS_LOCATION_3) * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(SYSCFG));
|
ESP.flashRead((SETTINGS_LOCATION_3 + 1) * SPI_FLASH_SEC_SIZE, (uint32*)&_SettingsH, sizeof(SYSCFGH));
|
||||||
spi_flash_read((SETTINGS_LOCATION_3 + 1) * SPI_FLASH_SEC_SIZE, (uint32*)&_SettingsH, sizeof(SYSCFGH));
|
if (Settings.save_flag < _SettingsH.save_flag) ESP.flashRead((SETTINGS_LOCATION_3 + 1) * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(SYSCFG));
|
||||||
if (Settings.save_flag < _SettingsH.save_flag)
|
if ((Settings.cfg_holder != CFG_HOLDER) || (Settings.version >= 0x04020000)) SettingsDefault();
|
||||||
spi_flash_read((SETTINGS_LOCATION_3 + 1) * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(SYSCFG));
|
|
||||||
interrupts();
|
|
||||||
if ((Settings.cfg_holder != CFG_HOLDER) || (Settings.version >= 0x04020000)) {
|
|
||||||
SettingsDefault();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
settings_hash = GetSettingsHash();
|
settings_hash = GetSettingsHash();
|
||||||
@ -323,25 +309,33 @@ void SettingsLoad()
|
|||||||
RtcSettingsLoad();
|
RtcSettingsLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsErase()
|
void SettingsErase(uint8_t type)
|
||||||
{
|
{
|
||||||
SpiFlashOpResult result;
|
/*
|
||||||
|
0 = Erase from program end until end of physical flash
|
||||||
|
1 = Erase SDK parameter area at end of linker memory model (0x0FDxxx - 0x0FFFFF) solving possible wifi errors
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool result;
|
||||||
|
|
||||||
uint32_t _sectorStart = (ESP.getSketchSize() / SPI_FLASH_SEC_SIZE) + 1;
|
uint32_t _sectorStart = (ESP.getSketchSize() / SPI_FLASH_SEC_SIZE) + 1;
|
||||||
uint32_t _sectorEnd = ESP.getFlashChipRealSize() / SPI_FLASH_SEC_SIZE;
|
uint32_t _sectorEnd = ESP.getFlashChipRealSize() / SPI_FLASH_SEC_SIZE;
|
||||||
|
if (1 == type) {
|
||||||
|
_sectorStart = SETTINGS_LOCATION +2; // SDK parameter area above EEPROM area (0x0FDxxx - 0x0FFFFF)
|
||||||
|
_sectorEnd = SETTINGS_LOCATION +5;
|
||||||
|
}
|
||||||
|
|
||||||
boolean _serialoutput = (LOG_LEVEL_DEBUG_MORE <= seriallog_level);
|
boolean _serialoutput = (LOG_LEVEL_DEBUG_MORE <= seriallog_level);
|
||||||
|
|
||||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_ERASE " %d " D_UNIT_SECTORS), _sectorEnd - _sectorStart);
|
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_ERASE " %d " D_UNIT_SECTORS), _sectorEnd - _sectorStart);
|
||||||
AddLog(LOG_LEVEL_DEBUG);
|
AddLog(LOG_LEVEL_DEBUG);
|
||||||
|
|
||||||
for (uint32_t _sector = _sectorStart; _sector < _sectorEnd; _sector++) {
|
for (uint32_t _sector = _sectorStart; _sector < _sectorEnd; _sector++) {
|
||||||
noInterrupts();
|
result = ESP.flashEraseSector(_sector);
|
||||||
result = spi_flash_erase_sector(_sector);
|
|
||||||
interrupts();
|
|
||||||
if (_serialoutput) {
|
if (_serialoutput) {
|
||||||
Serial.print(F(D_LOG_APPLICATION D_ERASED_SECTOR " "));
|
Serial.print(F(D_LOG_APPLICATION D_ERASED_SECTOR " "));
|
||||||
Serial.print(_sector);
|
Serial.print(_sector);
|
||||||
if (SPI_FLASH_RESULT_OK == result) {
|
if (result) {
|
||||||
Serial.println(F(" " D_OK));
|
Serial.println(F(" " D_OK));
|
||||||
} else {
|
} else {
|
||||||
Serial.println(F(" " D_ERROR));
|
Serial.println(F(" " D_ERROR));
|
||||||
@ -352,6 +346,27 @@ void SettingsErase()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copied from 2.4.0 as 2.3.0 is incomplete
|
||||||
|
bool SettingsEraseConfig(void) {
|
||||||
|
const size_t cfgSize = 0x4000;
|
||||||
|
size_t cfgAddr = ESP.getFlashChipSize() - cfgSize;
|
||||||
|
|
||||||
|
for (size_t offset = 0; offset < cfgSize; offset += SPI_FLASH_SEC_SIZE) {
|
||||||
|
if (!ESP.flashEraseSector((cfgAddr + offset) / SPI_FLASH_SEC_SIZE)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsSdkErase()
|
||||||
|
{
|
||||||
|
WiFi.disconnect(true); // Delete SDK wifi config
|
||||||
|
SettingsErase(1);
|
||||||
|
SettingsEraseConfig();
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsDump(char* parms)
|
void SettingsDump(char* parms)
|
||||||
{
|
{
|
||||||
#define CFG_COLS 16
|
#define CFG_COLS 16
|
||||||
|
@ -170,7 +170,7 @@ uint8_t blinkstate = 0; // LED state
|
|||||||
|
|
||||||
uint8_t blockgpio0 = 4; // Block GPIO0 for 4 seconds after poweron to workaround Wemos D1 RTS circuit
|
uint8_t blockgpio0 = 4; // Block GPIO0 for 4 seconds after poweron to workaround Wemos D1 RTS circuit
|
||||||
uint8_t lastbutton[MAX_KEYS] = { NOT_PRESSED, NOT_PRESSED, NOT_PRESSED, NOT_PRESSED }; // Last button states
|
uint8_t lastbutton[MAX_KEYS] = { NOT_PRESSED, NOT_PRESSED, NOT_PRESSED, NOT_PRESSED }; // Last button states
|
||||||
uint8_t holdbutton[MAX_KEYS] = { 0 }; // Timer for button hold
|
uint16_t holdbutton[MAX_KEYS] = { 0 }; // Timer for button hold
|
||||||
uint8_t multiwindow[MAX_KEYS] = { 0 }; // Max time between button presses to record press count
|
uint8_t multiwindow[MAX_KEYS] = { 0 }; // Max time between button presses to record press count
|
||||||
uint8_t multipress[MAX_KEYS] = { 0 }; // Number of button presses within multiwindow
|
uint8_t multipress[MAX_KEYS] = { 0 }; // Number of button presses within multiwindow
|
||||||
uint8_t lastwallswitch[MAX_SWITCHES]; // Last wall switch states
|
uint8_t lastwallswitch[MAX_SWITCHES]; // Last wall switch states
|
||||||
@ -1475,7 +1475,8 @@ void MqttDataCallback(char* topic, byte* data, unsigned int data_len)
|
|||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command , D_JSON_RESET_AND_RESTARTING);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command , D_JSON_RESET_AND_RESTARTING);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
restart_flag = 212;
|
case 3:
|
||||||
|
restart_flag = 210 + payload;
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_RESET "\":\"" D_JSON_ERASE ", " D_JSON_RESET_AND_RESTARTING "\"}"));
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_RESET "\":\"" D_JSON_ERASE ", " D_JSON_RESET_AND_RESTARTING "\"}"));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -2370,9 +2371,12 @@ void StateLoop()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (restart_flag && (backlog_pointer == backlog_index)) {
|
if (restart_flag && (backlog_pointer == backlog_index)) {
|
||||||
if (212 == restart_flag) {
|
if (213 == restart_flag) {
|
||||||
SettingsErase();
|
SettingsSdkErase(); // Erase flash SDK parameters
|
||||||
restart_flag--;
|
restart_flag = 2;
|
||||||
|
} else if (212 == restart_flag) {
|
||||||
|
SettingsErase(0); // Erase all flash from program end to end of physical flash
|
||||||
|
restart_flag = 211;
|
||||||
}
|
}
|
||||||
if (211 == restart_flag) {
|
if (211 == restart_flag) {
|
||||||
SettingsDefault();
|
SettingsDefault();
|
||||||
|
@ -160,7 +160,7 @@ void WifiWpsStatusCallback(wps_cb_status status);
|
|||||||
|
|
||||||
//#include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0)
|
//#include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0)
|
||||||
#ifndef ARDUINO_ESP8266_RELEASE
|
#ifndef ARDUINO_ESP8266_RELEASE
|
||||||
#define ARDUINO_ESP8266_RELEASE "STAGED"
|
#define ARDUINO_ESP8266_RELEASE "STAGE"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // _SONOFF_POST_H_
|
#endif // _SONOFF_POST_H_
|
@ -561,7 +561,8 @@ void WifiBegin(uint8_t flag)
|
|||||||
WiFi.mode(WIFI_OFF); // See https://github.com/esp8266/Arduino/issues/2186
|
WiFi.mode(WIFI_OFF); // See https://github.com/esp8266/Arduino/issues/2186
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
WiFi.disconnect();
|
WiFi.disconnect(true); // Delete SDK wifi config
|
||||||
|
delay(200);
|
||||||
WiFi.mode(WIFI_STA); // Disable AP mode
|
WiFi.mode(WIFI_STA); // Disable AP mode
|
||||||
if (Settings.sleep) {
|
if (Settings.sleep) {
|
||||||
WiFi.setSleepMode(WIFI_LIGHT_SLEEP); // Allow light sleep during idle times
|
WiFi.setSleepMode(WIFI_LIGHT_SLEEP); // Allow light sleep during idle times
|
||||||
@ -697,6 +698,7 @@ void WifiCheck(uint8_t param)
|
|||||||
if (WIFI_SMARTCONFIG == wifi_config_type) {
|
if (WIFI_SMARTCONFIG == wifi_config_type) {
|
||||||
WiFi.stopSmartConfig();
|
WiFi.stopSmartConfig();
|
||||||
}
|
}
|
||||||
|
SettingsSdkErase();
|
||||||
restart_flag = 2;
|
restart_flag = 2;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user