mirror of https://github.com/hak5/shark-files.git
31 lines
657 B
Bash
Executable File
31 lines
657 B
Bash
Executable File
#!/bin/sh
|
|
|
|
OFFSET=448
|
|
|
|
GPIO40=$((40 + $OFFSET))
|
|
GPIO41=$((41 + $OFFSET))
|
|
|
|
setup() {
|
|
echo "${1}" > /sys/class/gpio/export 2>/dev/null
|
|
echo in > "/sys/class/gpio/gpio${1}/direction" 2>/dev/null
|
|
}
|
|
|
|
check_gpio() {
|
|
if [ ! -d "/sys/class/gpio/gpio${1}" ]; then
|
|
setup "${1}"
|
|
fi
|
|
state=$(cat "/sys/class/gpio/gpio${1}/value")
|
|
echo "${state}"
|
|
}
|
|
|
|
gpio40=$(check_gpio $GPIO40)
|
|
gpio41=$(check_gpio $GPIO41)
|
|
|
|
if [ "${gpio40}" -eq "0" ] && [ "${gpio41}" -eq "0" ]; then
|
|
echo "discharging"
|
|
elif [ "${gpio40}" -eq "0" ]; then
|
|
echo "full"
|
|
elif [ "${gpio41}" -eq "0" ]; then
|
|
echo "charging"
|
|
fi
|