Add reset daemon for cameras with gpio buttons (#718)

Co-authored-by: jayfan0 <>
pull/731/head
jayfan0 2023-04-15 15:35:38 +01:00 committed by GitHub
parent 1200a1bef0
commit 56b39ddb45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,8 @@
#!/bin/sh
case "$1" in
start)
echo -e '\nLoading resetd...'
/usr/sbin/resetd &
;;
esac

View File

@ -0,0 +1,33 @@
#!/bin/sh
# Set Reset switch GPIO
GPIO=
[ -z $GPIO ] && echo "GPIO not set. Exiting" && echo "[resetd] GPIO undefined in /usr/sbin/resetd" > /dev/kmsg && exit
# Counter for button press until reset
count=0
# prepare the pin
if [ ! -d /sys/class/gpio/gpio${GPIO} ]; then
echo "${GPIO}" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio"${GPIO}"/direction
fi
# continuously monitor current value of reset switch
while [ true ]
do
if [ "$(cat /sys/class/gpio/gpio"${GPIO}"/value)" -eq 1 ]; then
count=0
else
count=$((count+1))
# 20 counts =~ 5 seconds @ 0.25 sleep intervals
if [ $count -eq 20 ]; then
echo 'RESETTING FIRMWARE'
firstboot
fi
fi
# This interval uses 1% CPU. Less sleep = more CPU
sleep 0.25
done