Posted: Sat Nov 21, 2015 22:41 Post subject: TP-Link Archer C9 GPIO pins
I started tinkering about with the GPIO pins as an experiment.
I gather the layout is something like:
gpio 1 - Ethernet
gpio 2 - WPS
gpio 3 - RESET (input - warning!!)
gpio 4 - WLAN 2.4Ghz
gpio 5 - WLAN 5.0Ghz
gpio 6 - USB (RHS)
gpio 7 - USB (LHS)
I wrote a script that will correctly display the WLAN LEDs - dependent on whether the WLAN is really on or off, e.g. for 2.4Ghz:
Code:
#!/bin/sh
wlan_led()
{
wlan_device=$1
led_gpio_pin=$2
gpio disable ${led_gpio_pin}
wlan_status=0
while sleep 2; do
previous_wlan_status=${wlan_status}
wlan_mode=$( nvram get "${wlan_device}_net_mode" )
wlan_radio=$( nvram get "${wlan_device}_radio" )
wlan_status=1
if [[ "${wlan_mode}" == "disabled" ]] || [[ ${wlan_radio} == 0 ]]; then
wlan_status=0
fi
if [ ${wlan_status} -eq 0 ]; then
gpio disable ${led_gpio_pin}
elif [ ${wlan_status} -ne ${previous_wlan_status} ]; then
gpio enable ${led_gpio_pin}
fi
done
}
wlan_led "wl0" 4
Despite my "extensive knowledge" garnered from using Gentoo Desktop Linux (i.e. not Android or DOS)...
Both ip and ifconfig are slightly odd/striped down BusyBox versions of the tools I'm used to using! Items I would use - like the carrier field - are disabled...
I just can't figure out a way of seeing if any of the 4 wired Ethernet LAN ports are physically connected... It would be nice to figure this out to control the LAN LED (which is currently ignored).
From:
Simplified wrt54g block diagram
It looks like testing for packet transfer activity on VLAN1 would be the only way to check whether any of the LAN ports is connected...
Any thoughts? Is there a better / more reliable way to do this?
Posted: Tue May 03, 2016 0:25 Post subject: Archer C9 ethernet led
This worked for me! I logged into telnet and ran the script and then typed 'gpio enable 1' and the ethernet led came on! I was looking everywhere to try and get this led on, since it went off after flashing with DD-WRT (was on with stock firmware). Got rest of lights on--see original post to control all lights, including WPS.
router_lights_shrunk.JPG
Description:
Filesize:
105.19 KB
Viewed:
10737 Time(s)
Last edited by takeahike on Sun Jun 19, 2016 22:22; edited 2 times in total
Posted: Tue May 03, 2016 4:30 Post subject: Re: Archer C9 ethernet led
takeahike wrote:
This worked for me! I logged into telnet and ran the script and then typed 'gpio enable 1' and the ethernet led came on! I was looking everywhere to try and get this led on, since it went off after flashing with DD-WRT (was on with stock firmware).
Fascinating, does it turn off if you disconnect the cat cord?
Posted: Tue May 03, 2016 16:00 Post subject: Re: Archer C9 ethernet led
wirelesskebab wrote:
Fascinating, does it turn off if you disconnect the cat cord?
I have to confess that it's so long since I wrote my little script can't remember... I think I updated it a bit with activity levels for the Wi-Fi channels, etc... I'm away on holiday just now- so I can't easily check!
Posted: Tue May 03, 2016 20:57 Post subject: Re: Archer C9 ethernet led
wirelesskebab wrote:
takeahike wrote:
This worked for me! I logged into telnet and ran the script and then typed 'gpio enable 1' and the ethernet led came on! I was looking everywhere to try and get this led on, since it went off after flashing with DD-WRT (was on with stock firmware).
Fascinating, does it turn off if you disconnect the cat cord?
Posted: Mon May 09, 2016 3:02 Post subject: Re: Archer C9 ethernet led
takeahike wrote:
This worked for me! I logged into telnet and ran the script and then typed 'gpio enable 1' and the ethernet led came on! I was looking everywhere to try and get this led on, since it went off after flashing with DD-WRT (was on with stock firmware).
If you want the WPS light on as well just follow the procedure above and type 'gpio enable 2.' I've found that playing with gpio can cause you to lose your connection if you play with number 3 (see warning in original post). No big deal--the router will just re-boot.
This is really just a hack that turns off the LAN LED on extremely low network activity. I can't really be bothered to dig about to find out if there's a way to directly access the ethernet driver status (i.e. to find if a cable is physically plugged or not).
You get a nice flashing light - where the flashing speed increases - as your network activity level increases...
The wlan_led script tests both if the radios are disabled/enabled and also whether the radios are turned off/on (i.e. a radio needs to be enabled and turned on to be "really" on - go figure).
You get nice flashing LEDS - for your WLAN network activity... The flashing frequency is again dependent on the activity level of the WLAN band (as per the LAN script above).
wlan_led.sh
Code:
#!/bin/sh
wlan_device=$1
led_gpio_pin=$2
virtual_wlan_device=$( nvram get "${wlan_device}_ifname" )
gpio disable ${led_gpio_pin}
wlan_enabled=0
while sleep 2; do
prev_wlan_enabled=${wlan_enabled}
wlan_mode=$( nvram get "${wlan_device}_net_mode" )
wlan_status=$( wl -i ${virtual_wlan_device} radio )
wlan_status=$(( ${wlan_status} & 0x0001 ))
if [[ "${wlan_mode}" == "disabled" ]] || [[ ${wlan_status} == 1 ]]; then
wlan_enabled=0
else
wlan_enabled=1
fi
if [ ${wlan_enabled} -eq 0 ]; then
gpio disable ${led_gpio_pin}
elif [ ${wlan_enabled} -ne ${prev_wlan_enabled} ]; then
gpio enable ${led_gpio_pin}
fi
done
Posted: Sun May 15, 2016 3:30 Post subject: Error with wireless led script
Got the following errors running wireless script. Also, when I run the lan led script it affects the light but it doesn't return to the telnet prompt at the end.
Posted: Sun May 15, 2016 4:33 Post subject: Re: Error with wireless led script
takeahike wrote:
Got the following errors running wireless script. Also, when I run the lan led script it affects the light but it doesn't return to the telnet prompt at the end.
The name of each script file is in bold before the code contents.
The .startup scripts will auto start each time you boot (although that's the theory - because my dd-wrt installation has a habit of partially wiping them, from the jffs storage, during a reboot sometimes??!!)
To start them manually you have to run each .startup script as a background process...
The wlan_led script tests both if the radios are disabled/enabled and also whether the radios are turned off/on (i.e. a radio needs to be enabled and turned on to be "really" on - go figure).
Hi!
Will this script work on TP-Link Archer C7 V4?
I'd want my Wifi LEDs just to lit continuously if radios are turned on or off, instead of blinking for activity.
Will this script work on TP-Link Archer C7 V4?
I'd want my Wifi LEDs just to lit continuously if radios are turned on or off, instead of blinking for activity.
Thanks indeed!
Yeah, the script will work on any TP-Link router, where the LEDs are wired up to the GPIO pins.
To not flash the LEDs on activity you'd just do something like:
Code:
wlan_led.sh
Code:
#!/bin/sh
wlan_device=$1
led_gpio_pin=$2
virtual_wlan_device=$( nvram get "${wlan_device}_ifname" )
gpio disable ${led_gpio_pin}
wlan_enabled=0
while sleep 2; do
wlan_mode=$( nvram get "${wlan_device}_net_mode" )
wlan_status=$( wl -i ${virtual_wlan_device} radio )
wlan_status=$(( ${wlan_status} & 0x0001 ))
if [[ "${wlan_mode}" == "disabled" ]] || [[ ${wlan_status} == 1 ]]; then
wlan_enabled=0
else
wlan_enabled=1
fi
if [ ${wlan_enabled} -eq 0 ]; then
gpio disable ${led_gpio_pin}
else
gpio enable ${led_gpio_pin}
fi
done
Obviously the GPIO pin numbering may differ between TP-Link devices. You have been warned!
Obviously the GPIO pin numbering may differ between TP-Link devices. You have been warned!
Bob
Hi Bob,
Many thanks.
I was brave enough and actually now tried some pin numbers with gpio command directly before applying the script. But below commands didn't work for me on C7 V4:
gpio enable 4
gpio enable 5
gpio enable 9
gpio enable 33
Do you use the WPS button on your router to turn on/off the wifi radio? Is it working for you?
For me the button is not doing any activity. I have these settings:
Administration -> Reset Button: Enable (was default)
Services -> SES / AOSS / EZ-SETUP / WPS Button -> Turning off radio: Enable.
I read on various topics that it doesn't work for many.
Obviously the GPIO pin numbering may differ between TP-Link devices. You have been warned!
Bob
Hi Bob,
Many thanks.
I was brave enough and actually now tried some pin numbers with gpio command directly before applying the script. But below commands didn't work for me on C7 V4:
gpio enable 4
gpio enable 5
gpio enable 9
gpio enable 33
If you poking about trying to find the GPIO pins for the LED, then you are looking at the right file. But you obviously would use this block (a bit lower down in the file):
Do you use the WPS button on your router to turn on/off the wifi radio? Is it working for you?
For me the button is not doing any activity. I have these settings:
Administration -> Reset Button: Enable (was default)
Services -> SES / AOSS / EZ-SETUP / WPS Button -> Turning off radio: Enable.
I read on various topics that it doesn't work for many.
Thanks
I recall that the WPS button just crashed dd-wrt and didn't allow me to toggle the WiFi radios.
Anyway at present, I'm not using my Archer C9. It bricked after a routine update. Quite frankly I can't be bothered with that hassle... I.e. if I have to hook up my USB->serial connector, to fix the device, on every update... I'd personally rather just use a cheap commodity x86 board, running pfsense.