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 Non-blocking Version of localIP Function for WiFiS3 library and fix FifoBuffer.h #408

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

Conversation

MYusufY
Copy link

@MYusufY MYusufY commented Nov 30, 2024

This PR introduces a non-blocking version of the localIP function, named localIPNonBlocking, to the WiFi.cpp file. The new function addresses situations where the current localIP implementation, which uses a blocking delay(100) call, can cause issues such as triggering a watchdog timer (WDT).

This PR also solves:

New Function: localIPNonBlocking

Added to libraries/WiFiS3/src/WiFi.cpp at line 357 (after the existing localIP implementation).
Utilizes a timeout mechanism with millis() to avoid blocking delays.
Returns the device's local IP address or a default address (0.0.0.0) if the timeout expires.

Example Usage:

unsigned long timeout = 5000; // 5-second timeout
IPAddress ip = WiFi.localIPNonBlocking(timeout);

if (ip) {
    Serial.println(ip); // Print the IP if successfully retrieved
} else {
    Serial.println("Failed to get IP within the timeout period");
}

@CLAassistant
Copy link

CLAassistant commented Nov 30, 2024

CLA assistant check
All committers have signed the CLA.

@JAndrassy
Copy link
Contributor

the localIP() function just gets the IP from the esp32 over UART. it should be quick

this platform has more networking libraries so please add to the title that this is about WiFiS3 library

@MYusufY MYusufY changed the title Add Non-blocking Version of localIP Function Add Non-blocking Version of localIP Function for WiFiS3 library Nov 30, 2024
@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Nov 30, 2024
@per1234 per1234 linked an issue Nov 30, 2024 that may be closed by this pull request
@MYusufY MYusufY changed the title Add Non-blocking Version of localIP Function for WiFiS3 library Add Non-blocking Version of localIP Function for WiFiS3 library and fix FifoBuffer.h Dec 1, 2024
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