How to reconnect while parsePacket/read
Posted: Wed Jan 27, 2016 1:35 am
Hello!
I'm using client UDP application like this:
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!
I'm using client UDP application like this:
Code: Select all
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!