Skip to contentSkip to conversation

iwctl force autoconnect

DISCUSSION Yuri D'Elia 3 participants 8 messages Mar 26, 2021 – Mar 29, 2021

lore
Share & tools
lore
#0 lore raw

Is it possible to force iwd to connect to a known network without explicitly giving a network name? That is, to force attempting to autoconnect?

Currently "station <net> connect" requires a ssid. It would be nice if that would be made optional, causing iwd to go through the automatic connect logic.

I assumed that issuing a "station <net> scan" *would* attempt to autoconnect if a known network is seen and we're currently disconnected, but it's not always the case. If we disconnected from a known network due to AP disappearing and reappearing sometime later, "scan" will the network, but connection is still performed after some longer timeout.

I want to bind an action to force a scan+connect without having to wait, and without having to hardcode a network name. When I'm moving a laptop between offices and go through some blind spots (elevator) I end-up in a situation where I'm disconnected, and I want to force a connection right away.

#1 lore raw

Hi Yuri,

Quoted 8 lines · Yuri D'Elia

Is it possible to force iwd to connect to a known network without explicitly giving a network name? That is, to force attempting to autoconnect?

Currently "station <net> connect" requires a ssid. It would be nice if that would be made optional, causing iwd to go through the automatic connect logic.

Quoted 5 lines

I assumed that issuing a "station <net> scan" *would* attempt to autoconnect if a known network is seen and we're currently disconnected, but it's not always the case. If we disconnected from a known network due to AP disappearing and reappearing sometime later, "scan" will the network, but connection is still performed after some longer timeout.

So in theory this should always be happening. Once iwd is in 'autoconnect' state (starting state, or when we lose a connection) then any scan results triggered (either internal scanning logic or scans triggered via dbus/iwctl) should then be considered for autoconnect purposes. You say that 'it's not always the case'. So this works for you sometimes and not other times? Can you capture some logs for us? Also, are you running any other network managers on top of iwd or just iwd standalone?

Quoted 6 lines

I want to bind an action to force a scan+connect without having to wait, and without having to hardcode a network name. When I'm moving a laptop between offices and go through some blind spots (elevator) I end-up in a situation where I'm disconnected, and I want to force a connection right away.

We set some very conservative scan timeouts, perhaps you can play with more aggressive settings to see if iwd's autoconnect logic will work in your case? See 'man 5 iwd.config', InitialPeriodicScanInterval and MaximumPeriodicScanInterval.

I think our default for MaximumPeriodicScanInterval is way too high actually.

Regards,
-Denis

#2 lore raw

Il 29/03/2021 18:12, Denis Kenzior ha scritto:

Quoted 17 lines

Hi Yuri,

Quoted 8 lines · Yuri D'Elia

Is it possible to force iwd to connect to a known network without explicitly giving a network name? That is, to force attempting to autoconnect?

Currently "station <net> connect" requires a ssid. It would be nice if that would be made optional, causing iwd to go through the automatic connect logic.

Quoted 5 lines

I assumed that issuing a "station <net> scan" *would* attempt to autoconnect if a known network is seen and we're currently disconnected, but it's not always the case. If we disconnected from a known network due to AP disappearing and reappearing sometime later, "scan" will the network, but connection is still performed after some longer timeout.

Quoted 8 lines

So in theory this should always be happening.  Once iwd is in 'autoconnect' state (starting state, or when we lose a connection) then any scan results triggered (either internal scanning logic or scans triggered via dbus/iwctl) should then be considered for autoconnect purposes.  You say that 'it's not always the case'. So this works for you sometimes and not other times?  Can you capture some logs for us?  Also, are you running any other network managers on top of iwd or just iwd standalone?

I am guessing he needs to re-enter 'autoconnect' state after an explicit disconnect.

Use case for this would be to disconnect from the currently connected net and try to connect to some other, if available.

What would be command sequence for this?

Quoted 13 lines
Quoted 7 lines

I want to bind an action to force a scan+connect without having to wait, and without having to hardcode a network name. When I'm moving a laptop between offices and go through some blind spots (elevator) I end-up in a situation where I'm disconnected, and I want to force a connection right away.

We set some very conservative scan timeouts, perhaps you can play with more aggressive settings to see if iwd's autoconnect logic will work in your case? See 'man 5 iwd.config', InitialPeriodicScanInterval and MaximumPeriodicScanInterval.

Quoted 9 lines

I think our default for MaximumPeriodicScanInterval is way too high actually.

Regards,
-Denis
_______________________________________________
iwd mailing list -- iwd(a)lists.01.org
To unsubscribe send an email to iwd-leave(a)lists.01.org

Regards

Mauro

#3 lore raw
Quoted 6 lines

Il 29/03/2021 18:12, Denis Kenzior ha scritto:

Quoted 5 lines

So in theory this should always be happening.  Once iwd is in 'autoconnect' state (starting state, or when we lose a connection) then any scan results triggered (either internal scanning logic or scans triggered via dbus/iwctl) should then be considered for autoconnect purposes.  You say that 'it's not always the case'.

Indeed. AP disappears. Some time passes. I issue a 'station <net> scan'. In some cases, iwd immediately connects to a known network. In some other cases, I can see it with 'station <net> get-networks', but nothing happens. Issuing a manual 'connect' will bring the network up immediately.

Quoted 2 lines
Quoted 2 lines

Also, are you running any other network managers on top of iwd or just iwd standalone?

I'm using iwd standalone.

Quoted 2 lines · Mauro Condarelli

I am guessing he needs to re-enter 'autoconnect' state after an explicit disconnect.

I didn't explicitly disconnect in this case, but this makes me wonder if iwd can exit the 'autoconnect' state by itself for some other reason.

Quoted 4 lines

Use case for this would be to disconnect from the currently connected net and try to connect to some other, if available.

What would be command sequence for this?

Would be curious about that too.

#4 lore raw
In reply to Mauro Condarelli

Hi Mauro,

Quoted 9 lines · Mauro Condarelli
Quoted 8 lines

So in theory this should always be happening.  Once iwd is in 'autoconnect' state (starting state, or when we lose a connection) then any scan results triggered (either internal scanning logic or scans triggered via dbus/iwctl) should then be considered for autoconnect purposes.  You say that 'it's not always the case'. So this works for you sometimes and not other times?  Can you capture some logs for us?  Also, are you running any other network managers on top of iwd or just iwd standalone?

Quoted 3 lines

I am guessing he needs to re-enter 'autoconnect' state after an explicit disconnect.

'explicit disconnect' as in 'station wlan0 disconnect'? That should really never be necessary, and in fact it has the side-effect of disabling autoconnect.
We probably should have never enabled this command in iwctl.

Quoted 4 lines

Use case for this would be to disconnect from the currently connected net and try to connect to some other, if available.

What would be command sequence for this?

So while connected, it should just be 'station wlan0 connect <some other network>'. iwd will gracefully switch networks (disconnect from old + connect to new) for you.

Regards,
-Denis

#5 lore raw
Quoted 16 lines · Denis Kenzior

Hi Mauro,

Quoted 9 lines · Mauro Condarelli
Quoted 8 lines

So in theory this should always be happening.  Once iwd is in 'autoconnect' state (starting state, or when we lose a connection) then any scan results triggered (either internal scanning logic or scans triggered via dbus/iwctl) should then be considered for autoconnect purposes.  You say that 'it's not always the case'. So this works for you sometimes and not other times?  Can you capture some logs for us?  Also, are you running any other network managers on top of iwd or just iwd standalone?

Quoted 3 lines

I am guessing he needs to re-enter 'autoconnect' state after an explicit disconnect.

Quoted 8 lines

'explicit disconnect' as in 'station wlan0 disconnect'?  That should really never be necessary, and in fact it has the side-effect of disabling autoconnect.  We probably should have never enabled this command in iwctl.

Quoted 4 lines

Use case for this would be to disconnect from the currently connected net and try to connect to some other, if available.

What would be command sequence for this?

So while connected, it should just be 'station wlan0 connect <some other network>'.  iwd will gracefully switch networks  (disconnect from old + connect to new) for you.

That is not exactly what I asked.
This is for use case "I want to connect to a specific network".

I asked for the "negated": "please connect to *any* net  *but* the current one".

There are also cases where you want to temporarily disconnect and later reconnect to the same or other net, without necessarily having preferences.

This would be particularly useful for "unattended servers" where there's nobody to actually chose.

I think a "enter autoconnect state" command could be useful, at the very least for testing/fallback.

Quoted 7 lines

Regards,
-Denis
_______________________________________________
iwd mailing list -- iwd(a)lists.01.org
To unsubscribe send an email to iwd-leave(a)lists.01.org

Regards
Mauro

#6 lore raw

Hi Mauro,

Quoted 6 lines
Quoted 1 line

So while connected, it should just be 'station wlan0 connect <some other network>'.  iwd will gracefully switch networks  (disconnect from old + connect to new) for you.

That is not exactly what I asked.
This is for use case "I want to connect to a specific network".

I asked for the "negated": "please connect to *any* net  *but* the current one".

That is not a usecase we support and I'm not sure I understand why that would even be wanted. Patches are always welcome of course.

Quoted 1 line

There are also cases where you want to temporarily disconnect and later reconnect to the same or other net, without necessarily having preferences.

That is what rfkill is for.

Quoted 4 lines

This would be particularly useful for "unattended servers" where there's nobody to actually chose.

I think a "enter autoconnect state" command could be useful, at the very least for testing/fallback.

Perhaps. We've been contemplating doing this and are quite open to the idea. But no one has yet formulated a concrete and compelling use case for us to do so.

Regards,
-Denis

#7 lore raw
Quoted 10 lines · Denis Kenzior

Hi Mauro,

Quoted 6 lines
Quoted 1 line

So while connected, it should just be 'station wlan0 connect <some other network>'.  iwd will gracefully switch networks  (disconnect from old + connect to new) for you.

That is not exactly what I asked.
This is for use case "I want to connect to a specific network".

I asked for the "negated": "please connect to *any* net  *but* the current one".

That is not a usecase we support and I'm not sure I understand why that would even be wanted.  Patches are always welcome of course.

My "real use case" (I don't know how "compelling" it may be since workarounds are available) is:
- I am maintaining a small headless device that's sold through a net of "installers".
- Installer gets a bunch of devices and preconfigures them "at home", often using his cellphone hotspot as A.P.
- Preconfigured devices are then taken to customer where the customer network is set-up.
- A physical pushbutton switches device in "production mode" (switching from cellphone HS to whatever else).
- if something goes wrong same PB can revert in "programming mode" (should go back to installer HS).

Currently switching involves powering down either cellphone HS (easy) or customer AP (a nuisance).

Having a way to "cycle through available" without actually having the names would be handy.

Quoted 4 lines
Quoted 2 lines

There are also cases where you want to temporarily disconnect and later reconnect to the same or other net, without necessarily having preferences.

That is what rfkill is for.

I'm unsure if it could be made available on our target; I'll check. Thanks for the hint.

Quoted 7 lines
Quoted 5 lines

This would be particularly useful for "unattended servers" where there's nobody to actually chose.

I think a "enter autoconnect state" command could be useful, at the very least for testing/fallback.

Perhaps.  We've been contemplating doing this and are quite open to the idea. But no one has yet formulated a concrete and compelling use case for us to do so.

Please see above.
That is my real use-case.

Quoted 6 lines

Regards,
-Denis
_______________________________________________
iwd mailing list -- iwd(a)lists.01.org
To unsubscribe send an email to iwd-leave(a)lists.01.org

Regards
Mauro