The Things Network LoRaWAN Stack V3 学习笔记 2.4 使用 Packet Forward 让 LoRaWAN 网关接入

前言

应用创建好之后,先让 LoRaWAN 网关接入进来。本篇笔记使用树莓派 LoRaWAN 网关搭配 Packet Forward,做修改后接入到 Stack。

小能手这段时间在学习 The Things Network LoRaWAN Stack V3,从使用和代码等角度对该 Stack 进行了分析,详细可点此查看

1 网关端修改

PurposeProtocolAuthenticationPortPort (TLS)
Gateway dataSemtech Packet ForwarderNone1700 (UDP)N/A
Gateway dataMQTTAPI key, token18828882

我们先使用 Packet Forward 让网关接入,主要修改 IP 和 GWEUI,这些主要是在 local_conf.json 里调整。

{
 "gateway_conf": {
  "gateway_ID": "33800000A0000001",
  "server_address": "your_ip",
  "serv_port_up": 1700,
  "serv_port_down": 1700,
  "serv_enabled": true,
  "ref_latitude": 0,
  "ref_longitude": 0,
  "ref_altitude": 0 
 }
}

其他关于网关的CN470 频段等信息,可以在 global_conf.json 里调整。

2 网关接入日志

NS 上可以使用 netstat 查看下监听端口的打开情况。

# netstat -nua
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
udp        0      0 127.0.0.1:6969          0.0.0.0:*
udp        0      0 0.0.0.0:68              0.0.0.0:*
udp        0      0 172.20.0.1:123          0.0.0.0:*
udp        0      0 172.19.0.1:123          0.0.0.0:*
udp        0      0 172.18.0.1:123          0.0.0.0:*
udp        0      0 172.17.0.1:123          0.0.0.0:*
udp        0      0 10.0.8.5:123            0.0.0.0:*
udp        0      0 127.0.0.1:123           0.0.0.0:*
udp        0      0 0.0.0.0:123             0.0.0.0:*
udp6       0      0 :::1700                 :::*
udp6       0      0 :::2700                 :::*
udp6       0      0 :::123                  :::*

网关上线后在 NS 上会得到日志:

 DEBUG Run database query                       duration=2ms grpc_method=GetIden
tifiersForEUI grpc_service=ttn.lorawan.v3.GatewayRegistry namespace=db query=SELewaECT id, created_at, updated_at, gateway_id, gateway_eui FROM "gateways"  WHERE "
gateways"."deleted_at" IS NULL AND ((gateway_eui = $1)) ORDER BY "gateways"."id"
 ASC LIMIT 1 request_id=01D6SZGVKPBBNBVFPMC8MKXRYJ rows=1 source=gateway_store.g
o:115 values=[33800000A0000001]
  INFO Finished unary call                      duration=3.739592ms grpc_method=
GetIdentifiersForEUI grpc_service=ttn.lorawan.v3.GatewayRegistry namespace=grpc
request_id=01D6SZGVKPBBNBVFPMC8MKXRYJ
 DEBUG Finished unary call                      duration=4.471146ms grpc_method=
GetIdentifiersForEUI grpc_service=ttn.lorawan.v3.GatewayRegistry namespace=grpc
 DEBUG Run database query                       duration=2ms grpc_method=Get grp
c_service=ttn.lorawan.v3.GatewayRegistry namespace=db query=SELECT id, created_a
t, updated_at, gateway_id, gateway_eui, frequency_plan_id, schedule_downlink_lat
e, enforce_duty_cycle, downlink_path_constraint FROM "gateways"  WHERE "gateways
"."deleted_at" IS NULL AND ((gateway_id = $1) AND (gateway_eui = $2)) ORDER BY "
gateways"."id" ASC LIMIT 1 request_id=01D6SZGVKTAJ46Z1Y0JTRNT91E rows=1 source=g
ateway_store.go:115 values=[ttgtw1 33800000A0000001]
  INFO Finished unary call                      duration=3.249904ms grpc_method=
Get grpc_service=ttn.lorawan.v3.GatewayRegistry namespace=grpc request_id=01D6SZ
GVKTAJ46Z1Y0JTRNT91E
 DEBUG Finished unary call                      duration=3.686266ms grpc_method=
Get grpc_service=ttn.lorawan.v3.GatewayRegistry namespace=grpc
  INFO Connected                                gateway_eui=33800000A0000001 gat
eway_uid=ttgtw1 namespace=gatewayserver/io/udp 

断开的日志:

  WARN Downlink path expired                    gateway_eui=33800000A0000001 gateway_uid=ttgtw1 namespace=gatewayserver/io/udp
  WARN Connection expired                       gateway_eui=33800000A0000001 namespace=gatewayserver/io/udp
  INFO Disconnected                             gateway_eui=33800000A0000001 gateway_uid=ttgtw1 namespace=gatewayserver/io/udp

3 网关端的一些备忘

如果网关无法建立 socket,可以使用 nc 工具测试下网络情况。

$ nc -z -v -u your_ip 1700
found 0 associations
found 1 connections:
     1: flags=82<CONNECTED,PREFERRED>
 outif (null)
 src 10.70.84.139 port 52632
 dst your_ip port 1700
 rank info not available

Connection to your_ip port 1700 [udp/mps-raft] succeeded!

netstat 也是个不错的选择。

$ netstat -nua

END


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值