This repository was archived by the owner on Mar 17, 2025. It is now read-only.
This repository was archived by the owner on Mar 17, 2025. It is now read-only.
investigate non blocking connect #29
Open
Description
apparently lwip support it: https://github.com/goertzenator/lwip/blob/master/contrib-1.4.0/apps/socket_examples/socket_examples.c#L25
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
proppy commentedon Dec 29, 2015
esp8266 core uses lwip raw API which is supposed to be already non blocking.
https://github.com/esp8266/Arduino/blob/342c4ae6fb847bfc787f80b89a2bb888d942dc32/libraries/ESP8266WiFi/src/WiFiClient.cpp#L126
esp_yield
yields control back to the OS until theconnected
callback is called:https://github.com/esp8266/Arduino/blob/342c4ae6fb847bfc787f80b89a2bb888d942dc32/libraries/ESP8266WiFi/src/WiFiClient.cpp#L137
The callback will resume the sketch by calling
esp_schedule
:https://github.com/esp8266/Arduino/blob/2b941f5e2c70267b65ed6cb8fc40c73e65ef26d5/cores/esp8266/core_esp8266_main.cpp#L76
esp_schedule
will invoke the loop task:https://github.com/esp8266/Arduino/blob/2b941f5e2c70267b65ed6cb8fc40c73e65ef26d5/cores/esp8266/core_esp8266_main.cpp#L75
Which will resume the loop_wrapper continuation in the
connect()
function:https://github.com/esp8266/Arduino/blob/2b941f5e2c70267b65ed6cb8fc40c73e65ef26d5/cores/esp8266/core_esp8266_main.cpp#L110
@Links2004 explained it better here :)
https://gitter.im/esp8266/Arduino?at=568310093acb611716002cfd
proppy commentedon Dec 29, 2015
A non blocking implementation would add a new
connect_async
function or a flag with a different callback and no yield/schedule call.And the http connect version could return early rather than erroring:
https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp#L670-L673
Links2004 commentedon Dec 30, 2015
the HTTP client changes are more complex then just return.
connect
is never called form outside the class:https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h#L192
its only called in
sendRequest
https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp#L298
the connect shut be fast if the server is there,
only when there is no server it can block for a longer time until:
https://github.com/esp8266/Arduino/blob/342c4ae6fb847bfc787f80b89a2bb888d942dc32/libraries/ESP8266WiFi/src/WiFiClient.cpp#L149
is called.
proppy commentedon Dec 30, 2015
@Links2004 yes, I was planning to investigate exposing connect with #28
proppy commentedon Jun 25, 2016
also see https://github.com/me-no-dev/ESPAsyncTCP/blob/master/src/ESPAsyncTCP.cpp
proppy commentedon Jun 25, 2018
Note that this would be affected by #353.
yhua537 commentedon Aug 16, 2018
Like the idea using ESPAsyncTCP(as I am using it for other connections), can I suggest use injection to allow us choosing which type of connection to use?
Also, should the scope of this library to a easier use of firebase API?
kiralikbeyin commentedon Mar 11, 2019
#420 (comment)