I wrote this so I could find out my DHCP-assigned IP address without having to poke around with nmap or other tools. It was written for a TP-LINK TL-WR703N but you can adjust to suit your hardware. Just change the LEDFILE variable to the LED that you want to blink. This script assumes you are using DHCP on the LAN interface, in a bridged configuration (br-lan).
EDIT: Zeros are represented by a longer blink, or "dash", and the periods between octets by a 3 second pause.
#!/bin/sh
# Script for controlling the LED on a TP-LINK TL-WR703N
# Use at bootup to find your LAN IP address
LEDFILE=/sys/devices/platform/leds-gpio/leds/tp-link\:blue\:system/brightness
IPADDR=$(ifconfig br-lan | grep inet | sed 's/^.*addr://' | sed 's/ Bcast.*//')
turnoff ()
{
echo "0" > $LEDFILE
}
turnon ()
{
echo "1" > $LEDFILE
}
dot ()
{
turnon
sleep 1
turnoff
sleep 1
}
dash ()
{
turnon
sleep 2
turnoff
sleep 1
}
turnoff
echo $IPADDR | while IFS= read -r -n1 char
do
echo $char
if [[ "$char" != "." && "$char" != "0" && "$char" != "" ]]; then
for n in `seq 1 $char`; do
dot
done
sleep 1
elif [[ "$char" == "0" ]]; then
dash
else
sleep 3
fi
done
(Last edited by greenleaf on 4 Feb 2012, 21:00)