WPS button to toggle guest networks

My apologies if this is in the wrong thread.

I have a Linksys WRT3200ACM with the primary partition being the most recent Linksys firmware and the latest OpenWRT on the alternate. Working good but I had an idea to make it better. In OpenWRT my radios(0/1) contain the main network and a disabled guest network to match the schema I'm trying to make. That leaves a button that was meant for WPS, but no thank you. I have a good feeling that it can be reprogrammed to toggle two WiFi networks on/off.

Any questions, comments or inspiring ideas are always welcomed.

https://openwrt.org/docs/guide-user/hardware/hardware.button

On your router,

wifi help

From what I can tell, that command takes the entire WiFi on/offline, I'm trying to pinpoint two non-default networks on separate radios.

Radio0.network0 is a 5Ghz a/c for the primary network
Radio0.network1 is my guest network that I want to have toggled via hardware button
Radio1.network0 is a 2Ghz b/g/n for smart home devices
Radio1.network1 is also a guest network for older devices that I want toggled simultaneously

Any ideas?

That is correct. At this time, all SSIDs and all radios get "reset" when there is a change, such as with wifi reload. There is some work afoot on being able to manage individual SSIDs without restarting the others on master, but I haven't kept up with it.

To manage a single SSID, you can use uci to set its disabled option to 1, uci commit, and then reload. If you name your wifi-iface sections, it may be easier to reference the "right" SSIDs.

1 Like

OKOKOK!! Sooo, the wifi-iface can be renamed to a "user friendly" name? Is that the option on the Web console->Network->Wireless->Interface Configuration->Advanced->Interface Name? Then how do I reference it using uci?

Here's what I've come up with

X=$(uci get wireless.@wifi-iface[3].disabled)
Y=$(uci get wireless.@wifi-iface[4].disabled)

if [ ${BUTTON} = 'wps' ] && [ ${ACTION} = 'pressed' ] ; then

if [ $X = 1 ] || [ $Y = 1 ] ; then

logger Starting Guest Networks.....
 uci set wireless.@wifi-iface[3].disabled=0
 uci set wireless.@wifi-iface[4].disabled=0
 uci commit wireless
 sync
logger Guest Networks Started

        else

logger Stopping Guest Networks.....
 uci set wireless.@wifi-iface[3].disabled=1
 uci set wireless.@wifi-iface[4].disabled=1
 uci commit wireless
 sync
logger Guest Networks Stopped
        fi
fi

Anybody have experience with WPS LED both amber and white. I would like to have it amber while only one guest network is active and white when both are.

  • go to luci > system > led configuration...
  • add your settings then
#> uci show system | grep '@led'
system.@led[0]=led
system.@led[0].default='0'
system.@led[0].sysfs='bcm53xx:green:wps'
system.@led[0].trigger='phy0radio'

you can then use the above values ( or similar ) in your hotplug script to toggle trigger > none... or whichever settings you desire... ( take care with any alternate access to the same led via loaded modules or conflicting config )

uci show system | grep led

system.ntp.enabled='1'
system.led_wan=led
system.led_wan.name='WAN'
system.led_wan.sysfs='pca963x:rango:white:wan'
system.led_wan.trigger='netdev'
system.led_wan.mode='link tx rx'
system.led_wan.dev='eth1'
system.led_wan.default='0'
system.led_usb1=led
system.led_usb1.name='USB 1'
system.led_usb1.sysfs='pca963x:rango:white:usb2'
system.led_usb1.trigger='usbport'
system.led_usb1.default='0'
system.led_usb1.port='usb1-port1'
system.led_usb2=led
system.led_usb2.name='USB 2'
system.led_usb2.sysfs='pca963x:rango:white:usb3_1'
system.led_usb2.trigger='usbport'
system.led_usb2.port='usb2-port1' 'usb3-port1'
system.led_usb2.default='0'
system.led_usb2_ss=led
system.led_usb2_ss.name='USB 2 SS'
system.led_usb2_ss.sysfs='pca963x:rango:white:usb3_2'
system.led_usb2_ss.trigger='usbport'
system.led_usb2_ss.default='0'
system.led_usb2_ss.port='usb3-port1'
system.@led[4]=led
system.@led[4].default='0'
system.@led[4].name='OneGuest'
system.@led[4].sysfs='pca963x:rango:amber:wps'
system.@led[4].trigger='phy0radio'
system.@led[5]=led
system.@led[5].default='0'
system.@led[5].name='BothGuests'
system.@led[5].sysfs='pca963x:rango:white:wps'
system.@led[5].trigger='phy0radio'

Beginner question: How/Where do I manipulate where the trigger points?

system.@led[_].trigger='phy0radio'
cat $(find /sys | grep 'trigger$'| grep 'wps' | grep -v 'soc')

or just look in luci...

wulfy23

That was a lot of good information but it's hard for me to decipher what to use. Here's what turned up and I believe that using a case statement inside the file that controls the WPS LED will work. Problem: file location? I'll start work on the code to verify the light functions work according to plan.

find /sys | grep 'trigger
/sys/devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-0068/leds/pca963x:0:68:3/trigger
/sys/devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-0068/leds/pca963x:0:68:10/trigger
/sys/devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-0068/leds/pca963x:rango:white:usb2/trigger
/sys/devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-0068/leds/pca963x:rango:amber:wps/trigger
/sys/devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-0068/leds/pca963x:rango:white:usb3_1/trigger
/sys/devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-0068/leds/pca963x:0:68:15/trigger
/sys/devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-0068/leds/pca963x:0:68:13/trigger
/sys/devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-0068/leds/pca963x:0:68:4/trigger
/sys/devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-0068/leds/pca963x:0:68:11/trigger
/sys/devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-0068/leds/pca963x:rango:amber:wan/trigger
/sys/devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-0068/leds/pca963x:0:68:2/trigger
/sys/devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-0068/leds/pca963x:rango:white:wps/trigger
/sys/devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-0068/leds/pca963x:rango:white:usb3_2/trigger
/sys/devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-0068/leds/pca963x:0:68:14/trigger
/sys/devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-0068/leds/pca963x:0:68:12/trigger
/sys/devices/platform/soc/soc:internal-regs/f1011000.i2c/i2c-0/0-0068/leds/pca963x:rango:white:wan/trigger
/sys/devices/platform/soc/soc:internal-regs/f10d8000.sdhci/leds/mmc0::/trigger
/sys/devices/platform/gpio-leds/leds/rango:white:power/trigger
/sys/devices/platform/gpio-leds/leds/rango:white:wlan_5g/trigger
/sys/devices/platform/gpio-leds/leds/rango:white:wlan_2g/trigger
/sys/devices/platform/gpio-leds/leds/rango:white:sata/trigger
/sys/firmware/devicetree/base/gpio-leds/sata/linux,default-trigger

just use uci set... to toggle the values you got using luci and uci show... why complicate things?

(example using my led[num] )

uci -q set system.@led[0].trigger='default-on'
uci -q set system.@led[0].trigger='none'

( double up and invert trigger for two leds i.e. green off > orange on )

this is your wps ( did you write the script above? because I assumed you were comfortable with uci based on it )

system.@led[4].sysfs='pca963x:rango:amber:wps'

and you might try toggling this instead of trigger or as a base setting ( i'm not testing any of this and some devices may have the default set to off or incorrect ) play with luci... get to know whats right... then do the script side.

uci -q set  system.@led[4].default='0'
uci -q set  system.@led[4].default='1'
1 Like

you'll want code more like this to achieve your goal of having one on at a time...

#!/bin/sh

X=$(uci get wireless.radio0.disabled)
Y=$(uci get wireless.radio1.disabled)
Z=$(expr $X + $Y)

echo "X: $X"
echo "Y: $Y"
echo "Z: $Z"

case "$Z" in
        0) #set 2 ghz on
                echo "setting 2ghz on"
                uci -q set system.@led[4].default='1'; uci -q set system.@led[5].default='0'
        ;;
        1) #if 2ghz is on invert with 5 ghz ... if 5Ghz is on set both on

                if [ "$X" -eq 1 ]; then
                        echo "switching 2ghz for 5 ghz"
                else
                        echo "setting both 2ghz + 5 ghz on"
                        uci -q set system.@led[4].default='0'; uci -q set system.@led[5].default='1'
                fi
        ;;
        2) #both were on toggle both off
                echo "setting both off"
                uci -q set system.@led[4].default='0'; uci -q set system.@led[5].default='0'
        ;;
esac
1 Like

wulfy23,

I'm comfortable using UCI and I'm in the middle of reading the Linux Scripting Bible. So I'm almost up to speed and looking at your examples, I'm inspired!
The X+Y=Z correlating to:
0=BothOff (NoLED)
1=OneOn (AmberLED) *indicating an error (Not required)
2=BothOn (WhiteLED)

Your case template is excatly what I needed to build the configuration. Thank you so much.

1 Like