Skip to content

Commit b42c0f8

Browse files
committed
ota: wip add spiffs format on fail flag
1 parent 7ea9dfb commit b42c0f8

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

Diff for: libraries/OTAUpdate/src/OTAUpdate.cpp

+17-4
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,26 @@ int OTAUpdate::begin() {
4242
return static_cast<int>(Error::Modem);
4343
}
4444

45-
int OTAUpdate::begin(const char* file_path) {
45+
int OTAUpdate::begin(const char* file_path, bool formatOnFail) {
4646
string res = "";
47+
int fwVersion = 0;
48+
49+
if(modem.write(string(PROMPT(_FWVERSION_U32)), res, CMD_READ(_FWVERSION_U32))) {
50+
fwVersion = atoi(res.c_str());
51+
}
52+
4753
if ( file_path != nullptr && strlen(file_path) > 0) {
48-
if (modem.write(string(PROMPT(_OTA_BEGIN)), res, "%s%s\r\n", CMD_WRITE(_OTA_BEGIN), file_path)) {
49-
return atoi(res.c_str());
54+
if(fwVersion >= 0x50) {
55+
if (modem.write(string(PROMPT(_OTA_BEGIN)), res, "%s%s,%d\r\n", CMD_WRITE(_OTA_BEGIN), file_path, formatOnFail)) {
56+
return atoi(res.c_str());
57+
}
58+
return static_cast<int>(Error::Modem);
59+
} else {
60+
if (modem.write(string(PROMPT(_OTA_BEGIN)), res, "%s%s\r\n", CMD_WRITE(_OTA_BEGIN), file_path)) {
61+
return atoi(res.c_str());
62+
}
63+
return static_cast<int>(Error::Modem);
5064
}
51-
return static_cast<int>(Error::Modem);
5265
}
5366
return static_cast<int>(Error::Library);
5467
}

Diff for: libraries/OTAUpdate/src/OTAUpdate.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class OTAUpdate {
3939
OTAUpdate();
4040
int setCACert(const char* root_ca);
4141
int begin();
42-
int begin(const char* file_path);
42+
int begin(const char* file_path, bool formatOnFail = false);
4343
int download(const char* url);
4444
int download(const char* url, const char* file_path);
4545
int verify();

0 commit comments

Comments
 (0)