@@ -70,6 +70,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
7070#ifdef DEBUG_UPDATER
7171 DEBUG_UPDATER.println (F (" [begin] already running" ));
7272#endif
73+ _setError (UPDATE_ERROR_RUNNING_ALREADY);
7374 return false ;
7475 }
7576
@@ -86,7 +87,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
8687 _setError (UPDATE_ERROR_BOOTSTRAP);
8788 return false ;
8889 }
89-
90+
9091#ifdef DEBUG_UPDATER
9192 if (command == U_FS) {
9293 DEBUG_UPDATER.println (F (" [begin] Update Filesystem." ));
@@ -133,7 +134,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
133134
134135 // make sure that the size of both sketches is less than the total space (updateEndAddress)
135136 if (updateStartAddress < currentSketchSize) {
136- _setError (UPDATE_ERROR_SPACE);
137+ _setError (UPDATE_ERROR_SPACE);
137138 return false ;
138139 }
139140 }
@@ -162,6 +163,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
162163#ifdef DEBUG_UPDATER
163164 DEBUG_UPDATER.println (F (" [begin] Unknown update command." ));
164165#endif
166+ _setError (UPDATE_ERROR_UNKNOWN_COMMAND);
165167 return false ;
166168 }
167169
@@ -404,7 +406,7 @@ bool UpdaterClass::_writeBuffer(){
404406 modifyFlashMode = true ;
405407 }
406408 }
407-
409+
408410 if (eraseResult) {
409411 if (!_async) yield ();
410412 writeResult = ESP.flashWrite (_currentAddress, _buffer, _bufferLen);
@@ -488,7 +490,7 @@ bool UpdaterClass::_verifyEnd() {
488490 uint8_t buf[4 ] __attribute__ ((aligned (4 )));
489491 if (!ESP.flashRead (_startAddress, (uint32_t *) &buf[0 ], 4 )) {
490492 _currentAddress = (_startAddress);
491- _setError (UPDATE_ERROR_READ);
493+ _setError (UPDATE_ERROR_READ);
492494 return false ;
493495 }
494496
@@ -500,7 +502,7 @@ bool UpdaterClass::_verifyEnd() {
500502 return true ;
501503 } else if (buf[0 ] != 0xE9 ) {
502504 _currentAddress = (_startAddress);
503- _setError (UPDATE_ERROR_MAGIC_BYTE);
505+ _setError (UPDATE_ERROR_MAGIC_BYTE);
504506 return false ;
505507 }
506508
@@ -512,7 +514,7 @@ bool UpdaterClass::_verifyEnd() {
512514 // check if new bin fits to SPI flash
513515 if (bin_flash_size > ESP.getFlashChipRealSize ()) {
514516 _currentAddress = (_startAddress);
515- _setError (UPDATE_ERROR_NEW_FLASH_CONFIG);
517+ _setError (UPDATE_ERROR_NEW_FLASH_CONFIG);
516518 return false ;
517519 }
518520#endif
@@ -649,6 +651,12 @@ String UpdaterClass::getErrorString() const {
649651 case UPDATE_ERROR_OOM:
650652 out = F (" Out of memory" );
651653 break ;
654+ case UPDATE_ERROR_RUNNING_ALREADY:
655+ out = F (" Update already running" );
656+ break ;
657+ case UPDATE_ERROR_UNKNOWN_COMMAND:
658+ out = F (" Unknown update command" );
659+ break ;
652660 default :
653661 out = F (" UNKNOWN" );
654662 break ;
0 commit comments