Programming the Router Buttons

All routers have at least one button on it, such as the reset button that is normally used, by factory firmware, to reset the router to its default state.

In the ROOter firmware we can program these buttons to do other actions than what they did in the factory firmware. The reset button has been reprogrammed to allow deleting the password or resetting to the flashed state but this can be changed to do other actions as well.

Because the buttons are controlled by software, we can reprogram them quite easily from the web interface.

Button Names

All buttons have a name associated with them and we need to know this name before we can reprogram them. Different routers assign different names to a button that, from the factory, does the same action. In some routers the button used to reset the router could be known as reset and in others it may be known as wps. So we need to get the button name before we can do anything with it.

To find out the name of the button and the name of the action it takes, press the button for a short period, 1 to 2 seconds. Then go to the Status section of the web interface and then to the System Log subsection.

Scroll down to the bottom and you will see several entries dealing with the button. They will look like the following.

Button Checker : Button Name : wps Action : pressed
Button Checker : Button Name : wps Action : released

This tells us the button is named wps and it generates two state actions, one when pressed and one when released. We can have the button perform its action on either state, when pressed or when released.

Repeat this procedure for all the buttons you wish to reprogram, recording the button name and the state actions it can perform.

Button Programming

Once we have thw names of the buttons we can proceed to program them to do the action we desire. To do this, go to the System section and the Buttons subsection.

Here, you will find an entry for every button that is programmed in the firmware. By default, there are 4 button actions defined, 2 for the reset button and 2 for the wps button.

The above button is the reset button and, if it is held down for from 5 to 15 seconds and then released, will execute the /etc/btnaction script, passing in a parameter called reset_short. This script will delete the the password and reboot the router.

All of the parameters can be altered to fit your needs or the entire entry can be removed by clicking on the Delete button.

The Minimum and Maximum Hold Time are only used when the Action is set to released. They are not used by any other action. They only appear when the action selected is released. If the hold times are left blank then the button can be held for any amount of time and still have the action executed.

A button can have multiple actions attached to it by changing the minimum and maximum hold times and the Handler script. This has been done to the reset button so it can either remove the password or reset the router to flash state.

So, if the reset button is held for 5 to 15 seconds it executes the /etc/btnaction script with the reset_short parameter. If it is held for 17 to 30 seconds it will execute the same script but with a different parameter, reset_long. The script then sorts out what should be done by checking the parameter that is passed to it.

The wps button is also programmed to execute the same script, /etc/btnaction, but with different parameters depending on the hold time. These button presses do nothing and can be deleted without any adverse effects.

If you wish to add a new action for a button, click on the Add button at the bottom of the page. This will create a new blank button entry, ready for you to fill in the parameters.

Be sure to click on Save & Apply in the lower right corner when you have finished making your changes.

Built in Script Actions

There are 6 different actions built in to the /etc/btnaction script. These are the following.

/etc/btnaction reset_short Delete the password and reboot the router
/etc/btnaction reset_long Reset the firmware to the last flash state and reboot router
/etc/btnaction wifi Toggle the wifi on or off
/etc/btnaction wifi on Turn the wifi on
/etc/btnaction wifi off Turn the wifi off
/etc/btnaction power_toggle Toggle the USB power off and then on

By placing any of these actions in the Handler of the button you can have the specified action take place.

You can also use any other command or script that you desire as the Handler but that will not be covered here, as it requires a knowledge of Linux and OpenWRT.

A Simple Example

To demonstrate how to reprogram the buttons so they do something else we will look at changing the QSS button on the MR3420V1 so it toggles the wifi on and off.

Press the Qss button for a short period and then look in the System Log to see what it says about this button. It will show the following.

Button Checker : Button Name : wps Action : pressed
Button Checker : Button Name : wps Action : released

The button name is wps and it has both the pressed and released actions.

When you go to the Buttons subsection you will see that the wps button already has two entries. Since we are only going to have this button perform one action we will delete the second entry for wps.

Next, we have to change the Handler of the remaining wps entry. Changing it to /etc/btnaction wifi will make the button toggle the wifi.

Since we don't care how long the button is held down, we can delete the values in the Minimum Hold Time and Maximum Hold Time boxes. This means that, regardless of how long we hold down the button, the wifi will be toggled when we release the button.

Click on Save & Apply in the lower right corner to save the changes.

The QSS button will now toggle the wifi on and off with each press.

Fixing the TP-Link WR842ND

The TP-Link WR842ND has the names of the router buttons mixed up so it doesn't work as expected. The button labeled Wifi On/Off is actually named internally as reset and the button labled WPS/Reset is named internally as wps.

Because of this, by default, pressing the Wifi On/Off button will cause the router to delete the password and reboot. Not exactly what we want. To fix this we must reprogram the buttons.

By default, you will find 4 entries in the Buttons subsection. Delete the last entry, as it is not needed.

In the first two entries, change the Name from reset to wps and in the last entry, change the Name from wps to reset. This switches the actions of the two buttons so the one labelled WPS/Reset actually does reset the router.

Then change the Handler in the last entry, the one whose Name is now reset. Set it to be /etc/btnaction wifi and delete the values from the Minimum Hold Time and Maximum Hold Time boxes.

Click on Save & Apply in the lower right corner to save the changes.

After this, pressing the Wifi On/Off button will toggle the wifi on and off.