1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2015 OpenWrt.org
15 config_get gpio_pin
"$1" gpio_pin
16 config_get name
"$1" name
17 config_get value
"$1" value
0
19 local gpio_path
="/sys/class/gpio/gpio${gpio_pin}"
20 # export GPIO pin for access
21 [ -d "$gpio_path" ] ||
{
22 echo "$gpio_pin" >/sys
/class
/gpio
/export
23 # we need to wait a bit until the GPIO appears
24 [ -d "$gpio_path" ] ||
sleep 1
27 # direction attribute only exists if the kernel supports changing the
29 if [ -e "${gpio_path}/direction" ]; then
30 # set the pin to output with high or low pin value
31 { [ "$value" = "0" ] && echo "low" ||
echo "high"; } >"$gpio_path/direction"
33 { [ "$value" = "0" ] && echo "0" ||
echo "1"; } >"$gpio_path/value"
39 procd_add_reload_trigger
"system"
44 [ -e /sys
/class
/gpio
/ ] && {
46 config_foreach load_gpio_switch gpio_switch