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

Fix issue due to repeated status()/connected() call #73

Merged
merged 2 commits into from
Jul 29, 2021

Conversation

giulcioffi
Copy link
Contributor

When a sketch repeatedly calls client.status() and client.connected() functions, the connection occasionally gets stuck.
This issue had already been address by PR #50 ,which was then reverted thinking that its functionality was already covered by further code modifications.
Unfortunately it still seems to be needed.
A further modification has been introduce to let the driver correctly detect a client disconnection. In order to avoid lockups, we need to call available() function. This function, calling lwip_ioctl_r(), returns the number of bytes of pending data already received in the socket’s network. At most the result is 0. However, available() is never able to detect a network disconnection.
peek() , on the other hand, is the function to call to receive data with lwip_recv_r(). This function can actually return an error if the connection went down.
The procedure adopted here is to check if there are already available data and, if not, try to read from the network. In this way we avoid lockups by always checking if there are already available data before trying to receive new ones and we are also able to detect a disconnection.

@giulcioffi giulcioffi requested a review from aentinger July 29, 2021 08:45
@aentinger
Copy link
Contributor

Firmware for NINA-W102 for Arduino Nano RP2040 Connect:
NINA_W102-PR-73-Nano-RP2040-Connect.zip

@aentinger
Copy link
Contributor

OTA works for Nano RP2040 Connect.

@aentinger aentinger merged commit 77ac756 into arduino:master Jul 29, 2021
@pennam
Copy link
Contributor

pennam commented Aug 2, 2021

OTA works also on MKR WIFI 1010

@aentinger
Copy link
Contributor

OTA works also on MKR WIFI 1010

Thank you 👍 🤗

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.

3 participants