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

The error code is not compiled: 'class WiFiServer' does not have a member named 'accept' #865

Open
GGI1 opened this issue Jan 13, 2024 · 4 comments

Comments

@GGI1
Copy link

GGI1 commented Jan 13, 2024

Arduino: 1.8.19 (Windows 10), Плата:"LOLIN(WEMOS) D1 R2 & mini, 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, None, Only Sketch, 921600"

C:\Users\USER\Documents\Arduino\libraries\arduinoWebSockets-master\src\WebSocketsServer.cpp: In member function 'void WebSocketsServer::handleNewClients()':

C:\Users\USER\Documents\Arduino\libraries\arduinoWebSockets-master\src\WebSocketsServer.cpp:658:86: error: 'class WiFiServer' has no member named 'accept'

WEBSOCKETS_NETWORK_CLASS * tcpClient = new WEBSOCKETS_NETWORK_CLASS(_server->accept());

exit status 1

Compilation error for the board LOLIN(WEMOS) D1 R2 & mini.

I do not know how to fix it. Please help me :-(

@artemes548
Copy link

Аналогичная ошибка.

@lucky62
Copy link

lucky62 commented Feb 4, 2024

I replaced accept() with available():

        // WEBSOCKETS_NETWORK_CLASS * tcpClient = new WEBSOCKETS_NETWORK_CLASS(_server->accept());
        WEBSOCKETS_NETWORK_CLASS * tcpClient = new WEBSOCKETS_NETWORK_CLASS(_server->available());

Compilation is ok and initial work also. I can connect to the http://192.168.4.1 and put the WiFi SSID/Password.
But after restart the web server is always returning: "Not Found:"

Edit:
ok, firmware update page is available (login required):
image

going to try Serial communication.

@MarkEhr
Copy link

MarkEhr commented Mar 9, 2024

I have this same problem. Since it was working before I think it is a problem with a new version. I will look further into it later. For now I was able to fix it pointing my dependency directly to the version 2.4.0
Using PlatformIO you need to change you platformio.ini file like this:

...
lib_deps=
    https://github.com/Links2004/arduinoWebSockets#2.4.0

@woodlist
Copy link

woodlist commented Apr 5, 2024

I replaced accept() with available():

        // WEBSOCKETS_NETWORK_CLASS * tcpClient = new WEBSOCKETS_NETWORK_CLASS(_server->accept());
        WEBSOCKETS_NETWORK_CLASS * tcpClient = new WEBSOCKETS_NETWORK_CLASS(_server->available());

Compilation is ok and initial work also. I can connect to the http://192.168.4.1 and put the WiFi SSID/Password. But after restart the web server is always returning: "Not Found:"

Edit: ok, firmware update page is available (login required): image

going to try Serial communication.

In my case this was happened in vise versa:
c:\Users\woodl\Documents\Arduino\libraries\WebSockets\src\WebSocketsServer.cpp: In member function 'void WebSocketsServer::handleNewClients()': c:\Users\woodl\Documents\Arduino\libraries\WebSockets\src\WebSocketsServer.cpp:649:95: warning: 'WiFiClient WiFiServer::available(uint8_t*)' is deprecated: Use accept(). [-Wdeprecated-declarations] 649 | WEBSOCKETS_NETWORK_CLASS * tcpClient = new WEBSOCKETS_NETWORK_CLASS(_server->available()); | ~~~~~~~~~~~~~~~~~~^~ In file included from C:\Users\woodl\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\3.7.2\libraries\WiFi\src/WiFi.h:8, from c:\Users\woodl\Documents\Arduino\libraries\WebSockets\src\WebSockets.h:220, from c:\Users\woodl\Documents\Arduino\libraries\WebSockets\src\WebSocketsServer.cpp:25: C:\Users\woodl\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\3.7.2\libraries\WiFi\src/WiFiServer.h:81:16: note: declared here 81 | WiFiClient available(uint8_t* status = nullptr) __attribute__((deprecated("Use accept()."))); | ^~~~~~~~~

The library has not trouble on ESP32, but gave an introduced warning on Raspberry Pico W. The Arduino IDE version is 2.3.2

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

No branches or pull requests

5 participants