网关接入之后,再让节点接入。本篇笔记重点记录一些小坑,注意跳过。
小能手这段时间在学习 The Things Network LoRaWAN Stack V3,从使用和代码等角度对该 Stack 进行了分析,详细可点此查看。
LoRa节点目前还是拿商用模组来做测试,我手上拿的是四信的F8L10D,串口操作直接调整下 DevEUI/AppKEY/AppEUI 。
发起加网之后,NS 上会看到日志。
DEBUG Synchronized gateway time gateway_eui=33800000A0000001 gat
eway_uid=ttgtw1 namespace=gatewayserver/io/udp time=2019-03-28 18:48:58.22907294
+0800 CST m=-729.155054651 timestamp=821789556
DEBUG Deduplicating uplink... grpc_method=HandleUplink grpc_se
rvice=ttn.lorawan.v3.GsNs namespace=grpc request_id=01D71ZEN4KGQNG0147PQV3CWDT
DEBUG Handling join-request... grpc_method=HandleUplink grpc_se
rvice=ttn.lorawan.v3.GsNs namespace=grpc request_id=01D71ZEN4KGQNG0147PQV3CWDT
DEBUG Sending join-request to Join Server... dev_addr=01D7F0E1 dev_eui=3304A3
0B001C0530 device_uid=ttapp1.ttdev1 grpc_method=HandleUplink grpc_service=ttn.lo
rawan.v3.GsNs join_eui=800000000000000C namespace=grpc request_id=01D71ZEN4KGQNG
0147PQV3CWDT
INFO Finished unary call duration=2.809079ms grpc_method=
HandleJoin grpc_service=ttn.lorawan.v3.NsJs namespace=grpc request_id=01D71ZEN4N
16RQP763G092EAZR
DEBUG Finished unary call duration=3.312379ms grpc_method=
HandleJoin grpc_service=ttn.lorawan.v3.NsJs namespace=grpc request_id=01D71ZEN4K
GQNG0147PQV3CWDT
DEBUG Join-accept received from Join Server dev_addr=01D7F0E1 dev_eui=3304A3
0B001C0530 device_uid=ttapp1.ttdev1 grpc_method=HandleUplink grpc_service=ttn.lo
rawan.v3.GsNs join_eui=800000000000000C namespace=grpc request_id=01D71ZEN4KGQNG
0147PQV3CWDT
DEBUG Sending join-accept to AS... application_uid=ttapp1 dev_addr=
01D7F0E1 dev_eui=3304A30B001C0530 device_uid=ttapp1.ttdev1 grpc_method=HandleUpl
ink grpc_service=ttn.lorawan.v3.GsNs join_eui=800000000000000C namespace=grpc re
quest_id=01D71ZEN4KGQNG0147PQV3CWDT
DEBUG Received AppSKey from Network Server application_uid=ttapp1 dev_eui=3
304A30B001C0530 device_uid=ttapp1.ttdev1 join_eui=800000000000000C session_key_i
d=0169C3F75496FFD517CC95095989F5B5
DEBUG Waiting for collection window to be closed... grpc_method=HandleUplink gr
pc_service=ttn.lorawan.v3.GsNs namespace=grpc request_id=01D71ZEN4KGQNG0147PQV3C
WDT
DEBUG Processing downlink task... delay=2.249289ms device_uid=ttap
p1.ttdev1 start_at=2019-03-28 11:02:40.2244995 +0000 UTC
DEBUG Scheduling downlink... attempt_rx1=true attempt_rx2=tru
e delay=2.249289ms device_class=CLASS_A device_uid=ttapp1.ttdev1 downlink_class=
CLASS_A downlink_type=join-accept path_count=1 rx1_delay=5 rx1_frequency=5003000
00 rx2_data_rate=0 rx2_frequency=505300000 start_at=2019-03-28 11:02:40.2244995
+0000 UTC
DEBUG Scheduling downlink class=CLASS_A gateway_eui=338000
00A0000001 gateway_uid=ttgtw1 namespace=gatewayserver/io/udp
DEBUG Scheduled downlink class=CLASS_A data_rate=3 durati
on=164.864ms frequency=500300000 gateway_eui=33800000A0000001 gateway_uid=ttgtw1
namespace=gatewayserver/io/udp rx_window=1 starts=826789556000
DEBUG Dropping message dev_eui=3304A30B001C0530 error=e
rror:pkg/redis:not_found (entity not found) gateway_eui=33800000A0000001 gateway
_uid=ttgtw1 join_eui=7538904770366680 namespace=gatewayserver/io/udp
检查节点 AppEUI,需要和 CLI 注册的节点信息保持一致。
AppEui= 75-38-90-47-70-36-66-80
INFO: Received pkt from mote: 0000000C (fcnt=0)
JSON up: {"rxpk":[{"tmst":50967924,"chan":5,"rfch":0,"freq":470.500000,"stat":1,"modu":"LORA","datr":"SF9BW125","codr":"4/5","lsnr":12.0,"rssi":-95,"size":23,"data":"AAwAAAAAAACAMAUcAAujBDOGM03p00s="}]}
INFO: [up] PUSH_ACK received in 8 ms
INFO: [down] PULL_RESP received - token[0:20] :)
JSON down: {"txpk":{"imme":false,"tmst":55967924,"freq":500.5,"brd":0,"ant":0,"rfch":0,"powe":17,"modu":"LORA","datr":"SF9BW125","codr":"4/5","ipol":true,"size":17,"ncrc":true,"data":"IFLv2WuO9RobkkZGScaRIdc="}}
ERROR: Packet REJECTED, unsupported RF power for TX - 17
INFO: [down] PULL_ACK received in 9 ms
这个问题可以在 packet forwarder 源码中找到答案。
/* parse TX power (optional field) */
val = json_object_get_value(txpk_obj,"powe");
if (val != NULL) {
txpkt.rf_power = (int8_t)json_value_get_number(val) - antenna_gain;
}
...
if (jit_result == JIT_ERROR_OK) {
for (i=0; i<txlut.size; i++) {
if (txlut.lut[i].rf_power == txpkt.rf_power) {
/* this RF power is supported, we can continue */
break;
}
}
if (i == txlut.size) {
/* this RF power is not supported */
jit_result = JIT_ERROR_TX_POWER;
MSG("ERROR: Packet REJECTED, unsupported RF power for TX - %d\n", txpkt.rf_power);
}
}
所以可以修改 global_conf.json 里头的 “antenna_gain” 或者 其中 tx gain table 里的 “rf_power”字段,使之满足 17 。这点挺蛋疼的,后续频点计划由 NS 来控制的话,就会好一点。