-->
Page 1 of 1

How to reconnect while parsePacket/read

PostPosted: Wed Jan 27, 2016 1:35 am
by espTroll
Hello!
I'm using client UDP application like this:

Code: Select allWiFiUDP port;
...
void setup() {
  Serial.begin(115200);
  WiFi.begin("yourssid", "yourpassword");
  port.begin(localPort);
}

void loop() {
  int packetSize = port.parsePacket();
  if (packetSize) {
    port.read(packetBuffer, packetSize);
    ...
  }
}


It works as expected expect the case of connection lost.
When WiFi is down and up again I need reconnect and continue consuming bytes.
Instead of this method parsePacket or read hangs up and never return control to the loop()

Please advice how I can interrupt and reconnect again :-)

Thanks!