hardware reset fixes

This commit is contained in:
justmarvinn 2025-05-05 23:26:44 +02:00
parent 95b9f4cb63
commit 33d22addae
5 changed files with 40 additions and 33 deletions

View File

@ -1,3 +1,11 @@
## Dependencies
### Ubuntu
```SHELL
sudo apt remove -y inetutils-ping
sudo apt install -y ppp iputils-ping
```
## Install
### Ubuntu
@ -9,27 +17,17 @@ curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/main/install.sh" |
- Start & enable on startup
```SHELL
sudo systemctl start sim800
sudo systemctl enable sim800
sudo systemctl start sim800-healthcheck.timer
sudo systemctl enable sim800-healthcheck.timer
```
- Stop
- Stop & disable on startup
```SHELL
sudo systemctl stop sim800
sudo systemctl stop sim800-healthcheck.timer
sudo systemctl disable sim800-healthcheck.timer
```
- Restart
- Restart immediately
```SHELL
sudo systemctl restart sim800
```
## Dependencies
### Ubuntu
```SHELL
sudo apt remove -y inetutils-ping
sudo apt install -y ppp iputils-ping
```

View File

@ -2,11 +2,11 @@
[Unit]
Description=SIM800 healthcheck timer
After=sim800.service
After=rc-local.service
[Timer]
OnBootSec=1min
OnUnitActiveSec=1m
OnBootSec=2min
OnUnitActiveSec=2m
[Install]
WantedBy=timers.target

View File

@ -24,7 +24,3 @@ curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/main/healthcheck-s
curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/main/healthcheck-timer" > /etc/systemd/system/sim800-healthcheck.timer
chmod +x /etc/init.d/sim800c
systemctl enable sim800
systemctl start sim800
systemctl enable sim800-healthcheck
systemctl start sim800-healthcheck

37
script
View File

@ -2,34 +2,47 @@
# /etc/init.d/sim800c
INTERFACE_NAME=ppp0
# see https://wiki.luckfox.com/Luckfox-Pico/Luckfox-Pico-GPIO for details
PIN_NUMBER=34
case "$1" in
start)
# echo "AT+CFUN=1,1" > /dev/ttyS3
# sleep 3
# echo "AT+IPR=115200" > /dev/ttyS3
# sleep 1
if ip link show $INTERFACE_NAME > /dev/null 2>&1; then
echo "Interface $INTERFACE_NAME already exists"
exit 1
fi
if [ ! -d "/sys/class/gpio/gpio{PIN_NUMBER}" ]; then
echo $PIN_NUMBER > /sys/class/gpio/export
fi
echo out > "/sys/class/gpio/gpio$PIN_NUMBER/direction"
echo 1 > "/sys/class/gpio/gpio$PIN_NUMBER/active_low"
echo 1 > "/sys/class/gpio/gpio$PIN_NUMBER/value"
pon sim800c
;;
stop)
poff sim800c
# sleep 3
# echo "+++" > /dev/ttyS3
# sleep 3
# echo "AT+CFUN=1,1" > /dev/ttyS3
# sleep 3
echo 0 > "/sys/class/gpio/gpio$PIN_NUMBER/value"
echo $PIN_NUMBER > /sys/class/gpio/unexport
;;
restart|reload)
$0 stop
sleep 1
sleep 10
$0 start
;;
healthcheck)
if ! ping -I ppp0 -c 5 -W 5 1.1.1.1 > /dev/null; then
# DNS names also available
PUBLIC_ADDR=1.1.1.1
PACKET_COUNT=5
TIMEOUT=10
if ! ping -I $INTERFACE_NAME -c $PACKET_COUNT -W $TIMEOUT $PUBLIC_ADDR > /dev/null 2>&1; then
echo "Healthcheck failed"
systemctl restart sim800
systemctl restart sim800.service
# $0 restart
exit 1
else
echo "Healthcheck passed"

View File

@ -6,9 +6,9 @@ After=rc-local.service
[Service]
Type=forking
# PIDFile=/run/ppp0.pid
ExecStart=/etc/init.d/sim800c start
ExecStop=/etc/init.d/sim800c stop
# PIDFile=/run/ppp0.pid
# Restart=on-failure
# RestartSec=5s