free udp receive buffers before parsePacket

robustness improvement - parsepacket() will fail if the udp handler still has an active receive buffer.
This commit is contained in:
Frank
2023-06-21 00:29:16 +02:00
parent 8aef4347a1
commit 708cd8e73d
2 changed files with 4 additions and 0 deletions

View File

@@ -226,6 +226,7 @@ void sendNTPPacket()
bool checkNTPResponse()
{
ntpUdp.flush();
int cb = ntpUdp.parsePacket();
if (!cb) return false;

View File

@@ -240,8 +240,10 @@ void handleNotifications()
if (!udpConnected) return;
bool isSupp = false;
notifierUdp.flush();
int packetSize = notifierUdp.parsePacket(); // WLEDMM function returns int, not size_t
if ((packetSize < 1) && udp2Connected) {
notifier2Udp.flush();
packetSize = notifier2Udp.parsePacket();
isSupp = true;
}
@@ -249,6 +251,7 @@ void handleNotifications()
//hyperion / raw RGB
if (!packetSize && udpRgbConnected) {
rgbUdp.flush();
packetSize = rgbUdp.parsePacket();
if (packetSize) {
if (!receiveDirect) {rgbUdp.flush(); notifierUdp.flush(); notifier2Udp.flush(); return;}