8000 Abort update if http.begin() returns false. Fix a typo in httpUpdate.… · ashendrik/arduino-esp32@0596a2a · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0596a2a

Browse files
Jeroen88me-no-dev
Jeroen88
authored andcommitted
Abort update if http.begin() returns false. Fix a typo in httpUpdate.ino (espressif#2156)
1 parent fe1fdd2 commit 0596a2a

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

libraries/HTTPUpdate/examples/httpUpdate/httpUpdate.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void loop() {
5656

5757
switch (ret) {
5858
case HTTP_UPDATE_FAILED:
59-
Serial.printf("HTTP_UPDATE_FAILD Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
59+
Serial.printf("HTTP_UPDATE_FAILED Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
6060
break;
6161

6262
case HTTP_UPDATE_NO_UPDATES:

libraries/HTTPUpdate/src/HTTPUpdate.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,31 @@ HTTPUpdate::~HTTPUpdate(void)
4949
HTTPUpdateResult HTTPUpdate::update(WiFiClient& client, const String& url, const String& currentVersion)
5050
{
5151
HTTPClient http;
52-
http.begin(client, url);
52+
if(!http.begin(client, url))
53+
{
54+
return HTTP_UPDATE_FAILED;
55+
}
5356
return handleUpdate(http, currentVersion, false);
5457
}
5558

5659
HTTPUpdateResult HTTPUpdate::updateSpiffs(WiFiClient& client, const String& url, const String& currentVersion)
5760
{
5861
HTTPClient http;
59-
http.begin(client, url);
62+
if(!http.begin(client, url))
63+
{
64+
return HTTP_UPDATE_FAILED;
65+
}
6066
return handleUpdate(http, currentVersion, true);
6167
}
6268

6369
HTTPUpdateResult HTTPUpdate::update(WiFiClient& client, const String& host, uint16_t port, const String& uri,
6470
const String& currentVersion)
6571
{
6672
HTTPClient http;
67-
http.begin(client, host, port, uri);
73+
if(!http.begin(client, host, port, uri))
74+
{
75+
return HTTP_UPDATE_FAILED;
76+
}
6877
return handleUpdate(http, currentVersion, false);
6978
}
7079

0 commit comments

Comments
 (0)
0