From f74027c8b3597026a80913afcca351367344ea0d Mon Sep 17 00:00:00 2001 From: gsg2820 <35265177+saak2820@users.noreply.github.com> Date: Thu, 6 Jan 2022 09:27:11 +0100 Subject: [PATCH 1/2] arduino Stream->find, shorten the search timeout parsing the response XML will result in timeout. maximum milliseconds to wait for stream data, it defaults to 1000 milliseconds. --- src/tr064.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tr064.cpp b/src/tr064.cpp index f1cc9f8..bfd45ac 100644 --- a/src/tr064.cpp +++ b/src/tr064.cpp @@ -573,6 +573,7 @@ String TR064::byte2hex(byte number){ /**************************************************************************/ bool TR064::xmlTakeParam(String (*params)[2], int nParam) { WiFiClient * stream = &tr064client; + stream->setTimeout(40); while(stream->connected()) { if(!http.connected()) { deb_println("[TR064][xmlTakeParam] http connection lost", DEBUG_INFO); From 5110276a8718b07022f83e4e27bf9a3f72710025 Mon Sep 17 00:00:00 2001 From: gsg2820 <35265177+saak2820@users.noreply.github.com> Date: Fri, 21 Jan 2022 12:01:45 +0100 Subject: [PATCH 2/2] set timeout at readStringUntil() function to 40 milliseconds parsing the response XML with readStringUntil will result in timeout. maximum milliseconds to wait for stream data, it defaults to 1000 milliseconds. this will set it to 40 milliseconds --- src/tr064.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/tr064.cpp b/src/tr064.cpp index bfd45ac..ea24777 100644 --- a/src/tr064.cpp +++ b/src/tr064.cpp @@ -573,7 +573,7 @@ String TR064::byte2hex(byte number){ /**************************************************************************/ bool TR064::xmlTakeParam(String (*params)[2], int nParam) { WiFiClient * stream = &tr064client; - stream->setTimeout(40); + stream->Stream::setTimeout(40); while(stream->connected()) { if(!http.connected()) { deb_println("[TR064][xmlTakeParam] http connection lost", DEBUG_INFO); @@ -581,8 +581,9 @@ bool TR064::xmlTakeParam(String (*params)[2], int nParam) { } 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; iStream::setTimeout(40); while(stream->connected()) { if(!http.connected()) { deb_println("[TR064][xmlTakeParam] http connection lost", DEBUG_INFO); @@ -696,4 +697,4 @@ void TR064::deb_println(const String& message, int level) { //Serial.flush(); } } -} +} \ No newline at end of file