Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9b32541

Browse filesBrowse files
WiFiClient - rename flush() to clear() (breaking) (espressif#9453)
Co-authored-by: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com>
1 parent cff2a18 commit 9b32541
Copy full SHA for 9b32541

File tree

6 files changed

+27
-9
lines changed
Filter options

6 files changed

+27
-9
lines changed

‎docs/en/migration_guides/2.x_to_3.0.rst

Copy file name to clipboardExpand all lines: docs/en/migration_guides/2.x_to_3.0.rst
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,11 @@ Functional changes
197197
* Any pin set as -1 in ``begin()`` or ``setPins()`` won't be changed nor detached.
198198
* ``begin(baud)`` will not change any pins that have been set before this call, through a previous ``begin(baud, rx, tx)`` or ``setPin()``.
199199
* If the application only uses RX or TX, ``begin(baud, -1, tx)`` or ``begin(baud, rx)`` will change only the assigned pin and keep the other unchanged.
200+
201+
WiFi
202+
----
203+
204+
Functional changes
205+
******************
206+
207+
* In Arduino (and other frameworks) the method named ``flush()`` is intended to send out the transmit buffer content. ``WiFiClient`` and ``WiFiUDP`` method ``flush()`` won't clear the receive buffer anymore. A new method called ``clear()`` is now used for that. Currently ``flush()`` does nothing in ``WiFiClient``, ``WiFiClientSecure`` and ``WiFiUDP``.

‎libraries/Network/src/NetworkClient.cpp

Copy file name to clipboardExpand all lines: libraries/Network/src/NetworkClient.cpp
+8-5Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class NetworkClientRxBuffer {
159159
return _fill - _pos + r_available();
160160
}
161161

162-
void flush(){
162+
void clear(){
163163
if(r_available()){
164164
fillBuffer();
165165
}
@@ -391,6 +391,11 @@ int NetworkClient::read()
391391
return data;
392392
}
393393

394+
void NetworkClient::flush()
395+
{
396+
397+
}
398+
394399
size_t NetworkClient::write(const uint8_t *buf, size_t size)
395400
{
396401
int res =0;
@@ -534,11 +539,9 @@ int NetworkClient::available()
534539
return res;
535540
}
536541

537-
// Though flushing means to send all pending data,
538-
// seems that in Arduino it also means to clear RX
539-
void NetworkClient::flush() {
542+
void NetworkClient::clear() {
540543
if (_rxBuffer != nullptr) {
541-
_rxBuffer->flush();
544+
_rxBuffer->clear();
542545
}
543546
}
544547

‎libraries/Network/src/NetworkClient.h

Copy file name to clipboardExpand all lines: libraries/Network/src/NetworkClient.h
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ class NetworkClient : public ESPLwIPClient
5959
size_t write(const uint8_t *buf, size_t size);
6060
size_t write_P(PGM_P buf, size_t size);
6161
size_t write(Stream &stream);
62+
void flush(); // Print::flush tx
6263
int available();
6364
int read();
6465
int read(uint8_t *buf, size_t size);
6566
int peek();
66-
void flush();
67+
void clear(); // clear rx
6768
void stop();
6869
uint8_t connected();
6970
void setSSE(bool sse);

‎libraries/Network/src/NetworkUdp.cpp

Copy file name to clipboardExpand all lines: libraries/Network/src/NetworkUdp.cpp
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,11 @@ size_t NetworkUDP::write(const uint8_t *buffer, size_t size){
288288
return i;
289289
}
290290

291+
void NetworkUDP::flush()
292+
{
293+
294+
}
295+
291296
int NetworkUDP::parsePacket(){
292297
if(rx_buffer)
293298
return 0;
@@ -374,7 +379,7 @@ int NetworkUDP::peek(){
374379
return rx_buffer->peek();
375380
}
376381

377-
void NetworkUDP::flush(){
382+
void NetworkUDP::clear(){
378383
if(!rx_buffer) return;
379384
cbuf *b = rx_buffer;
380385
rx_buffer = 0;

‎libraries/Network/src/NetworkUdp.h

Copy file name to clipboardExpand all lines: libraries/Network/src/NetworkUdp.h
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,14 @@ class NetworkUDP : public UDP {
6363
int endPacket();
6464
size_t write(uint8_t);
6565
size_t write(const uint8_t *buffer, size_t size);
66+
void flush(); // Print::flush tx
6667
int parsePacket();
6768
int available();
6869
int read();
6970
int read(unsigned char* buffer, size_t len);
7071
int read(char* buffer, size_t len);
7172
int peek();
72-
void flush();
73+
void clear(); // clear rx
7374
IPAddress remoteIP();
7475
uint16_t remotePort();
7576
};

‎libraries/WiFi/examples/WiFiIPv6/WiFiIPv6.ino

Copy file name to clipboardExpand all lines: libraries/WiFi/examples/WiFiIPv6/WiFiIPv6.ino
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void wifiConnectedLoop(){
5050
if(packetLength >= NTP_PACKET_SIZE){
5151
ntpClient.read(ntpPacketBuffer, NTP_PACKET_SIZE);
5252
}
53-
ntpClient.flush();
53+
ntpClient.clear();
5454
uint32_t secsSince1900 = (uint32_t)ntpPacketBuffer[40] << 24 | (uint32_t)ntpPacketBuffer[41] << 16 | (uint32_t)ntpPacketBuffer[42] << 8 | ntpPacketBuffer[43];
5555
//Serial.printf("Seconds since Jan 1 1900: %u\n", secsSince1900);
5656
uint32_t epoch = secsSince1900 - 2208988800UL;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.