Internet of Things communication method and device, equipment, storage medium and program product
By dynamically loading and matching protocol resolution plug-ins in the Internet of Things system, the problem of insufficient flexibility and scalability in traditional systems when facing new protocols or needing to update parsing logic is solved, and the flexibility and scalability of the system are greatly improved.
Patent Information
- Application Number
- CN202510222606.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-27
- Publication Date
- 2025-05-30
AI Technical Summary
When traditional IoT systems face new communication protocols or need to update protocol parsing logic, they have low flexibility and scalability, and require modification of source code and redeployment of the system.
Through the dynamic loading protocol analysis plug-in, match the target plug-in based on the received working data, and use the plug-in to parse the data to extract the target information. When the system starts, scan the plug-in files in the preset directory through the plug-in manager, use Python's importlib module to dynamically load the plug-in, and register it in the plug-in list.
Improves the flexibility and scalability of IoT systems, allowing the system to support new protocols and update parsing logic without modifying core code, and adapts to diverse IoT devices.
Smart Images

Figure CN120075102A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the technical field of the Internet of Things, and in particular, to an Internet of Things communication method, device, equipment, storage medium, and program product. Background Art
[0002] An Internet of Things system usually involves multiple devices. These devices may use different communication protocols for data exchange, and there may also be an addition of devices using new communication protocols. Traditional protocol parsing methods are usually implemented by hard coding in the system. This method is difficult to handle when facing new protocols or when the protocol parsing logic needs to be updated. It requires modifying the source code and redeploying the system, resulting in low flexibility and scalability of the Internet of Things system. Summary of the Invention
[0003] Embodiments of the present invention provide an Internet of Things communication method, device, equipment, storage medium, and program product to improve the flexibility and scalability of the Internet of Things system.
[0004] In a first aspect, embodiments of the present invention provide an Internet of Things communication method, which includes:
[0005] Receiving working data sent by an Internet of Things device;
[0006] Matching a target protocol parsing plugin according to the working data;
[0007] Using the target protocol parsing plugin to parse the working data and extracting target information.
[0008] Optionally, the method further includes:
[0009] When the system starts, scanning plugin files in a preset directory through a plugin manager, dynamically loading protocol parsing plugins using the importlib module of Python, checking whether the plugin files exist, whether the plugins have a correct module structure, and whether the plugins implement a standard protocol parsing interface during the loading process, and registering the successfully loaded protocol parsing plugins in a plugin list.
[0010] Optionally, the matching a target protocol parsing plugin according to the working data includes:
[0011] Determining the target protocol parsing plugin based on the header information or port number of the working data and a preset plugin routing table.
[0012] Optionally, after the target information is extracted, it further includes:
[0013] Converting the target information into a preset unified data structure.
[0014] Optionally, after parsing the working data using the target protocol parsing plugin, the following steps are further included:
[0015] If an error occurs during parsing, at least one of the following operations is performed: logging, reporting the error content, and attempting to reconnect.
[0016] Optionally, the target protocol parsing plugin includes at least one of an MQTT protocol plugin, an HTTP protocol plugin, a CoAP protocol plugin, and a Modbus protocol plugin.
[0017] In a second aspect, an embodiment of the present invention further provides an Internet of Things communication device, which includes:
[0018] A data receiving module, configured to receive working data sent by an Internet of Things device;
[0019] A plugin matching module, configured to obtain a target protocol parsing plugin according to the working data;
[0020] A data parsing module, configured to parse the working data using the target protocol parsing plugin and extract target information.
[0021] In a third aspect, an embodiment of the present invention further provides a computer device, which includes:
[0022] One or more processors;
[0023] A memory, configured to store one or more programs;
[0024] When the one or more programs are executed by the one or more processors, the one or more processors implement the Internet of Things communication method provided in any embodiment of the present invention.
[0025] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, it implements the Internet of Things communication method provided in any embodiment of the present invention.
[0026] In a fifth aspect, an embodiment of the present invention further provides a computer program product, which includes a computer program, and when the program is executed by a processor, it implements the Internet of Things communication method provided in any embodiment of the present invention.
[0027] An embodiment of the present invention provides an Internet of Things (IoT) communication method. When receiving working data sent by an IoT device, a target protocol parsing plugin is matched according to the working data, and then the determined target protocol parsing plugin is used to parse the working data to extract target information therefrom. The IoT communication method provided by the embodiment of the present invention can greatly improve the flexibility and scalability of the IoT system when dealing with diverse IoT devices by dynamically loading appropriate protocol parsing plugins for corresponding data parsing as needed at runtime of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 It is a flowchart of the IoT communication method provided in Embodiment 1 of the present invention;
[0029] Figure 2 It is a schematic structural diagram of the IoT communication device provided in Embodiment 2 of the present invention;
[0030] Figure 3 It is a schematic structural diagram of the computer device provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0031] The present invention will be further described in detail below with reference to the drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the present invention, rather than limiting the present invention. Additionally, it should be noted that for the sake of description, only parts related to the present invention rather than all structures are shown in the drawings.
[0032] Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the steps as sequential processes, many of the steps can be implemented in parallel, concurrently, or simultaneously. In addition, the order of the steps can be rearranged. The process can be terminated when its operations are completed, but it can also have additional steps not included in the drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0033] Embodiment 1
[0034] Figure 1 It is a flowchart of the IoT communication method provided in Embodiment 1 of the present invention. This embodiment is applicable to the situation where an IoT system communicates with IoT devices using different communication protocols. This method can be executed by the IoT communication device provided by the embodiment of the present invention, and the device can be implemented in a hardware and / or software manner and is generally integrated into a computer device. As Figure 1 shown, it specifically includes the following steps:
[0035] S11. Receive the working data sent by the IoT device.
[0036] S12. Match a target protocol parsing plugin according to the work data.
[0037] S13. Use the target protocol parsing plugin to parse the work data and extract target information.
[0038] Specifically, the Internet of Things (IoT) system can communicate with various IoT devices. Each IoT device can support different communication protocols, such as MQTT, CoAP, HTTP, Modbus, etc. Among them, the MQTT protocol is suitable for lightweight communication, the CoAP protocol is suitable for low-power devices, the HTTP protocol is often used to transmit control commands, and the Modbus protocol is commonly used in industrial devices. Exemplarily, sensors may use the MQTT protocol to send data. The IoT system needs to be able to process data of various protocols and ensure interoperability and data compatibility between devices. To flexibly support these different communication protocols, a plug-in protocol parsing method can be adopted, which provides great convenience for the use of the IoT system. The plug-in protocol parsing method defines a standard protocol parsing interface, allowing different protocol parsing modules to exist as plug-ins. Each plug-in is responsible for parsing and processing data of a specific protocol, and the standard protocol parsing interface can ensure that the plug-ins have the same parsing function. The plug-in protocol parsing method draws on the idea of modular design, decouples each functional module of the system, so that each module can be developed, tested, deployed, and maintained independently without affecting other parts of the system. New protocol support can be extended or existing parsing logic can be updated without shutting down the system. It can easily integrate and parse different types of protocols without modifying the core code. Further, to simplify the development and management of plug-ins, a plug-in framework such as OSGi (Open Service Gateway Initiative), Java plug-in framework, etc. can be used to provide standard plug-in development, deployment, and management mechanisms, enabling plug-in developers to focus on the implementation of business logic without having to pay too much attention to the details of plug-in loading and management.
[0039] Optionally, the method further includes: when the system starts, scanning for plugin files in a preset directory through a plugin manager, dynamically loading protocol parsing plugins using Python's importlib module, and during the loading process, checking whether the plugin files exist, whether the plugins have the correct module structure, and whether the plugins implement the standard protocol parsing interface, and registering the successfully loaded protocol parsing plugins in the plugin list. Specifically, it can be implemented through the plugin manager, and those that pass the check can be successfully loaded and registered in the plugin list of the plugin manager for selection. The plugin files can be, for example, Python module files ending with.py. After the protocol parsing plugin is loaded, its initialization method can be called first for initialization. The initialization method can receive preset configuration parameters, such as the path of the log file, the network port number, etc. The initialization process can include the initialization of resources and the loading of configuration files. For example, a certain plugin may need to connect to a database or load a configuration file to set its working environment. Correspondingly, the plugins can be managed through configuration files or other means to flexibly configure the protocol parsing behavior of the system according to needs, thereby making it easy to modify and adjust the system behavior and improving the configurability of the system.
[0040] When an Internet of Things device sends working data to the Internet of Things system, the system can first select the corresponding target protocol parsing plugin. Specifically, the protocol parsing plugin can be dynamically loaded and managed through the plugin manager, and according to the protocol types adopted by different devices, the appropriate target protocol parsing plugin can be automatically loaded. The selection process can be responsible for by a policy module and is selected based on preset rules. Optionally, obtaining the target protocol parsing plugin according to the working data includes: determining the target protocol parsing plugin based on the header information or port number of the working data and a preset plugin routing table, and the preset plugin routing table can determine the plugin corresponding to each protocol. Exemplarily, when the system detects that an Internet of Things device sends working data through the MQTT protocol, the MQTT protocol plugin can be automatically loaded for data parsing. Among them, optionally, the target protocol parsing plugin includes at least one of an MQTT protocol plugin, an HTTP protocol plugin, a CoAP protocol plugin, and a Modbus protocol plugin. The MQTT protocol plugin is responsible for parsing MQTT messages and can extract sensor data (such as temperature, humidity, pressure, etc.), the HTTP protocol plugin is responsible for parsing the data received through HTTP, such as device control instructions or status updates, the CoAP protocol plugin is responsible for parsing CoAP protocol messages, and the Modbus protocol plugin is responsible for parsing Modbus protocol messages.
[0041] After selecting the target protocol parsing plugin, the system can transfer the working data to the target protocol parsing plugin for parsing. Subsequently, the target protocol parsing plugin can parse the working data according to the protocol specifications and extract the required target information and return it to the system. Exemplarily, the HTTP protocol plugin can extract the request method, path, header information, etc. Optionally, after the target information is extracted, it further includes: converting the target information into a preset unified data structure. Specifically, the corresponding target protocol parsing plugin can implement data extraction, conversion, formatting, etc., and can convert it into a data format that the system can process to ensure that the data meets the requirements of the IoT system and is convenient for other parts of the system to use. Exemplarily, for sensor data, specific sensor values (such as temperature, humidity, etc.) can be parsed and these values can be converted into a format that can be used internally in the system. For control commands, corresponding instructions can be parsed, such as turning on / off devices, adjusting device configurations, etc., so as to perform corresponding operations according to the instructions. After the parsing process is completed, the plugin can also be unloaded through the plugin manager to wait for the next data processing. Additionally, the plugin manager is also responsible for plugin updates. When new devices or protocols are connected, new parsing plugins can be seamlessly added to the system without affecting other parts of the system.
[0042] The IoT system can also pre-load multiple protocol parsing plugins and keep them working. For the situation where a large number of IoT devices send a large amount of working data to the system successively, the received working data can be classified first, such as adding it to the corresponding data queue. Each data queue can correspond to a protocol parsing plugin, and the corresponding multiple pre-loaded protocol parsing plugins can parallelly obtain the working data from the corresponding data queues one by one for parsing, thereby improving the data processing efficiency.
[0043] Based on the above technical solution, optionally, after using the target protocol parsing plugin to parse the working data, it further includes: if an error occurs during parsing, performing at least one of the operations of logging, reporting the error content, and attempting to reconnect. Specifically, various errors may be encountered during the parsing process, such as data format errors, network connection interruptions, etc. Then, these errors can be captured by the target protocol parsing plugin and appropriately processed to avoid affecting the stability and reliability of the system.
[0044] After the extraction of the target information is completed, the system can respond and execute based on the target information. Specifically, different processing logics can be called or corresponding response messages can be sent according to the requirements of different protocol types. Exemplarily, when the data of a temperature and humidity sensor is received, such as when the temperature is too high, the system can trigger an alarm, or when a control command is received, the system can correspondingly adjust the working state of the device, etc.
[0045] When the technical solution provided by the embodiment of the present invention receives the working data sent by the Internet of Things device, it matches the target protocol parsing plugin according to the working data, and then uses the determined target protocol parsing plugin to parse the working data to extract the target information therein. By dynamically loading appropriate protocol parsing plugins for corresponding data parsing as needed during system operation, the flexibility and scalability of the Internet of Things system can be greatly improved when dealing with diverse Internet of Things devices.
[0046] Embodiment 2
[0047] Figure 2 It is a schematic structural diagram of the Internet of Things communication device provided by the second embodiment of the present invention. This device can be implemented in a hardware and / or software manner and is generally integrated into a computer device for executing the Internet of Things communication method provided by any embodiment of the present invention. As Figure 2 shown, the device includes:
[0048] A data receiving module 21, configured to receive the working data sent by the Internet of Things device;
[0049] A plugin matching module 22, configured to match the target protocol parsing plugin according to the working data;
[0050] A data parsing module 23, configured to parse the working data using the target protocol parsing plugin and extract the target information.
[0051] When the technical solution provided by the embodiment of the present invention receives the working data sent by the Internet of Things device, it matches the target protocol parsing plugin according to the working data, and then uses the determined target protocol parsing plugin to parse the working data to extract the target information therein. By dynamically loading appropriate protocol parsing plugins for corresponding data parsing as needed during system operation, the flexibility and scalability of the Internet of Things system can be greatly improved when dealing with diverse Internet of Things devices.
[0052] Based on the above technical solution, optionally, the device further includes:
[0053] A plugin registration module, configured to scan the plugin files in the preset directory through the plugin manager when the system starts, dynamically load the protocol parsing plugins using the importlib module of Python, check whether the plugin files exist, whether the plugins have the correct module structure, and whether the plugins implement the standard protocol parsing interface during the loading process, and register the successfully loaded protocol parsing plugins in the plugin list.
[0054] Based on the above technical solution, optionally, the plugin matching module 22 is specifically configured to:
[0055] Based on the header information or port number of the working data, determine the target protocol parsing plugin based on a preset plugin routing table.
[0056] Based on the above technical solution, optionally, the device further includes:
[0057] A data unification module, configured to convert the target information into a preset unified data structure after the target information is extracted.
[0058] Based on the above technical solution, optionally, the device further includes:
[0059] An error handling module, configured to perform at least one of logging, reporting error content, and attempting to reconnect in case of an error after parsing the working data using the target protocol parsing plugin.
[0060] Based on the above technical solution, optionally, the target protocol parsing plugin includes at least one of an MQTT protocol plugin, an HTTP protocol plugin, a CoAP protocol plugin, and a Modbus protocol plugin.
[0061] The Internet of Things communication device provided by the embodiments of the present invention can execute the Internet of Things communication method provided by any embodiment of the present invention, and has corresponding functional modules and beneficial effects for executing the method.
[0062] It should be noted that in the embodiments of the above Internet of Things communication device, the included units and modules are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific names of the functional units are only for the convenience of mutual distinction and do not limit the protection scope of the present invention.
[0063] Embodiment III
[0064] Figure 3 It is a schematic structural diagram of a computer device provided by Embodiment III of the present invention, showing a block diagram of an exemplary computer device suitable for implementing the embodiments of the present invention. Figure 3 The displayed computer device is only an example and should not bring any limitations to the functions and usage scope of the embodiments of the present invention. As Figure 3 shown, the computer device includes a processor 31, a memory 32, an input device 33, and an output device 34; the number of processors 31 in the computer device can be one or more, Figure 3 taking one processor 31 as an example, the processor 31, the memory 32, the input device 33, and the output device 34 in the computer device can be connected through a bus or other means, Figure 3 taking connection through a bus as an example.
[0065] The memory 32, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as the program instructions / modules corresponding to the Internet of Things communication method in the embodiments of the present invention (for example, the data receiving module 21, the plug-in matching module 22, and the data parsing module 23 in the Internet of Things communication device). The processor 31 executes various functional applications and data processing of the computer device by running the software programs, instructions, and modules stored in the memory 32, that is, implements the above-mentioned Internet of Things communication method.
[0066] The memory 32 may mainly include a program storage area and a data storage area. Among them, the program storage area can store an operating system and application programs required for at least one function; the data storage area can store data created according to the use of the computer device. In addition, the memory 32 may include high-speed random access memory and may also include non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some instances, the memory 32 may further include a memory remotely set relative to the processor 31, and these remote memories can be connected to the computer device through a network. Examples of the above network include but are not limited to the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.
[0067] The input device 33 can be used to receive the working data sent by the Internet of Things device and generate key signal inputs related to the user settings and function controls of the computer device. The output device 34 can be used to send control instructions to the device, etc.
[0068] Embodiment Four
[0069] Embodiment Four of the present invention further provides a storage medium containing computer-executable instructions, and the computer-executable instructions are used to execute an Internet of Things communication method when executed by a computer processor. The method includes:
[0070] Receiving the working data sent by the Internet of Things device;
[0071] Matching a target protocol parsing plug-in according to the working data;
[0072] Using the target protocol parsing plug-in to parse the working data and extracting target information.
[0073] The storage medium can be any of various types of memory devices or storage devices. The term "storage medium" is intended to include: installation media such as CD-ROMs, floppy disks, or magnetic tape devices; computer system memory or random access memory such as DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory such as flash memory, magnetic media (such as hard disks or optical storage); registers or other similar types of memory elements, etc. The storage medium can also include other types of memory or combinations thereof. Additionally, the storage medium can be located in the computer system in which the program is executed, or it can be located in a different second computer system that is connected to the computer system via a network (such as the Internet). The second computer system can provide program instructions to the computer for execution. The term "storage medium" can include two or more storage media that can reside in different locations (such as in different computer systems connected via a network). The storage medium can store program instructions (such as embodied as a computer program) executable by one or more processors.
[0074] Of course, for a storage medium containing computer-executable instructions provided by an embodiment of the present invention, the computer-executable instructions are not limited to the method operations as described above, and can also execute related operations in the Internet of Things communication method provided by any embodiment of the present invention.
[0075] A computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device.
[0076] The program code contained on a computer-readable medium can be transmitted using any appropriate medium, including but not limited to wireless, wire, optical fiber, RF, etc., or any suitable combination of the above.
[0077] Through the above description of the embodiments, those skilled in the art can clearly understand that the present invention can be implemented by means of software and necessary general hardware. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as a floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disc of a computer, etc., including several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments of the present invention.
[0078] Embodiment 5
[0079] Embodiment 5 of the present invention further provides a computer program product. This computer program product includes a computer program (which can also be called code, instruction), and this computer program can be stored in a computer-readable storage medium. When this computer program is executed by a processor, it is used to execute the Internet of Things communication method provided in any of the above embodiments, and has the corresponding beneficial effects of the execution method.
[0080] Note that the above is only the preferred embodiment of the present invention and the applied technical principle. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described here. Various obvious changes, re-adjustments and substitutions can be made by those skilled in the art without departing from the protection scope of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments. Without departing from the concept of the present invention, it can also include more other equivalent embodiments, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. An Internet of Things communication method, characterized in that: include: Receive working data sent by IoT devices; Obtaining a target protocol parsing plug-in according to the working data matching; The target protocol parsing plug-in is used to parse the working data and extract the target information.
2. The Internet of Things communication method according to claim 1, characterized in that: The method further comprises: When the system starts, the plug-in manager scans the plug-in files in the preset directory and uses Python's importlib module to dynamically load the protocol parsing plug-in. During the loading process, it checks whether the plug-in file exists, whether the plug-in has the correct module structure, and whether the plug-in implements the standard protocol parsing interface. The successfully loaded protocol parsing plug-in is registered in the plug-in list.
3. The Internet of Things communication method according to claim 1, characterized in that: The step of obtaining a target protocol parsing plug-in according to the working data matching includes: According to the header information or port number of the working data, the target protocol parsing plug-in is determined based on a preset plug-in routing table.
4. The Internet of Things communication method according to claim 1, characterized in that: After the target information is extracted, the method further includes: The target information is converted into a preset unified data structure.
5. The Internet of Things communication method according to claim 1, characterized in that: After the working data is parsed using the target protocol parsing plug-in, the method further includes: If an error occurs in the parsing, at least one of the following operations is performed: logging, reporting the error content, and attempting to reconnect.
6. The Internet of Things communication method according to claim 1, characterized in that: The target protocol parsing plug-in includes at least one of an MQTT protocol plug-in, an HTTP protocol plug-in, a CoAP protocol plug-in, and a Modbus protocol plug-in.
7. An Internet of Things communication device, characterized in that: include: A data receiving module, used to receive working data sent by IoT devices; A plug-in matching module, used for matching and obtaining a target protocol parsing plug-in according to the working data; The data parsing module is used to parse the working data using the target protocol parsing plug-in and extract the target information.
8. A computer device, characterized in that: include: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the Internet of Things communication method as described in any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the Internet of Things communication method as described in any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the Internet of Things communication method as described in any one of claims 1 to 6.
Citation Information
Cited By
Data processing method and device, optical storage direct flexible equipment, system and storage medium
CN120881173A
Signal analysis method, system and equipment of cloud original biological networking equipment
CN122204972A