Hello squix78,
First, thank You a lot this great work. I am trying to apply your library into my home project.
I would like to periodically read a specific value from the EasyIoT server. Using ESP8266 with WiFi library.
As I can see, the parsing process runs only once as a very first. Then, on the second and next loops, it is not parsing anything, however, as I can see, char c is read and can be printed on Serial Monitor.
Tried to stop clients but it did not help. Could you, please, take a look and provide any hint how to solve that?
ExampleParser.cpp - without modifications (yet).
void switch1RpiCheck() {
parser.setListener(&listener);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
while (!rPiClient.connect(EIOT_IP_ADDRESS, EIOT_PORT)) {
Serial.println("connection failed");
}
Serial.println("Debug1: Connected to EasyIoT");
String url = "";
url = "/esp8266/4";
//Serial.print("POST data to URL: ");
//Serial.println(url);
rPiClient.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + EIOT_IP_ADDRESS + "\r\n" +
"Connection: close\r\n" +
"Authorization: Basic " + unameenc + " \r\n" +
"Content-Length: 0\r\n" +
"\r\n"
);
boolean isBody = false;
char c;
int size = 0;
while (rPiClient.connected()) {
while ((size = rPiClient.available()) > 0) {
c = rPiClient.read();
//Serial.println(c);
if (c == '{' || c == '[') {
isBody = true;
//Serial.println("Debug2: isBody=true");
}
if (isBody) {
//Serial.println(c);
Serial.println("Debug3: parsing(c)");
parser.parse(c);
}
}
}
parse.reset(); //ATTENTION - SOLUTION FOUND: Adding this line fixed the issue.
};
Hello squix78, First, thank You a lot this great work. I am trying to apply your library into my home project. I would like to periodically read a specific value from the EasyIoT server. Using ESP8266 with WiFi library.
As I can see, the parsing process runs only once as a very first. Then, on the second and next loops, it is not parsing anything, however, as I can see, char c is read and can be printed on Serial Monitor.
Tried to stop clients but it did not help. Could you, please, take a look and provide any hint how to solve that?
ExampleParser.cpp - without modifications (yet).
Thank You in advance! Best regards, Artur