File tree Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Expand file tree Collapse file tree 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() {
4141 closeStorage ();
4242}
4343
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 )
4545{
4646 /* ... configure board Magic number */
4747 setMagic (magic);
4848
49- if (!SPIFFS.begin ()) {
49+ if (!SPIFFS.begin (formatOnFail )) {
5050 DEBUG_ERROR (" %s: failed to initialize SPIFFS" , __FUNCTION__);
5151 return Error::OtaStorageInit;
5252 }
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ class Arduino_UNOWIFIR4_OTA : public Arduino_ESP32_OTA
4646 };
4747
4848 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 );
5050
5151 using Arduino_ESP32_OTA::download;
5252 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() {
5757 return chAT::CommandStatus::OK;
5858 }
5959 case chAT::CommandMode::Write: {
60- if (parser.args .size () != 1 ) {
60+ if (parser.args .size () != 1 && parser. args . size () != 2 ) {
6161 return chAT::CommandStatus::ERROR;
6262 }
6363
@@ -66,7 +66,16 @@ void CAtHandler::add_cmds_ota() {
6666 return chAT::CommandStatus::ERROR;
6767 }
6868
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);
7079 String error = String ((int )ota_error) + _ENDL;
7180 srv.write_response_prompt ();
7281 srv.write_str ((const char *)(error.c_str ()));
You can’t perform that action at this time.
0 commit comments