Frex wrote:As for using the QSS LED that way, you will likely have to manipulate it using defaulton/none/timer.
I think it's better leave it unset or off in the system configuration and manually control it in the hotplug event.
/usr/bin/gpioctl dirout 5
/usr/bin/gpioctl set 5
/usr/bin/gpioctl clear 5
Here's how I control wlan by reset button on Fon2201.
/etc/hotplug.d/button/00-button:
. /etc/functions.sh
do_button () {
local button
local action
local handler
local min
local max
config_get button "$1" button
config_get action "$1" action
config_get handler "$1" handler
config_get min "$1" min
config_get max "$1" max
[ "$ACTION" = "$action" -a "$BUTTON" = "$button" -a -n "$handler" ] && {
if [ -z "$min" ]; then
[ -z "$max" -o "$max" -ge $SEEN ] && eval $handler
elif [ -z "$max" ]; then
[ $min -le $SEEN ] && eval $handler
else
[ $min -le $SEEN -a $max -ge $SEEN ] && eval $handler
fi
}
}
#logger "$BUTTON was $ACTION for $SEEN seconds"
config_load system
config_foreach do_button button
/etc/config/system:
config 'button' 'woggle'
option 'button' 'reset'
option 'action' 'released'
option 'handler' '/sbin/woggle'
option 'min' '0'
option 'max' '1'
config 'button' 'reset'
option 'button' 'reset'
option 'action' 'released'
option 'handler' 'firstboot && reboot'
option 'min' '30'
option 'max' '60'
/sbin/woggle: (make it executable by 'chmod +x /sbin/woggle')
#!/bin/sh
if [ -d /var/run/hostapd-ath0 -o -d /var/run/hostapd-ath1 ]; then
/usr/bin/logger "WiFi button used: WiFi down"
/sbin/wifi down
/usr/bin/gpioctl dirout 2 > /dev/null
/usr/bin/gpioctl clear 2 > /dev/null
/usr/bin/gpioctl dirout 1 > /dev/null
/usr/bin/gpioctl set 1 > /dev/null
else
/usr/bin/logger "WiFi button used: WiFi up"
/usr/bin/gpioctl dirout 1 > /dev/null
/usr/bin/gpioctl clear 1 > /dev/null
/sbin/uci set wireless.wifi0.disabled=0
/sbin/wifi up
/sbin/uci revert wireless.wifi0.disabled
fi
/etc/rc.local: (I have wlan disabled by default)
if [ -d /var/run/hostapd-ath0 -o -d /var/run/hostapd-ath1 ] || {
/usr/bin/gpioctl dirout 2 > /dev/null
/usr/bin/gpioctl clear 2 > /dev/null
/usr/bin/gpioctl dirout 1 > /dev/null
/usr/bin/gpioctl set 1 > /dev/null
}
exit 0
Fon2201 led gpio no.:
wlan:green - gpio 2
wlan:orange - gpio 1