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
06a399b8
Unverified
Commit
06a399b8
authored
Sep 16, 2019
by
Me No Dev
Committed by
GitHub
Sep 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend logging of ArduinoOTA (#3217)
parent
4ce2cc3c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
32 deletions
+23
-32
libraries/ArduinoOTA/src/ArduinoOTA.cpp
libraries/ArduinoOTA/src/ArduinoOTA.cpp
+17
-32
libraries/Update/src/Update.h
libraries/Update/src/Update.h
+2
-0
libraries/Update/src/Updater.cpp
libraries/Update/src/Updater.cpp
+4
-0
No files found.
libraries/ArduinoOTA/src/ArduinoOTA.cpp
View file @
06a399b8
...
@@ -127,9 +127,7 @@ void ArduinoOTAClass::begin() {
...
@@ -127,9 +127,7 @@ void ArduinoOTAClass::begin() {
}
}
_initialized
=
true
;
_initialized
=
true
;
_state
=
OTA_IDLE
;
_state
=
OTA_IDLE
;
#ifdef OTA_DEBUG
log_i
(
"OTA server at: %s.local:%u"
,
_hostname
.
c_str
(),
_port
);
OTA_DEBUG
.
printf
(
"OTA server at: %s.local:%u
\n
"
,
_hostname
.
c_str
(),
_port
);
#endif
}
}
int
ArduinoOTAClass
::
parseInt
(){
int
ArduinoOTAClass
::
parseInt
(){
...
@@ -173,6 +171,7 @@ void ArduinoOTAClass::_onRx(){
...
@@ -173,6 +171,7 @@ void ArduinoOTAClass::_onRx(){
_md5
=
readStringUntil
(
'\n'
);
_md5
=
readStringUntil
(
'\n'
);
_md5
.
trim
();
_md5
.
trim
();
if
(
_md5
.
length
()
!=
32
){
if
(
_md5
.
length
()
!=
32
){
log_e
(
"bad md5 length"
);
return
;
return
;
}
}
...
@@ -198,6 +197,7 @@ void ArduinoOTAClass::_onRx(){
...
@@ -198,6 +197,7 @@ void ArduinoOTAClass::_onRx(){
}
else
if
(
_state
==
OTA_WAITAUTH
)
{
}
else
if
(
_state
==
OTA_WAITAUTH
)
{
int
cmd
=
parseInt
();
int
cmd
=
parseInt
();
if
(
cmd
!=
U_AUTH
)
{
if
(
cmd
!=
U_AUTH
)
{
log_e
(
"%d was expected. got %d instead"
,
U_AUTH
,
cmd
);
_state
=
OTA_IDLE
;
_state
=
OTA_IDLE
;
return
;
return
;
}
}
...
@@ -205,6 +205,7 @@ void ArduinoOTAClass::_onRx(){
...
@@ -205,6 +205,7 @@ void ArduinoOTAClass::_onRx(){
String
cnonce
=
readStringUntil
(
' '
);
String
cnonce
=
readStringUntil
(
' '
);
String
response
=
readStringUntil
(
'\n'
);
String
response
=
readStringUntil
(
'\n'
);
if
(
cnonce
.
length
()
!=
32
||
response
.
length
()
!=
32
)
{
if
(
cnonce
.
length
()
!=
32
||
response
.
length
()
!=
32
)
{
log_e
(
"auth param fail"
);
_state
=
OTA_IDLE
;
_state
=
OTA_IDLE
;
return
;
return
;
}
}
...
@@ -225,6 +226,7 @@ void ArduinoOTAClass::_onRx(){
...
@@ -225,6 +226,7 @@ void ArduinoOTAClass::_onRx(){
}
else
{
}
else
{
_udp_ota
.
beginPacket
(
_udp_ota
.
remoteIP
(),
_udp_ota
.
remotePort
());
_udp_ota
.
beginPacket
(
_udp_ota
.
remoteIP
(),
_udp_ota
.
remotePort
());
_udp_ota
.
print
(
"Authentication Failed"
);
_udp_ota
.
print
(
"Authentication Failed"
);
log_w
(
"Authentication Failed"
);
_udp_ota
.
endPacket
();
_udp_ota
.
endPacket
();
if
(
_error_callback
)
_error_callback
(
OTA_AUTH_ERROR
);
if
(
_error_callback
)
_error_callback
(
OTA_AUTH_ERROR
);
_state
=
OTA_IDLE
;
_state
=
OTA_IDLE
;
...
@@ -234,9 +236,9 @@ void ArduinoOTAClass::_onRx(){
...
@@ -234,9 +236,9 @@ void ArduinoOTAClass::_onRx(){
void
ArduinoOTAClass
::
_runUpdate
()
{
void
ArduinoOTAClass
::
_runUpdate
()
{
if
(
!
Update
.
begin
(
_size
,
_cmd
))
{
if
(
!
Update
.
begin
(
_size
,
_cmd
))
{
#ifdef OTA_DEBUG
Update
.
printError
(
OTA_DEBUG
);
log_e
(
"Begin ERROR: %s"
,
Update
.
errorString
()
);
#endif
if
(
_error_callback
)
{
if
(
_error_callback
)
{
_error_callback
(
OTA_BEGIN_ERROR
);
_error_callback
(
OTA_BEGIN_ERROR
);
}
}
...
@@ -272,21 +274,15 @@ void ArduinoOTAClass::_runUpdate() {
...
@@ -272,21 +274,15 @@ void ArduinoOTAClass::_runUpdate() {
}
}
if
(
!
waited
){
if
(
!
waited
){
if
(
written
&&
tried
++
<
3
){
if
(
written
&&
tried
++
<
3
){
#ifdef OTA_DEBUG
log_i
(
"Try[%u]: %u"
,
tried
,
written
);
OTA_DEBUG
.
printf
(
"Try[%u]: %u
\n
"
,
tried
,
written
);
#endif
if
(
!
client
.
printf
(
"%u"
,
written
)){
if
(
!
client
.
printf
(
"%u"
,
written
)){
#ifdef OTA_DEBUG
log_e
(
"failed to respond"
);
OTA_DEBUG
.
printf
(
"failed to respond
\n
"
);
#endif
_state
=
OTA_IDLE
;
_state
=
OTA_IDLE
;
break
;
break
;
}
}
continue
;
continue
;
}
}
#ifdef OTA_DEBUG
log_e
(
"Receive Failed"
);
OTA_DEBUG
.
printf
(
"Receive Failed
\n
"
);
#endif
if
(
_error_callback
)
{
if
(
_error_callback
)
{
_error_callback
(
OTA_RECEIVE_ERROR
);
_error_callback
(
OTA_RECEIVE_ERROR
);
}
}
...
@@ -295,9 +291,7 @@ void ArduinoOTAClass::_runUpdate() {
...
@@ -295,9 +291,7 @@ void ArduinoOTAClass::_runUpdate() {
return
;
return
;
}
}
if
(
!
available
){
if
(
!
available
){
#ifdef OTA_DEBUG
log_e
(
"No Data: %u"
,
waited
);
OTA_DEBUG
.
printf
(
"No Data: %u
\n
"
,
waited
);
#endif
_state
=
OTA_IDLE
;
_state
=
OTA_IDLE
;
break
;
break
;
}
}
...
@@ -317,18 +311,14 @@ void ArduinoOTAClass::_runUpdate() {
...
@@ -317,18 +311,14 @@ void ArduinoOTAClass::_runUpdate() {
log_w
(
"didn't write enough! %u != %u"
,
written
,
r
);
log_w
(
"didn't write enough! %u != %u"
,
written
,
r
);
}
}
if
(
!
client
.
printf
(
"%u"
,
written
)){
if
(
!
client
.
printf
(
"%u"
,
written
)){
#ifdef OTA_DEBUG
log_w
(
"failed to respond"
);
OTA_DEBUG
.
printf
(
"failed to respond
\n
"
);
#endif
}
}
total
+=
written
;
total
+=
written
;
if
(
_progress_callback
)
{
if
(
_progress_callback
)
{
_progress_callback
(
total
,
_size
);
_progress_callback
(
total
,
_size
);
}
}
}
else
{
}
else
{
#ifdef OTA_DEBUG
log_e
(
"Write ERROR: %s"
,
Update
.
errorString
());
Update
.
printError
(
OTA_DEBUG
);
#endif
}
}
}
}
...
@@ -351,10 +341,7 @@ void ArduinoOTAClass::_runUpdate() {
...
@@ -351,10 +341,7 @@ void ArduinoOTAClass::_runUpdate() {
Update
.
printError
(
client
);
Update
.
printError
(
client
);
client
.
stop
();
client
.
stop
();
delay
(
10
);
delay
(
10
);
#ifdef OTA_DEBUG
log_e
(
"Update ERROR: %s"
,
Update
.
errorString
());
OTA_DEBUG
.
print
(
"Update ERROR: "
);
Update
.
printError
(
OTA_DEBUG
);
#endif
_state
=
OTA_IDLE
;
_state
=
OTA_IDLE
;
}
}
}
}
...
@@ -366,9 +353,7 @@ void ArduinoOTAClass::end() {
...
@@ -366,9 +353,7 @@ void ArduinoOTAClass::end() {
MDNS
.
end
();
MDNS
.
end
();
}
}
_state
=
OTA_IDLE
;
_state
=
OTA_IDLE
;
#ifdef OTA_DEBUG
log_i
(
"OTA server stopped."
);
OTA_DEBUG
.
println
(
"OTA server stopped."
);
#endif
}
}
void
ArduinoOTAClass
::
handle
()
{
void
ArduinoOTAClass
::
handle
()
{
...
@@ -395,4 +380,4 @@ void ArduinoOTAClass::setTimeout(int timeoutInMillis) {
...
@@ -395,4 +380,4 @@ void ArduinoOTAClass::setTimeout(int timeoutInMillis) {
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_ARDUINOOTA)
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_ARDUINOOTA)
ArduinoOTAClass
ArduinoOTA
;
ArduinoOTAClass
ArduinoOTA
;
#endif
#endif
\ No newline at end of file
libraries/Update/src/Update.h
View file @
06a399b8
...
@@ -80,6 +80,8 @@ class UpdateClass {
...
@@ -80,6 +80,8 @@ class UpdateClass {
*/
*/
void
printError
(
Stream
&
out
);
void
printError
(
Stream
&
out
);
const
char
*
errorString
();
/*
/*
sets the expected MD5 for the firmware (hexString)
sets the expected MD5 for the firmware (hexString)
*/
*/
...
...
libraries/Update/src/Updater.cpp
View file @
06a399b8
...
@@ -363,4 +363,8 @@ void UpdateClass::printError(Stream &out){
...
@@ -363,4 +363,8 @@ void UpdateClass::printError(Stream &out){
out
.
println
(
_err2str
(
_error
));
out
.
println
(
_err2str
(
_error
));
}
}
const
char
*
UpdateClass
::
errorString
(){
return
_err2str
(
_error
);
}
UpdateClass
Update
;
UpdateClass
Update
;
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