Wi-Fi pauses for several seconds after about 150 packets

kbaud1
Posts: 71
Joined: Wed Jan 17, 2018 11:55 pm

Wi-Fi pauses for several seconds after about 150 packets

Postby kbaud1 » Thu Jan 18, 2018 12:32 am

Searched for this issue here and on google. It appears this is not a problem when using IDF examples but only with the Arduino Wi-Fi examples. I think the reason is the IDF examples can increase the rx/tx buffer size using menuconfig but arduino is unable to use menuconfig. Is there a way to change sdkconfig or change these values within a sketch?

Code I am using:

Code: Select all

// code examples from espressif ESP32 examples on github

#include <WiFi.h>

const char* ssid       = "myAPssid"; 
const char* password   = "myAPpassword";


WiFiServer server(7777);

void setup()
{
    Serial.begin(115200);
    pinMode(5, OUTPUT);      // set the LED pin mode

    delay(10);

    // We start by connecting to a WiFi network

    Serial.print("Connecting to \""); Serial.print(ssid); Serial.println("\"");

    WiFi.disconnect(true);    // delete old config
    WiFi.begin(ssid, password);

    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }

    Serial.println("");
    Serial.println("WiFi connected.");
    Serial.print("IP address: "); Serial.println(WiFi.localIP());
    
    server.begin();
    server.setNoDelay(true);  //reduces latency in connection at the expense of some packet loss? tried with and without (not much change)
    Serial.println("waiting for client to connect...");
}

int value = 0;  // what is this used for? was in the example

void loop(){ 
 WiFiClient client = server.available();   // listen for incoming clients

  if (client) {                             // if you get a client,
   // Serial.print("New client: ");           // print a message out the serial port
   // Serial.println(client.remoteIP());
        
    String currentLine = "";                // make a String to hold incoming data from the client
  //  unsigned long startTime = millis();     // for timing connection length
    
    while (client.connected()) {            // loop while the client's connected
      if (client.available()) {             // if there's bytes to read from the client,
        char c = client.read();             // read a byte, then
        Serial.write(c);                    // print it out the serial monitor
        if (c == '\n') {                    // if the byte is a newline character

            // after any data from client is taken care of, send some data to the client         
            client.println("msg from server12345");          // send 20 bytes and remote on Windows echoes it back

            // break out of the while loop:
            break;

        } else if (c != '\r') {  // if you got anything else but a carriage return character,
          currentLine += c;      // add it to the end of the currentLine
        }
      }
    }                                         // end loop: while client is connected
    
    // close the connection:
       client.stop();
       delay(5);
      // Serial.println("\nClient Disconnected.");

   // currentLine = String("Elapsed time = ") + (millis() - startTime) + "ms";
   // Serial.println(currentLine);
  }
}


Thank you for any suggestions!

Who is online

Users browsing this forum: m8nix70 and 110 guests