Skip to content

Commit

Permalink
Merge pull request #58 from saak2820/StreamTimeout
Browse files Browse the repository at this point in the history
set Stream Timeout at readStringUntil() function to 40 milliseconds
Fixes various issues people have been encountering.
  • Loading branch information
Aypac authored Jul 27, 2022
2 parents 3fb0d1b + 5110276 commit 2c14910
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/tr064.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,15 +573,17 @@ String TR064::byte2hex(byte number){
/**************************************************************************/
bool TR064::xmlTakeParam(String (*params)[2], int nParam) {
WiFiClient * stream = &tr064client;
stream->Stream::setTimeout(40);
while(stream->connected()) {
if(!http.connected()) {
deb_println("[TR064][xmlTakeParam] http connection lost", DEBUG_INFO);
return false;
}
if(stream->find("<")){
const String htmltag = stream->readStringUntil('>');
const String value = stream->readStringUntil('<');
deb_println("[TR064][xmlTakeParam] htmltag: "+htmltag, DEBUG_VERBOSE);
const String value = stream->readStringUntil('<');


if (nParam > 0) {
for (uint16_t i=0; i<nParam; ++i) {
Expand Down Expand Up @@ -638,7 +640,7 @@ bool TR064::xmlTakeParam(String (*params)[2], int nParam) {
/**************************************************************************/
bool TR064::xmlTakeParam(String& value, const String& needParam) {
WiFiClient * stream = &tr064client;
stream->Stream::setTimeout(40);
while(stream->connected()) {
if(!http.connected()) {
deb_println("[TR064][xmlTakeParam] http connection lost", DEBUG_INFO);
Expand Down Expand Up @@ -695,4 +697,4 @@ void TR064::deb_println(const String& message, int level) {
//Serial.flush();
}
}
}
}

0 comments on commit 2c14910

Please sign in to comment.