Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-esp32
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-esp32
Commits
8c150e21
Unverified
Commit
8c150e21
authored
Nov 29, 2023
by
Vlastimil Hajek
Committed by
GitHub
Nov 29, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: adding possibility to manually set MD5 checksum for HTTP update (#7629)
parent
789ae4c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
5 deletions
+42
-5
libraries/HTTPUpdate/src/HTTPUpdate.cpp
libraries/HTTPUpdate/src/HTTPUpdate.cpp
+22
-5
libraries/HTTPUpdate/src/HTTPUpdate.h
libraries/HTTPUpdate/src/HTTPUpdate.h
+20
-0
No files found.
libraries/HTTPUpdate/src/HTTPUpdate.cpp
View file @
8c150e21
...
...
@@ -33,15 +33,18 @@
// To do extern "C" uint32_t _SPIFFS_end;
HTTPUpdate
::
HTTPUpdate
(
void
)
:
_httpClientTimeout
(
8000
),
_ledPin
(
-
1
)
:
HTTPUpdate
(
8000
)
{
_followRedirects
=
HTTPC_DISABLE_FOLLOW_REDIRECTS
;
}
HTTPUpdate
::
HTTPUpdate
(
int
httpClientTimeout
)
:
_httpClientTimeout
(
httpClientTimeout
),
_ledPin
(
-
1
)
{
_followRedirects
=
HTTPC_DISABLE_FOLLOW_REDIRECTS
;
_md5Sum
=
String
();
_user
=
String
();
_password
=
String
();
_auth
=
String
();
}
HTTPUpdate
::~
HTTPUpdate
(
void
)
...
...
@@ -220,6 +223,14 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient& http, const String& curren
requestCB
(
&
http
);
}
if
(
!
_user
.
isEmpty
()
&&
!
_password
.
isEmpty
())
{
http
.
setAuthorization
(
_user
.
c_str
(),
_password
.
c_str
());
}
if
(
!
_auth
.
isEmpty
())
{
http
.
setAuthorization
(
_auth
.
c_str
());
}
const
char
*
headerkeys
[]
=
{
"x-MD5"
};
size_t
headerkeyssize
=
sizeof
(
headerkeys
)
/
sizeof
(
char
*
);
...
...
@@ -243,8 +254,14 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient& http, const String& curren
log_d
(
" - code: %d
\n
"
,
code
);
log_d
(
" - len: %d
\n
"
,
len
);
if
(
http
.
hasHeader
(
"x-MD5"
))
{
log_d
(
" - MD5: %s
\n
"
,
http
.
header
(
"x-MD5"
).
c_str
());
String
md5
;
if
(
_md5Sum
.
length
())
{
md5
=
_md5Sum
;
}
else
if
(
http
.
hasHeader
(
"x-MD5"
))
{
md5
=
http
.
header
(
"x-MD5"
);
}
if
(
md5
.
length
())
{
log_d
(
" - MD5: %s
\n
"
,
md5
.
c_str
());
}
log_d
(
"ESP32 info:
\n
"
);
...
...
@@ -341,7 +358,7 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient& http, const String& curren
}
*/
}
if
(
runUpdate
(
*
tcp
,
len
,
http
.
header
(
"x-MD5"
)
,
command
))
{
if
(
runUpdate
(
*
tcp
,
len
,
md5
,
command
))
{
ret
=
HTTP_UPDATE_OK
;
log_d
(
"Update ok
\n
"
);
http
.
end
();
...
...
libraries/HTTPUpdate/src/HTTPUpdate.h
View file @
8c150e21
...
...
@@ -85,6 +85,22 @@ public:
_ledOn
=
ledOn
;
}
void
setMD5sum
(
const
String
&
md5Sum
)
{
_md5Sum
=
md5Sum
;
}
void
setAuthorization
(
const
String
&
user
,
const
String
&
password
)
{
_user
=
user
;
_password
=
password
;
}
void
setAuthorization
(
const
String
&
auth
)
{
_auth
=
auth
;
}
t_httpUpdate_return
update
(
WiFiClient
&
client
,
const
String
&
url
,
const
String
&
currentVersion
=
""
,
HTTPUpdateRequestCB
requestCB
=
NULL
);
t_httpUpdate_return
update
(
WiFiClient
&
client
,
const
String
&
host
,
uint16_t
port
,
const
String
&
uri
=
"/"
,
...
...
@@ -123,6 +139,10 @@ protected:
private:
int
_httpClientTimeout
;
followRedirects_t
_followRedirects
;
String
_user
;
String
_password
;
String
_auth
;
String
_md5Sum
;
// Callbacks
HTTPUpdateStartCB
_cbStart
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment