I'm using client UDP application like this:
WiFiUDP 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!