- Sun Sep 17, 2017 4:32 pm
#70059
andre_teprom wrote:tele_player wrote:I don't know the answer, but it would only take a minute to write code to test the time spent in WiFi.status() .
I appreciate your kind help, but the suggested method based on pure experimentation instead of using a resource aware of its implications does not answer the raised question. I am not willing to deal with a situation that could work properly on an equipment (still at the limit of operability) and later the system does not work, and have to guess that I could have been overlooked this aspect; but again thanks for taking part in this debate.
Maybe I misunderstood your questions, and I didn't notice a debate.
Your question asked about the overhead of checking WiFi status in the main loop, this is easily determined experimentally. WiFi.status() takes about 1.5 seconds for 1000000 calls, when WiFi is connected. 1.5 microseconds is low enough to call it in Loop() without noticing the cost, unless your other code is operating at the limits of CPU capacity.
You have the source code for the libraries involved, if you care to look deeper into what is involved. At the lowest level, it might be in Espressif code for which source isn't published.
For the question in the subject, " How often is needed to check Wi-fi status ?", there really is no simple answer. Maybe your AP crashes a lot, or drops connections intermittently. Defensive programming would check the status before every attempt to use WiFi, and check the return codes of all WiFi calls. It's up to you to determine what is appropriate for your application.