From 9cb5dd54f09675dab9e13b292ad58b740e2d3ccd Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Mon, 26 Aug 2024 11:37:05 +0300 Subject: [PATCH] fix(client): Make flush() call clear() and deprecate it This is a compromise for issues caused by https://github.com/espressif/arduino-esp32/pull/9453 --- libraries/Network/src/NetworkClient.cpp | 4 +++- libraries/Network/src/NetworkClient.h | 1 + libraries/Network/src/NetworkUdp.cpp | 4 +++- libraries/Network/src/NetworkUdp.h | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libraries/Network/src/NetworkClient.cpp b/libraries/Network/src/NetworkClient.cpp index 9f4806df18a..614a310de83 100644 --- a/libraries/Network/src/NetworkClient.cpp +++ b/libraries/Network/src/NetworkClient.cpp @@ -369,7 +369,9 @@ int NetworkClient::read() { return data; } -void NetworkClient::flush() {} +void NetworkClient::flush() { + clear(); +} size_t NetworkClient::write(const uint8_t *buf, size_t size) { int res = 0; diff --git a/libraries/Network/src/NetworkClient.h b/libraries/Network/src/NetworkClient.h index 572292a7a99..bdf857e9637 100644 --- a/libraries/Network/src/NetworkClient.h +++ b/libraries/Network/src/NetworkClient.h @@ -56,6 +56,7 @@ class NetworkClient : public ESPLwIPClient { size_t write(const uint8_t *buf, size_t size); size_t write_P(PGM_P buf, size_t size); size_t write(Stream &stream); + [[deprecated("Use clear() instead.")]] void flush(); // Print::flush tx int available(); int read(); diff --git a/libraries/Network/src/NetworkUdp.cpp b/libraries/Network/src/NetworkUdp.cpp index 21f568f65b0..73e0607c5ff 100644 --- a/libraries/Network/src/NetworkUdp.cpp +++ b/libraries/Network/src/NetworkUdp.cpp @@ -288,7 +288,9 @@ size_t NetworkUDP::write(const uint8_t *buffer, size_t size) { return i; } -void NetworkUDP::flush() {} +void NetworkUDP::flush() { + clear(); +} int NetworkUDP::parsePacket() { if (rx_buffer) { diff --git a/libraries/Network/src/NetworkUdp.h b/libraries/Network/src/NetworkUdp.h index ec05991b7e3..e70ec9b2127 100644 --- a/libraries/Network/src/NetworkUdp.h +++ b/libraries/Network/src/NetworkUdp.h @@ -64,6 +64,7 @@ class NetworkUDP : public UDP { int endPacket(); size_t write(uint8_t); size_t write(const uint8_t *buffer, size_t size); + [[deprecated("Use clear() instead.")]] void flush(); // Print::flush tx int parsePacket(); int available();