Skip to content

Instantly share code, notes, and snippets.

@yon2004
Created October 7, 2021 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yon2004/4ddf47ac079a6e8335be5d8bc9eaed7a to your computer and use it in GitHub Desktop.
Save yon2004/4ddf47ac079a6e8335be5d8bc9eaed7a to your computer and use it in GitHub Desktop.
[Unit]
Description=Lora BasicStation
After=syslog.target network.target
[Service]
SuccessExitStatus=143
#User=appuser
#Group=appgroup
Type=simple
WorkingDirectory=/opt/basicstation/bin/
ExecStart=/opt/basicstation/bin/station
ExecStop=/bin/kill -15 $MAINPID
[Install]
WantedBy=multi-user.target
#!/bin/sh
# This script is intended to be used on SX1301 LoraGoPort platform, it performs
# the following actions:
# - export/unpexort GPIO25 used to reset the SX1301 chip
#
# Usage examples:
# ./reset_lgw.sh stop
# ./reset_lgw.sh start
# GPIO mapping has to be adapted with HW
#
SX1301_RESET_PIN=25
WAIT_GPIO() {
sleep 0.1
}
init() {
# setup GPIOs
echo "$SX1301_RESET_PIN" > /sys/class/gpio/export; WAIT_GPIO
# set GPIOs as output
echo "out" > /sys/class/gpio/gpio$SX1301_RESET_PIN/direction; WAIT_GPIO
}
reset() {
echo "LoraGoPort reset through GPIO$SX1302_RESET_PIN..."
echo "1" > /sys/class/gpio/gpio$SX1301_RESET_PIN/value; WAIT_GPIO
echo "0" > /sys/class/gpio/gpio$SX1301_RESET_PIN/value; WAIT_GPIO
}
term() {
# cleanup all GPIOs
if [ -d /sys/class/gpio/gpio$SX1301_RESET_PIN ]
then
echo "$SX1301_RESET_PIN" > /sys/class/gpio/unexport; WAIT_GPIO
fi
}
case "$1" in
start)
term # just in case
init
reset
;;
stop)
reset
term
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac
exit 0
sudo cp -r basicstation/build-rpi-std/* /opt/basicstation/
sudo nano /etc/systemd/system/basicstation.service
sudo systemctl daemon-reload
sudo systemctl enable basicstation.service
sudo systemctl start basicstation.service
{
/* If slave-X.conf present this acts as default settings */
"SX1301_conf": { /* Actual channel plan is controlled by server */
"lorawan_public": true, /* is default */
"clksrc": 1, /* radio_1 provides clock to concentrator */
/* path to the SPI device, un-comment if not specified on the command line e.g., RADIODEV=/dev/spidev0.0 */
"device": "/dev/spidev0.0",
/* freq/enable provided by LNS - only HW specific settings listed here */
"radio_0": {
"type": "SX1257",
"rssi_offset": -166.0,
"tx_enable": true,
"antenna_gain": 0
},
"radio_1": {
"type": "SX1257",
"rssi_offset": -166.0,
"tx_enable": false
}
/* chan_multiSF_X, chan_Lora_std, chan_FSK provided by LNS */
},
"station_conf": {
"log_file": "stderr",
"log_level": "NOTICE", /* XDEBUG,DEBUG,VERBOSE,INFO,NOTICE,WARNING,ERROR,CRITICAL */
"log_size": 10000000,
"log_rotate": 3,
"CUPS_RESYNC_INTV": "1s",
"routerid": "aaaaaafffeaaaaaa",
"radio_init": "./reset_lgw.sh start",
"RADIO_INIT_WAIT": "1s",
"gps": "/dev/ttyAMA0",
"pps": "gps"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment