一种LoRaWAN网关虚拟终端

源码来自ARM mbed,第三方开发,所以不是标准实现。HCI基于UART,采用VT100终端协议。拿来对比,以避免遗漏HCI需求。

const menu_item_t menu_items[] = 
{   /* after first character, command names must be [A-Za-z] */
    { "?", cmd_help, "","show available commands"}, 
    { ".", cmd_status, "","read status"}, 
    { "f", cmd_filter, "%x","set dev_addr print filter"}, 
    { "b", cmd_beacon_payload, "<%x>","set beacon payload"}, 
    { "sb", cmd_skip_beacon, "<%d>","skip beacons"}, 
    { "list", cmd_list_motes, "","list active motes"}, 
    { "dl", cmd_send_downlink, "[%x %s]","send downlink  "}, 
    { "rxr", cmd_rx_restart, "", "restart RX"},
    { "brgb", cmd_beacon_rgb, "%u %u %u", "load RGB command into next beacon" },
    { "rgb", cmd_downlink_rgb, "%x %u %u %u", "load RGB command to mote"},
    { "bgpo", cmd_beacon_gpo, "%d", "load output pin command into next beacon"},
    { "gpo", cmd_downlink_gpo, "%x %d", "load output pin command to mote"},
    { "op", cmd_op, "","(TX) get/set TX power"},  
#ifdef TYPE_ABZ
    { "pas", cmd_pa_select, "","(TX) toggle PaSelect"},  
#endif
    { "tz", cmd_set_time, "", "set seconds to zero"},   
    { "p", cmd_pwm, "%x %u %u", "send pwm period, duty to dev_addr"},
    { "bp", cmd_beacon_pwm, "%u %u", "send pwm period, duty on beacon"},
    { "ntxp", cmd_endnode_txp, "%x %u", "send txpower index to dev_addr"},
    { "bntxp", cmd_beacon_endnode_txp, "%u", "send txpower index on beacon"},
    { "hm", cmd_hide_mac, "", "hide mac layer printing "},
    { "hp", cmd_hide_payload, "", "hide payload printing"},
    { "sa", cmd_show_all, "", "show both mac and app layers"},
    { NULL, NULL, NULL, NULL }
};

解释

从HCI指令注释和代码,可以看出有beacon与mote两种设备。分别可以远程设置PWM/GPIO/TXP等参数。此外都是调试和其他辅助功能。大多数与应用相关的指令可以中性化,简化通用为配置、下发、上传等。

  • 帮助,可以忽略
  • 状态,返回PA/OpMode/IRQ/Dio/Fifo等寄存器
  • 地址过滤,开关设备地址过滤器
  • 信标负荷,将符合数据发送给Beacon设备
  • 跳过信标,Beacon数据包是可以忽略的
  • 设备列表,罗列当前活跃的设备和地址信息
  • 下发信息,向特定地址设备下发数据
  • 接收重启,把收发器重置为接受状态
  • 信标RGB,把RGB信息下发到Beacon设备
  • MoteRGB,把RGB信息下发到Mote设备
  • 信标引脚,把GPO信息下发到Beacon设备
  • Mote引脚,把GPO信息下发到Mote设备
  • 设置功率,读写TX功率
  • 切换功放,切换PaSelect选择合适的功放电路
  • 重置定时器,把MCU内置tick复位
  • 信标PWM,设置Beacon PWM输出
  • MotePWM,设置Mote PWM输出
  • 下发TXP,设置远程设备的TXP输出
  • 信标TXP,设置Beacon的TXP输出
  • 隐藏MAC层打印,辅助
  • 隐藏负荷打印,辅助
  • 隐藏MAC/APP层打印,辅助

这个网关代码已经实现了LoRaWAN MAC层和应用层,还包括了大量加解密算法。编译后的代码为74KB。如果将这些指令、MAC/APP简化,很大概率可以压缩在64KB里。

你可能感兴趣的:(一种LoRaWAN网关虚拟终端)