mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 02:36:35 +00:00
Update support_tasmota.ino
This commit is contained in:
parent
74912e7cc2
commit
c5df7ed1ae
@ -1019,23 +1019,23 @@ void Every250mSeconds(void)
|
|||||||
if (TasmotaGlobal.ota_state_flag && BACKLOG_EMPTY) {
|
if (TasmotaGlobal.ota_state_flag && BACKLOG_EMPTY) {
|
||||||
TasmotaGlobal.ota_state_flag--;
|
TasmotaGlobal.ota_state_flag--;
|
||||||
if (2 == TasmotaGlobal.ota_state_flag) {
|
if (2 == TasmotaGlobal.ota_state_flag) {
|
||||||
RtcSettings.ota_loader = 0; // Try requested image first
|
RtcSettings.ota_loader = 0; // Try requested image first
|
||||||
ota_retry_counter = OTA_ATTEMPTS;
|
ota_retry_counter = OTA_ATTEMPTS;
|
||||||
ESPhttpUpdate.rebootOnUpdate(false);
|
ESPhttpUpdate.rebootOnUpdate(false);
|
||||||
SettingsSave(1); // Free flash for OTA update
|
SettingsSave(1); // Free flash for OTA update
|
||||||
}
|
}
|
||||||
if (TasmotaGlobal.ota_state_flag <= 0) {
|
if (TasmotaGlobal.ota_state_flag <= 0) {
|
||||||
#ifdef USE_BLE_ESP32
|
#ifdef USE_BLE_ESP32
|
||||||
ExtStopBLE();
|
ExtStopBLE();
|
||||||
#endif // USE_BLE_ESP32
|
#endif // USE_BLE_ESP32
|
||||||
#ifdef USE_COUNTER
|
#ifdef USE_COUNTER
|
||||||
CounterInterruptDisable(true); // Prevent OTA failures on 100Hz counter interrupts
|
CounterInterruptDisable(true); // Prevent OTA failures on 100Hz counter interrupts
|
||||||
#endif // USE_COUNTER
|
#endif // USE_COUNTER
|
||||||
#ifdef USE_WEBSERVER
|
#ifdef USE_WEBSERVER
|
||||||
if (Settings.webserver) StopWebserver();
|
if (Settings.webserver) StopWebserver();
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
#ifdef USE_ARILUX_RF
|
#ifdef USE_ARILUX_RF
|
||||||
AriluxRfDisable(); // Prevent restart exception on Arilux Interrupt routine
|
AriluxRfDisable(); // Prevent restart exception on Arilux Interrupt routine
|
||||||
#endif // USE_ARILUX_RF
|
#endif // USE_ARILUX_RF
|
||||||
TasmotaGlobal.ota_state_flag = 92;
|
TasmotaGlobal.ota_state_flag = 92;
|
||||||
ota_result = 0;
|
ota_result = 0;
|
||||||
@ -1043,6 +1043,7 @@ void Every250mSeconds(void)
|
|||||||
if (ota_retry_counter) {
|
if (ota_retry_counter) {
|
||||||
char ota_url[TOPSZ];
|
char ota_url[TOPSZ];
|
||||||
strlcpy(TasmotaGlobal.mqtt_data, GetOtaUrl(ota_url, sizeof(ota_url)), sizeof(TasmotaGlobal.mqtt_data));
|
strlcpy(TasmotaGlobal.mqtt_data, GetOtaUrl(ota_url, sizeof(ota_url)), sizeof(TasmotaGlobal.mqtt_data));
|
||||||
|
#ifdef ESP8266
|
||||||
#ifndef FIRMWARE_MINIMAL
|
#ifndef FIRMWARE_MINIMAL
|
||||||
if (RtcSettings.ota_loader) {
|
if (RtcSettings.ota_loader) {
|
||||||
// OTA File too large so try OTA minimal version
|
// OTA File too large so try OTA minimal version
|
||||||
@ -1061,8 +1062,8 @@ void Every250mSeconds(void)
|
|||||||
// Replace http://192.168.2.17:80/api/arduino/tasmota.bin with http://192.168.2.17:80/api/arduino/tasmota-minimal.bin
|
// Replace http://192.168.2.17:80/api/arduino/tasmota.bin with http://192.168.2.17:80/api/arduino/tasmota-minimal.bin
|
||||||
// Replace http://192.168.2.17/api/arduino/tasmota.bin.gz with http://192.168.2.17/api/arduino/tasmota-minimal.bin.gz
|
// Replace http://192.168.2.17/api/arduino/tasmota.bin.gz with http://192.168.2.17/api/arduino/tasmota-minimal.bin.gz
|
||||||
|
|
||||||
char *bch = strrchr(TasmotaGlobal.mqtt_data, '/'); // Only consider filename after last backslash prevent change of urls having "-" in it
|
char *bch = strrchr(TasmotaGlobal.mqtt_data, '/'); // Only consider filename after last backslash prevent change of urls having "-" in it
|
||||||
if (bch == nullptr) { bch = TasmotaGlobal.mqtt_data; } // No path found so use filename only
|
if (bch == nullptr) { bch = TasmotaGlobal.mqtt_data; } // No path found so use filename only
|
||||||
char *ech = strchr(bch, '.'); // Find file type in filename (none, .ino.bin, .ino.bin.gz, .bin, .bin.gz or .gz)
|
char *ech = strchr(bch, '.'); // Find file type in filename (none, .ino.bin, .ino.bin.gz, .bin, .bin.gz or .gz)
|
||||||
if (ech == nullptr) { ech = TasmotaGlobal.mqtt_data + strlen(TasmotaGlobal.mqtt_data); } // Point to '/0' at end of mqtt_data becoming an empty string
|
if (ech == nullptr) { ech = TasmotaGlobal.mqtt_data + strlen(TasmotaGlobal.mqtt_data); } // Point to '/0' at end of mqtt_data becoming an empty string
|
||||||
|
|
||||||
@ -1077,6 +1078,14 @@ void Every250mSeconds(void)
|
|||||||
snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s-" D_JSON_MINIMAL "%s"), TasmotaGlobal.mqtt_data, ota_url_type); // Minimal filename must be filename-minimal
|
snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s-" D_JSON_MINIMAL "%s"), TasmotaGlobal.mqtt_data, ota_url_type); // Minimal filename must be filename-minimal
|
||||||
}
|
}
|
||||||
#endif // FIRMWARE_MINIMAL
|
#endif // FIRMWARE_MINIMAL
|
||||||
|
if (ota_retry_counter < OTA_ATTEMPTS / 2) {
|
||||||
|
if (!strcasecmp_P(TasmotaGlobal.mqtt_data, PSTR(".gz"))) {
|
||||||
|
ota_retry_counter = 1;
|
||||||
|
} else {
|
||||||
|
strcat_P(TasmotaGlobal.mqtt_data, PSTR(".gz"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // ESP8266
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "%s"), TasmotaGlobal.mqtt_data);
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "%s"), TasmotaGlobal.mqtt_data);
|
||||||
WiFiClient OTAclient;
|
WiFiClient OTAclient;
|
||||||
ota_result = (HTTP_UPDATE_FAILED != ESPhttpUpdate.update(OTAclient, TasmotaGlobal.mqtt_data));
|
ota_result = (HTTP_UPDATE_FAILED != ESPhttpUpdate.update(OTAclient, TasmotaGlobal.mqtt_data));
|
||||||
@ -1084,26 +1093,28 @@ void Every250mSeconds(void)
|
|||||||
#ifndef FIRMWARE_MINIMAL
|
#ifndef FIRMWARE_MINIMAL
|
||||||
int ota_error = ESPhttpUpdate.getLastError();
|
int ota_error = ESPhttpUpdate.getLastError();
|
||||||
DEBUG_CORE_LOG(PSTR("OTA: Error %d"), ota_error);
|
DEBUG_CORE_LOG(PSTR("OTA: Error %d"), ota_error);
|
||||||
|
#ifdef ESP8266
|
||||||
if ((HTTP_UE_TOO_LESS_SPACE == ota_error) || (HTTP_UE_BIN_FOR_WRONG_FLASH == ota_error)) {
|
if ((HTTP_UE_TOO_LESS_SPACE == ota_error) || (HTTP_UE_BIN_FOR_WRONG_FLASH == ota_error)) {
|
||||||
RtcSettings.ota_loader = 1; // Try minimal image next
|
RtcSettings.ota_loader = 1; // Try minimal image next
|
||||||
}
|
}
|
||||||
|
#endif // ESP8266
|
||||||
#endif // FIRMWARE_MINIMAL
|
#endif // FIRMWARE_MINIMAL
|
||||||
TasmotaGlobal.ota_state_flag = 2; // Upgrade failed - retry
|
TasmotaGlobal.ota_state_flag = 2; // Upgrade failed - retry
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (90 == TasmotaGlobal.ota_state_flag) { // Allow MQTT to reconnect
|
if (90 == TasmotaGlobal.ota_state_flag) { // Allow MQTT to reconnect
|
||||||
TasmotaGlobal.ota_state_flag = 0;
|
TasmotaGlobal.ota_state_flag = 0;
|
||||||
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
|
||||||
ResponseAppend_P(PSTR(D_JSON_SUCCESSFUL ". " D_JSON_RESTARTING));
|
ResponseAppend_P(PSTR(D_JSON_SUCCESSFUL ". " D_JSON_RESTARTING));
|
||||||
TasmotaGlobal.restart_flag = 2;
|
TasmotaGlobal.restart_flag = 2;
|
||||||
} else {
|
} else {
|
||||||
ResponseAppend_P(PSTR(D_JSON_FAILED " %s"), ESPhttpUpdate.getLastErrorString().c_str());
|
ResponseAppend_P(PSTR(D_JSON_FAILED " %s"), ESPhttpUpdate.getLastErrorString().c_str());
|
||||||
}
|
}
|
||||||
ResponseAppend_P(PSTR("\"}"));
|
ResponseAppend_P(PSTR("\"}"));
|
||||||
// TasmotaGlobal.restart_flag = 2; // Restart anyway to keep memory clean webserver
|
// TasmotaGlobal.restart_flag = 2; // Restart anyway to keep memory clean webserver
|
||||||
MqttPublishPrefixTopic_P(STAT, PSTR(D_CMND_UPGRADE));
|
MqttPublishPrefixTopic_P(STAT, PSTR(D_CMND_UPGRADE));
|
||||||
#ifdef USE_COUNTER
|
#ifdef USE_COUNTER
|
||||||
CounterInterruptDisable(false);
|
CounterInterruptDisable(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user