WR1043ND - Fine setup of QSS led as WIFI state led

General discussion about Gargoyle, OpenWrt or anything else even remotely related to the project

Moderator: Moderators

Post Reply
varma
Posts: 37
Joined: Thu Feb 17, 2011 7:53 pm

WR1043ND - Fine setup of QSS led as WIFI state led

Post by varma »

Hi everybody,

I setup my router to on-off the wireless LAN using crontab and using the QSS button.
I have a table that swithces off the wlan during the night at certains hours and turns it on in the morning, the evening and in weekends.
When I need wifi in other times I use the switch.
I would like that when the router boots the QSS led turns on only if the previous condition of wifi is ON.
Otherwise could be enough to force the wifi_on (or wifi_off) script at boot to condition the QSS led to the real state of wifi.
Both ways are good, but I dunno how to make them.

I'm using 1.5.6 Gargoyle

Theese are my scripts:

/etc/crontabs/root

Code: Select all

0 0,4,8,12,16,20 * * * /usr/bin/backup_quotas >/dev/null 2>&1
0 1,3,5,10 * * 1,2,3,4,5 /sbin/wifi_off
0 7,19 * * 1,2,3,4,5 /sbin/wifi_on
0 1,3,5 * * 0,6 /sbin/wifi_off
0 7 * * 0,6 /sbin/wifi_on
0 0,4,8,12,16,20 * * * date -u  +"%Y.%m.%d-%H:%M:%S" >/usr/data/time_backup
0,1,11,21,31,41,51 * * * * /usr/bin/set_kernel_timezone >/dev/null 2>&1
/etc/config/system

Code: Select all

config 'button' 'reset_button'
	option 'button' 'BTN_0'
	option 'action' 'released'
	option 'handler' 'logger restore defaults ; /usr/lib/gargoyle/restore.sh /etc/original_backup/backup.tar.gz 1 ; reboot ;'
	option 'min' '3'
	option 'max' '90'

config 'button' 'wifionoff'
	option 'button' 'BTN_1'
	option 'action' 'released'
	option 'handler' '/sbin/wifionoff'
	option 'min' '0'
	option 'max' '2'

config 'led' 'led_onoff'
	option 'sysfs' 'tl-wr1043nd:green:qss'
	option 'trigger' 'timer'
	option 'mode' 'link'
	option 'default' '1'
	option 'delayon' '2000'
	option 'delayoff' '3000'

config 'button' 'reboot_button'
	option 'button' 'BTN_1'
	option 'action' 'released'
	option 'handler' 'logger reboot ; /usr/lib/gargoyle/reboot.sh ;'
	option 'min' '3'
	option 'max' '90'

config 'led' 'wlan_led'
	option 'name' 'WLAN'
	option 'sysfs' 'tl-wr1043nd:green:wlan'
	option 'trigger' 'phy0rx'

config 'system' 'system'
	option 'hostname' 'Gargoyle'
	option 'timezone' 'CET-1CEST,M3.5.0/2,M10.5.0/3'

config timeserver ntp
           list server     0.pool.ntp.org
           list server     1.pool.ntp.org
           list server     2.pool.ntp.org
/sbin/wifionoff

Code: Select all

#!/bin/sh
SW=$(uci -q get wireless.@wifi-device[0].disabled)

if [ "$SW" == "0" ] ; then
echo 0 > /sys/class/leds/tl-wr1043nd\:green\:qss/brightness
else
echo 1 > /sys/class/leds/tl-wr1043nd\:green\:qss/brightness
echo timer > /sys/class/leds/tl-wr1043nd\:green\:qss/trigger
echo 3000 > /sys/class/leds/tl-wr1043nd\:green\:qss/delay_off
echo 2000 > /sys/class/leds/tl-wr1043nd\:green\:qss/delay_on
fi

[ "$SW" == "1" ] && uci set wireless.@wifi-device[0].disabled=0
[ "$SW" == "1" ] || uci set wireless.@wifi-device[0].disabled=1
wifi
/sbin/wifi_on

Code: Select all

#!/bin/sh
uci set wireless.@wifi-device[0].disabled=0
wifi
echo 1 > /sys/class/leds/tl-wr1043nd\:green\:qss/brightness
echo timer > /sys/class/leds/tl-wr1043nd\:green\:qss/trigger
echo 3000 > /sys/class/leds/tl-wr1043nd\:green\:qss/delay_off
echo 2000 > /sys/class/leds/tl-wr1043nd\:green\:qss/delay_on
/sbin/wifi_off

Code: Select all

#!/bin/sh
uci set wireless.@wifi-device[0].disabled=1
wifi
echo 0 > /sys/class/leds/tl-wr1043nd\:green\:qss/brightness
wifi_on, wifi_off, wifionoff are executables

Thank you very much

I hope somebody will like this configuration :)
Tp-Link WR1043ND v1.4 using Gargoyle 1.7.2
Tp-Link WDR3600 v1.5 using OpenWRT CC by SamKnows

Image

varma
Posts: 37
Joined: Thu Feb 17, 2011 7:53 pm

Re: WR1043ND - Fine setup of QSS led as WIFI state led

Post by varma »

I inserted in rc.local this few lines

Code: Select all

SW=$(uci -q get wireless.@wifi-device[0].disabled)

if [ "$SW" == "0" ] ; then
echo 0 > /sys/class/leds/tl-wr1043nd\:green\:qss/brightness
else
echo 1 > /sys/class/leds/tl-wr1043nd\:green\:qss/brightness
echo timer > /sys/class/leds/tl-wr1043nd\:green\:qss/trigger
echo 3000 > /sys/class/leds/tl-wr1043nd\:green\:qss/delay_off
echo 2000 > /sys/class/leds/tl-wr1043nd\:green\:qss/delay_on
fi
I will let you know if this works
Tp-Link WR1043ND v1.4 using Gargoyle 1.7.2
Tp-Link WDR3600 v1.5 using OpenWRT CC by SamKnows

Image

BashfulBladder
Moderator
Posts: 250
Joined: Thu Jan 17, 2013 11:43 pm

Re: WR1043ND - Fine setup of QSS led as WIFI state led

Post by BashfulBladder »

I am currently coding scheduled wifi service for addition to Gargoyle. The interface on a naked html page is done, but the backend work isn't finished. This is the idea:
weeklyTimer-S.png
weeklyTimer-S.png (21.22 KiB) Viewed 4924 times
I see in your crontab wifi goes off @ 0100, 0300, 0500 & 1000. My interface wouldn't allow that - there would have to be an accompanying on period between 0100-0300, between 0300-0500 & between 0500-1000. Is there some reason why you are explicitly taking wifi down at those hours instead of just:

Code: Select all

0 1 * * 1,2,3,4,5 /sbin/wifi_off

Also instead of 1,2,3,4,5, you could write 1-5
TP-Link WDR3600 v1.1 running 1.5.10+ L10n-English (Built 20130922 - OpenWrt r38093)
TP-Link WDR4300 running 1.5.10+ i18n-English (Built 20131010 - OpenWrt r38286)

https://github.com/BashfulBladder/gargoyle-plugins/wiki

varma
Posts: 37
Joined: Thu Feb 17, 2011 7:53 pm

Re: WR1043ND - Fine setup of QSS led as WIFI state led

Post by varma »

Of course I decided the policy to shutdown three times in the night.
Sometimes I watch movies via wireless in late night or I spend the night surfing the web.
Usually I get bed before 0100.
Sometimes I get over 0100 but my laziness doesnt allow me to exit my room to reach the router (10 meters walking in the night....too hard!)
So the routers shuts down the wifi for extra conditions at 0300 and 0500. :)

I didnt follow enough your setup (english is not my first language) but for sure I'm going to read it later!
It looks well, GUIs for windows users are always a good way to feel comfortable ;)

Hope to see it as a plugin for the new versions!
Last edited by varma on Mon Feb 25, 2013 5:22 pm, edited 1 time in total.
Tp-Link WR1043ND v1.4 using Gargoyle 1.7.2
Tp-Link WDR3600 v1.5 using OpenWRT CC by SamKnows

Image

BashfulBladder
Moderator
Posts: 250
Joined: Thu Jan 17, 2013 11:43 pm

Re: WR1043ND - Fine setup of QSS led as WIFI state led

Post by BashfulBladder »

Thank you for helping me to understand.

I will look into adding forced events like you have once everything is done.

and us lazy Mac people love GUI goodness too.
TP-Link WDR3600 v1.1 running 1.5.10+ L10n-English (Built 20130922 - OpenWrt r38093)
TP-Link WDR4300 running 1.5.10+ i18n-English (Built 20131010 - OpenWrt r38286)

https://github.com/BashfulBladder/gargoyle-plugins/wiki

Post Reply