1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-07 16:23:38 +03:00

Updater - missing error codes (#9104)

Adds the two missing error states when beginning an Update. There were debugging logs for this but the error state was not set which would lead to confusion
This commit is contained in:
David Refoua 2024-03-18 00:25:29 +03:30 committed by GitHub
parent 760dbeeda9
commit 1248d3874e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 9 deletions

View File

@ -70,6 +70,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
#ifdef DEBUG_UPDATER #ifdef DEBUG_UPDATER
DEBUG_UPDATER.println(F("[begin] already running")); DEBUG_UPDATER.println(F("[begin] already running"));
#endif #endif
_setError(UPDATE_ERROR_RUNNING_ALREADY);
return false; return false;
} }
@ -162,6 +163,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
#ifdef DEBUG_UPDATER #ifdef DEBUG_UPDATER
DEBUG_UPDATER.println(F("[begin] Unknown update command.")); DEBUG_UPDATER.println(F("[begin] Unknown update command."));
#endif #endif
_setError(UPDATE_ERROR_UNKNOWN_COMMAND);
return false; return false;
} }
@ -649,6 +651,12 @@ String UpdaterClass::getErrorString() const {
case UPDATE_ERROR_OOM: case UPDATE_ERROR_OOM:
out = F("Out of memory"); out = F("Out of memory");
break; break;
case UPDATE_ERROR_RUNNING_ALREADY:
out = F("Update already running");
break;
case UPDATE_ERROR_UNKNOWN_COMMAND:
out = F("Unknown update command");
break;
default: default:
out = F("UNKNOWN"); out = F("UNKNOWN");
break; break;

View File

@ -21,6 +21,8 @@
#define UPDATE_ERROR_SIGN (12) #define UPDATE_ERROR_SIGN (12)
#define UPDATE_ERROR_NO_DATA (13) #define UPDATE_ERROR_NO_DATA (13)
#define UPDATE_ERROR_OOM (14) #define UPDATE_ERROR_OOM (14)
#define UPDATE_ERROR_RUNNING_ALREADY (15)
#define UPDATE_ERROR_UNKNOWN_COMMAND (16)
#define U_FLASH 0 #define U_FLASH 0
#define U_FS 100 #define U_FS 100
@ -69,7 +71,7 @@ class UpdaterClass {
bool begin(size_t size, int command = U_FLASH, int ledPin = -1, uint8_t ledOn = LOW); bool begin(size_t size, int command = U_FLASH, int ledPin = -1, uint8_t ledOn = LOW);
/* /*
Run Updater from asynchronous callbacs Run Updater from asynchronous callbacks
*/ */
void runAsync(bool async){ _async = async; } void runAsync(bool async){ _async = async; }