前言
目前 Stack 在 CN470 采用的是 FSB_11 子频段,手头的网关大多使用 FSB_1,本篇笔记演示如何为 Stack 新增一个子频段。
小能手这段时间在学习 The Things Network LoRaWAN Stack V3,从使用和代码等角度对该 Stack 进行了分析,详细可点此查看。
1 现有的频段处理
TTN 默认是抓取了自己的 github 仓库。
// DefaultFrequencyPlansConfig is the default config to retrieve frequency plans.
var DefaultFrequencyPlansConfig = config.FrequencyPlansConfig{
URL: "https://raw.githubusercontent.com/TheThingsNetwork/lorawan-frequency-plans/master",
}
2 Fork仓库进行修改
Fork 了 TTN 的仓库来做修改,主要是新增 CN_470_510_FSB_1.yml,并且在 frequency-plans.yml 进行登记。
https://github.com/twowinter/lorawan-frequency-plans/commit/050223fc9981095e31ef6d13ebd02dd3acb1df5d
3 stack 配置环境变量
将频点计划的 URL 改为我的 github 。
export TTN_LW_FREQUENCY_PLANS_URL=https://raw.githubusercontent.com/twowinter/lorawan-frequency-plans/master
4 验证
# ./ttn-lw-cli end-devices list-frequency-plans
[{
"id": "EU_863_870",
"name": "Europe 863-870 MHz",
"base_frequency": 868
}, {
"id": "EU_863_870_TTN",
"base_id": "EU_863_870",
"name": "Europe 863-870 MHz (TTN)",
"base_frequency": 868
}, {
"id": "US_902_928_FSB_1",
"name": "United States 902-928 MHz, FSB 1",
"base_frequency": 915
}, {
"id": "US_902_928_FSB_2",
"name": "United States 902-928 MHz, FSB 2 (TTN)",
"base_frequency": 915
}, {
"id": "AU_915_928_FSB_1",
"name": "Australia 915-928 MHz, FSB 1",
"base_frequency": 915
}, {
"id": "AU_915_928_FSB_2",
"name": "Australia 915-928 MHz, FSB 2 (TTN)",
"base_frequency": 915
}, {
"id": "CN_470_510_FSB_1",
"name": "China 470-510 MHz, FSB 1",
"base_frequency": 470
}, {
"id": "CN_470_510_FSB_11",
"name": "China 470-510 MHz, FSB 11",
"base_frequency": 470
}, {
"id": "AS_920_923",
"name": "Asia 920-923 MHz",
"base_frequency": 915
}, {
"id": "AS_920_923_LBT",
"base_id": "AS_920_923",
"name": "Asia 920-923 MHz with LBT",
"base_frequency": 915
}, {
"id": "AS_923_925",
"name": "Asia 923-925 MHz",
"base_frequency": 915
}, {
"id": "AS_923_925_LBT",
"base_id": "AS_923_925",
"name": "Asia 923-925 MHz with LBT",
"base_frequency": 915
}, {
"id": "KR_920_923_TTN",
"name": "South Korea 920-923 MHz",
"base_frequency": 915
}, {
"id": "IN_865_867",
"name": "India 865-867 MHz",
"base_frequency": 868
}, {
"id": "RU_864_870_TTN",
"name": "Russia 864-870 MHz",
"base_frequency": 868
}]
5 注册新的应用和设备
./ttn-lw-cli gateways create ttgtw1 --user-id admin --frequency-plan-id CN_470_510_FSB_1 --gateway-eui 33800000A0000001 --enforce-duty-cycle
./ttn-lw-cli applications create ttapp1 --user-id admin
./ttn-lw-cli end-devices create ttapp1 ttdev1 --dev-eui 3304A30B001C0530 --join-eui 800000000000000C --frequency-plan-id CN_470_510_FSB_1 --root-keys.app-key.key 752BAEC23EAE7964AF27C325F4C23C9A --lorawan-phy-version 1.0.2-b --lorawan-version 1.0.2
./ttn-lw-cli app api-keys create --application-id ttapp1 --right-application-link
./ttn-lw-cli app link set ttapp1 --api-key NNSXS.VEEBURF3KR77ZR..