support server.accept() for WiFiNINA library #79
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A PR in WiFiNINA library follows.
There are almost no comments in the fw source code so I didn't add any too. But it is not too complicated. The only catch is that
CommandHandlerClass::updateGpio0Pin
periodically calls server.available() which accepts clients for _spawnedSockets (available() and write-to-all clients management). A new function server.hasClient (inspired by the ESP32 core WiFi library's WiFiServer) is used to outrun available() in accepting a new client from updateGpio0Pin. If after IRQ pin is activated, the sketch calls accept(), the pre-accepted client is returned and not used for _spawnedSockets. If available() is called from sketch, then the pre-accepted socket is added to _spawnedSockets.btw: WiFiServer::available() should be rewritten to only get new clients if there is a slot in _spawnedSockets.