diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2018-11-21 11:22:08 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2018-11-29 17:50:00 +0100 |
commit | 3a999475efa40fcba3ffc7bd918236d89417598a (patch) | |
tree | 2c5ddf022edb33c9c14fbdf66f7918930198e141 | |
parent | 64b95d567ba89cb904a1795a16f9910552382b87 (diff) |
wifi/olpc-mesh: allow autoconnect
There's no reason the mesh shouldn't autoconnect. Almost.
The mesh and regular Wi-Fi shares the same radio. There, in the first
place, probably shouldn't have been separate NMDevices. Not sure whether
we can fix it at this point, but we can surely avoid unnecessary
competition between the two devices: give the regular Wi-Fi priority and
only connect mesh if the regular companion stays disconnected.
For the record; connections shipped on XO-1 laptops all have
autoconnect=off and thus are not affected by this.
-rw-r--r-- | src/devices/wifi/nm-device-olpc-mesh.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c index 0b2161627..f7efcc7a4 100644 --- a/src/devices/wifi/nm-device-olpc-mesh.c +++ b/src/devices/wifi/nm-device-olpc-mesh.c @@ -82,7 +82,19 @@ G_DEFINE_TYPE (NMDeviceOlpcMesh, nm_device_olpc_mesh, NM_TYPE_DEVICE) static gboolean get_autoconnect_allowed (NMDevice *device) { - return FALSE; + NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device); + NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self); + + /* We shall always have a companion if we're >= DISCONENCTED, and this + * ought not be called until then. */ + g_return_val_if_fail (priv->companion, FALSE); + + /* We must not attempt to autoconnect when the companion is connected or + * connecting, * because we'd tear down its connection. */ + if (nm_device_get_state (priv->companion) > NM_DEVICE_STATE_DISCONNECTED) + return FALSE; + + return TRUE; } #define DEFAULT_SSID "olpc-mesh" @@ -262,6 +274,11 @@ companion_state_changed_cb (NMDeviceWifi *companion, NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (user_data); NMDeviceState self_state = nm_device_get_state (NM_DEVICE (self)); + if ( old_state > NM_DEVICE_STATE_DISCONNECTED + && state <= NM_DEVICE_STATE_DISCONNECTED) { + nm_device_emit_recheck_auto_activate (NM_DEVICE (self)); + } + if ( self_state < NM_DEVICE_STATE_PREPARE || self_state > NM_DEVICE_STATE_ACTIVATED || state < NM_DEVICE_STATE_PREPARE |