LoRaServer 笔记 1.3 源码编译

前言

本篇笔记介绍如何进行几个组件的源码编译,对实际编译过程中的一些问题也做了记录。

小能手最近在学习 LoRa Server 项目,应该是最有影响力的 LoRaWAN 服务器开源项目。它组件丰富,代码可读性强,是个很好的学习资料。更多学习笔记,可点此查看

整个开源项目还是用 GO 编译,因此需要安装基础的 Go 环境。

另外整个编译过程绝对还是会出现包被墙的情况,9102年了,GO 1.11 有个 moudule 可以很方便的处理这些情况。大家可以处理下 go.mod 的文件,具体在我另一篇笔记中有记录,The Things Network LoRaWAN Stack V3 学习笔记 1.2 源码编译

1 LoRa Gateway Bridge

git clone https://github.com/brocaar/lora-gateway-bridge
cd lora-gateway-bridge/
make dev-requirements
make build
./build/lora-gateway-bridge configfile > lora-gateway-bridge.toml

2 LoRa Server

git clone https://github.com/brocaar/loraserver
cd loraserver/
make dev-requirements
make build

2.1 go-bindata 的安装

我们在 make build 时可能会遇到 缺少 go-bindata 的问题:

# make build
Generating static files
internal/migrations/migrations.go:1: running "go-bindata": exec: "go-bindata": executable file not found in $PATH
make: *** [statics] Error 1
go get -u github.com/jteeuwen/go-bindata/...

安装完了之后可能会找不到go-bindata,提示错误:“-bash: /usr/bin/go-bindata: No such file or directory”。原因在于由于没有定义GOBIN目录,它会自动安装到GOPATH\bin目录下。去那里找找。

找到之后,在PATH里面追加go-bindata的路径。

#通过命令行加入GOBIN的PATH
export PATH=$PATH:$GOPATH/bin

3 LoRa App Server

AS 需要 Node.js 和 Go protocol buffer

git clone https://github.com/brocaar/lora-app-server
cd lora-app-server/
make dev-requirements ui-requirements
make clean
make build

3.1 make api 时 protoc 的安装

如果调整了 .proto 文件,那就需要 make api 处理下,否则可以跳过这一步。当前的 api 的目录下

make api 时遇到了问题,没有找到 protoc 命令。

# make api
Generating API code from .proto files
go: downloading github.com/golang/appengine v1.6.0
go: extracting github.com/golang/appengine v1.6.0
gen.sh: line 10: protoc: command not found
gen.sh: line 28: protoc: command not found
gen.sh: line 46: protoc: command not found

安装之:

PROTOC_ZIP=protoc-3.7.1-linux-x86_64.zip
curl -OL https://github.com/google/protobuf/releases/download/v3.7.1/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
rm -f $PROTOC_ZIP

END


  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值