-->
Page 1 of 1

WifiClient Async ?

PostPosted: Tue Apr 12, 2016 11:31 pm
by Robinson Mesino
Hello, I'm using this library -->https://github.com/esp8266/Arduino and i'm trying to implement an small personal project using an esp8266 -- ESP-12 module, the project consists in activate/deactivate relay using a button, and notify to an MQTT Server the status (activate/deactivate) on every button press, so, my question is if exists some form to use WifiClient in async mode, because some times the connect method blocks the button (activate/deactivate relay) logic, for example, some publish to MQTT server blocks a little the button logic like a lag, or for example if the MQTT server IP is down, then the button logic is blocked for long times because the connect method of WifiClient class is trying to connect.

I found this issue --> https://github.com/esp8266/Arduino/pull/709 that refers to the async issue, but i can't found this implementation in the last release code of the library...

Am doing something wrong ? or can i implement this project differently ?

Thanks,

Re: WifiClient Async ?

PostPosted: Fri Apr 15, 2016 3:50 pm
by Robinson Mesino
I solved this issue passing the button logic to an interrupt function and refactoring some code, all works great !! Thanks !! :D

Re: WifiClient Async ?

PostPosted: Sat Apr 16, 2016 1:52 am
by Marvin Roger
Glad you got it working, however there is, as you requested, an async TCP client available : https://github.com/me-no-dev/ESPAsyncTCP ;)

However, the current MQTT libs won't work correctly and would need to be refactored.

Re: WifiClient Async ?

PostPosted: Wed Nov 17, 2021 3:25 pm
by noliver
Would you mind sharing your code? I am facing the exact same problem. If you don't want to share your code, it would be helpful if you could tell me how you refactored your code. Especially what you put inside the interrupt. I read that you should only do some light work inside an interrupt, like setting a variable or something.