Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add Non-blocking Version of localIP Function for WiFiS3 library and fix FifoBuffer.h #408

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

Closed
MYusufY wants to merge 3 commits into arduino:main from MYusufY:main

Conversation

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");
}

Copy link

CLAassistant commented Nov 30, 2024
edited
Loading

CLA assistant check
All committers have signed the CLA.

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
Copy link
Contributor

@andreagilardoni andreagilardoni Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any good reasons to make changes to this file? If not I would recommend you to drop them and open a new PR with these changes instead.

Copy link
Contributor

@andreagilardoni andreagilardoni Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to override the functionality of localIP() instead of writing a new one. I think you had a good Idea to specify in the function signature the timeout, so I would keep it, but with the addition of making it default to _timeout value. Could you also modify the comment above accordingly?

Copy link
Contributor

@andreagilardoni andreagilardoni Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As described in WiFi.h file I would integrate these changes in localIP() function.

Copy link
Contributor

@andreagilardoni andreagilardoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MYusufY, thanks for your contribution! Your work is very much appreciated! I am suggesting you some changes in order for your PR to properly address some issues we are facing.

Copy link
Contributor

I would also change the PR name, since we are changing the behavior from an attempt based approach to a timeout based one. The function is still blocking, but now the user may set the timeout to 0 to make it non blocking and deal with the logic of retrial on his own.

Copy link
Author

MYusufY commented Feb 12, 2025
edited
Loading

Thanks for your interest! I will try to make these changes and create a new PR soon. Also, i think i accidentaly edited that file :) (the one i put a space below)

Copy link
Contributor

Don't worry, I can guide you through this and fix this PR, you don't need to open a new one for this feature.

The usual method to contribute on github is to create a branch on your personal fork of the repo you are contributing to. That way you can always go back to the public repo status with git checkout. Please tell me if you need any help on that.

Copy link
Contributor

pennam commented Feb 26, 2025

Superseded by #450

@per1234 per1234 added the conclusion: duplicate Has already been submitted label Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@andreagilardoni andreagilardoni andreagilardoni requested changes

Assignees
No one assigned
Labels
conclusion: duplicate Has already been submitted topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Non-blocking version of WiFi::localIP()

AltStyle によって変換されたページ (->オリジナル) /