File tree 3 files changed +14
-5
lines changed
3 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -41,12 +41,12 @@ Arduino_UNOWIFIR4_OTA::~Arduino_UNOWIFIR4_OTA() {
41
41
closeStorage ();
42
42
}
43
43
44
- Arduino_ESP32_OTA::Error Arduino_UNOWIFIR4_OTA::begin (const char * file_path, uint32_t magic)
44
+ Arduino_ESP32_OTA::Error Arduino_UNOWIFIR4_OTA::begin (const char * file_path, uint32_t magic, bool formatOnFail )
45
45
{
46
46
/* ... configure board Magic number */
47
47
setMagic (magic);
48
48
49
- if (!SPIFFS.begin ()) {
49
+ if (!SPIFFS.begin (formatOnFail )) {
50
50
DEBUG_ERROR (" %s: failed to initialize SPIFFS" , __FUNCTION__);
51
51
return Error::OtaStorageInit;
52
52
}
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ class Arduino_UNOWIFIR4_OTA : public Arduino_ESP32_OTA
46
46
};
47
47
48
48
using Arduino_ESP32_OTA::begin;
49
- Arduino_ESP32_OTA::Error begin (const char * file_path, uint32_t magic = ARDUINO_RA4M1_OTA_MAGIC);
49
+ Arduino_ESP32_OTA::Error begin (const char * file_path, uint32_t magic = ARDUINO_RA4M1_OTA_MAGIC, bool formatOnfail = false );
50
50
51
51
using Arduino_ESP32_OTA::download;
52
52
int download (const char * ota_url, const char * file_path);
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ void CAtHandler::add_cmds_ota() {
57
57
return chAT::CommandStatus::OK;
58
58
}
59
59
case chAT::CommandMode::Write: {
60
- if (parser.args .size () != 1 ) {
60
+ if (parser.args .size () != 1 && parser. args . size () != 2 ) {
61
61
return chAT::CommandStatus::ERROR;
62
62
}
63
63
@@ -66,7 +66,16 @@ void CAtHandler::add_cmds_ota() {
66
66
return chAT::CommandStatus::ERROR;
67
67
}
68
68
69
- Arduino_ESP32_OTA::Error ota_error = OTA.begin (path.c_str ());
69
+ bool formatOnFail = false ;
70
+ if (parser.args .size () == 2 ) {
71
+ auto &format = parser.args [1 ];
72
+ if (format.empty ()) {
73
+ return chAT::CommandStatus::ERROR;
74
+ }
75
+ formatOnFail = strtol (format.c_str (), NULL , 10 ) != 0 ;
76
+ }
77
+
78
+ Arduino_ESP32_OTA::Error ota_error = OTA.begin (path.c_str (), ARDUINO_RA4M1_OTA_MAGIC, formatOnFail);
70
79
String error = String ((int )ota_error) + _ENDL;
71
80
srv.write_response_prompt ();
72
81
srv.write_str ((const char *)(error.c_str ()));
You can’t perform that action at this time.
0 commit comments