[Solved] TP-Link RE650: Adding a function to a button

Hello everyone,

I'm trying to add function to a button on my RE650 on OpenWrt 21.02.

Reading the wiki and this post gave me some idea, but I didn't succeed so far.


gpiochip2: GPIOs 416-447, parent: platform/1e000600.gpio, 1e000600.gpio-bank2:

gpiochip1: GPIOs 448-479, parent: platform/1e000600.gpio, 1e000600.gpio-bank1:

gpiochip0: GPIOs 480-511, parent: platform/1e000600.gpio, 1e000600.gpio-bank0:
 gpio-498 (                    |wps                 ) in  hi IRQ
 gpio-499 (                    |reset               ) out hi ACTIVE LOW
 gpio-502 (                    |blue:power          ) out lo ACTIVE LOW
 gpio-503 (                    |blue:wifi2g         ) out lo ACTIVE LOW
 gpio-504 (                    |blue:wifi5g         ) out hi ACTIVE LOW
 gpio-505 (                    |power               ) in  hi IRQ
 gpio-506 (                    |red:wps             ) out lo
 gpio-507 (                    |blue:wps            ) out lo
 gpio-508 (                    |green:eth_act       ) out hi ACTIVE LOW
 gpio-509 (                    |green:eth_link      ) out lo ACTIVE LOW
 gpio-510 (                    |led                 ) in  hi IRQ
 gpio-511 (                    |reset               ) in  hi IRQ

So the button "led" seems to be known to the system. That's why I thought adding the following file and doing "chmod 755" could be enough, but no /root/buttonpress.test appears when pressing the button.



[ "${ACTION}" = "released" ] || exit 0

echo "pressed" > /root/buttonpress.test

return 0

Any help on this is very much appreciated!

i'd probably put the file in /tmp/ just to make sure it's not an auth issue.

Thank you for the suggestion, but unfortunately the same result. Do I have to restart / reload anything for the new button script in /etc/rc.button/ to be picked up?

Also I keep reading about DTS (like in the above mentioned post) and don't know if I need to do further customization around that topic to make the button work...

might also want to put an echo before the variable check, just to check if the script gets executed, at all.

It doesn't. Still nothing with the following file in /etc/rc.button:


echo "pressed" > /tmp/buttonpress.test
echo "${ACTION}" >> /tmp/buttonpress.test

return 0

If you haven’t already read this, take a look at the buttons hotplug tutorial.

1 Like

I read the whole article but don't really understand what is being said about procd vs hotplug. It seems my device on 21.02 uses procd?

I can find the following packages installed on my default installation:

/etc/hotplug.d exists, but no subdir "button".

The first script in the preliminary steps will show you if the button name is really "led" and if there are detected any actions.

Nice, thank you pavelgl. The hotplug-script worked and told me that the button was called "lights_toggle" instead of "led".

Creating /etc/rc.button/lights_toggle and giving it execute permission worked as expected. I will post back with the complete script as soon as I've finished and tested it!

This is what I came up with to toggle all LEDs. Thank you all for your help!



[ "${ACTION}" = "released" ] || exit 0

if [ "$(cat /sys/class/leds/blue:power/brightness)" -eq 255 ]; then
        logger "Button 'lights_toggle' pressed, disabling LEDs"
        echo 0 > /sys/class/leds/blue:power/brightness
        echo "none" > /sys/class/leds/blue:wifi2g/trigger
        echo "none" > /sys/class/leds/blue:wifi5g/trigger
        echo "none" > /sys/class/leds/green:eth_link/trigger
        echo "none" > /sys/class/leds/green:eth_act/trigger
        logger "Button 'lights_toggle' pressed, enabling LEDs"
        echo 255 > /sys/class/leds/blue:power/brightness
        echo "phy0tpt" > /sys/class/leds/blue:wifi2g/trigger
        echo "phy1tpt" > /sys/class/leds/blue:wifi5g/trigger
        # Ethernet port LEDs are configured in /etc/config/system, restore them by restarting service
        /etc/init.d/led restart

return 0

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.