Skip to content

Commit

Permalink
Abort update if http.begin() returns false. Fix a typo in httpUpdate.…
Browse files Browse the repository at this point in the history
…ino (#2156)
  • Loading branch information
Jeroen88 authored and me-no-dev committed Dec 6, 2018
1 parent fe1fdd2 commit 0596a2a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libraries/HTTPUpdate/examples/httpUpdate/httpUpdate.ino
Expand Up @@ -56,7 +56,7 @@ void loop() {

switch (ret) {
case HTTP_UPDATE_FAILED:
Serial.printf("HTTP_UPDATE_FAILD Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
Serial.printf("HTTP_UPDATE_FAILED Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
break;

case HTTP_UPDATE_NO_UPDATES:
Expand Down
15 changes: 12 additions & 3 deletions libraries/HTTPUpdate/src/HTTPUpdate.cpp
Expand Up @@ -49,22 +49,31 @@ HTTPUpdate::~HTTPUpdate(void)
HTTPUpdateResult HTTPUpdate::update(WiFiClient& client, const String& url, const String& currentVersion)
{
HTTPClient http;
http.begin(client, url);
if(!http.begin(client, url))
{
return HTTP_UPDATE_FAILED;
}
return handleUpdate(http, currentVersion, false);
}

HTTPUpdateResult HTTPUpdate::updateSpiffs(WiFiClient& client, const String& url, const String& currentVersion)
{
HTTPClient http;
http.begin(client, url);
if(!http.begin(client, url))
{
return HTTP_UPDATE_FAILED;
}
return handleUpdate(http, currentVersion, true);
}

HTTPUpdateResult HTTPUpdate::update(WiFiClient& client, const String& host, uint16_t port, const String& uri,
const String& currentVersion)
{
HTTPClient http;
http.begin(client, host, port, uri);
if(!http.begin(client, host, port, uri))
{
return HTTP_UPDATE_FAILED;
}
return handleUpdate(http, currentVersion, false);
}

Expand Down

0 comments on commit 0596a2a

Please sign in to comment.