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
278fa0d8
Commit
278fa0d8
authored
Dec 15, 2018
by
me-no-dev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix read(), peek() and available() in WiFiClientSecure
closes:
https://github.com/espressif/arduino-esp32/pull/2151
parent
b37f4069
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
15 deletions
+10
-15
libraries/WiFiClientSecure/src/WiFiClientSecure.cpp
libraries/WiFiClientSecure/src/WiFiClientSecure.cpp
+10
-15
No files found.
libraries/WiFiClientSecure/src/WiFiClientSecure.cpp
View file @
278fa0d8
...
...
@@ -156,13 +156,6 @@ size_t WiFiClientSecure::write(uint8_t data)
int
WiFiClientSecure
::
read
()
{
uint8_t
data
=
-
1
;
if
(
_peek
>=
0
){
data
=
_peek
;
_peek
=
-
1
;
return
data
;
}
int
res
=
read
(
&
data
,
1
);
if
(
res
<
0
)
{
return
res
;
...
...
@@ -186,7 +179,8 @@ 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
()))
{
int
avail
=
available
();
if
((
!
buf
&&
size
)
||
avail
<=
0
)
{
return
-
1
;
}
if
(
!
size
){
...
...
@@ -196,7 +190,8 @@ int WiFiClientSecure::read(uint8_t *buf, size_t size)
buf
[
0
]
=
_peek
;
_peek
=
-
1
;
size
--
;
if
(
!
size
||
!
available
()){
avail
--
;
if
(
!
size
||
!
avail
){
return
1
;
}
buf
++
;
...
...
@@ -206,23 +201,23 @@ int WiFiClientSecure::read(uint8_t *buf, size_t size)
int
res
=
get_ssl_receive
(
sslclient
,
buf
,
size
);
if
(
res
<
0
)
{
stop
();
return
res
;
return
peeked
?
peeked
:
res
;
}
return
res
+
peeked
;
}
int
WiFiClientSecure
::
available
()
{
int
peeked
=
(
_peek
>=
0
);
if
(
!
_connected
)
{
return
0
;
return
peeked
;
}
int
res
=
data_to_read
(
sslclient
);
if
(
res
<
0
)
{
if
(
res
<
0
)
{
stop
();
}
else
if
(
_peek
>=
0
)
{
res
+=
1
;
return
peeked
?
peeked
:
res
;
}
return
res
;
return
res
+
peeked
;
}
uint8_t
WiFiClientSecure
::
connected
()
...
...
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