Summary of the invention
Based on this, it is necessary to which in view of the above technical problems, LoRa network system can be simplified by providing one kind, and it is difficult to reduce deployment
Gateway, LoRa network system, gateway operation method and the storage medium of degree.
To achieve the goals above, on the one hand, the embodiment of the invention provides a kind of gateway, including gateway unit and
LoRaServer unit;LoRaServer unit includes southbound interface module and LoRaWan protocol stack module;
The terminal message received is transferred to southbound interface module by gateway unit;Terminal message be networking request message or
Terminal data message;
Southbound interface module will handle the networking that networking request message obtains and request in plain text, to be transferred to LoRaWan protocol stack
Module;And protocol conversion is carried out to terminal data message, obtain the terminal data network report for being uploaded to application server
Text;
LoRaWan protocol stack module obtains terminal address according to the request that networks in plain text, and is used for based on terminal address
It is handed down to the networking response message of terminal.
LoRaServer unit further includes application service module in one of the embodiments,;
Terminal data network message is transferred to application service module by southbound interface module;
Terminal data network message is uploaded to application server by application service module.
Application service module gives the management message transmissions received to LoRaWan protocol stack in one of the embodiments,
Module;Managing message is terminal management message or gateway management message;
LoRaWan protocol stack module parses gateway management message, obtains gateway configuration-direct;
LoRaWan protocol stack module parses terminal management message, obtains terminal management data;And terminal management number will be based on
Southbound interface module is transferred to according to obtained terminal management analytic message;
Southbound interface resume module terminal management analytic message, the terminal management parsing obtained for being handed down to terminal are close
Text.
Southbound interface module receives the periodical pull message of gateway unit transmission in one of the embodiments,;
LoRaWan protocol stack module is when southbound interface module receives periodical pull message, by terminal management message
It is transferred to southbound interface module.
Southbound interface module includes default port in one of the embodiments,;Default port includes loopback interface;
Terminal message is transferred to default port by loopback interface by gateway unit;
Southbound interface module obtains terminal message from default port.
Gateway unit includes LoRa drive module and terminal forwarding module in one of the embodiments,;
LoRa drive module carries out frame decoding to terminal message;
Terminal message after frame decoding is transferred to southbound interface module by terminal forwarding module.
Southbound interface module carries out protocol conversion to terminal data message in one of the embodiments, is based on
The terminal data network message of ieee802.3 agreement.
On the other hand, the embodiment of the invention also provides a kind of LoRa network system, including terminal and application server, with
And the gateway in each embodiment of connection between the terminal and the application server.
On the other hand, the embodiment of the invention also provides a kind of gateway operation methods, comprising:
Receive terminal message;Terminal message is networking request message or terminal data message;
Networking request message is handled, obtains networking request in plain text;According to request is networked in plain text, with obtaining terminal
Location, and the networking response message for being handed down to terminal is obtained based on terminal address;
Protocol conversion is carried out to terminal data message, obtains the terminal data network report for being uploaded to application server
Text.
On the other hand, the embodiment of the invention also provides a kind of computer readable storage medium, it is stored thereon with computer
Program, the step of above-mentioned gateway operation method is realized when computer program is executed by processor.
A technical solution in above-mentioned technical proposal is had the following advantages and beneficial effects:
Southbound interface module, LoRaWan protocol stack module in LoRaServer unit realize traditional LoRa network
The function of LoRa network server in system;That is the gateway of the application can integrate the function of LoRa network server, Jin Erben
The gateway of application is when being applied to LoRa network system, without still further disposing LoRa network service in LoRa network system
Device simplifies LoRa network system, reduces deployment difficulty.
Specific embodiment
It is with reference to the accompanying drawings and embodiments, right in order to which the objects, technical solutions and advantages of the application are more clearly understood
The application is further elaborated.It should be appreciated that specific embodiment described herein is only used to explain the application, not
For limiting the application.
As shown in Figure 1, traditional LoRa network system includes sequentially connected terminal (EndNodes in Fig. 1), gateway
(Concentrator/Gateway in Fig. 1), LoRa network server (LoRaNetworkServer in Fig. 1) and application
Server (ApplicationServer in Fig. 1).
Wherein, terminal: monitored object and its status data is acquired.Gateway: access terminal, the LoRa association that forwarding terminal is sent
Discuss message;LoRa network server: the core of LoRaWan protocol network, the access of processing terminal, management, uplink and downlink data
Encrypt and Decrypt, packet parsing and data packet synthesis etc.;Application server: management terminal and gateway, reception and analysing terminal acquisition
Data.
Gateway provided by the present application can be applied in LoRa network system as shown in Figure 5.Terminal 102 passes through gateway
104 carry out network communication with application server 106.
It is specific:
Terminal 102: monitored object and acquisition state data;
The gateway 104 of integrated LoRa web server function: it is responsible for access, the management of terminal 102, realizes LoRa agreement
Stack realizes the conversion of LoRaWan agreement and ieee802.3 protocol massages;
Application server 106: 104 subordinate terminal 102 of management gateway 104 and gateway, and the data uploaded according to terminal 102
Certain control strategy is taken terminal 102.
Wherein, terminal 102 can be, but not limited to be water meter, gas meter, flow meter, ammeter, calorimeter, smoke alarm, pet tracking
The various detection devices such as device, application server 106 can use the server of the either multiple server compositions of independent server
Cluster is realized.
In one embodiment, it as shown in Fig. 2, providing a kind of gateway, is said so that the gateway application is in Fig. 5 as an example
It is bright, comprising: gateway unit and LoRaServer unit;LoRaServer unit includes southbound interface module and LoRaWan association
Discuss stack module;
The terminal message received is transferred to southbound interface module by gateway unit;Terminal message be networking request message or
Terminal data message;
Southbound interface module will handle the networking that networking request message obtains and request in plain text, to be transferred to LoRaWan protocol stack
Module;And protocol conversion is carried out to terminal data message, obtain the terminal data network for being uploaded to application server 106
Message;
LoRaWan protocol stack module obtains terminal address according to the request that networks in plain text, and is used for based on terminal address
It is handed down to the networking response message of terminal 102.
Specifically, terminal message is to be sent to gateway unit by terminal 102;Gateway unit can be to the terminal report received
Text carries out frame decoding processing.
Southbound interface module can be decoding and decryption to the processing of networking request message;Southbound interface module is to number of terminals
The terminal data message that carrying out protocol conversion according to message can be by former base in LoRaWan agreement is converted to based on ieee802.3
The terminal data message of agreement.
Terminal address is obtained according to the terminal identification information in the request plaintext that networks, such as MAC Address, distribution;It obtains
Networking response message can be issued to corresponding terminal 102 by gateway unit.
In above-mentioned gateway, southbound interface module, LoRaWan protocol stack module in LoRaServer unit realize LoRa
The function of network server;Namely above-mentioned gateway is integrated with the function of LoRa network server, and then does not need in LoRa network
LoRa network server is still further disposed in system, simplifies LoRa network system, reduces deployment difficulty.
It should be noted that under the premise of deferring to LoRaWan agreement completely, original discrete LoRa network server
It has been integrated into gateway, since separate unit gateway covering terminal number is few, gateway generally uses 100,000,000 or more high-performance MCU to handle
Unit so being substantially unaffected in terms of gate performance, and due to integrated reason, can save a LoRa network service
The deployment of device, so that the more flattening of whole system network, management easy to maintain, while being suitable for the LoRa Internet of Things of small-sized garden
The application scenarios of screen cloth net, reduce system cost, meet the actual demand of middle-size and small-size user.
In one embodiment, it as shown in figure 3, providing a kind of gateway, is said so that the gateway application is in Fig. 5 as an example
It is bright, comprising:
Gateway unit and LoRaServer unit;LoRaServer unit includes application service module, southbound interface module
And LoRaWan protocol stack module;Gateway unit includes LoRa drive module, terminal forwarding module;
LoRa drive module carries out frame decoding to the terminal message received;
Terminal message after frame decoding is transferred to southbound interface module by terminal forwarding module;
Terminal message after frame decoding is networking request message or terminal data message;
Southbound interface module will handle the networking that networking request message obtains and request in plain text, to be transferred to LoRaWan protocol stack
Module;And protocol conversion is carried out to terminal data message, and obtained terminal data network message is transferred to application service
Module;
LoRaWan protocol stack module obtains terminal address according to the request that networks in plain text, and is used for based on terminal address
It is handed down to the networking response message of terminal 102;
Application service module, for terminal data network message to be uploaded to application server 106.
Specifically, southbound interface module can be decoding and decryption to the processing of networking request message.
LoRaWan protocol stack module is distributed according to the terminal identification information in the request plaintext that networks, such as MAC Address
To terminal address.
Application service module can upload to terminal data network message in application server 106 by return network,
Return network therein can be the data access network such as wired, WIFI, 2G, 3G or 4G.
Further, application service module gives the management message transmissions received to LoRaWan protocol stack module;Management report
Text is terminal management message or gateway management message;
LoRaWan protocol stack module parses gateway management message, obtains gateway configuration-direct;
LoRaWan protocol stack module parses terminal management message, obtains terminal management data;And terminal management number will be based on
Southbound interface module is transferred to according to obtained terminal management analytic message;
Southbound interface resume module terminal management analytic message, the terminal management parsing obtained for being handed down to terminal are close
Text.
Specifically, southbound interface module can be encryption and coding to the processing mode of terminal management analytic message.
It should be noted that management message can be and be sent to application service module by application server 106;And application clothes
Business device 106 can analyze the terminal data network message received, obtain terminal management report according to preset policing algorithm
Text namely application server 106 produce the corresponding actions of terminal management message controlling terminal 102.
Further, gateway unit may also include gateway radio-frequency module;
Terminal management parsing ciphertext is transferred to terminal forwarding module by southbound interface module;Terminal forwarding module, being used for will
Terminal management parsing ciphertext is transferred to LoRa drive module;LoRa drive module, for carrying out group to terminal management parsing ciphertext
Frame, and the terminal management ciphertext after framing is transferred to gateway radio-frequency module;
Networking response message is transferred to southbound interface module by LoRaWan protocol stack module;Southbound interface module is to networking
Response message encryption and coding, obtain networking response cyphertext, and networking response cyphertext is transferred to terminal forwarding module;Terminal turns
It sends out module and networking response cyphertext is transferred to LoRa drive module;LoRa drive module carries out framing to networking response message, and
Networking response cyphertext after framing is transferred to gateway radio-frequency module;
Terminal management after framing is parsed ciphertext to gateway radio-frequency module and networking response cyphertext is issued to corresponding terminal;
And for receiving networking request message and terminal data message, and the networking request message or number of terminals that will be received from terminal
LoRa drive module is given according to message transmissions.
It should be noted that terminal 102 can be returned to gateway 104 when corresponding terminal 102 receives terminal management ciphertext
Answer the first ACK (Acknowledgement, confirmation) message.
Further, southbound interface module receives the periodical pull message of terminal forwarding module transmission;
LoRaWan protocol stack module is when southbound interface module receives periodical pull message, by terminal management message
It is transferred to southbound interface module.
Further, southbound interface module includes default port;Default port includes loopback interface;
Terminal message is transferred to default port by loopback interface by gateway unit;
Southbound interface module obtains terminal message from default port.Southbound interface module includes default port;Default end
Mouth includes loopback interface;
Terminal message is transferred to default port by loopback interface by gateway unit;
Southbound interface module obtains terminal message from default port.
Wherein, presetting port and loopback interface can be independently arranged, and set-up mode includes network management Remote configuration, local
The various ways such as web configuration and local profile.
Further, southbound interface module, which carries out protocol conversion to terminal data message, can be former base in LoRaWan
The terminal data message of agreement is converted to the terminal data message based on ieee802.3 agreement.
Wherein the transport layer of the terminal data message of ieee802.3 agreement follows UDP (User Datagram
Protocol, User Datagram Protocol) agreement, application layer using JSON (JavaScript Object Notation,
JavaScript object numbered musical notation) agreement.
Further, southbound interface module responds the 2nd ACK report to terminal forwarding module when obtaining networking request plaintext
Text.
Specifically, the group packet protocol of networking request message MAC layer follows LoRaWan agreement, transport layer uses udp protocol,
Application layer uses JSON agreement;
It include tri- parameters of AppEUI, DevEUI and DevNonce in networking request message, wherein AppEUI is for identifying
It uniquely applies supplier, such as the dustbin of each family to monitor application, smoke alarm application etc., all has unique
AppEUI, for the parameter being arranged in the terminal in advance;DevEUI can be the MAC Address of terminal for identifying unique terminal;
DevNonce is the RSSI random value of LoRa chip in terminal;
LoRaWan protocol stack module is according to the terminal address that the DevEUI in networking request message is distributed
The NetID generated when DevAddr, DevAddr are together with AppNonce and distribution forms networking response message, and wherein AppNonce is
It is randomly generated, the effect of NetID is similar to subnet mask;
After terminal 102 receives networking response cyphertext, extract DevAddr therein, and combine AppKey, AppNonce,
NetID and DevNonce, is encrypted using aes128, generates 2 keys: NekSKey and AppSKey, and terminal 102, which networks, to be completed.
Wherein NekSKey is used for the encryption and decryption of terminal management message, and AppSKey is used for the encryption and decryption of terminal data message;AppKey by
Terminal 102 and the shared use of gateway 104, are pre-stored in terminal 102 and gateway 104, for response cyphertext and the networking of networking
The encryption and decryption of request message.
The above-mentioned encryption and decryption referred to uses AES128 mode, and encoding and decoding use Base64 mode.
Specifically, the algorithm that distribution obtains terminal address is a kind of DHCPD ((the Dynamic Host of simplification
Configuration Protocol (server) daemon), dynamic host configuration protocol finger daemon) algorithm, in addition to being used for
Realize that the terminal address above-mentioned distributed according to DevEUI is DevAddr, additionally it is possible to which the MAC Address that gateway is arranged is old
Change the time, the terminal address that distribution can be made to obtain is not overlapped, and is realized by the MAC address aging time and handed over for a long time without message
Mechanism is withdrawn in the address changed, and avoids occupying DevAddr when terminal 102 is not online for a long time after networking.
It should be further noted that since the transport layer for managing message that application server 106 issues is assisted using UDP
View, application layer uses JSON agreement, and LoRaWan agreement provides that LoRa network server is sent to the management message of gateway and abides by
GWMP (LoRa Gateway Message Protocol, LoRa gateway message protocol) agreement is followed, so LoRaWan protocol stack
Module needs to parse management message, and concrete processing procedure includes: that the first JSON load is parsed from terminal management message
Lotus obtains terminal management analytic message as terminal management data, based on terminal management data;When southbound interface module receives
When pull message, using terminal management analytic message as PULL_RESP message, LoRaWan protocol stack mould is by PULL_RESP message
It is transferred to southbound interface module;Wherein, PULL_RESP message length must not exceed 1000 eight bit bytes.Concrete processing procedure
Further include: the 2nd JSON load is parsed from gateway management message, obtains gateway configuration-direct.
The southbound interface module referred in above-mentioned gateway receives the periodical pull message of terminal forwarding module transmission, practical
On be equal in traditional LoRa network system as shown in Figure 1 gateway to LoRa network server sending cycle pull message
(periodical pull message for keep it turned on the firewall of LoRa network server), and combine default port and
Loopback interface can independently be arranged and southbound interface module to terminal forwarding module respond the 2nd ACK message.Actually protect
The function of sending and receiving data between gateway unit and LoRa network server is stayed, even if so that above-mentioned gateway has been internally integrated equally
In the LoRaServer unit of LoRa network server, the application environment that can be also compatible in Fig. 1 can be with the LoRa network of Fig. 1
LoRa network server in system connects and sends data, and flexibility is good, applied widely.
Compare traditional LoRa network system as shown in Figure 1, since the gateway in each embodiment of the application is integrated with
It is same as the LoRaServer unit of LoRa network server, and then reduces the deployment of a network element (LoRa network server),
But the functional structure without changing LoRa network system can follow to still follow LoRaWan agreement with other
The device interoperability of LoRaWan agreement.
Since LoRa network server is integrated into the reason of gateway, cause the terminal communicated with LoRa network server can be only
The quantity of terminal comprising gateway down-hanging, the terminal that can be communicated to LoRa network server corresponding can be reduced.But due to LoRa
The small feature of wireless network coverage wide (covering radius is up to 15 kilometers or more), data volume, gateway base from performance
Originally the covering to terminal in a median size garden, and the angle of the deployment from reduction LoRa network server be can satisfy
Degree, is more suitable for the middle-size and small-size user sensitive to engineering price, and to sum up, LoRa network system as shown in Figure 5 is simpler, more
It is easy deployment, more flattening.
Modules in above-mentioned gateway can be realized fully or partially through software, hardware and combinations thereof.Above-mentioned each mould
Block can be embedded in the form of hardware or independently of in the processor in computer equipment, can also be stored in calculating in a software form
In memory in machine equipment, the corresponding operation of the above modules is executed in order to which processor calls.
In one embodiment, a kind of gateway operation method as shown in Figure 4 is provided, comprising:
Step S402, receives terminal message;Terminal message is networking request message or terminal data message;
Step S404 handles networking request message, obtains networking request in plain text;According to request is networked in plain text, obtain
The networking response message for being handed down to terminal is obtained to terminal address, and based on terminal address;
Step S406 carries out protocol conversion to terminal data message, obtains the number of terminals for being uploaded to application server
According to network message.
It should be understood that although each step in the flow chart of Fig. 4 is successively shown according to the instruction of arrow, this
A little steps are not that the inevitable sequence according to arrow instruction successively executes.Unless expressly state otherwise herein, these steps
It executes there is no the limitation of stringent sequence, these steps can execute in other order.Moreover, at least part in Fig. 4
Step may include that perhaps these sub-steps of multiple stages or stage are executed in synchronization to multiple sub-steps
It completes, but can execute at different times, the execution sequence in these sub-steps or stage, which is also not necessarily, successively to be carried out,
But it can be executed in turn or alternately at least part of the sub-step or stage of other steps or other steps.
In one embodiment, a kind of LoRa network system as shown in Figure 5, including sequentially connected terminal are provided
102, gateway 104 and application server 106.
Above-mentioned LoRa network system includes at least three kinds of operating statuses as shown in FIG. 6:
Terminal 102 enters network process:
1, AppKey, the parameter (are equal to the LoRa in traditional LoRa network system by the LoRaServer unit of gateway
Network server) and the shared use of terminal 102, for doing the encryption and decryption of join_request message, join_accept message.
2, terminal 102 configured AppEUI (offer of LoRaServer unit) and DevEUI (terminal 102 itself is exclusive,
Such as MAC Address);And the RSSI random value for taking LoRa chip in terminal 102, obtains DevNonce.By AppKey, AppEUI and
This 3 parameters of DevEUI, are organized into join_request message, (are equal to traditional LoRa network by gateway unit after encryption
Gateway in system) it is sent to LoRaServer unit.
3, LoRaServer unit receives join_request message, after decryption, distributes for terminal 102
DevAddr, together with AppNonce (parameter that LoRaServer unit is randomly generated) and NetID (generated when distribution DevAddr,
Similar subnet mask), it is organized into join_accept message, encryption sends back to terminal 102.
4, after terminal 102 receives join_accept message, DevAddr therein is extracted;In conjunction with following 4 parameters:
AppKey, AppNonce, NetID and DevNonce are encrypted using aes128, generate 2 keys: NekSKey and AppSKey.
It is used as the encryption and decryption of terminal management message in its NekSKey, AppSKey is used as terminal data message encryption and decryption, and terminal 102 enters
Net is completed.
Data upload process: the terminal data message that terminal 102 issues turns by gateway unit and LoRaServer unit
Issue application server 106.
Control management process:
The terminal management message that application server 106 issues is issued to terminal by LoRaServer unit and gateway unit
102;The gateway management message that application server 106 issues is issued to gateway unit by LoRaServer unit.
It is no longer superfluous here mentioned by the detailed operation of above-mentioned three kinds of operating statuses has had in the above embodiments
It states.
In one embodiment, a kind of computer readable storage medium is provided, computer program is stored thereon with, is calculated
Machine program realizes the step of above-mentioned gateway operation method when being executed by processor.
Those of ordinary skill in the art will appreciate that realizing all or part of the process in above-described embodiment method, being can be with
Instruct relevant hardware to complete by computer program, computer program to can be stored in a non-volatile computer readable
It takes in storage medium, the computer program is when being executed, it may include such as the process of the embodiment of above-mentioned each method.Wherein, this Shen
Please provided by any reference used in each embodiment to memory, storage, database or other media, may each comprise
Non-volatile and/or volatile memory.Nonvolatile memory may include read-only memory (ROM), programming ROM
(PROM), electrically programmable ROM (EPROM), electrically erasable ROM (EEPROM) or flash memory.Volatile memory may include
Random access memory (RAM) or external cache.By way of illustration and not limitation, RAM is available in many forms,
Such as static state RAM (SRAM), dynamic ram (DRAM), synchronous dram (SDRAM), double data rate sdram (DDRSDRAM), enhancing
Type SDRAM (ESDRAM), synchronization link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM
(RDRAM), direct memory bus dynamic ram (DRDRAM) and memory bus dynamic ram (RDRAM) etc..
Each technical characteristic of above embodiments can be combined arbitrarily, for simplicity of description, not to above-described embodiment
In each technical characteristic it is all possible combination be all described, as long as however, the combination of these technical characteristics be not present lance
Shield all should be considered as described in this specification.
Above embodiments only express the several embodiments of the application, and the description thereof is more specific and detailed, but can not
Therefore it is construed as limiting the scope of the patent.It should be pointed out that for those of ordinary skill in the art,
Under the premise of not departing from the application design, various modifications and improvements can be made, these belong to the protection scope of the application.
Therefore, the scope of protection shall be subject to the appended claims for the application patent.