User avatar
allfox
Posts: 452
Joined: Sat Jun 22, 2013 1:36 pm
Location: Guang Dong, China

[HOWTO] Make the ACT LED blink for on board WiFi

Fri Jan 13, 2017 3:55 pm

Long Long Ago, someone shouted about no LEDs on Pi WiFi: viewtopic.php?f=63&t=129812&p=867395

By lucky, I accidentally find a solution today, by blinking the on board ACT LED.

It should also work for any network interface, even it's a virtual interface like a bridge.

This solution is not tested thoroughly by myself, so if it's not working, or blow up your Pi, post back and blame luck.

More information about the solution could be found on "man iptables-extensions", at the LED target extension clause.




Step 1: Create a new text file at /etc/dhcpcd.exit-hook

Step 2: Put these into it:

Code: Select all

#!/bin/sh

LED_ON_INTERFACE="wlan0"

LED_OPTIONS="--led-trigger-id led --led-delay 100"
IPTABLES="/sbin/iptables"

$IPTABLES --check INPUT --in-interface "$LED_ON_INTERFACE" --jump LED $LED_OPTIONS
check=$?
if [ "$check" -eq 1 ]
then
        $IPTABLES --insert INPUT --in-interface "$LED_ON_INTERFACE" --jump LED $LED_OPTIONS
fi

$IPTABLES --check FORWARD --in-interface "$LED_ON_INTERFACE" --jump LED $LED_OPTIONS
check=$?
if [ "$check" -eq 1 ]
then
        $IPTABLES --insert FORWARD --in-interface "$LED_ON_INTERFACE" --jump LED $LED_OPTIONS
fi

$IPTABLES --check FORWARD --out-interface "$LED_ON_INTERFACE" --jump LED $LED_OPTIONS
check=$?
if [ "$check" -eq 1 ]
then
        $IPTABLES --insert FORWARD --out-interface "$LED_ON_INTERFACE" --jump LED $LED_OPTIONS
fi

$IPTABLES --check OUTPUT --out-interface "$LED_ON_INTERFACE" --jump LED $LED_OPTIONS
check=$?
if [ "$check" -eq 1 ]
then
        $IPTABLES --insert OUTPUT --out-interface "$LED_ON_INTERFACE" --jump LED $LED_OPTIONS
fi

echo netfilter-led > /sys/class/leds/led0/trigger

exit 0

Step 3: "sudo dhcpcd --rebind" or reboot.

Return to “General discussion”