From 708cd8e73d53b9f72d0b7c0eb2dd6b7d08bda40b Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 21 Jun 2023 00:29:16 +0200 Subject: [PATCH] free udp receive buffers before parsePacket robustness improvement - parsepacket() will fail if the udp handler still has an active receive buffer. --- wled00/ntp.cpp | 1 + wled00/udp.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/wled00/ntp.cpp b/wled00/ntp.cpp index 3c04873d..c5393cde 100644 --- a/wled00/ntp.cpp +++ b/wled00/ntp.cpp @@ -226,6 +226,7 @@ void sendNTPPacket() bool checkNTPResponse() { + ntpUdp.flush(); int cb = ntpUdp.parsePacket(); if (!cb) return false; diff --git a/wled00/udp.cpp b/wled00/udp.cpp index 8da51911..a9ea2856 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -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;}