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
Adapting my code from regular WifiClient to AsyncClient #36
Comments
Async is nothing like Sync :) You do not have available(), instead you have onData callback to handle incoming data as it comes.
|
Reading about TCP connection flow could help you immensely in understanding what each callback is and when it's used/called. You can not send as much data as you want, because you are sending packets and separating a large chunk is now your job to do. After you send a packet, you need to wait for onAck callback to signal that the other end got the packet. And there is surely more... Async is not easy in any way. |
@me-no-dev Hi, |
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions. |
Hello, everyone!
I'm working on a project that needs a non-blocking connect() function to use in a ESP8266 working as a wifi client.
Every program cycle, my ESP reads some analog data from a matrix of sensors. Whenever the matrix remains "calm" (with no changes on the sensors) for at least 2 seconds, the ESP will connect to the wifi server and send its accumulated data.
The problem is that the WifiClient.connect() function takes up to 5 seconds trying to reach the server. During the connection process, I can lose critical reading from my sensors matrix. I need this time to be shorter.
Following the advise of @me-no-dev, I am adapting my code to the ESPAsyncTCP library. However, the present examples in the Issues section do not explain the "use" of the "non-blocking feature" of AsyncClient and/or AsyncPrinter clearly (or so I think).
I am a newcomer to these type of projects and the lack of documentation in the ESP8266 github libraries doesn't help much either.
For example, what's the equivalent function for WifiClient.available() in the AsyncClient class? How do you poll the client's buffer?
Anyway, I am looking for some example or documentation that explains the differences between the "Sync" and the "Async" modes of WiFi communication from the client's point of view.
Any help will be appreciated. Thank you so much!
The text was updated successfully, but these errors were encountered: