You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.1 KiB
58 lines
1.1 KiB
|
8 years ago
|
#!/bin/sh
|
||
|
|
#
|
||
|
|
# Starts Lora packet forwarder
|
||
|
|
#
|
||
|
|
|
||
|
|
# Allow a few customizations from a config file
|
||
|
|
test -r /etc/default/packet-forwarder && . /etc/default/packet-forwarder
|
||
|
|
|
||
|
|
reset_sx1301() {
|
||
|
|
echo "$SX1301_RESET_BCM_PIN" > /sys/class/gpio/export
|
||
|
|
echo "out" > /sys/class/gpio/gpio$SX1301_RESET_BCM_PIN/direction
|
||
|
|
echo "0" > /sys/class/gpio/gpio$SX1301_RESET_BCM_PIN/value
|
||
|
|
sleep 0.1
|
||
|
|
echo "1" > /sys/class/gpio/gpio$SX1301_RESET_BCM_PIN/value
|
||
|
|
sleep 0.1
|
||
|
|
echo "0" > /sys/class/gpio/gpio$SX1301_RESET_BCM_PIN/value
|
||
|
|
sleep 0.1
|
||
|
|
echo "$SX1301_RESET_BCM_PIN" > /sys/class/gpio/unexport
|
||
|
|
}
|
||
|
|
|
||
|
|
start() {
|
||
|
|
printf "Starting LoRa packet forwarder: "
|
||
|
|
umask 077
|
||
|
|
|
||
|
|
reset_sx1301
|
||
|
|
|
||
|
|
cd /etc/ttn
|
||
|
|
start-stop-daemon -S -b -q -p /var/run/packet-forwarder.pid \
|
||
|
|
--exec /usr/bin/poly_pkt_fwd -- $PACKETFORWARDER_ARGS
|
||
|
|
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||
|
|
}
|
||
|
|
stop() {
|
||
|
|
printf "Stopping LoRa packet forwarder: "
|
||
|
|
start-stop-daemon -K -q -p /var/run/packet-forwarder.pid
|
||
|
|
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||
|
|
}
|
||
|
|
restart() {
|
||
|
|
stop
|
||
|
|
start
|
||
|
|
}
|
||
|
|
|
||
|
|
case "$1" in
|
||
|
|
start)
|
||
|
|
start
|
||
|
|
;;
|
||
|
|
stop)
|
||
|
|
stop
|
||
|
|
;;
|
||
|
|
restart|reload)
|
||
|
|
restart
|
||
|
|
;;
|
||
|
|
*)
|
||
|
|
echo "Usage: $0 {start|stop|restart}"
|
||
|
|
exit 1
|
||
|
|
esac
|
||
|
|
|
||
|
|
exit $?
|