Skip to content

Commit 98e0bc6

Browse files
authored
AR: minor update for better compatibility with arduino-esp32 V3.x
WiFiUDP.flush() -> WiFiUDP.clear()
1 parent cb049fb commit 98e0bc6

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

usermods/audioreactive/audio_reactive.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,12 @@ class AudioReactive : public Usermod {
13001300

13011301
size_t packetSize = fftUdp.parsePacket();
13021302
#ifdef ARDUINO_ARCH_ESP32
1303-
if ((packetSize > 0) && ((packetSize < 5) || (packetSize > UDPSOUND_MAX_PACKET))) fftUdp.flush(); // discard invalid packets (too small or too big) - only works on esp32
1303+
if ((packetSize > 0) && ((packetSize < 5) || (packetSize > UDPSOUND_MAX_PACKET)))
1304+
#if ESP_IDF_VERSION_MAJOR < 5
1305+
fftUdp.flush(); // discard invalid packets (too small or too big) - only works on esp32
1306+
#else
1307+
fftUdp.clear(); // function was renamed in newer frameworks
1308+
#endif
13041309
#endif
13051310
if ((packetSize > 5) && (packetSize <= UDPSOUND_MAX_PACKET)) {
13061311
//DEBUGSR_PRINTLN("Received UDP Sync Packet");
@@ -1612,7 +1617,11 @@ class AudioReactive : public Usermod {
16121617
have_new_sample = receiveAudioData();
16131618
if (have_new_sample) last_UDPTime = millis();
16141619
#ifdef ARDUINO_ARCH_ESP32
1620+
#if ESP_IDF_VERSION_MAJOR < 5
16151621
else fftUdp.flush(); // Flush udp input buffers if we haven't read it - avoids hickups in receive mode. Does not work on 8266.
1622+
#else
1623+
else fftUdp.clear(); // function was remaned in newer framework versions
1624+
#endif
16161625
#endif
16171626
lastTime = millis();
16181627
}

0 commit comments

Comments
 (0)