Custom use of cgi-bin switchset api on AR750s

Hi All,

I am running some custom scripts on my Slate that I would like to enable and disable using the hardware switch on the side of the router. I thought it would be a good idea to customise the GLInet WebUI and add another option to the button settings. VueJS is very familiar to me so I made the UI changes OK but I am stuck where the VueJS layer calls the /cgi-bin/api/router/switch/set API. I don’t have the source code for that so I am guessing at the parameters and hoping it will make the appropriate updates to the UCI glconfig.switch_button settings. Unfortunately I can’t get it to save my custom settings.

  1. Can I find out more about this API? The parameters, what it does, the source code?

  2. Is there another API I can call to just simply set a UCI parameter?

Thanks,
Martin

here is where I ended up with buttons and switches.

easy and hardway

easy way for four scripts or less
go to /usr/bin/button_released
and switch network reload or factory default with your script and play with the button released time settings if you want more by adding more (larger times at top down)

hardway for 8 or more scripts
I’m going to tell you where you want to end up and why.
you want to use the reset button in conjunction with the slide switch.

for example
if you press the reset button less then 1 second you look at the switch setting of left or right and launch 1 of two choices. usually you can combine 1 switch enable and disable setting by toggling what it is you want to do. (so I write a script that detects if wifi is up and if wifi is enabled then disable or if wifi disabled enable)

I
now I use lessthan 1 second press with a left or right button settings
a greaterthan 1 second press with a left or right button setting
a greater than 2 second press with a left or right button setting
a geater than 4 second press with a left or right button setting

so with single buttton press of 5 seconds I can launch up to 8 scripts (choice of 4 of them within a 2 second button press)

now I did with on an ar750 with vanilla openwrt

so once you get that working with button released…with reset button

try
cat /sys/kernel/debug/gpio

and hit your usb swich left and right and rerun and verify if gpio-0 or which one

then add similar to button_released section

if grep -E '^ gpio-0 .*) in  hi' /sys/kernel/debug/gpio ; then
            echo "Switch is on right ge4 second press" >> /root/switch.txt
            else
            echo "Switch is off left ge4  second press" >> /root/switch.txt
          fi

so

Ok, interesting stuff, but not exactly the experience I am looking for. I prefer to use a setting in uci to decide what action the button should perform. Where I am stuck is how update uci with the web cgi-bin api.

I changed the title of my question to better reflect what I am asking for help with.

my prefered method but.
look here then

Yes, I have seen that and I am using that for inspiration. But my question is not how to respond to the button state change, it’s how to customise the Web UI and use the cgi-bin api.

The CGI files are all proprietary. What you could do is make your own page, and link it from the UI to extend it as you want, and make the corresponding scripts. The UI uses lighttpd so you wouldn’t have issues adding any kind of page.