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
febcda00
Commit
febcda00
authored
Apr 14, 2018
by
copercini
Committed by
Me No Dev
Apr 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add WiFiClientSecure::peek(); (#1310)
parent
69f72eca
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
9 deletions
+29
-9
libraries/WiFiClientSecure/src/WiFiClientSecure.cpp
libraries/WiFiClientSecure/src/WiFiClientSecure.cpp
+27
-5
libraries/WiFiClientSecure/src/WiFiClientSecure.h
libraries/WiFiClientSecure/src/WiFiClientSecure.h
+2
-4
No files found.
libraries/WiFiClientSecure/src/WiFiClientSecure.cpp
View file @
febcda00
...
...
@@ -39,7 +39,7 @@ WiFiClientSecure::WiFiClientSecure()
_CA_cert
=
NULL
;
_cert
=
NULL
;
_private_key
=
NULL
;
next
=
NULL
;
next
=
NULL
;
}
...
...
@@ -58,13 +58,13 @@ WiFiClientSecure::WiFiClientSecure(int sock)
_CA_cert
=
NULL
;
_cert
=
NULL
;
_private_key
=
NULL
;
next
=
NULL
;
next
=
NULL
;
}
WiFiClientSecure
::~
WiFiClientSecure
()
{
stop
();
delete
sslclient
;
delete
sslclient
;
}
WiFiClientSecure
&
WiFiClientSecure
::
operator
=
(
const
WiFiClientSecure
&
other
)
...
...
@@ -113,6 +113,14 @@ int WiFiClientSecure::connect(const char *host, uint16_t port, const char *_CA_c
return
1
;
}
int
WiFiClientSecure
::
peek
(){
if
(
_peek
>=
0
){
return
_peek
;
}
_peek
=
read
();
return
_peek
;
}
size_t
WiFiClientSecure
::
write
(
uint8_t
data
)
{
return
write
(
&
data
,
1
);
...
...
@@ -120,7 +128,14 @@ size_t WiFiClientSecure::write(uint8_t data)
int
WiFiClientSecure
::
read
()
{
uint8_t
data
=
0
;
uint8_t
data
=
-
1
;
if
(
_peek
>=
0
){
data
=
_peek
;
_peek
=
-
1
;
return
data
;
}
int
res
=
read
(
&
data
,
1
);
if
(
res
<
0
)
{
return
res
;
...
...
@@ -143,6 +158,13 @@ size_t WiFiClientSecure::write(const uint8_t *buf, size_t size)
int
WiFiClientSecure
::
read
(
uint8_t
*
buf
,
size_t
size
)
{
if
(
_peek
>=
0
){
uint8_t
data
=
-
1
;
data
=
_peek
;
_peek
=
-
1
;
return
data
;
}
if
(
!
available
())
{
return
-
1
;
}
...
...
@@ -161,7 +183,7 @@ int WiFiClientSecure::available()
int
res
=
data_to_read
(
sslclient
);
if
(
res
<
0
)
{
stop
();
}
}
return
res
;
}
...
...
libraries/WiFiClientSecure/src/WiFiClientSecure.h
View file @
febcda00
...
...
@@ -31,6 +31,7 @@ protected:
sslclient_context
*
sslclient
;
int
_lastError
=
0
;
int
_peek
=
-
1
;
const
char
*
_CA_cert
;
const
char
*
_cert
;
const
char
*
_private_key
;
...
...
@@ -44,15 +45,12 @@ public:
int
connect
(
const
char
*
host
,
uint16_t
port
);
int
connect
(
IPAddress
ip
,
uint16_t
port
,
const
char
*
rootCABuff
,
const
char
*
cli_cert
,
const
char
*
cli_key
);
int
connect
(
const
char
*
host
,
uint16_t
port
,
const
char
*
rootCABuff
,
const
char
*
cli_cert
,
const
char
*
cli_key
);
int
peek
();
size_t
write
(
uint8_t
data
);
size_t
write
(
const
uint8_t
*
buf
,
size_t
size
);
int
available
();
int
read
();
int
read
(
uint8_t
*
buf
,
size_t
size
);
int
peek
()
{
return
0
;
}
void
flush
()
{}
void
stop
();
uint8_t
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