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

Enable lwip non-blocking mode in ard_socket.c #112

Merged
merged 5 commits into from
Aug 29, 2022
Merged

Conversation

S10143806H
Copy link
Contributor

Add lwip_fcntl(_sock, F_SETFL, O_NONBLOCK); in start_server() and start_server_v6() to enable lwip non-blocking mode.


Remarks

**Thanks for Ameba Arduino user @jojoling's help with raising this bug and providing the solution.

How to reproduce this bug?

Add in any code after WiFiWebServer.ino line 89: (For example: Serial.println("abc");)**
https://github.com/ambiot/ambd_arduino/blob/2e8a9df1f8a297cc643e858b42204908e391addf/Arduino_package/hardware/libraries/WiFi/examples/WiFiWebServer/WiFiWebServer.ino#L89

After the example is uploaded to the board and running, while no client is connecting to the Ameba board, the added line will never be able to be printed in the serial monitor.

Provided solution

This is due to lwip's default running in "blocking" mode. Adding lwip_fcntl(_sock, F_SETFL, O_NONBLOCK); in start_server() and start_server_v6() to enable lwip non-blocking mode.

Add `lwip_fcntl(_sock, F_SETFL, O_NONBLOCK);` in `start_server()` and `start_server_v6()` to enable lwip non-blocking mode.
+ support cpp standard library `#include <string>` in line 37
Note:
Tested and verified on AmebaD
update `int WiFiClient::available()` function, added try again condition
@ambiot ambiot merged commit 2ef427c into Ameba-AIoT:dev Aug 29, 2022
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.

2 participants