[Solved]Change script for WPS to toggle radio on/off on BT hub 5a but not working as expected

Can't figure out how to run this script below by pushing wps button on BT hub5A to toggle the radio0 on/off. I replaced /etc/rc.button/wps with this excutable script.

#!/bin/sh
{ 
    SW="$(uci -q get wireless.default_radio0.disabled)"
    [ "${SW}" = "1" ] \
        && uci del wireless.default_radio0.disabled \
        || uci set wireless.default_radio0.disabled='1'
    wifi
}

It will turn on the default_radio0, but when I press it again it won't turn it off. If i run the script from ssh it will toggle it on and off as I would expect it to work .

If I replace wps and reboot with the 2 scripts below then I can press one button to turn default_radio0 on and other button to turn it off.

#!/bin/sh
{
 uci set wireless.default_radio0.disabled=0; uci commit wireless; wifi reload
}

return 0



#!/bin/sh
{
 uci set wireless.default_radio1.disabled=0; uci commit wireless; wifi reload
}

return 0

Tried various combinations with/without return 0, disabled='0', disabled="0", with/without uci commit wireless and wifi reload but no joy.
Tried hotplug and then triggerhappy as suggested in https://openwrt.org/docs/guide-user/hardware/hardware.button#procdbuttons but couldn't get them to work.

Is it just a syntax mistake or the way the device runs a script from button push?

This way your script is called twice - once when you press the button and then again when you release it. That's why the final result is always the same...

Set some criteria at the beginning:

#!/bin/sh

[ "$ACTION" = "released" -a "$BUTTON" = "wps" ] || exit 0

{ ...
3 Likes

you're pretty much doing the same as in [SOLVED]How to use physical buttons to "ifup a interface"?

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.