Skip to content

Commit

Permalink
ota: wip add spiffs format on fail flag
Browse files Browse the repository at this point in the history
  • Loading branch information
pennam committed Nov 26, 2024
1 parent 7ea9dfb commit b42c0f8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions libraries/OTAUpdate/src/OTAUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,26 @@ int OTAUpdate::begin() {
return static_cast<int>(Error::Modem);
}

int OTAUpdate::begin(const char* file_path) {
int OTAUpdate::begin(const char* file_path, bool formatOnFail) {
string res = "";
int fwVersion = 0;

if(modem.write(string(PROMPT(_FWVERSION_U32)), res, CMD_READ(_FWVERSION_U32))) {
fwVersion = atoi(res.c_str());
}

if ( file_path != nullptr && strlen(file_path) > 0) {
if (modem.write(string(PROMPT(_OTA_BEGIN)), res, "%s%s\r\n", CMD_WRITE(_OTA_BEGIN), file_path)) {
return atoi(res.c_str());
if(fwVersion >= 0x50) {
if (modem.write(string(PROMPT(_OTA_BEGIN)), res, "%s%s,%d\r\n", CMD_WRITE(_OTA_BEGIN), file_path, formatOnFail)) {
return atoi(res.c_str());
}
return static_cast<int>(Error::Modem);
} else {
if (modem.write(string(PROMPT(_OTA_BEGIN)), res, "%s%s\r\n", CMD_WRITE(_OTA_BEGIN), file_path)) {
return atoi(res.c_str());
}
return static_cast<int>(Error::Modem);
}
return static_cast<int>(Error::Modem);
}
return static_cast<int>(Error::Library);
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/OTAUpdate/src/OTAUpdate.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class OTAUpdate {
OTAUpdate();
int setCACert(const char* root_ca);
int begin();
int begin(const char* file_path);
int begin(const char* file_path, bool formatOnFail = false);
int download(const char* url);
int download(const char* url, const char* file_path);
int verify();
Expand Down

0 comments on commit b42c0f8

Please sign in to comment.