Skip to content

Instantly share code, notes, and snippets.

@yon2004
Last active April 9, 2025 05:31
Show Gist options
  • Select an option

  • Save yon2004/4ddf47ac079a6e8335be5d8bc9eaed7a to your computer and use it in GitHub Desktop.

Select an option

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/bash
# Define the GPIO pin for SX1301 reset (adjust this to your actual GPIO pin)
SX1301_RESET_PIN=25
# Function to initialize GPIO
init() {
echo "Setting up GPIO$SX1301_RESET_PIN as output..."
# No need to export/unexport with libgpiod; just set the pin as output
}
# Function to reset the LoRa module
reset() {
echo "LoRaGoPort reset through GPIO$SX1301_RESET_PIN..."
# Set GPIO to high (1)
echo "1"
gpioset gpiochip0 $SX1301_RESET_PIN=1
sleep 0.1 # Short delay to ensure the reset signal is registered
# Set GPIO to low (0)
echo "0"
gpioset gpiochip0 $SX1301_RESET_PIN=0
sleep 0.1 # Short delay after reset
}
# Function to clean up GPIO
term() {
echo "Cleaning up GPIO$SX1301_RESET_PIN..."
# Set the pin to input mode to "release" it (optional)
echo "Setting $SX1301_RESET_PIN to input mode..."
# No direct unexport equivalent in libgpiod, but we can set it to 0
gpioset gpiochip0 $SX1301_RESET_PIN=0
}
# Main script logic
case "$1" in
start)
# Just in case, initialize and reset
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/Serial0",
"pps": "gps"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment