mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 10:46:31 +00:00
Refactor version compatibility
This commit is contained in:
parent
6c060b9801
commit
1c0db7e689
@ -343,10 +343,10 @@ void SetFlashModeDout(void)
|
|||||||
delete[] _buffer;
|
delete[] _buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t OtaVersion(void)
|
bool VersionCompatible(void)
|
||||||
{
|
{
|
||||||
if (Settings.flag3.compatibility_check) {
|
if (Settings.flag3.compatibility_check) {
|
||||||
return 0xFFFFFFFF;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
eboot_command ebcmd;
|
eboot_command ebcmd;
|
||||||
@ -362,17 +362,17 @@ uint32_t OtaVersion(void)
|
|||||||
if ((address == start_address) && (0x1F == (buffer[0] & 0xFF))) {
|
if ((address == start_address) && (0x1F == (buffer[0] & 0xFF))) {
|
||||||
version[1] = 0xFFFFFFFF; // Ota file is gzipped and can not be checked for compatibility
|
version[1] = 0xFFFFFFFF; // Ota file is gzipped and can not be checked for compatibility
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
} else {
|
||||||
}
|
|
||||||
for (uint32_t i = 0; i < (FLASH_SECTOR_SIZE / 4); i++) {
|
for (uint32_t i = 0; i < (FLASH_SECTOR_SIZE / 4); i++) {
|
||||||
version[0] = version[1];
|
version[0] = version[1];
|
||||||
version[1] = version[2];
|
version[1] = version[2];
|
||||||
version[2] = buffer[i];
|
version[2] = buffer[i];
|
||||||
if ((version[0] == MARKER_START) && (version[2] == MARKER_END)) {
|
if ((MARKER_START == version[0]) && (MARKER_END == version[2])) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (found) { break; }
|
if (found) { break; }
|
||||||
}
|
}
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
@ -381,13 +381,13 @@ uint32_t OtaVersion(void)
|
|||||||
|
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("OTA: Version 0x%08X, Compatible 0x%08X"), version[1], VERSION_COMPATIBLE);
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("OTA: Version 0x%08X, Compatible 0x%08X"), version[1], VERSION_COMPATIBLE);
|
||||||
|
|
||||||
return version[1];
|
if (version[1] < VERSION_COMPATIBLE) {
|
||||||
}
|
uint32_t eboot_magic = 0; // Abandon OTA result
|
||||||
|
|
||||||
void AbandonOta(void)
|
|
||||||
{
|
|
||||||
uint32_t eboot_magic = 0;
|
|
||||||
ESP.rtcUserMemoryWrite(0, (uint32_t*)&eboot_magic, sizeof(eboot_magic));
|
ESP.rtcUserMemoryWrite(0, (uint32_t*)&eboot_magic, sizeof(eboot_magic));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsBufferFree(void)
|
void SettingsBufferFree(void)
|
||||||
|
@ -869,8 +869,7 @@ void Every250mSeconds(void)
|
|||||||
Response_P(PSTR("{\"" D_CMND_UPGRADE "\":\""));
|
Response_P(PSTR("{\"" D_CMND_UPGRADE "\":\""));
|
||||||
if (ota_result) {
|
if (ota_result) {
|
||||||
// SetFlashModeDout(); // Force DOUT for both ESP8266 and ESP8285
|
// SetFlashModeDout(); // Force DOUT for both ESP8266 and ESP8285
|
||||||
if (OtaVersion() < VERSION_COMPATIBLE) {
|
if (!VersionCompatible()) {
|
||||||
AbandonOta();
|
|
||||||
ResponseAppend_P(PSTR(D_JSON_FAILED " " D_UPLOAD_ERR_14));
|
ResponseAppend_P(PSTR(D_JSON_FAILED " " D_UPLOAD_ERR_14));
|
||||||
} else {
|
} else {
|
||||||
ResponseAppend_P(PSTR(D_JSON_SUCCESSFUL ". " D_JSON_RESTARTING));
|
ResponseAppend_P(PSTR(D_JSON_SUCCESSFUL ". " D_JSON_RESTARTING));
|
||||||
|
@ -2398,8 +2398,7 @@ void HandleUploadLoop(void)
|
|||||||
Web.upload_error = 6; // Upload failed. Enable logging 3
|
Web.upload_error = 6; // Upload failed. Enable logging 3
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (OtaVersion() < VERSION_COMPATIBLE) {
|
if (!VersionCompatible()) {
|
||||||
AbandonOta();
|
|
||||||
Web.upload_error = 14; // Not compatible
|
Web.upload_error = 14; // Not compatible
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user