error messages

This commit is contained in:
netmindz
2023-10-21 16:57:45 +00:00
parent 3a4e84af69
commit 313c298e2f
2 changed files with 11 additions and 4 deletions

View File

@ -302,7 +302,7 @@ int WebOTA::add_http_routes(WebServer *server, const char *path) {
if (!Update.begin(maxSketchSpace)) { //start with max available size
if (_error_callback) {
_error_callback();
_error_callback(OTA_BEGIN_ERROR);
}
Update.printError(Serial);
}
@ -310,7 +310,7 @@ int WebOTA::add_http_routes(WebServer *server, const char *path) {
/* flashing firmware to ESP*/
if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) {
if (_error_callback) {
_error_callback();
_error_callback(OTA_END_ERROR);
}
Update.printError(Serial);
}
@ -334,7 +334,7 @@ int WebOTA::add_http_routes(WebServer *server, const char *path) {
Serial.printf("\r\nFirmware update successful: %u bytes\r\nRebooting...\r\n", upload.totalSize);
} else {
if (_error_callback) {
_error_callback();
_error_callback(OTA_END_ERROR);
}
Update.printError(Serial);
}

View File

@ -7,6 +7,14 @@
#include <WebServer.h>
#endif
typedef enum {
OTA_AUTH_ERROR,
OTA_BEGIN_ERROR,
OTA_CONNECT_ERROR,
OTA_RECEIVE_ERROR,
OTA_END_ERROR
} ota_error_t;
class WebOTA {
public:
unsigned int port;
@ -30,7 +38,6 @@ class WebOTA {
void set_custom_html(char const * const html);
typedef std::function<void(void)> THandlerFunction;
typedef std::function<void(void)> THandlerFunction_Error;
typedef std::function<void(ota_error_t)> THandlerFunction_Error;
typedef std::function<void(unsigned int, unsigned int)> THandlerFunction_Progress;