Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiFiServer - 'rename' available() to accept() #8419

Merged
merged 5 commits into from Jan 3, 2022

Conversation

JAndrassy
Copy link
Contributor

If this PR gets positive reviews, I will add commits with examples and documentation changes.

The available() method in WiFiServer and WiFiServerSecureBearSSL is not implemented as the available() in the Arduino WiFi library and other WiFi libraries by Arduino. The implementation of available() matches the Ethernet library's accept() method added in 2018.

This PR marks available() in WiFiServer as deprecated and adds the accept() method with implementation identical to available().

My addition to the ESP8266WiFi library, the ArduinoWiFiServer class has available() implemented the Arduino way.

@JAndrassy JAndrassy force-pushed the WiFiServer_accept branch 4 times, most recently from 6f368c3 to 09d7e57 Compare December 21, 2021 06:53
@JAndrassy
Copy link
Contributor Author

the checks treat (deprecated) warning as errors so I had to replace available() to accept() in libraries and examples.

now only the mock test fails with /home/runner/work/Arduino/Arduino/tests/host/../../libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h:284: undefined reference toWiFiServer::accept()'`, but I don't know how to fix that

@d-a-v
Copy link
Collaborator

d-a-v commented Dec 21, 2021

but I don't know how to fix that

diff --git a/tests/host/common/MockWiFiServer.cpp b/tests/host/common/MockWiFiServer.cpp
index 132ca5e8..7b449845 100644
--- a/tests/host/common/MockWiFiServer.cpp
+++ b/tests/host/common/MockWiFiServer.cpp
@@ -55,9 +55,8 @@ WiFiServer::WiFiServer (uint16_t port)
        _port = port;
 }
 
-WiFiClient WiFiServer::available (uint8_t* status)
+WiFiClient WiFiServer::accept ()
 {
-   (void)status;
        if (hasClient())
                return WiFiClient(new ClientContext(serverAccept(pcb2int(_listen_pcb))));
        return WiFiClient();

@JAndrassy JAndrassy force-pushed the WiFiServer_accept branch 2 times, most recently from 02858cf to 83e1cd8 Compare December 21, 2021 17:41
@JAndrassy JAndrassy marked this pull request as ready for review December 21, 2021 18:04
Copy link
Collaborator

@d-a-v d-a-v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, it is not a breaking change but a deprecation.
Per Ethernet.accept() it seems that our implementation for server::available() does not comply with Arduino. It was the ::accept() implementation.

doc/esp8266wifi/server-class.rst Outdated Show resolved Hide resolved
doc/esp8266wifi/server-class.rst Outdated Show resolved Hide resolved
@JAndrassy JAndrassy force-pushed the WiFiServer_accept branch 2 times, most recently from 29cabf0 to ee7aa0e Compare December 26, 2021 08:09
@d-a-v d-a-v merged commit f401f08 into esp8266:master Jan 3, 2022
naudhr pushed a commit to naudhr/RemoteDebug that referenced this pull request Apr 25, 2023
esp8266/Arduino#8419 deprecated WiFiServer::available
in favor to WiFiServer::accept.
naudhr pushed a commit to naudhr/RemoteDebug that referenced this pull request Apr 25, 2023
esp8266/Arduino#8419 deprecated WiFiServer::available
in favor to WiFiServer::accept.
@JAndrassy JAndrassy deleted the WiFiServer_accept branch November 24, 2023 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants