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
873876d9
Commit
873876d9
authored
Jun 27, 2018
by
me-no-dev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix peek, read and available logic in WiFiClientSecure
parent
05864526
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
10 deletions
+22
-10
libraries/WiFiClientSecure/src/WiFiClientSecure.cpp
libraries/WiFiClientSecure/src/WiFiClientSecure.cpp
+22
-10
No files found.
libraries/WiFiClientSecure/src/WiFiClientSecure.cpp
View file @
873876d9
...
...
@@ -81,6 +81,7 @@ void WiFiClientSecure::stop()
close
(
sslclient
->
socket
);
sslclient
->
socket
=
-
1
;
_connected
=
false
;
_peek
=
-
1
;
}
stop_ssl_socket
(
sslclient
,
_CA_cert
,
_cert
,
_private_key
);
}
...
...
@@ -105,7 +106,7 @@ int WiFiClientSecure::connect(const char *host, uint16_t port, const char *_CA_c
int
ret
=
start_ssl_client
(
sslclient
,
host
,
port
,
_CA_cert
,
_cert
,
_private_key
);
_lastError
=
ret
;
if
(
ret
<
0
)
{
log_e
(
"
lwip_connect_r: %d"
,
errno
);
log_e
(
"
start_ssl_client: %d"
,
ret
);
stop
();
return
0
;
}
...
...
@@ -117,7 +118,7 @@ int WiFiClientSecure::peek(){
if
(
_peek
>=
0
){
return
_peek
;
}
_peek
=
r
ead
();
_peek
=
timedR
ead
();
return
_peek
;
}
...
...
@@ -158,21 +159,30 @@ size_t WiFiClientSecure::write(const uint8_t *buf, size_t size)
int
WiFiClientSecure
::
read
(
uint8_t
*
buf
,
size_t
size
)
{
int
peeked
=
0
;
if
((
!
buf
&&
size
)
||
(
_peek
<
0
&&
!
available
()))
{
return
-
1
;
}
if
(
!
size
){
return
0
;
}
if
(
_peek
>=
0
){
uint8_t
data
=
-
1
;
data
=
_peek
;
buf
[
0
]
=
_peek
;
_peek
=
-
1
;
return
data
;
size
--
;
if
(
!
size
||
!
available
()){
return
1
;
}
buf
++
;
peeked
=
1
;
}
if
(
!
available
())
{
return
-
1
;
}
int
res
=
get_ssl_receive
(
sslclient
,
buf
,
size
);
if
(
res
<
0
)
{
stop
();
return
res
;
}
return
res
;
return
res
+
peeked
;
}
int
WiFiClientSecure
::
available
()
...
...
@@ -183,7 +193,9 @@ int WiFiClientSecure::available()
int
res
=
data_to_read
(
sslclient
);
if
(
res
<
0
)
{
stop
();
}
}
else
if
(
_peek
>=
0
)
{
res
+=
1
;
}
return
res
;
}
...
...
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