mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 00:55:52 +03:00
[GH-ISSUE #1459] WiFiManager::waitForConnectResult > while(millis() < timeoutmillis) #1249
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#1249
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Ramim256 on GitHub (Jul 24, 2022).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1459
I want to execute some line of code from my sketch when it's trying to connect, I mean when it is in the while loop printing the ".", at "WiFiManager.cpp > WiFiManager::waitForConnectResult > while(millis() < timeoutmillis)";
is there any possible way to do this ??
@tablatronix commented on GitHub (Jul 24, 2022):
I can add a callback here and see if it helps, you have to be careful though as wifi is very busy during this time and you can cause crashes, certainly no interrupts for eg.
another option I am considering
#1460
Another workaround is using your own esp event function and check for events that the esp lib emits when connecting.
If you have more info on your scenario, I can offer specific suggestions here
@Ramim256 commented on GitHub (Jul 28, 2022):
i want to access "ssid" variable from the main sketch, and execute some line of code from my sketch when it's trying to connect,

my code for 0.91 inch OLED display,
demo code:
void connectWiFi(void)
{
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
display.clearDisplay();
WiFi.begin(ssid, password);
int i = 10;
int j = 0;
if (WiFi.status() != WL_CONNECTED) {
while (currentMillis - previousMillis > reconnectInterval * 1000)
{
delay(500);
Serial.print(currentMillis - previousMillis);
Serial.print("\n");
if (i < 120) {
robojaxText("Connecting to ", 28, 0, 1, false);
robojaxText(ssid, 13, 14, 1, false);
robojaxText(".\n", i, 22, 1, false);
i = i + 5;
display.display();
if (WiFi.status() == WL_CONNECTED) {
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
String ipa = WiFi.localIP().toString();
display.clearDisplay();
robojaxText("Connected: ", 32, 0, 1, true);
robojaxText(ipa, 20, 12, 1, true);
delay(5000);
return;
}
}
else {
i = 10;
display.clearDisplay();
j = j + 1;
}
if (j > 1) {
display.clearDisplay();
reconnectInterval = 50;
robojaxText("Failed to Connect ", 12, 8, 1, false);
robojaxText("Retring in ", 6, 23, 1, false);
robojaxText(String(reconnectInterval), 72, 23, 1, false);
robojaxText("second", 92, 23, 1, false); //second
display.display();
delay(5000);
previousMillis = currentMillis;
j = 0;
}
}
}
}