add extra case to waitForConnection

This commit is contained in:
NeilClack
2026-06-27 17:04:34 -05:00
parent b0947bd594
commit 8567cd5bdb
+9 -8
View File
@@ -524,22 +524,23 @@ func waitForConnection(dev gonm.DeviceWireless, ssid string, timeout time.Durati
continue
}
// NmDeviceStateActivated = 100, fully connected with IP
if state == gonm.NmDeviceStateActivated {
// Confirm it's actually the SSID we wanted
logger.Debug("network: device state %d, waiting...", state)
switch state {
case gonm.NmDeviceStateActivated:
current, err := CurrentNetwork()
if err == nil && current == ssid {
logger.Info("network: fully connected to %q", ssid)
logger.Info("network: fully connected to %q (DHCP complete)", ssid)
return nil
}
}
// NmDeviceStateFailed = 120, NmDeviceStateDisconnected = 30
if state == gonm.NmDeviceStateFailed {
case gonm.NmDeviceStateFailed:
return fmt.Errorf("network: connection to %q failed (wrong password?)", ssid)
case gonm.NmDeviceStateDisconnected:
return fmt.Errorf("network: connection to %q was rejected by the network", ssid)
}
logger.Debug("network: device state %d, waiting...", state)
time.Sleep(500 * time.Millisecond)
}
return fmt.Errorf("network: timed out waiting for connection to %q", ssid)