I have programmed my Mango router side button to enable and disable a wifi interface. However after about 2 minutes, netifd (i suspect) detects this and (i suspect) automatically restarts some service which brings the wifi interface back up.
Any good options to handle or avoid this behaviour?
Did you install wifitoggle
for this purpose and/or did you follow the tutorial in the Wiki? https://openwrt.org/docs/guide-user/network/wifi/wifi_toggle
If not, how do you toggle WiFi?
The only change I needed to make was replace /usr/bin/switchaction with the following (chmod +x)
#!/bin/sh
switch_left=$(grep -o "BTN_0.*hi" /sys/kernel/debug/gpio)
if [ -n "$switch_left" ]; then
ifconfig apcli0 up
else
ifconfig apcli0 down
fi
This works perfectly except there is some service which will bring the interface back up automatically.
If instead of bringing the interface down with ifconfig I use 'wifi on' and 'wifi off' scripts - that will be more permanent - but it's not the result I want - because I just want to toggle the client wifi service which connects to the internet - not the one I am presenting to my devices to connect to. I think wifi toggle would suffer the same problem I'm trying to avoid.
AFAIK there is no /usr/bin/switchaction
on OpenWrt. Are you running an official image from openwrt.org?
The fact that you want to toggle only client side WiFi is new and would have been important in your first post.
1 Like
I didn't see any benefit from running an official image except a harder initial setup, so I reverted back to the manufacturer one which has the switchaction script. But it also uses openwrt under the hood.
Here is what i've tried this morning without much luck, changed my script to create a state file which if it exists, I loop constantly to bring down the interface every second. Turning the switch to the left removes the file and brings the interface up. It's not really working well though, it doesn't reliably bring up the service.
I might have to do it with iptables but i'd rather not..
I'm running out of ideas and this has taken 2 days already.
Then, I'm afraid, you are in the wrong spot and you should ask your question to the manufacturer. Nobody knows what your manufacturer did, what versions are used, which components are replaced and so on and so on.
If you have a Volvo with a Renault engine, you aren't going to ask Renault about the engine either, you direct your questions to Volvo.
If you complain about time: I've just wasted quite some of my time, too. Complain to the manufacturer, not to this forum.
1 Like
If you have a solution in mind which would work on the official image i'm happy to try it?
Since you want to toggle not all WiFis, but just one, I would have a look at the already-mentioned wifitoggle script and see what it does: https://github.com/openwrt/packages/blob/master/utils/wifitoggle/files/wifitoggle.hotplug
Then modify it to limit it to the required interface.
1 Like
Thank you. I have a feeling that method wont work because i only see one wifi interface on my device, which is what that script will toggle using the wifi script. It doesn't require any more finegrained control than that but I do unfortunately.