Fix filerun restart hold

This commit is contained in:
Theo Arends 2021-02-16 13:00:10 +01:00
parent 5a8719a439
commit e40bebd0ba
2 changed files with 17 additions and 6 deletions

View File

@ -961,6 +961,14 @@ void Every100mSeconds(void)
int ExtStopBLE();
#endif // USE_BLE_ESP32
bool CommandsReady(void) {
bool ready = BACKLOG_EMPTY ;
#ifdef USE_UFILESYS
ready |= FileRunReady();
#endif // USE_UFILESYS
return ready;
}
void Every250mSeconds(void)
{
// As the max amount of sleep = 250 mSec this loop should always be taken...
@ -1021,7 +1029,7 @@ void Every250mSeconds(void)
switch (TasmotaGlobal.state_250mS) {
case 0: // Every x.0 second
if (TasmotaGlobal.ota_state_flag && BACKLOG_EMPTY) {
if (TasmotaGlobal.ota_state_flag && CommandsReady()) {
TasmotaGlobal.ota_state_flag--;
if (2 == TasmotaGlobal.ota_state_flag) {
RtcSettings.ota_loader = 0; // Try requested image first
@ -1131,7 +1139,7 @@ void Every250mSeconds(void)
if (MidnightNow()) {
XsnsCall(FUNC_SAVE_AT_MIDNIGHT);
}
if (TasmotaGlobal.save_data_counter && BACKLOG_EMPTY) {
if (TasmotaGlobal.save_data_counter && CommandsReady()) {
TasmotaGlobal.save_data_counter--;
if (TasmotaGlobal.save_data_counter <= 0) {
if (Settings.flag.save_state) { // SetOption0 - Save power state and use after restart
@ -1151,7 +1159,7 @@ void Every250mSeconds(void)
TasmotaGlobal.save_data_counter = Settings.save_data;
}
}
if (TasmotaGlobal.restart_flag && BACKLOG_EMPTY) {
if (TasmotaGlobal.restart_flag && CommandsReady()) {
if ((214 == TasmotaGlobal.restart_flag) || (215 == TasmotaGlobal.restart_flag) || (216 == TasmotaGlobal.restart_flag)) {
// Backup current SSIDs and Passwords
char storage_ssid1[strlen(SettingsText(SET_STASSID1)) +1];

View File

@ -350,12 +350,15 @@ bool TfsRenameFile(const char *fname1, const char *fname2) {
}
/*********************************************************************************************\
* Autoexec support
* File command execute support
\*********************************************************************************************/
bool FileRunReady(void) {
return (UfsData.run_file_pos < 0);
}
void FileRunLoop(void) {
if (UfsData.run_file_pos < 0) { return; }
if (FileRunReady()) { return; }
if (!ffs_type) { return; }
if (strlen(UfsData.run_file) && !UfsData.run_file_mutex) {
@ -492,7 +495,7 @@ void UFSRename(void) {
void UFSRun(void) {
if (XdrvMailbox.data_len > 0) {
if ((UfsData.run_file_pos < 0) && TfsFileExists(XdrvMailbox.data)) {
if (FileRunReady() && TfsFileExists(XdrvMailbox.data)) {
snprintf(UfsData.run_file, sizeof(UfsData.run_file), XdrvMailbox.data);
UfsData.run_file_pos = 0;
ResponseClear();