hardware reset fixes
This commit is contained in:
parent
95b9f4cb63
commit
33d22addae
24
README.md
24
README.md
|
|
@ -1,3 +1,11 @@
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
### Ubuntu
|
||||||
|
```SHELL
|
||||||
|
sudo apt remove -y inetutils-ping
|
||||||
|
sudo apt install -y ppp iputils-ping
|
||||||
|
```
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
### Ubuntu
|
### Ubuntu
|
||||||
|
|
@ -9,27 +17,17 @@ curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/main/install.sh" |
|
||||||
|
|
||||||
- Start & enable on startup
|
- Start & enable on startup
|
||||||
```SHELL
|
```SHELL
|
||||||
sudo systemctl start sim800
|
|
||||||
sudo systemctl enable sim800
|
|
||||||
sudo systemctl start sim800-healthcheck.timer
|
sudo systemctl start sim800-healthcheck.timer
|
||||||
sudo systemctl enable sim800-healthcheck.timer
|
sudo systemctl enable sim800-healthcheck.timer
|
||||||
```
|
```
|
||||||
|
|
||||||
- Stop
|
- Stop & disable on startup
|
||||||
```SHELL
|
```SHELL
|
||||||
sudo systemctl stop sim800
|
|
||||||
sudo systemctl stop sim800-healthcheck.timer
|
sudo systemctl stop sim800-healthcheck.timer
|
||||||
|
sudo systemctl disable sim800-healthcheck.timer
|
||||||
```
|
```
|
||||||
|
|
||||||
- Restart
|
- Restart immediately
|
||||||
```SHELL
|
```SHELL
|
||||||
sudo systemctl restart sim800
|
sudo systemctl restart sim800
|
||||||
```
|
```
|
||||||
|
|
||||||
## Dependencies
|
|
||||||
|
|
||||||
### Ubuntu
|
|
||||||
```SHELL
|
|
||||||
sudo apt remove -y inetutils-ping
|
|
||||||
sudo apt install -y ppp iputils-ping
|
|
||||||
```
|
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=SIM800 healthcheck timer
|
Description=SIM800 healthcheck timer
|
||||||
After=sim800.service
|
After=rc-local.service
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnBootSec=1min
|
OnBootSec=2min
|
||||||
OnUnitActiveSec=1m
|
OnUnitActiveSec=2m
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=timers.target
|
WantedBy=timers.target
|
||||||
|
|
|
||||||
|
|
@ -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
|
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
|
chmod +x /etc/init.d/sim800c
|
||||||
systemctl enable sim800
|
|
||||||
systemctl start sim800
|
|
||||||
systemctl enable sim800-healthcheck
|
|
||||||
systemctl start sim800-healthcheck
|
|
||||||
|
|
|
||||||
37
script
37
script
|
|
@ -2,34 +2,47 @@
|
||||||
|
|
||||||
# /etc/init.d/sim800c
|
# /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
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
# echo "AT+CFUN=1,1" > /dev/ttyS3
|
if ip link show $INTERFACE_NAME > /dev/null 2>&1; then
|
||||||
# sleep 3
|
echo "Interface $INTERFACE_NAME already exists"
|
||||||
# echo "AT+IPR=115200" > /dev/ttyS3
|
exit 1
|
||||||
# sleep 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
|
pon sim800c
|
||||||
;;
|
;;
|
||||||
|
|
||||||
stop)
|
stop)
|
||||||
poff sim800c
|
poff sim800c
|
||||||
# sleep 3
|
echo 0 > "/sys/class/gpio/gpio$PIN_NUMBER/value"
|
||||||
# echo "+++" > /dev/ttyS3
|
echo $PIN_NUMBER > /sys/class/gpio/unexport
|
||||||
# sleep 3
|
|
||||||
# echo "AT+CFUN=1,1" > /dev/ttyS3
|
|
||||||
# sleep 3
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
restart|reload)
|
restart|reload)
|
||||||
$0 stop
|
$0 stop
|
||||||
sleep 1
|
sleep 10
|
||||||
$0 start
|
$0 start
|
||||||
;;
|
;;
|
||||||
|
|
||||||
healthcheck)
|
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"
|
echo "Healthcheck failed"
|
||||||
systemctl restart sim800
|
systemctl restart sim800.service
|
||||||
|
# $0 restart
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "Healthcheck passed"
|
echo "Healthcheck passed"
|
||||||
|
|
|
||||||
2
service
2
service
|
|
@ -6,9 +6,9 @@ After=rc-local.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=forking
|
Type=forking
|
||||||
# PIDFile=/run/ppp0.pid
|
|
||||||
ExecStart=/etc/init.d/sim800c start
|
ExecStart=/etc/init.d/sim800c start
|
||||||
ExecStop=/etc/init.d/sim800c stop
|
ExecStop=/etc/init.d/sim800c stop
|
||||||
|
# PIDFile=/run/ppp0.pid
|
||||||
# Restart=on-failure
|
# Restart=on-failure
|
||||||
# RestartSec=5s
|
# RestartSec=5s
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user