mirror of https://github.com/arendst/Tasmota.git
6.5.0.4 Fix Configure Timer Web GUI
6.5.0.4 20190402 * Fix Configure Timer Web GUI (#5568) * Add validation check when loading settings from flash
This commit is contained in:
parent
76eec9b8ab
commit
8ff2759ccc
|
@ -1,4 +1,8 @@
|
|||
/* 6.5.0.3 20190328
|
||||
/* 6.5.0.4 20190402
|
||||
* Fix Configure Timer Web GUI (#5568)
|
||||
* Add validation check when loading settings from flash
|
||||
*
|
||||
* 6.5.0.3 20190328
|
||||
* Add command Sensor20 1..255 to change Nova Fitness SDS01 working period in minutes (#5452)
|
||||
* Change some defines to const
|
||||
* Change IRsend and receive for 64-bit support (#5523)
|
||||
|
|
|
@ -185,12 +185,12 @@ struct SYSCFG {
|
|||
unsigned long bootcount; // 00C
|
||||
*/
|
||||
struct SYSCFG {
|
||||
uint16_t cfg_holder; // 000 v6 header
|
||||
uint16_t cfg_size; // 002
|
||||
uint16_t cfg_holder; // 000 v6 header
|
||||
uint16_t cfg_size; // 002
|
||||
unsigned long save_flag; // 004
|
||||
unsigned long version; // 008
|
||||
uint16_t bootcount; // 00C
|
||||
uint16_t cfg_crc; // 00E
|
||||
uint16_t bootcount; // 00C
|
||||
uint16_t cfg_crc; // 00E
|
||||
SysBitfield flag; // 010
|
||||
int16_t save_data; // 014
|
||||
int8_t timezone; // 016
|
||||
|
|
|
@ -460,13 +460,17 @@ void SettingsLoad(void)
|
|||
|
||||
settings_location = 0;
|
||||
uint32_t flash_location = SETTINGS_LOCATION +1;
|
||||
uint16_t cfg_holder = 0;
|
||||
for (uint8_t i = 0; i < CFG_ROTATES; i++) {
|
||||
flash_location--;
|
||||
ESP.flashRead(flash_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(SYSCFG));
|
||||
|
||||
bool valid = false;
|
||||
if (Settings.version > 0x06000000) {
|
||||
valid = (Settings.cfg_crc == GetSettingsCrc());
|
||||
bool almost_valid = (Settings.cfg_crc == GetSettingsCrc());
|
||||
// Sometimes CRC on pages below FB, overwritten by OTA, is fine but Settings are still invalid. So check cfg_holder too
|
||||
if (almost_valid && (0 == cfg_holder)) { cfg_holder = Settings.cfg_holder; } // At FB always active cfg_holder
|
||||
valid = (cfg_holder == Settings.cfg_holder);
|
||||
} else {
|
||||
ESP.flashRead((flash_location -1) * SPI_FLASH_SEC_SIZE, (uint32*)&_SettingsH, sizeof(SYSCFGH));
|
||||
valid = (Settings.cfg_holder == _SettingsH.cfg_holder);
|
||||
|
@ -485,7 +489,7 @@ void SettingsLoad(void)
|
|||
}
|
||||
if (settings_location > 0) {
|
||||
ESP.flashRead(settings_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(SYSCFG));
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG D_LOADED_FROM_FLASH_AT " %X, " D_COUNT " %d"), settings_location, Settings.save_flag);
|
||||
AddLog_P2(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG D_LOADED_FROM_FLASH_AT " %X, " D_COUNT " %lu"), settings_location, Settings.save_flag);
|
||||
}
|
||||
|
||||
#ifndef FIRMWARE_MINIMAL
|
||||
|
|
|
@ -20,6 +20,6 @@
|
|||
#ifndef _SONOFF_VERSION_H_
|
||||
#define _SONOFF_VERSION_H_
|
||||
|
||||
const uint32_t VERSION = 0x06050003;
|
||||
const uint32_t VERSION = 0x06050004;
|
||||
|
||||
#endif // _SONOFF_VERSION_H_
|
||||
|
|
|
@ -620,7 +620,12 @@ const char HTTP_TIMER_SCRIPT5[] PROGMEM =
|
|||
"function it(){" // Initialize elements and select first tab
|
||||
"var b,i,o,s;"
|
||||
"pt=eb('t0').value.split(',').map(Number);" // Get parameters from hidden area to array
|
||||
"s='';for(i=0;i<16;i++){b='';if(0==i){b=\" id='dP'\";}s+=\"<button type='button' class='tl' onclick='ot(\"+i+\",this)'\"+b+\">\"+(i+1)+\"</button>\"}"
|
||||
"s='';"
|
||||
"for(i=0;i<%d;i++){"
|
||||
"b='';"
|
||||
"if(0==i){b=\" id='dP'\";}"
|
||||
"s+=\"<button type='button' class='tl' onclick='ot(\"+i+\",this)'\"+b+\">\"+(i+1)+\"</button>\""
|
||||
"}"
|
||||
"eb('bt').innerHTML=s;" // Create tabs
|
||||
"if(%d>0){" // Create Output and Action drop down boxes
|
||||
"eb('oa').innerHTML=\"<b>" D_TIMER_OUTPUT "</b> <span><select style='width:60px;' id='d1' name='d1'></select></span> <b>" D_TIMER_ACTION "</b> <select style='width:99px;' id='p1' name='p1'></select>\";"
|
||||
|
@ -705,7 +710,7 @@ void HandleTimerConfiguration(void)
|
|||
#endif // USE_SUNRISE
|
||||
WSContentSend_P(HTTP_TIMER_SCRIPT3, devices_present);
|
||||
WSContentSend_P(HTTP_TIMER_SCRIPT4, devices_present);
|
||||
WSContentSend_P(HTTP_TIMER_SCRIPT5, devices_present);
|
||||
WSContentSend_P(HTTP_TIMER_SCRIPT5, MAX_TIMERS, devices_present);
|
||||
WSContentSend_P(HTTP_TIMER_SCRIPT6, devices_present);
|
||||
WSContentSendStyle_P(HTTP_TIMER_STYLE);
|
||||
WSContentSend_P(HTTP_FORM_TIMER1, (Settings.flag3.timers_enable) ? " checked" : "");
|
||||
|
|
Loading…
Reference in New Issue