You are not logged in.

#26 2023-03-22 14:01:47

seth
Member
Registered: 2012-09-03
Posts: 51,270

Re: [solved] Cannot connect to wi-fi using ConnMan

Ok, that seems to be NM specific (or maybe related to your NM config, I see no reason at all why NM would implicitly unblock the radio, maybe some dispatcher script?)

seth wrote:

What about connman?

(mind the iwd configuration!)

Offline

#27 2023-03-22 14:12:04

Strangiato
Member
Registered: 2020-01-10
Posts: 382

Re: [solved] Cannot connect to wi-fi using ConnMan

connman connects if iwd service is active. But the error with connman_iwd service persists, and the airplane does not work.
wifi disconnects and I'm unable to reconnect. connmanctl gives "not registered" error.

These are the dispachers on my system:

$ ls /etc/NetworkManager/dispatcher.d/
10-ntpd  no-wait.d  pre-down.d  pre-up.d  wlan_auto_toggle_newer.sh.old

Last edited by Strangiato (2023-03-22 14:12:50)

Offline

#28 2023-03-22 14:38:17

seth
Member
Registered: 2012-09-03
Posts: 51,270

Re: [solved] Cannot connect to wi-fi using ConnMan

the airplane does not work

Please don't paraphrase, https://bbs.archlinux.org/viewtopic.php?id=57855
=> updated journal?

These are the dispachers on my system:

The filenames won't really help all that much…

Offline

#29 2023-03-22 15:01:20

Strangiato
Member
Registered: 2020-01-10
Posts: 382

Re: [solved] Cannot connect to wi-fi using ConnMan

http://0x0.st/Hos8.txt

# cat 10-ntpd 
#!/bin/bash

case "$2" in
	up)
		      systemctl start ntpd.service
	;;
	down)
		      systemctl stop ntpd.service
	;;
esac
# cat wlan_auto_toggle_newer.sh.old 
#!/bin/sh

if [ "$1" = "enp1s0" ]; then
    case "$2" in
        up)
            nmcli radio wifi off
            ;;
        down)
            nmcli radio wifi on
            ;;
    esac
elif [ "$(nmcli -g GENERAL.STATE device show enp1s0)" = "20 (unavailable)" ]; then
    nmcli radio wifi on
fi

These directories are empty:

no-wait.d  pre-down.d	pre-up.d

Offline

#30 2023-03-22 15:23:19

seth
Member
Registered: 2012-09-03
Posts: 51,270

Re: [solved] Cannot connect to wi-fi using ConnMan

# cat wlan_auto_toggle_newer.sh.old 
#!/bin/sh

if [ "$1" = "enp1s0" ]; then
    case "$2" in
        up)
            nmcli radio wifi off
            ;;
        down)
            nmcli radio wifi on
            ;;
    esac
elif [ "$(nmcli -g GENERAL.STATE device show enp1s0)" = "20 (unavailable)" ]; then
    nmcli radio wifi on
fi

Is this supposed to be some elaborate joke?

Offline

#31 2023-03-22 15:27:40

Strangiato
Member
Registered: 2020-01-10
Posts: 382

Re: [solved] Cannot connect to wi-fi using ConnMan

Offline

#32 2023-03-22 15:36:19

seth
Member
Registered: 2012-09-03
Posts: 51,270

Re: [solved] Cannot connect to wi-fi using ConnMan

That's great and everything, but you're facing a situation where NM immediately reverts an rfkill and you've a dispatcher script around that conditionally flips the radio and that didn't give you any pause? You didn't feel like mentioning the fact?

Move that script away (*really* away, idk what NM will actually execute) and see what that does to "tHe aIrPlAnE MoDe dOeS NoT WoRk wItH NeTwOrKmAnAgEr"

Offline

#33 2023-03-22 16:17:53

Strangiato
Member
Registered: 2020-01-10
Posts: 382

Re: [solved] Cannot connect to wi-fi using ConnMan

I used the dispatcher without any problem with airplane mode for quite a while. At some point the airplane mode stopped working, that's why I renamed the dispatcher file to .old

I have just deleted the dispatcher file, now the airplane mode works with NM + iwd at least.
The error with connman_iwd service persists when connman is active but I don't care anymore.

Why is networking manager executing a .old file?

Last edited by Strangiato (2023-03-22 16:18:16)

Offline

#34 2023-03-22 16:21:48

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,742

Re: [solved] Cannot connect to wi-fi using ConnMan

The name doesn't matter, each executable file is executed.

As it reads that elif will simply get triggered no matter what on any kind of callback into the dispatcher and will activate the radio if it doesn't see a LAN cable attached. You probably want to expand that condition so that it does not turn the radio on when the device went down intentionally

Offline

#35 2023-03-22 16:25:05

Strangiato
Member
Registered: 2020-01-10
Posts: 382

Re: [solved] Cannot connect to wi-fi using ConnMan

V1del wrote:

The name doesn't matter, each executable file is executed.

Thanks for the info.

You probably want to expand that condition so that it does not turn the radio on when the device went down intentionally

Exactly. How to do it?

Offline

#36 2023-03-22 17:19:10

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,742

Re: [solved] Cannot connect to wi-fi using ConnMan

elif [ ! ( "$1" = "wlan0" -a "$2" = "down" )  -a "$(nmcli -g GENERAL.STATE device show enp1s0)" = "20 (unavailable)" ]; then
...

or so I'd guess.

Generally if this script "used to work". Did it stop working when you installed iwd? as that will enforce a change to the old names you'll likely need to check for eth0 rather than enp1s0

Offline

#37 2023-03-22 18:28:07

Strangiato
Member
Registered: 2020-01-10
Posts: 382

Re: [solved] Cannot connect to wi-fi using ConnMan

Thanks, V1del. Possibly the dispathcer stopped working after installing iwd. I'm not sure.

I have created this file:

/etc/NetworkManager/dispatcher.d/wlan_auto_toggle.sh

#!/bin/sh

if [ "$1" = "enp1s0" ]; then
    case "$2" in
        up)
            nmcli radio wifi off
            ;;
        down)
            nmcli radio wifi on
            ;;
    esac
elif [ ! ( "$1" = "wlan0" -a "$2" = "down" )  -a "$(nmcli -g GENERAL.STATE device show enp1s0)" = "20 (unavailable)" ]; then
    nmcli radio wifi on
fi

Ran:

$ sudo chmod +x /etc/NetworkManager/dispatcher.d/wlan_auto_toggle.sh
$ sudo systemctl restart NetworkManager

The airplane mode is still working but the wifi remains connected after connecting the network cable.

Connman is connecting, so I'm going to mark this topic as solved.
Thank you very much, seth and V1del. smile
And sorry for wasting your time, seth. sad

Offline

#38 2023-03-22 19:46:40

seth
Member
Registered: 2012-09-03
Posts: 51,270

Re: [solved] Cannot connect to wi-fi using ConnMan

There's no waste - in the end the situation got solved.
Just next time try to come up with possibly relevant details a bit earlier wink

Offline

#39 2023-03-22 20:35:56

Strangiato
Member
Registered: 2020-01-10
Posts: 382

Re: [solved] Cannot connect to wi-fi using ConnMan

Nice. Thanks again, seth. smile

I have just found a script to automatically enable and disable WiFi based on Ethernet connection.

/etc/NetworkManager/dispatcher.d/70-wifi-wired-exclusive.sh
#!/bin/bash
export LC_ALL=C

enable_disable_wifi ()
{
    result=$(nmcli dev | grep "ethernet" | grep -w "connected")
    if [ -n "$result" ]; then
        nmcli radio wifi off
    else
        nmcli radio wifi on
    fi
}

if [ "$2" = "up" ]; then
    enable_disable_wifi
fi

if [ "$2" = "down" ]; then
    enable_disable_wifi
fi

Then run

sudo chown root:root /etc/NetworkManager/dispatcher.d/70-wifi-wired-exclusive.sh
sudo chmod 744 /etc/NetworkManager/dispatcher.d/70-wifi-wired-exclusive.sh
sudo systemctl restart NetworkManager

source: https://blog.christophersmart.com/2021/ … rkmanager/

Now the wifi is disabled when connecting the cable, and re-enabled when disconnecting it.

Edit:
But then the airplane mode stops working again. lol
Looks like I have to choose between working airplane mode and automatically enabling and disabling WiFi based on Ethernet connection. lol

Last edited by Strangiato (2023-03-22 20:40:46)

Offline

Board footer

Powered by FluxBB