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

Add timeout for localIP #433

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

pennam
Copy link
Contributor

@pennam pennam commented Feb 10, 2025

Adds timeout for localIP() instead of waiting a fixed amount of time. Other proposed solution #408

Fixes #406

@pennam pennam requested review from maidnl and facchinm February 10, 2025 16:17
@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Feb 10, 2025
@JAndrassy
Copy link
Contributor

JAndrassy commented Feb 11, 2025

WiFi.begin is blocking until DHCP gets an IP address. there is no reason to have a timeout in localIP(). it will only return immediately if WiFi.begin was successful or wait the complete timeout if WiFi.begin didn't run or didn't connect.
there is nothing to wait for.

@pennam
Copy link
Contributor Author

pennam commented Feb 11, 2025

@JAndrassy I get your point. I do not understand why in the original code localIP() was doing the retry loop so I opted for a less impacting change. Probably @maidnl has some hints about the original reason of the retries.

@maidnl
Copy link
Contributor

maidnl commented Feb 11, 2025

@pennam if I remember correctly the problem was related to the use of begin() and, immediately after, localIP(). In this case the ESP32 took some (little) time to set up the address and give it back so that the first call could fail and give the impression of a failed connection or wrong DHCP set up. For this reason I added this "retry" mechanism. I think is safe to keep some sort of retry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Non-blocking version of WiFi::localIP()
4 participants