Wireless sensor equipment management and data processing system and method of gateway machine
By introducing wireless sensor equipment management and data processing systems into the gateway, the compatibility and scalability problems of wireless sensor equipment management and data processing are solved, efficient management and data transmission of wireless sensor equipment are realized, and a variety of operational needs are supported.
Patent Information
- Application Number
- CN202510482540.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2025-07-11
AI Technical Summary
In the prior art, when managing and processing wireless sensor equipment, it is difficult for the gateway to effectively take into account data transmission, control packet issuance and equipment management operations, especially in terms of access management, parameter configuration and version upgrade of wireless sensor equipment in the substation station building.
A wireless sensor device management and data processing system for gateways is designed, including wireless Lora access module, wireless sensor protocol conversion and management module, uplink protocol conversion module and wireless sensor web configuration management backend. Through serial communication and MQTT protocol conversion, data interaction and management of wireless sensor devices are realized.
It realizes efficient management of business data reporting and control packet issuance of wireless sensor equipment, supports access management, parameter configuration and version upgrade operations, and is compatible with the "Q/GDW 12184-2021 Internet of Things Sensor Data Specification for Power Transmission and Transformation Equipment", simplifies the message processing process and improves the flexibility and scalability of the system.
Smart Images

Figure CN120302340A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of wireless sensor device management and data processing, and relates to a wireless sensor device management and data processing system and method for a gateway device. Background Art
[0002] "Q / GDW 12184—2021 Specification for Sensor Data of Internet of Things for Transmission and Transformation Equipment" stipulates the message format requirements for the transmission of service data, control data, and fragmented transmission data by sensors of the Internet of Things for transmission and transformation equipment. The message adopts a data frame mode, and the transmission sequence is a binary byte stream. This standard is applicable to the design, application, and testing of communication data messages between sensors and node devices of the Internet of Things for transmission and transformation equipment.
[0003] In a substation building, various types of wireless sensor devices and gateway devices can be installed. The wireless sensor devices are used to collect environmental data information in the building, including temperature and humidity, gas concentration, smoke detection, infrared, etc.; the gateway device is provided with a wireless communication module for receiving wireless data messages from the wireless sensor devices, and the wireless data messages conform to the message specifications of "Q / GDW 12184—2021 Specification for Sensor Data of Internet of Things for Transmission and Transformation Equipment".
[0004] In addition to the data transmission of wireless sensors, the gateway also needs to perform operations such as access management, parameter configuration, and version upgrade on the wireless sensor devices. Summary of the Invention
[0005] The purpose of the present invention is to provide a wireless sensor device management and data processing system and method for a gateway device, including wireless sensor device access management, parameter configuration, and data transmission processing.
[0006] To achieve the above objectives, the first aspect of the present invention discloses a wireless sensor device management and data processing system for a gateway device, including:
[0007] A wireless Lora access module, configured to receive data messages sent by wireless sensor devices, and send query, configuration, and control messages to the wireless sensor devices; and perform data interaction with a wireless sensor protocol conversion and management module;
[0008] A wireless sensor protocol conversion and management module is used to communicate with a wireless Lora access module, read wireless sensor service data packets, and forward query, configuration, and control packets; it is used to respond to queries and configuration requests from a Web configuration client and encapsulate and forward the query and configuration requests to the wireless Lora access module; it is used for protocol conversion of wireless sensor service data, converting the read wireless sensor service data into MQTT packets and forwarding them to the upstream protocol conversion module; it converts the MQTT control command packets sent by the upstream protocol conversion module into wireless sensor control packets and forwards them to the wireless Lora access module.
[0009] An upstream protocol conversion module is used to receive the wireless sensor service data packets that have undergone protocol conversion by the wireless sensor protocol conversion and management module and forward them to the upstream platform; it is used to forward the control commands sent by the upstream platform, convert the control commands into MQTT control command packets, and send them to the wireless sensor protocol conversion and management module.
[0010] A wireless sensor Web configuration management backend is used to receive queries and configuration requests sent by a Web configuration client, convert them into HTTP queries and configuration requests, and send them to the wireless sensor protocol conversion and management module; it is used to receive the HTTP messages (i.e., HTTP response packets) replied by the wireless sensor protocol conversion and management module and forward them to the Web configuration client.
[0011] In a preferred embodiment, the wireless Lora access module, the wireless sensor protocol conversion and management module, the upstream protocol conversion module, and the wireless sensor Web configuration management backend are all set in a gateway machine.
[0012] Furthermore, the communication protocol between the wireless sensor protocol conversion and management module and the wireless Lora access module includes a message start flag, a message ID number, a message type, a fragmentation sequence number, a fragmentation quantity, a payload length, a payload content, and a CRC checksum.
[0013] In a preferred embodiment, the wireless sensor protocol conversion and management module communicates with the wireless Lora access module through a serial port; a received packet buffer is set in the wireless sensor protocol conversion and management module, and unpacking processing is performed on the received packet buffer.
[0014] The unpacking process of the received message buffer is as follows: Set the content from the message start flag to the payload length as the message header content, and set the CRC checksum as the message tail content; Enter the processing function interface of the received message buffer, and determine whether the message length in the received message buffer exceeds the limit length. If it exceeds the limit length, directly clear the message queue in the received message buffer; When the message length in the received message buffer is greater than the message header length + the message tail length, copy the message header content from the received message buffer and obtain the payload length in the message header; When the message length in the received message buffer is greater than or equal to the message header length + the message tail length + the payload length, copy the payload content and the CRC checksum of the message tail from the received message buffer; Calculate the CRC checksum of the message header and the payload content, and compare it with the CRC checksum of the message tail. If they are the same, it means the retrieved message is correct. Then, take out the message header, payload content, and message tail from the received message buffer and process them as a single message.
[0015] In a preferred implementation, the messages entering the received message buffer include wireless sensor data type messages forwarded by the wireless Lora access module and messages carrying the payload response result sent by the wireless Lora access module.
[0016] In a preferred implementation, in the wireless sensor protocol conversion and management module, the specific process of single message processing is as follows:
[0017] Copy the message header and obtain the message header information, and parse the message type according to the message type.
[0018] If the message type is the response message of HTTP query and configuration request, parse the response message (i.e., the message carrying the payload response result). The message carrying the payload response result is the message including the response result returned by the wireless sensor and the wireless Lora access module after the HTTP query and configuration request are forwarded to the wireless Lora access module and sent down to the wireless sensor; Organize the HTTP response message and reply the HTTP response message to the wireless sensor Web configuration management backend.
[0019] If the message type is wireless sensor data type, parse the payload content of the message to determine whether it is a service data message uploaded by the wireless sensor or a response message of the MQTT control command. Assign the corresponding MQTT protocol topic Topic, encapsulate the payload content of the service data message uploaded by the wireless sensor or the response message of the MQTT control command into an MQTT message, and then add it to the MQTT message buffer and wait for the MQTT message to be published. If it is a response message of the MQTT control command, this response message is returned by the wireless Lora access module (specifically, the wireless sensor returns the response result to the wireless Lora access module, and then the wireless Lora access module returns the response result message to the wireless sensor protocol conversion and management module).
[0020] Further, perform BASE64 encryption processing on the payload content of the service data message reported by the wireless sensor and encapsulate it in the MQTT message; perform BASE64 decryption processing on the MQTT control command message for the wireless sensor sent by the uplink protocol conversion module.
[0021] In a preferred embodiment, the wireless sensor Web configuration management backend receives the query and configuration requests sent by the Web configuration client, converts them into HTTP query and configuration requests, and sends them to the wireless sensor protocol conversion and management module; the wireless sensor protocol conversion and management module parses the content of the HTTP query and configuration requests, obtains the specific request tasks and data parts, organizes the payload content according to the preset data structure, adds a message header and a message tail to form a message, sends it to the wireless Lora access module, and then the wireless Lora access module forwards it to the wireless sensor; then start the message loop to wait, set the waiting timeout time, and within the timeout time, receive the serial port response (that is, receive the response from the wireless Lora access module, the wireless sensor sends the response result to the wireless Lora access module, and then the wireless Lora access module responds to the wireless sensor protocol conversion and management module). The wireless sensor protocol conversion and management module performs HTTP framing response (that is, organizes the HTTP response message) according to the content of the response, and replies to the wireless sensor Web configuration management backend, and then the wireless sensor Web configuration management backend forwards the HTTP response message to the connected HTTP client (that is, the Web configuration client).
[0022] The second aspect of the present invention is to provide a method for managing and disposing of wireless sensor devices by a gateway machine adopting the foregoing system.
[0023] The third aspect of the present invention is to disclose a gateway machine, including the wireless sensor device management and data disposal system of the foregoing gateway machine.
[0024] The beneficial effects of the present invention are as follows:
[0025] The processing method of the present invention can take into account the reporting of wireless sensor service data and the sending of control messages, as well as the management of all queries and configuration operations on wireless sensor devices, including admission management of the list, setting of wireless sensor parameters, etc., and can also perform version query and version upgrade on wireless sensors. Only need to agree on the corresponding command content in the message header and the format of the payload content, which is also convenient for expansion.
[0026] The payload part involved in serial communication for reporting wireless sensor service data and sending control messages complies with the "Q / GDW 12184—2021 Specification for Sensor Data of Internet of Things for Power Transmission and Transformation Equipment". For the reporting of wireless sensor service data, the payload content read from the serial port is taken out without modification. After being encrypted by BASE64, it is directly used as a part of the MQTT message. After the upstream protocol conversion module receives this MQTT message, it only needs to take out the BASE64-encrypted part of the MQTT message, first perform BASE64 decryption, and parse it according to the "Q / GDW 12184—2021 Specification for Sensor Data of Internet of Things for Power Transmission and Transformation Equipment", then the service data of the sensor can be obtained.
[0027] In addition, for the control commands sent by the upstream protocol conversion module, the control content is also encapsulated according to the "Q / GDW12184—2021 Specification for Sensor Data of Internet of Things for Power Transmission and Transformation Equipment", converted into BASE64 encryption, and then encapsulated into the MQTT control message. After the wireless sensor protocol conversion and management module receives this MQTT message, it only needs to take out the BASE64-encrypted part, first perform BASE64 decryption, then the content of the payload part can be obtained, and then add the message header and message tail, and it can be appended to the message sending queue for waiting to be sent.
[0028] Adding the function of HTTP service can directly respond to the HTTP requests of the Web configuration client, convert the content of the request into the payload part (i.e., the payload content), then add the message header and message tail, and it can be appended to the message sending queue for waiting to be sent. Start the message loop to wait, set the waiting timeout time. If a serial port response is received within the timeout time, perform HTTP framing response on the content of the response and reply to the connected HTTP client. The advantage of such processing is that it is processed by the same module, without the need for additional message forwarding, and the message can be directly processed and forwarded. Brief Description of the Drawings
[0029] Figure 1 It is a schematic diagram of the wireless sensor device management and data processing system of the gateway of the present invention;
[0030] Figure 2 It is a schematic diagram of Modbus serial communication;
[0031] Figure 3 It is a schematic diagram of the processing process of the received message buffer;
[0032] Figure 4 It is a schematic diagram of the processing process of a single message;
[0033] Figure 5 It is a schematic diagram of the MQTT processing process. Detailed Embodiment
[0034] The present invention will be specifically introduced below in conjunction with the accompanying drawings and specific embodiments.
[0035] As Figure 1 shown, four data processing modules are added to the gateway in the present invention:
[0036] 1. Wireless Lora access module, which has wireless signal communication function and serial port communication (such as Modbus serial port communication) function: The wireless signal communication function is mainly responsible for sending and receiving wireless sensor data. It uses the modulation and demodulation principle to receive the service data packets, response packets sent by the wireless sensor device, and send the query, configuration packets and control packets to the wireless sensor device; the serial port communication function is that the wireless Lora access module exchanges data with the wireless sensor protocol conversion and management module for the service data packets and response packets of the wireless sensor received, and the configuration, query, and control packets of the wireless sensor protocol conversion and management module are sent to the wireless Lora access module through the serial port.
[0037] 2. Wireless sensor protocol conversion and management module, which has serial port communication function, HTTP service function, and protocol conversion function: The serial port communication function is mainly to realize the serial port communication with the wireless Lora access module, and is used to read and forward the service data packets and response packets of the wireless sensor, and send down queries, configurations and controls, etc.; the HTTP service function is mainly to provide HTTP service, which is used to respond to the queries and configuration commands of the Web configuration client, encapsulate the queries and configuration commands into the aforementioned query and configuration packets and forward them to the wireless Lora access module, and organize the HTTP response packets according to the responses to the HTTP queries and configuration requests sent from the serial port; the protocol conversion function is mainly responsible for the protocol conversion of the wireless sensor data, converting the wireless sensor data read from the serial port (the service data of the wireless sensor and the response packets of the MQTT control commands) into MQTT packets and forwarding them to the upstream protocol conversion module; converting the MQTT control command packets sent by the upstream protocol conversion module into wireless sensor control packets (i.e., the aforementioned control packets) and forwarding them to the wireless Lora access module, and the wireless Lora access module forwards the control commands (that is, the wireless Lora access module forwards the wireless sensor control data to the wireless sensor device).
[0038] 3. Upstream Protocol Conversion Module: (1) It is responsible for receiving the wireless sensor service data packets and the response packets of MQTT control commands sent by the wireless sensor protocol conversion and management module, and forwarding them to the upstream platform (before forwarding to the upstream platform, the wireless sensor service data MQTT packets and the response packets of MQTT control commands sent by the wireless sensor protocol conversion and management module can be converted into the data format corresponding to the upstream protocol, and the upstream protocol refers to the protocol corresponding to the upstream platform); (2) It is responsible for forwarding the control commands issued by the upstream platform (such as the control of sensor data points, and the control values are high and low level values, generally 1 or 0), encapsulating the control commands issued by the upstream platform according to the "Q / GDW 12184—2021 Specification for Sensor Data of Internet of Things for Transmission and Transformation Equipment", encrypting them with BASE64, converting them into MQTT control command packets, and sending them to the wireless sensor protocol conversion and management module.
[0039] 4. Wireless Sensor Web Configuration Management Backend: (1) It is responsible for receiving the data requests (i.e., query and configuration requests) sent by the Web configuration client, and converting the query and configuration requests of the Web configuration client into HTTP query and configuration requests and sending them to the wireless sensor protocol conversion and management module; (2) It is responsible for receiving the HTTP messages (packets) replied by the wireless sensor protocol conversion and management module and forwarding them to the Web configuration client for data or result display.
[0040] This invention mainly introduces the processing logic of the wireless sensor protocol conversion and management module part.
[0041] Regarding the data and configuration of wireless sensor devices, it involves various types of data packets, including yellow list query, deletion and clearing, white list query, deletion and clearing, wireless sensor software upgrade, business data packet reporting, control command issuing, etc. Enumerations are defined for different data packet types respectively. Among them, yellow list query, deletion and clearing, wireless sensor parameter setting, white list query, deletion and clearing, and wireless sensor software upgrade all belong to the query and configuration related in the form of HTTP.
[0042] The wireless Lora access module automatically identifies wireless sensor devices and includes the identified wireless sensor devices in the yellow list. The Web configuration client selects from the yellow list and issues settings for the white list (data of the wireless sensor devices included in the white list needs to be uploaded to the wireless sensor protocol conversion and management module). When performing yellow list query, deletion, and clearing, and white list query, deletion, and clearing, the wireless sensor Web configuration management backend converts the query and configuration requests of the Web configuration client into HTTP query and configuration requests and sends them to the wireless sensor protocol conversion and management module. The wireless sensor protocol conversion and management module responds to the query and configuration commands of the Web configuration client, encapsulates and forwards the query and configuration requests to the wireless Lora access module, and then forwards them to the wireless sensor to complete the yellow list query, deletion, and clearing, and white list query, deletion, and clearing. When the wireless sensor software is upgraded, the wireless sensor Web configuration management backend converts the wireless sensor software upgrade request (including the wireless sensor software upgrade package) sent by the Web configuration client into an HTTP request and sends it to the wireless sensor protocol conversion and management module. The wireless sensor protocol conversion and management module encapsulates and forwards the HTTP request to the wireless Lora access module, and then forwards it to the wireless sensor to complete the wireless sensor software upgrade. When setting the parameters of the wireless sensor, the wireless sensor Web configuration management backend converts the wireless sensor parameter setting request (including specific parameter data) sent by the Web configuration client into an HTTP request and sends it to the wireless sensor protocol conversion and management module. The same applies to the remaining operations.
[0043] Design the communication protocol between the wireless sensor protocol conversion and management module and the wireless Lora access module as shown in Table 1 below:
[0044] Table 1 Communication protocol between the wireless sensor protocol conversion and management module and the wireless Lora access module
[0045]
[0046]
[0047] The content from the message start flag to the payload length in Table 1 is the message header, and the CRC check is the message tail. In Table 1, the message type is to meet the requirements of the multi-functional gateway. In addition to transmitting the service data messages of wireless sensors, it can also meet the requirements of other controls and configurations. Through the message type, different messages such as HTTP query responses, HTTP configuration responses, and wireless sensor data types can be distinguished; the fragment sequence number and the number of fragments are to solve the need for splitting and integrating large messages; for the message type of wireless sensor data, the format of the payload content conforms to the "Q / GDW 12184—2021 Specification for Sensor Data of Internet of Things for Transmission and Transformation Equipment"; for the message type of HTTP query, configuration request or response, the payload content has a preset data structure (i.e., a predefined format). For example, for low-power devices, the data structure of its payload content can include information such as sensor ID, sensor type, acquisition period, and acquired values. The specific format can be preset with reference to the commonly used data formats in the prior art.
[0048] After the wireless sensor protocol conversion and management module is started, three communication connections are started:
[0049] (1) Modbus serial communication: responsible for data communication with the wireless Lora access module;
[0050] (2) MQTT network connection: responsible for forwarding and receiving MQTT data messages; the wireless sensor protocol conversion and management module communicates with the upstream protocol conversion module;
[0051] (3) HTTP service: responsible for receiving and responding to HTTP messages; communicating with the wireless sensor Web configuration management backend.
[0052] In the wireless sensor protocol conversion and management module, a message sending queue is also formed. The message sending queue is the message queue sent to the wireless Lora data module, and the messages include query, configuration messages, and control messages. Specifically, the wireless sensor protocol conversion and management module receives an HTTP request command (i.e., the HTTP query and configuration requests sent by the wireless sensor Web configuration management backend) or receives an MQTT downlink message (i.e., the MQTT control command message sent by the upstream protocol conversion module), and after message encapsulation (i.e., encapsulation into the format required by Table 1), it then enters the message sending queue.
[0053] The encapsulation process of the MQTT control command message sent by the upstream protocol conversion module is as follows: The wireless sensor protocol conversion and management module extracts the payload content from the MQTT control command message sent by the upstream protocol conversion module, encapsulates the message header and message tail, obtains the encapsulated message, and puts it into the message sending queue.
[0054] The encapsulation process of the HTTP query and configuration request is as follows: The wireless sensor protocol conversion and management module parses the content of the HTTP query and configuration request (referring to all information in the request) to obtain specific request tasks (referring to specific configuration and query tasks, such as a whitelist configuration request, a whitelist query request, etc.) and / or data parts (referring to the specific data to be configured. For example, for a whitelist configuration request, the data part is the wireless sensor whitelist list; for a wireless sensor upgrade request, the data part can be an upgrade package, etc.). Among them, for a configuration request, specific request tasks and data parts can be parsed, while for a query request, only specific request tasks can be parsed. The parsing process is a conventional technology; the specific request tasks and / or data parts are organized into the payload content according to a preset data structure (which is a conventional technology), and then a message header and a message tail are added in the format of Table 1 to form a message, which is placed in the message sending queue; among them, due to the limitations of the serial communication message length and payload length, the wireless sensor protocol conversion and management module will perform unpacking and encapsulation processing on large data packets such as software upgrade packages, and set the fragment number and the number of fragments for each message respectively. The receiving end (i.e., the wireless Lora access module) receives the fragments and then integrates them.
[0055] The wireless sensor protocol conversion and management module periodically checks whether the message sending queue is empty. If it is not empty, it repeatedly retrieves messages from the message sending queue and writes them to the serial port (the messages are received by the wireless Lora access module) until all are retrieved and the message sending queue is emptied.
[0056] In the Modbus serial communication thread, a receiving message buffer is set in the wireless sensor protocol conversion and management module. The wireless sensor protocol conversion and management module listens for the serial port read signal. When serial port data is read, the data is appended to the receiving message buffer (the receiving message buffer is used to cache wireless sensor data type messages forwarded by the wireless Lora access module and messages carrying the payload response results sent by the wireless Lora access module), and the message processing process is started (unpacking processing + single message processing is performed by the wireless sensor protocol conversion and management module), as Figure 2 shown.
[0057] As Figure 3 shown, the unpacking process of the receiving message buffer is as follows:
[0058] Set the content from the message start flag to the payload length in Table 1 as the message header content, and set the CRC check in Table 1 as the message tail content.
[0059] Enter the interface of the receiving message buffer processing function, and judge whether the length of the message in the receiving message buffer (referring to the total length of all messages) exceeds the limit length. If it is too long, directly clear the message queue in the receiving message buffer. The purpose of this is to avoid the buffer becoming too large in case of anomalies, which may cause the program to crash.
[0060] Judge whether the length of the message in the receiving message buffer is greater than the length of the message header + the length of the message tail. If the message length is too small, wait for the next serial port data reception before processing. If the length is sufficient, traverse the message from the beginning to find the message start flag, copy the content of the message header corresponding to the message start flag from the receiving message buffer, and obtain the payload length in the message header. During unpacking, each message is unpacked separately. Therefore, the length of the message header and the length of the message tail during unpacking refer to the length of the message header and the length of the message tail of a single message (each message has the same message header length and the same message tail length). The length of the message in the receiving message buffer refers to the total length of all messages in the receiving message buffer.
[0061] Judge whether the length of the message in the receiving message buffer is greater than or equal to the length of the message header + the length of the message tail + the payload length. If the message length is too small, wait for the next serial port data reception before processing. If the length is sufficient, copy the payload content and the message tail check code from the receiving message buffer (that is, start copying the payload content and the corresponding message tail after the message header copied in the previous paragraph). The payload length in this paragraph refers to the payload length in the message header obtained in the previous paragraph.
[0062] For the message header, payload content, and message tail copied above, calculate the CRC check code of the data from the message start flag in the message header to the end of the payload content, and compare it with the CRC check code in the message tail. If they are the same, it means the message to be retrieved is correct. Then, take out the content of the message header, payload content, and message tail from the receiving message buffer for subsequent processing of this single message, and at the same time continue the next round of unpacking processing. If the check fails, continue to search for the first two bytes of the message header (i.e., the message start flag) after the first two bytes of the previous message header for the next round of judgment.
[0063] As Figure 4 shown, single message processing:
[0064] Obtain a single message through the above unpacking process of the receiving message buffer. For a single message, copy the message header, obtain the message header information, and judge the message type according to the message type in the message header. The message types include configuration operation result type (i.e., HTTP configuration response type), configuration query response type (i.e., HTTP query response type), and wireless sensor data type.
[0065] Configuration operation result class: After the wireless sensor Web configuration management backend issues a configuration request for the wireless sensor (such as deleting and clearing the yellow list, deleting and clearing the white list, file upgrade, etc.), an acknowledgment message (i.e., a message carrying the acknowledgment result) is sent by the wireless Lora access module. The acknowledgment result is generally success or failure. The wireless sensor protocol conversion and management module parses the data (such as the white list) and the acknowledgment result (success or failure) based on the payload content of the acknowledgment message, and then organizes an HTTP acknowledgment message according to the parsed content for HTTP acknowledgment reply.
[0066] Configuration query acknowledgment class: The wireless sensor Web configuration management backend issues a configuration query request for the wireless sensor (such as yellow list query, white list query, etc.). An acknowledgment message (i.e., a message carrying the acknowledgment result) is sent by the wireless Lora access module. The wireless sensor protocol conversion and management module parses the data (such as the yellow list) and the acknowledgment result (success or failure) according to the payload content of the acknowledgment message in accordance with the pre-agreed data structure, and then organizes an HTTP acknowledgment message according to the parsed content for HTTP acknowledgment reply.
[0067] For the configuration operation result class and configuration query acknowledgment class messages, after message parsing, the parsed content is cached and marked as read. Within the timeout period or after sensing that the reading is complete, an HTTP acknowledgment message is organized for acknowledgment according to the cached parsed content.
[0068] Wireless sensor data class: The wireless sensor data class includes service data messages (monitoring data messages, alarm data messages, etc.) uploaded by the wireless sensor; it also includes acknowledgment messages for MQTT control commands. By parsing the payload content of the wireless sensor data class message (specifically, the payload content contains message type information, for example, 000 represents a monitoring data message, 010 represents an alarm data message, 101 represents a control acknowledgment message), it is determined whether it is a wireless sensor service data message or an acknowledgment message for an MQTT control command, and the corresponding Topic topic of the MQTT protocol is assigned. The payload content is taken out from the wireless sensor data class message and data encapsulation is performed in combination with the Topic topic to publish the MQTT message.
[0069] Such as Figure 5As shown in the figure, for the MQTT processing thread, the MQTT client connects to the MQTT server according to the MQTT connection configuration (this server is also deployed in the gateway). It subscribes to relevant topics (for example: the topic corresponding to the monitoring data reporting is " / v1 / %1 / sensor / rawdata / upload", replace %1 in the expression with the sensor; the topic corresponding to the control response: " / v1 / %1 / sensor / rawdata / upload / ack", replace %1 in the expression with the sensor). Set up an MQTT message buffer (this buffer is set in the wireless sensor protocol conversion and management module). Among them, both the uplink protocol conversion module and the wireless sensor protocol conversion and management module are connected to the MQTT server. Inside the thread, the wireless sensor protocol conversion and management module continuously checks whether the MQTT message buffer is empty. If it is not empty, it sequentially extracts the MQTT message topic and payload content one by one and publishes the MQTT message.
[0070] When the MQTT processing thread (for example, the wireless sensor protocol conversion and management module) receives the subscribed topic message, the wireless sensor protocol conversion and management module determines the message type according to the topic (each topic has a unique corresponding message type, and the message types include control messages, control responses, wireless sensor service data, etc.). If it is a message for wireless sensor control and operation (MQTT control command message), it extracts the payload content in the MQTT message, adds a message header and a message tail, writes it through the serial port, and forwards it to the wireless Lora processing module for further processing. After the control is sent to the wireless sensor, an acknowledgment message will be returned; if it is found to be other messages (heartbeat, reset, process daemon, etc., these messages also have corresponding topics) after determining the message type according to the topic, the following processing flow for other messages can be carried out: parse the content of other messages, encapsulate other messages into the form in Table 1, then write it through the serial port and forward it to the wireless Lora processing module for further processing. After the wireless sensor is sent, an acknowledgment message will be returned. For the wireless sensor data type message read by the wireless sensor protocol conversion and management module, it determines whether it is a wireless sensor service data, an acknowledgment message of the MQTT control command, or an acknowledgment message of other messages through the payload content, and then organizes the corresponding MQTT message content according to different message topics and appends it to the MQTT message buffer, waiting for sending and processing.
[0071] The content of the MQTT payload is generally the service data uploaded by wireless sensors or the control commands sent by the upstream protocol conversion module to wireless sensors. The wireless sensor messages need to be further encapsulated. Generally, the payload content of the wireless sensor messages is encrypted using BASE64 and converted into visible characters, which are then encapsulated in the MQTT message as a part of the MQTT message. In this way, only the BASE64 encoding and decoding of the wireless sensor messages are required for uploading and downloading, which is more convenient for processing.
[0072] HTTP service processing thread:
[0073] The wireless sensor protocol conversion and management module starts the HTTP service and listens for HTTP data requests (i.e., HTTP query and configuration requests). When the wireless sensor protocol conversion and management module receives an HTTP request, it obtains the content of the HTTP request, performs data parsing to obtain the specific request task and data part, organizes the payload content according to the preset data structure, adds a message header and a message tail, and adds this part of the content to the message sending queue. Then it starts a message loop to wait, sets a waiting timeout, and if a serial port response is received within the timeout, it performs HTTP framing on the response content and replies to the connected HTTP client.
[0074] For example, for the white list query, the process is as follows: receive the HTTP white list query command - organize the white list query message - insert it into the serial port write queue - start the message loop to wait - serial port white list response - organize the white list response HTTP message - exit the message loop processing - reply to the HTTP white list message.
[0075] For the white list configuration, the process is as follows: receive the HTTP white list setting command - obtain the sensor white list in the HTTP white list setting request - organize the white list setting message - insert it into the serial port write queue - start the message loop to wait - serial port white list write response - organize the white list setting response HTTP message - exit the message loop processing - reply to the HTTP white list setting message.
[0076] The above embodiments are only used to illustrate the technical solutions of the present invention. Those skilled in the art should understand that the above embodiments do not limit the present invention in any form. Any technical solutions obtained by equivalent replacement or equivalent transformation fall within the protection scope of the present invention.
Claims
1. A wireless sensor device management and data handling system for a gateway device, characterized in that: Including: A wireless Lora access module, which is used to receive service data packets sent by wireless sensor devices and send query, configuration, and control packets to wireless sensor devices; And perform data interaction with the wireless sensor protocol conversion and management module; A wireless sensor protocol conversion and management module, which is used to communicate with the wireless Lora access module, read wireless sensor service data packets, and forward query, configuration, and control packets; It is used to respond to queries and configuration requests from the Web configuration client and encapsulate and forward the query and configuration requests to the wireless Lora access module; for protocol conversion of wireless sensor service data, convert the read wireless sensor service data into MQTT packets and forward them to the upstream protocol conversion module; convert the MQTT control command packets sent by the upstream protocol conversion module into wireless sensor control packets and forward them to the wireless Lora access module; An upstream protocol conversion module, which is used to receive the wireless sensor service data packets after protocol conversion by the wireless sensor protocol conversion and management module and forward them to the upstream platform; It is used to forward the control commands sent by the upstream platform, convert the control commands into MQTT control command packets and send them to the wireless sensor protocol conversion and management module; A wireless sensor Web configuration management backend, which is used to receive queries and configuration requests sent by the Web configuration client, convert them into HTTP queries and configuration requests and send them to the wireless sensor protocol conversion and management module; It is used to receive the HTTP messages replied by the wireless sensor protocol conversion and management module and forward them to the Web configuration client.
2. The wireless sensor device management and data handling system of a gateway machine according to claim 1, wherein: The wireless Lora access module, the wireless sensor protocol conversion and management module, the upstream protocol conversion module, and the wireless sensor Web configuration management backend are all set in the gateway machine.
3. A wireless sensor device management and data handling system for a network gateway according to claim 1, characterized in that: The communication protocol between the wireless sensor protocol conversion and management module and the wireless Lora access module includes a message start flag, a message ID number, a message type, a fragmentation sequence number, a fragmentation quantity, a payload length, a payload content, and a CRC check.
4. The wireless sensor device management and data handling system of a gateway machine according to claim 3, wherein: The wireless sensor protocol conversion and management module communicates with the wireless Lora access module through a serial port; a received packet buffer is set in the wireless sensor protocol conversion and management module, and the received packet buffer is unpacked. The unpacking process of the received message buffer is specifically as follows: Set the content from the message start flag to the payload length as the message header content, and set the CRC check as the message tail content; Enter the processing function interface of the received message buffer, and determine whether the message length in the received message buffer exceeds the limit length. If it exceeds the limit length, directly clear the message queue in the received message buffer; When the message length in the received message buffer is greater than the message header length + the message tail length, copy the message header content from the received message buffer and obtain the payload length in the message header; When the message length in the received message buffer is greater than or equal to the message header length + the message tail length + the payload length, copy the payload content and the CRC check code of the message tail from the received message buffer; Calculate the CRC check code of the message header and the payload content, and compare it with the CRC check code of the message tail. If they are consistent, it means the message to be retrieved is correct, and take out the message header, payload content, and message tail from the received message buffer for processing as a single message.
5. The wireless sensor device management and data handling system of a network gateway according to claim 4, characterized in that: The messages entering the received message buffer include the wireless sensor data type messages forwarded by the wireless Lora access module and the messages with payload response results sent by the wireless Lora access module.
6. The wireless sensor device management and data handling system of a web gateway according to claim 4, wherein: In the wireless sensor protocol conversion and management module, the specific process of single message processing is as follows: Copy the message header and obtain the message header information, and parse the message type according to the message type. If the message type is the response message for HTTP query and configuration request, parse the message with the payload response result. Organize the HTTP response message and reply the HTTP response message to the wireless sensor Web configuration management backend. If the message type is of the wireless sensor data type, parse the payload content of the message to determine whether it is a service data message uploaded by the wireless sensor or a response message to the MQTT control command, assign the corresponding MQTT protocol topic Topic, encapsulate the payload content of the service data message uploaded by the wireless sensor or the response message to the MQTT control command into an MQTT message, and then add it to the MQTT message buffer to wait for MQTT message publishing.
7. The wireless sensor device management and data handling system of a gateway computer according to claim 4, characterized in that: In the wireless sensor protocol conversion and management module, perform BASE64 encryption processing on the payload content of the service data message uploaded by the wireless sensor and encapsulate it in the MQTT message; perform BASE64 decryption processing on the MQTT control command message for the wireless sensor sent by the upstream protocol conversion module.
8. The wireless sensor device management and data handling system of a web gateway according to claim 4, characterized in that: The wireless sensor Web configuration management backend receives the query and configuration requests sent by the Web configuration client, converts them into HTTP query and configuration requests and sends them to the wireless sensor protocol conversion and management module. The wireless sensor protocol conversion and management module parses the content of the HTTP query and configuration request, obtains the specific request tasks and / or data parts, organizes the payload content, then adds a message header and a message tail to form a message, and sends it to the wireless Lora access module; then starts a message loop to wait, sets a waiting timeout, and if a serial port response is received within the timeout, the wireless sensor protocol conversion and management module organizes an HTTP response message according to the content of the response and replies to the wireless sensor Web configuration management backend, and then the wireless sensor Web configuration management backend forwards the HTTP response message to the connected Web configuration client.
9. A method for managing and disposing of wireless sensor devices of a network gateway using the system according to any one of claims 1-8.
10. A gateway, characterized in that, A system for managing and disposing of wireless sensor devices including the network gateway according to any one of claims 1-8.