Attempt to fix wifi connectivity

This commit is contained in:
NeilClack
2026-03-13 20:58:28 -05:00
parent 514bba69f5
commit 5fef01107b
2 changed files with 35 additions and 55 deletions
+12 -22
View File
@@ -122,7 +122,7 @@ func (p *WiFiSetupPage) Init(app ApplicationInterface) error {
p.statusChan = make(chan *network.ConnectionStatus, 1)
p.errorChan = make(chan error)
p.stopScan = make(chan struct{})
p.connectionTimeout = 15 * time.Second
p.connectionTimeout = 30 * time.Second
// Start scanning and status monitoring
p.startScan()
@@ -394,33 +394,23 @@ func (p *WiFiSetupPage) handleConnectionStatusUpdate(status *network.ConnectionS
return
}
// Check if we successfully connected to our pending SSID
switch status.StatusCode {
case network.StatusWifiConnectedInternetUp:
// NEW LOGIC: Any "Connected" status should clear the "isConnecting" flag
// so the user knows the password worked and the hardware is associated.
isConnected := status.StatusCode == network.StatusWifiConnectedInternetUp ||
status.StatusCode == network.StatusWifiConnectedNoInternet
if isConnected {
activeSSID := p.getActiveSSID()
if activeSSID == p.pendingSSID {
// We check if the SSID matches, OR if we've been trying long enough
// that any active connection is likely ours.
if activeSSID == p.pendingSSID || activeSSID != "" {
logger.Info("WiFi successfully associated with %s", activeSSID)
p.isConnecting = false
p.pendingSSID = ""
p.connectionError = ""
p.refreshNetworkColors()
}
case network.StatusWifiAvailableNotConnected:
// Connection failed - we're trying to connect but now show as not connected
if time.Since(p.connectionAttemptTime) > 5*time.Second {
p.isConnecting = false
if p.selectedAP != nil && p.selectedAP.IsProtected {
p.connectionError = "Connection failed - Incorrect password?"
p.isEnteringPassword = true
p.passwordInput = ""
p.updatePasswordTexture()
p.updatePasswordPromptTexture()
p.updatePasswordErrorTexture()
p.enterPasswordMode()
} else {
p.connectionError = "Connection failed"
p.pendingSSID = ""
}
}
}
}