前置步骤
-
安装Go环境
Golang官网,下载go语言的安装包 (go1.13.5.linux-amd64.tar.gz)
解压:sudo tar -zvxf go1.13.5.linux-amd64.tar.gz -C /usr/local配置环境:
在以下文件中加入相关配置/etc/environment : export GOPATH=$HOME/Lora /etc/profile : export GOROOT=/usr/local/go #设置为go安装的路径 export GOPATH=$HOME/Lora export PATH=$PATH:$GOROOT/bin:$GOPATH/bin #添加完之后 source /etc/profile #然后在GOPATH路径中新建目录:/bin,/src,/pkg cd ~/Lora mkdir bin src pkg
-
安装mosquitto,redis,postgresql并添加相应数据库
可参照官网#安装mosquitto,redis,postgresql sudo apt install mosquitto mosquitto-clients redis-server redis-tools postgresql
#添加用户和数据库 sudo -u postgres psql #-- set up the users and the passwords #-- (note that it is important to use single quotes and a semicolon at the end!) create role chirpstack_as with login password 'dbpassword'; create role chirpstack_ns with login password 'dbpassword'; #-- create the database for the servers create database chirpstack_as with owner chirpstack_as; create database chirpstack_ns with owner chirpstack_ns; #-- change to the ChirpStack Application Server database \c chirpstack_as #-- enable the pq_trgm and hstore extensions #-- (this is needed to facilitate the search feature) create extension pg_trgm; #-- (this is needed to store additional k/v meta-data) create extension hstore; #-- exit psql \q
源码编译安装
1.chirpstack-gateway-bridge
cd ~/Lora/src
git clone https://github.com/brocaar/chirpstack-gateway-bridge
cd chirpstack-gateway-bridge/
make dev-requirements
make build
生成配置文件
cd build
./chirpstack-gateway-bridge configfile > chirpstack-gateway-bridge.toml
2.chirpstack-network-server
cd ~/Lora/src
git clone https://github.com/brocaar/chirpstack-network-server
cd chirpstack-network-server/
make dev-requirements
make build
生成配置文件
cd build
./chirpstack-network-server configfile > chirpstack-network-server.toml
3.chirpstack-application-server
编译chirpstack-application-server需要node.js
cd ~/Lora/src
git clone https://github.com/brocaar/chirpstack-application-server
cd chirpstack-application-server/
make dev-requirements ui-requirements
make build
生成配置文件
cd build
./chirpstack-application-server configfile > chirpstack-application-server.toml
在make build的过程中,我遇到如下问题:
Creating an optimized production build...
Failed to compile.
./src/components/DataTable.js
Line 83:29: Parsing error: JSX value should be either an expression or a quoted JSX text
81 | <Table
82 | className={this.props.classes.table}
> 83 | rowsPerPageOptions=[10, 25, 50, 100, 200, 500]>
| ^
84 | <TableHead>
85 | {this.props.header}
86 | </TableHead>
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! chirpstack-application-server-ui@3.0.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the chirpstack-application-server-ui@3.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Makefile:41: recipe for target 'ui/build' failed
make: *** [ui/build] Error 1
这是由于JSX语法问题导致的。只需给该数组套个大括号,然后重新build即可:
#在chirpstack-application-server/ui/src/components/DataTable.js找到错误的部分,并修改
rowsPerPageOptions={[10, 25, 50, 100, 200, 500]}>
#然后回到chirpstack-application-server目录,重新build
make clean
make build
相关配置
-
chirpstack-network-server.toml
#设置连接数据库的用户和密码(前置步骤2中配置的用户和密码) [postgresql] dsn="postgres://chirpstack_ns:dbpassword@localhost/chirpstack_ns?sslmode=disable" #设置地区参数 [network_server.band] name="CN_470_510"
-
chirpstack-application-server.toml
#设置连接数据库的用户和密码(前置步骤2中配置的用户和密码) [postgresql] dsn="postgres://chirpstack_as:dbpassword@localhost/chirpstack_as?sslmode=disable" #设置jwt密钥 [application_server.external_api] jwt_secret="verysecret"