ChirpStack LoRaWAN 服务器使用笔记
## 网络结构
ChirpStack 是一款开源的 LoRaWAN 服务器,由 chirpstack-gateway-bridge、chirpstack-network-server、chirpstack-application-server 等部件组成,是用 Go 语言开发的。
!(https://file.mculoop.com/images/2022/10/28/clipboard.png)
<!--more-->
## 安装依赖
```
sudo apt install mosquitto
sudo apt install postgresql postgresql-contrib
sudo apt install redis-server
```
mosquitto 装好后会自动启动 /snap/mosquitto/704/launcher.sh,不要通过服务启动。
配置数据库
```
sudo -u postgres psql
```
**NS 数据库:**
```
create role chirpstack_ns with login password 'dbpassword';
create database chirpstack_ns with owner chirpstack_ns;
```
**AS 数据库:**
```
create role chirpstack_as with login password 'dbpassword';
create database chirpstack_as with owner chirpstack_as;
\c chirpstack_as
create extension pg_trgm;
create extension hstore;
-- exit the prompt
\q
```
**测试数据库:**
```
psql -h localhost -U chirpstack_ns -W chirpstack_ns
```
**添加源:**
```
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1CE2AFD36DBCCA00
sudo echo "deb https://artifacts.chirpstack.io/packages/3.x/deb stable main" | sudo tee /etc/apt/sources.list.d/chirpstack.list
sudo apt update
```
## 安装 Gateway Bridge
```
sudo apt install chirpstack-gateway-bridge
```
> The configuration file is located at:
>
>/etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml
>
> Some helpful commands for chirpstack-gateway-bridge:
>
> Start:
>
>$ sudo systemctl start chirpstack-gateway-bridge
>
> Restart:
>
>$ sudo systemctl restart chirpstack-gateway-bridge
>
> Stop:
>
>$ sudo systemctl stop chirpstack-gateway-bridge
>
> Display logs:
>
>$ sudo journalctl -f -n 100 -u chirpstack-gateway-bridge
```
sudo systemctl start chirpstack-gateway-bridge
```
## 安装 NS(网络服务器)
```
sudo apt install chirpstack-network-server
```
> The configuration file is located at:
>
>/etc/chirpstack-network-server/chirpstack-network-server.toml
>
> Some helpful commands for chirpstack-network-server:
>
> Start:
>
>$ sudo systemctl start chirpstack-network-server
>
> Restart:
>
>$ sudo systemctl restart chirpstack-network-server
>
> Stop:
>
>$ sudo systemctl stop chirpstack-network-server
>
> Display logs:
>
>$ sudo journalctl -f -n 100 -u chirpstack-network-server
**日志:**
```
tail -f /var/log/chirpstack-network-server/chirpstack-network-server.log
```
**修改配置文件:**
```
/etc/chirpstack-network-server/chirpstack-network-server.toml
dsn="postgres://localhost/chirpstack_ns_ns?sslmode=disable"
改为:
dsn="postgres://chirpstack_ns:dbpassword@localhost/chirpstack_ns?sslmode=disable"
sudo systemctl start chirpstack-network-server
```
## 安装 AS(应用服务器)
```
sudo apt-get install chirpstack-application-server
```
> The configuration file is located at:
>
>/etc/chirpstack-application-server/chirpstack-application-server.toml
>
> Some helpful commands for chirpstack-application-server:
>
> Start:
>
>$ sudo systemctl start chirpstack-application-server
>
> Restart:
>
>$ sudo systemctl restart chirpstack-application-server
>
> Stop:
>
>$ sudo systemctl stop chirpstack-application-server
>
> Display logs:
>
>$ sudo journalctl -f -n 100 -u chirpstack-application-server
**修改配置文件:**
```
/etc/chirpstack-application-server/chirpstack-application-server.toml
dsn="postgres://localhost/chirpstack_as?sslmode=disable"
改为:
dsn="postgres://chirpstack_as:dbpassword@localhost/chirpstack_as?sslmode=disable"
```
使用命令 `openssl rand -base64 32` 生成 `jwt_secret`
配置文件中的默认 WebUI 端口是 8080(NS 没有 WebUI)。
```
sudo systemctl start chirpstack-application-server
```
**打开WebUI:**
http://192.168.88.130:8080/
默认用户 admin,密码:admin
页:
[1]