Kononenko.ws
Volodymyr Kononenko's Personal Web Site

OpenWRT: TP-LINK TL-WDR3600 Wi-Fi On/Off Switch Button

TP-LINK TL-WDR3600 has a very usefull hardware switch button, which allows to turn on/off wi-fi. But OpenWRT does not support this feature out of the box (corresponding ticket).

Here is a method how to enable it.

1. Create script (e.g. /root/bin/wifi_on_off.sh) with the following content:

#!/bin/sh
 
HW_SWITCH_STATE=$(cat /sys/kernel/debug/gpio | grep gpio-17 | awk '{print $6}')
UCI_WIFI_DISABLED=$(uci get wireless.@wifi-device[0].disabled)
 
if [ "lo" == ${HW_SWITCH_STATE} ]; then
    HW_SWITCH_STATE=0
elif [ "hi" == ${HW_SWITCH_STATE} ]; then
    HW_SWITCH_STATE=1
else
    exit 1
fi
 
if [ ${HW_SWITCH_STATE} != ${UCI_WIFI_DISABLED} ]
then
    uci set wireless.@wifi-device[0].disabled=${HW_SWITCH_STATE}
    uci commit wireless
    wifi
fi


2. Add exec permissions to the script and create cron job:

*/1    *    *    *    *        /root/bin/wifi_on_off.sh 2>&1 >/dev/null


3. Enable cron autostart and start it:

/etc/init.d/cron enable
/etc/init.d/cron start



Note: Disadvantage of this method is that switching the button will not react immediately, but with maximum 1 minute delay in the worth case.

Posted: Volodymyr M. Kononenko on 2013-11-18 at 21:28

Tags:

Comments



   _  __   __ __   ___    ___   _      __
  / |/ /  / // /  / _ \  / _ \ | | /| / /
 /    /  / _  /  / , _/ / ___/ | |/ |/ / 
/_/|_/  /_//_/  /_/|_| /_/     |__/|__/


Page Tools

Development and Design by Volodymyr Kononenko
Powered by DokuWiki