Skip to content
Open
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
99b4293
allows WiFi to attempt reconnect more than once as defined, default 6…
sandeepkumar0153 Oct 5, 2025
4f1156c
Merge branch 'meshtastic:develop' into develop
sandeepkumar0153 Oct 5, 2025
b78e35d
Merge branch 'develop' into develop
sandeepkumar0153 Oct 6, 2025
e8dcc30
changes to pin config based on custom hardware.
sandeepkumar0153 Oct 5, 2025
8bb91b6
Merge branch 'meshtastic:develop' into develop
sandeepkumar0153 Oct 6, 2025
f6631fb
Merge branch 'meshtastic:develop' into develop
sandeepkumar0153 Oct 7, 2025
bfa17f5
Merge branch 'develop' into develop
thebentern Oct 7, 2025
6966392
Merge branch 'meshtastic:develop' into develop
sandeepkumar0153 Oct 7, 2025
55a7c95
Update src/mesh/wifi/WiFiAPClient.cpp
sandeepkumar0153 Oct 7, 2025
bdc28f9
Update src/mesh/wifi/WiFiAPClient.cpp
sandeepkumar0153 Oct 7, 2025
38d5e46
Update variant.h to default
sandeepkumar0153 Oct 7, 2025
c2224ad
Update variant.h to default
sandeepkumar0153 Oct 7, 2025
c6c5307
Update variant.h
sandeepkumar0153 Oct 7, 2025
4ff4358
Update WiFiAPClient.cpp
sandeepkumar0153 Oct 7, 2025
bcb8274
Merge branch 'develop' into develop
sandeepkumar0153 Oct 8, 2025
9e08b7b
Merge branch 'meshtastic:develop' into develop
sandeepkumar0153 Oct 12, 2025
90be0ae
Merge branch 'develop' into develop
thebentern Oct 12, 2025
0d32fc6
Merge branch 'develop' into develop
thebentern Oct 12, 2025
5e4ff85
Macros have been capitalised, Updated WiFiAPClient.cpp
sandeepkumar0153 Oct 12, 2025
3fd00a6
Merge branch 'meshtastic:develop' into develop
sandeepkumar0153 Oct 13, 2025
69bde4b
Merge branch 'meshtastic:develop' into develop
sandeepkumar0153 Oct 16, 2025
e073e09
Merge branch 'develop' into develop
sandeepkumar0153 Oct 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions src/mesh/wifi/WiFiAPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ char ourHost[16];
// To replace blocking wifi connect delay with a non-blocking sleep
static unsigned long wifiReconnectStartMillis = 0;
static bool wifiReconnectPending = false;
static unsigned char wifiConnectAttempts = 0;

#ifndef MAXWIFICONNECTIONATTEMPTS
#define MAXWIFICONNECTIONATTEMPTS 6
#endif

#ifndef WIFIRECONNECTGAP
#define WIFIRECONNECTGAP 10000
#endif

bool APStartupComplete = 0;

Expand Down Expand Up @@ -170,28 +179,44 @@ static int32_t reconnectWiFi()
#elif defined(ARCH_RP2040)
WiFi.disconnect(false);
#endif
LOG_INFO("Reconnecting to WiFi access point %s", wifiName);
LOG_INFO("Connecting to WiFi access point %s", wifiName);

// Start the non-blocking wait for 5 seconds
wifiReconnectStartMillis = millis();
wifiReconnectPending = true;
// Do not attempt to connect yet, wait for the next invocation
return 5000; // Schedule next check soon
return WIFIRECONNECTGAP; // Schedule next check soon
}

// Check if we are ready to proceed with the WiFi connection after the 5s wait
if (wifiReconnectPending) {
if (millis() - wifiReconnectStartMillis >= 5000) {
if (millis() - wifiReconnectStartMillis >= WIFIRECONNECTGAP) {
if (!WiFi.isConnected()) {
wifiConnectAttempts++;
LOG_INFO("Reconnecting to WiFi access point %s, attempt %d", wifiName, wifiConnectAttempts);
#ifdef CONFIG_IDF_TARGET_ESP32C3
WiFi.mode(WIFI_MODE_NULL);
WiFi.useStaticBuffers(true);
WiFi.mode(WIFI_STA);
#endif
WiFi.begin(wifiName, wifiPsw);
wifiReconnectStartMillis = millis();
if(wifiConnectAttempts < MAXWIFICONNECTIONATTEMPTS){
needReconnect = true;
}
else{
needReconnect = false;
wifiReconnectPending = false;
LOG_INFO("Maximum connection attempts reached %d", wifiConnectAttempts);
LOG_INFO("Unable to connect access point %s", wifiName);
}

}
else{
LOG_INFO("WiFi successfully connected to access point %s", wifiName);
LOG_INFO("Connection attempts %d", wifiConnectAttempts);
wifiReconnectPending = false;
}
isReconnecting = false;
wifiReconnectPending = false;
} else {
// Still waiting for 5s to elapse
return 100; // Check again soon
Expand Down Expand Up @@ -514,4 +539,4 @@ uint8_t getWifiDisconnectReason()
{
return wifiDisconnectReason;
}
#endif // HAS_WIFI
#endif // HAS_WIFI