67 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			67 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
| # Packet Forwarder
 | |
| 
 | |
| SSH to the Raspberry Pi.
 | |
| 
 | |
| Run `raspi-config` and
 | |
| 
 | |
| - Enable SPI
 | |
| - Enable I2C
 | |
| - Turn off login shell but keep serial port active
 | |
| - Reboot
 | |
| 
 | |
| Clone the packet forwarder repository: `git clone https://github.com/Lora-net/sx1302_hal.git`.
 | |
| 
 | |
| Go into the repo and run `make`.
 | |
| 
 | |
| Make pf user + give permissions
 | |
| 
 | |
| - `sudo useradd -m -s /usr/sbin/nologin pf`
 | |
|   - `-m`: create home
 | |
|   - `-s /usr/sbin/nologin`: don't allow logging in; the user's only purpose is to own the packet forwarder process
 | |
|   - `pf`: the username
 | |
| - `sudo usermod -aG gpio,spi,i2c,dialout pf`
 | |
| 
 | |
| From the packet forwarder repo, copy files to pf user's home and set permissions:
 | |
| 
 | |
| ```sh
 | |
| sudo cp packet_forwarder/{global_conf.json.sx1250.US915,lora_pkt_fwd} /home/pf
 | |
| sudo cp tools/reset_lgw.sh /home/pf
 | |
| sudo chown pf:pf /home/pf/{global_conf.json.sx1250.US915,lora_pkt_fwd,reset_lgw.sh}
 | |
| sudo chmod +x /home/pf/{lora_pkt_fwd,reset_lgw.sh}
 | |
| ```
 | |
| 
 | |
| Modify the packet forward config at `/home/pf/global_conf.json.sx1250.US915`. Change `gateway_ID` to something nice (????). 8 bytes (16 uppercase hex characters)
 | |
| 
 | |
| Modify the `reset_lgw.sh` file to have the following GPIO values, [ref](https://wiki.seeedstudio.com/WM1302_module/#step4-run-semtech-sx1302-packet-forwarder):
 | |
| 
 | |
| ```sh
 | |
| SX1302_RESET_PIN=17     # SX1302 reset
 | |
| SX1302_POWER_EN_PIN=18  # SX1302 power enable
 | |
| SX1261_RESET_PIN=5     # SX1261 reset (LBT / Spectral Scan)
 | |
| AD5338R_RESET_PIN=13    # AD5338R reset (full-duplex CN490 reference design)
 | |
| ```
 | |
| 
 | |
| Create SystemD unit file at `/etc/systemd/system/packet-forwarder.service`:
 | |
| 
 | |
| ```systemd
 | |
| [Unit]
 | |
| Description=SX1302 Packet Forwarder
 | |
| After=network.target
 | |
| StartLimitIntervalSec=0
 | |
| 
 | |
| [Service]
 | |
| Type=simple
 | |
| Restart=always
 | |
| RestartSec=1
 | |
| User=pf
 | |
| WorkingDirectory=/home/pf
 | |
| ExecStart=/home/pf/lora_pkt_fwd -c global_conf.json.sx1250.US915
 | |
| 
 | |
| [Install]
 | |
| WantedBy=multi-user.target
 | |
| ```
 | |
| 
 | |
| Start and enable `sudo systemctl enable --now packet-forwarder.service`.
 | |
| 
 | |
| Check that it is running with `sudo systemctl status packet-forwarder.service`.
 |