前言LoRaWAN 协议定义了系统拓扑,这是我们最常见的系统拓扑图。但当了解到LoRaServerProject时,这套系统拓扑有了更细致的展现,采用 MQTT 来实现 Gateway、NS、AS 的协议处理。深入到这个开源项目中,会体会到 MQTT 给这个系统架构所带来的高效率与灵活性。
一、工程总体介绍Lora Server project 是一套开源应用软件,实现从 网关接收到节点数据 一直到 应用程序接收到数据 这一段链路的处理。The Lora Server project is an open-source set of applications that fill the gap between the gateways receiving messages from the nodes to just before the applications receiving the data. It provides mechanisms for managing the gateways on the LoRa network, the applications supported, and the devices associated with the applications.整个工程设计地非常灵活,这样可以用不同方式来使用它。例如 LoRa App Server 组件实现 应用服务器组件,为用户提供一套 Web UI 来访问和修改他们的网关、应用程序和节点,还可以通过 gRPC and JSON REST APIs 编程接口来访问系统。而且,API设计地也很灵活,子系统可以用其他相同接口的软件来替代。The project is designed so that it may be used in a very flexible manner. For example the LoRa App Server component implements the application-server component and offers a Web UI for users to access and modify their gateways, applications and nodes. The system can also be accessed via programmatic interfaces implemented in gRPC and JSON REST APIs. Further, the APIs are designed such that the subsystems may be replaced by other software implementing the same interfaces.二、系统架构LoRa nodesLoRa gateway网关从节点接收数据,实现包的转发。LoRa Gateway BridgeLoRa Gateway Bridge负责处理网关的通讯。将网关转发的UDP协议转化成MQTT上的JSON。它比直接用UDP来传输,有如下优点:调试容易下行数据时只要知道网关的相应MQTT主题,MQTT broker 会找到负责相应网关的LoRa Gateway Bridge。使得网关和NS直接可以使用更安全的连接(使用 MQTT over TLS )未来,不同的bridge版本可以处理不同的网关协议,因此其余设备只需要知道 MQTT格式上的JSON串。LoRa ServerLoRa Server组件能知道激活节点会话,当新节点加网时,它会向AS询问这个节点是否可以加入网络,如果准许的话,应该给这个节点采用何种设置。对于激活节点会话,它对接收到的数据包做去重,并且对日期做校正(避免转发攻击),它转发数据给AS,会询问AS是否有东西要回复。除了管理数据流,也可以通过所谓的MAC命令等来管理节点状态。LoRa Server 使用 gRPC API,以方便你建立自己的AS。LoRa App ServerLoRa App Server组件实现了一套对接 LoRa Server 的应用服务器。它提供了针对各个应用或者各个机构的节点管理,也提供了针对各个机构的网关管理。它还提供了用户管理以及针对不同机构、应用的用户的权限分配。它和应用的通讯是使用 JSON over MQTT,使用裸露的APIs。LoRa App Servers提供了一个WEB界面,用来管理网关和节点,也提供API端点,这样它可以集成到你的自有产品中。LoRa App Servers offers a web-interface that can be used for gateway, node and gateway management, but also offers API endpoints so that it can be integrated with your own products.Application应用则通过订阅MQTT主题来接收节点的数据,也能通过MQTT回传数据。如果需要,它可以用 gRPC or JSON REST api 来和AS进行交互。三、功能特性ISM bands满足 Regional Parameters 1.0 。Devices classes目前支持 LoRaWAN Class-A and Class-CAdaptive data-rate (ADR)Channel re-configuration标准只使用了一部分信道,而这边支持信道重配置。Web-interface提供了Web界面,它提供了针对各个应用或者各个机构的节点管理,也提供了针对各个机构的网关管理。它还提供了用户管理以及针对不同机构、应用的用户的权限分配。它和应用的通讯是使用 JSON over MQTT,使用裸露的APIs。APINS和AS都提供了API来集成到你的产品中。如果需要的话,也可以使用 LoRa Server API 来实现一套自己的节点管理系统,来完全替代掉 LoRa App Server 。Gateway management提供了网关管理功能,这样可以管理你的网关,及他们的GPS位置,以及一些他们的性能追踪。LoRa Server 功能设备类型(Device classes)Class ALoRa Server 全面支持 Class-A 设备。接收到的数据会做去重处理,然后转发给AS。当 接收窗口 打开时,LoRa Server 会向 AS poll 下行数据。通过 polling 这种方式,AS 可以按照 速率相应的最大载荷长度 的相关规定来安排下行数据。Class BTodoClass CLoRa Server 全面支持 Class-C 设备。它会记住上一次的接收参数(每个网关接收到的上行数据情况),因此可以判断出最近的那个网关,从而下发下行数据。下行数据可以调用 NetworkServer.PushDataDown API 来处理。带应答的上下行数据(Confirmed data up / down)带应答的上下行数据都是 LoRa Server 来处理,特别是下行数据, LoRa Server 会一直保存着它的序列号,直到等到节点的应答。终端加网(Node activation)LoRa Server 支持 ABP 和 OTAA 两种加网方式。在 ABP 方式中,AS 提供给 LoRa Server 一个 node-session 。在 OTAA 方式中,LoRa Server 会调用将接收到的 join-request 发给 AS,如果准许的话,它会发送 join-accept 给节点。速率自适应(实验阶段)(Adaptive data-rate (experimental))LoRa Server 支持 速率自适应(ADR)。LoRa Server has support for adaptive data-rate (ADR). In order to activate ADR, The node must have the ADR interval and installation margin configured. The first one contains the number of frames after which to re-calculate the ideal data-rate and TX power of the node, the latter one holds the installation margin of the network (the default recommended value is 5dB). From the node-side it is required that the ADR flag is set for each uplink transmission.Important: ADR is only suitable for static devices, thus devices that do not move!网关管理和统计(Gateway management and stats)Gateways can be created either automatically when LoRa Server receives statistics from the gateways or by using the API. Gateway statistics will be aggregated on the given intervals and are exposed through the api API. See also gateway management.接收窗口(Receive windows)Through OTAA and ABP, it is possible to configure which RX window to use for downlink transmissions. This also includes the parameters like data-rate (for RX2) and the delay to use.释放帧序号(Relax frame-counter)A problem with many ABP devices is that after a power-cycle, the frame-counter of the device is reset. Since this reset is not known by LoRa Server it means that all payloads with a frame-counter smaller or equal than the known counter get rejected. In order to work around this issue it is possible to enable the relax frame-counter mode. Important to know, this compromises security!ISM频段(ISM bands)As different regions have have different regulations regarding the license-free bands, you have to specify the ISM band to operate on when starting LoRa Server. At this moment the following ISM bands have been implemented:AS 923AU 915-928CN 470-510CN 779-787EU 433EU 863-870IN 865-867KR 920-923US 902-928
了解详情