Post by zoltano on Aug 1, 2020 6:45:44 GMT -8
Using WeatherPlus V1 board with V3.6 software. I've been having problems with the board hanging when I access via HTTP to get REST output. This mostly happens when OLED display is set for medium or large mode. I finally looked at the code and found that handling REST calls is repeated in the main loop and in the medium and large display modes. The main loop has a fix that prevents an infinite loop while medium and large do not.
In main loop:
void loop() {
// put your main code here, to run repeatedly:
//Serial.println("Starting Main Loop");
// Handle REST calls
WiFiClient client = server.available();
int timeout;
timeout = 0;
if (client)
{
// Thank you to MAKA69 for this suggestion
while (!client.available()) {
Serial.print(".");
delay(1);
timeout++;
if (timeout > 1000) {
Serial.print("INFINITE LOOP BREAK!");
break;
}
}
if (client.available())
{
rest.handle(client);
}
}
client.stop();
in medium and large display:
// Handle REST calls
WiFiClient client = server.available();
if (client)
{
while (!client.available()) {
delay(1);
}
if (client.available())
{
rest.handle(client);
}
}
Should the code in the display output not exist, or should it have the "fix" applied?
Thanks!
PS: found that the REST handler exists in couple of other places as well.
In main loop:
void loop() {
// put your main code here, to run repeatedly:
//Serial.println("Starting Main Loop");
// Handle REST calls
WiFiClient client = server.available();
int timeout;
timeout = 0;
if (client)
{
// Thank you to MAKA69 for this suggestion
while (!client.available()) {
Serial.print(".");
delay(1);
timeout++;
if (timeout > 1000) {
Serial.print("INFINITE LOOP BREAK!");
break;
}
}
if (client.available())
{
rest.handle(client);
}
}
client.stop();
in medium and large display:
// Handle REST calls
WiFiClient client = server.available();
if (client)
{
while (!client.available()) {
delay(1);
}
if (client.available())
{
rest.handle(client);
}
}
Should the code in the display output not exist, or should it have the "fix" applied?
Thanks!
PS: found that the REST handler exists in couple of other places as well.