Multi-protocol multi-communication interface switching control method for air monitor
By implementing a multi-protocol and multi-interface switching control method in the air monitoring equipment, the problems of insufficient equipment compatibility, flexibility and maintenance capabilities are solved, the equipment adaptability and system stability are improved, and efficient data transmission and easy-to-maintenance operations are achieved.
Patent Information
- Application Number
- CN202411801330.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-03-28
AI Technical Summary
Existing air monitoring equipment has significant shortcomings in compatibility, flexibility, resource management and maintenance capabilities, and it is difficult to meet the needs of modern smart buildings and IoT applications for multi-protocol, multi-interface, high reliability and easy maintenance.
It provides a multi-protocol multi-communication interface switching control method, collects environmental data through sensors, supports multiple communication protocols (such as Modbus RTU, BACnet IP, MQTT) and physical interfaces (such as RS485, WiFi, Ethernet, 4G, LoRa), realizes data exchange between protocol tasks and communication interface tasks, and realizes equipment fault diagnosis, parameter calibration and software upgrade through remote maintenance protocols.
It improves the adaptability and compatibility of the equipment, enhances the stability and operating efficiency of the system, reduces operation and maintenance costs, and realizes flexible configuration and efficient maintenance of the equipment.
Smart Images

Figure CN119728797A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of air quality monitoring, and in particular to a multi-protocol multi-communication interface switching control method for an air monitor. Background Art
[0002] With the rapid development of industrial automation, building intelligence and Internet of Things technology, air quality monitors have been widely used in indoor environmental quality monitoring, energy management and green building certification. However, existing air monitoring equipment has exposed some shortcomings in practical applications. Most air monitors only support a single communication protocol and communication interface, which makes them difficult to be compatible with different building management systems or cloud platforms. This design limits the applicability of the equipment in complex and diverse application scenarios, and increases the difficulty of system integration.
[0003] In addition, existing devices usually need to rely on additional gateways or adapters when connecting to multiple systems, which not only increases deployment costs, but also may introduce additional failure points, reducing the overall reliability of the system. When user needs change, device protocol upgrades or interface expansions often require hardware replacement or reconfiguration of the entire system, resulting in high maintenance complexity and lack of flexibility.
[0004] At the same time, current air monitors lack effective resource management and task scheduling mechanisms in data transmission, and are unable to maintain the stability and real-time performance of data transmission when multiple protocols are running concurrently. Especially when faced with multiple users, multiple interfaces, and high-frequency data interaction requirements, the equipment often suffers from performance degradation due to resource competition, and even causes system crashes.
[0005] In addition, the maintenance capabilities of existing equipment are limited, and most devices lack remote diagnosis, parameter calibration, or software upgrade functions. Once a failure occurs, technicians are usually required to go to the site for repair, which not only prolongs the maintenance cycle but also increases operating costs. This problem is particularly evident in large-scale distributed deployment scenarios.
[0006] In summary, existing air monitoring equipment has significant deficiencies in compatibility, flexibility, resource management, and maintenance capabilities, and is unable to meet the requirements of modern smart buildings and Internet of Things applications for multiple protocols, multiple interfaces, high reliability, and easy maintainability. Summary of the invention
[0007] In view of the deficiencies in the prior art, the present invention provides a multi-protocol and multi-communication interface switching control method for an air monitor, which solves the problems of poor compatibility, insufficient flexibility, inefficient resource management and complex maintenance of existing air monitoring equipment.
[0008] To achieve the above objectives, the present invention is implemented through the following technical solutions: a multi-protocol multi-communication interface switching control method for an air monitor, comprising the following steps: Collecting environmental data through sensors and storing the environmental data in a data storage pool; According to user needs, select at least one communication protocol and communication interface to activate; The communication protocol is set to run as an independent task and a unique Socket ID is assigned to manage the source and destination of data; Data exchange between protocol tasks and communication interface tasks is realized through software and hardware data exchange buffers; The processed data is transmitted to the target device or cloud server via the activated communication interface.
[0009] The present invention also provides a multi-protocol multi-communication interface switching control device for an air monitor, comprising: Sensor module, used to collect environmental parameter data; Communication protocol processing module, used to support independent task operation of multiple communication protocols, and encode and parse data; Communication interface module, used to support multiple physical interfaces to realize data transmission and reception; The task management module is used to allocate independent running tasks and resources to each communication protocol, and realize multi-protocol concurrency through dynamic scheduling; A storage module is used to store protocol parameters, task configurations, and selection information entered by users; The configuration module is used to receive the communication protocol and interface selected by the user, and transmit the selection information to the communication protocol processing module and the task management module to activate the corresponding functions.
[0010] The present invention provides a multi-protocol multi-communication interface switching control method for an air monitor, which has the following beneficial effects: 1. The present invention supports multiple communication protocols such as Modbus RTU, BACnet IP, MQTT, and multiple physical interfaces such as RS485, WiFi, Ethernet, 4G, LoRa, etc., so that the air monitor can be seamlessly connected with different building management systems, industrial control equipment and cloud platforms. Users can select protocols and interfaces according to actual needs to achieve data transmission requirements in multiple scenarios, thereby improving the adaptability and compatibility of the equipment.
[0011] 2. The present invention uses a real-time operating system to divide each protocol into independent tasks and dynamically allocate resources to them, effectively avoiding resource competition and data conflicts when multiple tasks are running. Through real-time resource monitoring and priority scheduling mechanisms, it ensures that tasks of high real-time protocols can run first, improving the stability and operating efficiency of the system.
[0012] 3. The present invention realizes data sharing and exchange between protocol tasks and communication interface tasks through the data exchange buffer design combining software and hardware. The buffer supports double buffer mechanism and concurrent read and write operations, effectively avoiding data blocking and delay problems between tasks, and improving the overall data throughput and transmission efficiency of the system.
[0013] 4. The present invention realizes the functions of fault diagnosis, parameter calibration and software upgrade by reserving independent remote maintenance protocol tasks. Users can activate the maintenance channel through the configuration interface and establish an encrypted communication connection with the maintenance server for remote operation. After the maintenance is completed, the system automatically releases resources and resumes normal operation, reducing operation and maintenance costs and improving service efficiency.
[0014] 5. By supporting dynamic updating and loading of the protocol stack, the present invention can be compatible with new communication protocols added in the future. Users can enable new protocols through the configuration interface and dynamically adjust resource allocation to support the operation of protocol tasks. This design extends the life cycle of the device and enhances the device's ability to adapt to future changes in technology and application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a schematic diagram of the method flow of the present invention; Figure 2 It is a schematic diagram of the structure of the device of the present invention; Figure 3 Schematic diagram of the system architecture of an embodiment of the present invention.
[0016] Among them, 10, sensor module; 20, communication protocol processing module; 30, communication interface module; 40, task management module; 50, storage module; 60, configuration module. DETAILED DESCRIPTION
[0017] The following will be combined with the drawings in the specification of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0018] Please refer to the attached Figure 1 The present invention provides a multi-protocol and multi-communication interface switching control method for an air monitor, which aims to realize multi-protocol transmission and multi-interface switching of environmental data and improve the compatibility and flexibility of the equipment. The method of the present invention realizes efficient collection, processing and transmission of environmental data through modular design, dynamic task management and resource optimization. The method of the present invention and its implementation are described in detail below in combination with the various steps of the present invention.
[0019] S1. Collect environmental data through sensors and store the environmental data in the data storage pool Generally, air monitors need to collect multiple environmental parameters, such as temperature and humidity, particle concentration, gas concentration, etc. These parameter data are acquired and aggregated through various types of sensors for subsequent multi-protocol transmission and multi-interface data exchange. In the implementation process, the reliability of collected data and the structured design of storage are the key to ensuring system stability.
[0020] In this embodiment, the air monitor is equipped with various types of sensors for collecting different types of environmental data, including but not limited to: Temperature and humidity sensor, used to measure ambient temperature and humidity; Particle sensor, used to detect the concentration of PM2.5 and PM10 in the air; Gas sensors, including carbon dioxide sensors, carbon monoxide sensors, sulfur dioxide sensors and ozone sensors, are used to monitor the concentration of various harmful gases; Ambient light sensor, used to measure light intensity; Ambient noise sensor to detect noise level; Atmospheric pressure sensor, used to measure the ambient air pressure.
[0021] In one possible implementation, all sensors are connected via a standardized hardware interface (such as I 2 C, SPI or UART) is connected to the controller. Specifically, the output signal of each sensor is parsed through the interface protocol, and the parsed data is transmitted to the controller in the form of a digital signal.
[0022] In some implementations, in order to improve the stability and accuracy of data collection, the controller pre-processes the sensor data, including: Data format verification: Perform structural verification on the received data frame to ensure the integrity of the data frame; Data rationality check: eliminate abnormal values that exceed the sensor measurement range; Data denoising: Reduce the impact of external interference on sensor data through filtering algorithms.
[0023] Generally, the processed sensor data will be stored in a data storage pool. The data storage pool is designed as a shared memory area to support concurrent access and multi-protocol call requirements. In this embodiment, each record in the data storage pool is stored in a unified data structure, which includes: Data type identifier, such as temperature, humidity, particulate matter concentration, etc. Data values, such as specific temperature values or gas concentration values; Timestamp, used to mark the specific time of data collection; Data unit and range information, for example, the unit of temperature is "℃".
[0024] In one possible design, the memory capacity of the data storage pool is dynamically adjusted according to the actual needs of the device to adapt to the high-frequency acquisition scenario. Specifically, when there are rapidly changing gas concentrations or particulate matter levels in the monitoring environment, the system will increase the acquisition frequency and allocate more storage space to record a large amount of data in a short period of time.
[0025] As an option, the data storage pool can support persistent storage. After the device is restarted or powered off, the previously collected data can be automatically restored to ensure data integrity and continuity. In some implementations, persistent storage is implemented through a built-in flash chip or an external memory card.
[0026] In another implementation, the data collected by the sensor can also directly trigger the alarm mechanism. For example, when the carbon dioxide concentration or PM2.5 concentration exceeds the set safety threshold, the device will generate a real-time alarm signal, remind the user through a local buzzer or indicator light, and store the alarm information in a specific tag field of the data storage pool for subsequent protocol tasks to call.
[0027] Through the above design, the present invention can ensure the integrity and reliability of the collected environmental data and provide a basic guarantee for subsequent multi-protocol and multi-interface data transmission.
[0028] S2. Select and activate at least one communication protocol and communication interface according to user needs. Generally, user needs may put forward specific requirements for the communication protocol and interface of the device due to different application scenarios. For example, in an industrial environment, the Modbus RTU protocol and RS485 interface may be preferred, while in an IoT scenario, the MQTT protocol and WiFi or 4G interface may be preferred. In order to meet the needs of different users, the present invention designs a flexible configuration mechanism so that users can freely select and switch communication protocols and interfaces according to specific needs.
[0029] In this embodiment, the air monitor provides multiple configuration methods, and the user can select the activated communication protocol and interface through the following ways: Configuration web page: Access is provided through the device's built-in web server. Users can enter the device's IP address through a browser to enter the web configuration interface.
[0030] Bluetooth APP: After pairing with the device via Bluetooth, users can complete the selection of protocols and interfaces in the mobile APP.
[0031] Physical buttons and display: The device integrates buttons and screen at the hardware level, which is suitable for simple local configuration requirements.
[0032] Specifically, during the configuration process, the user needs to select the following: Communication protocols, such as Modbus RTU, BACnet MS / TP, MQTT, Tuya, etc. Communication interfaces, such as RS485, WiFi, Ethernet, 4G, LoRa.
[0033] Generally, the information selected by the user will be written into the device storage unit immediately for subsequent operation configuration. In a possible implementation, the device storage unit can use EEPROM or Flash memory to ensure the persistent storage of user configuration after power failure.
[0034] In some implementations, in order to improve the convenience and fault tolerance of configuration, the configuration interface will also verify the information entered by the user. For example: Verify that the selected protocol matches the interface. For example, the Modbus RTU protocol should correspond to the RS485 interface, and the MQTT protocol should correspond to the WiFi or 4G interface.
[0035] Prompts users about resource usage that may be caused by protocol activation. For example, activating multiple high-load protocols may increase device operating pressure.
[0036] When the user selects an incompatible protocol and interface combination, the interface displays an error message and refuses to save the configuration.
[0037] As an option, after completing the protocol and interface configuration, the device automatically initializes related system resources, including: Create a protocol task: According to the protocol selected by the user, load the corresponding protocol stack code into the memory and allocate running resources.
[0038] Initialize the interface module: According to the selected interface type, complete the setting of parameters such as network address, port number and transmission rate.
[0039] Update device status: mark the activated protocols and interfaces as "enabled" for subsequent task management module calls.
[0040] In some implementations, in order to facilitate batch deployment, the device supports the import and export functions of configuration files. Users can upload configuration files via USB or network to achieve fast configuration and reduce repeated operations.
[0041] Through the above design, the present invention can effectively meet the user's flexible configuration requirements for communication protocols and interfaces, and ensure that the configuration process is simple, easy to use, stable and reliable.
[0042] S3. Set the communication protocol to run as an independent task and assign a unique Socket ID to manage the source and destination of data. Generally, the complexity of multi-protocol multi-task operation is high. In order to avoid resource competition and data confusion between tasks, the present invention adopts the method of independent task operation and Socket identification to ensure that multi-protocol tasks can run in parallel and stably. In the implementation process, the creation of protocol tasks, resource allocation and dynamic management of Socket ID are key links.
[0043] In this embodiment, the air monitor runs based on a real-time operating system (RTOS) and implements independent task operations of the communication protocol through a task management module. Specifically, whenever a user activates a communication protocol, the task management module will assign an independent running task to the protocol and dynamically allocate related resources, including memory space, CPU time slices, and network connection resources.
[0044] In a possible implementation, creating a task includes the following steps: Load protocol stack code: Read the stack code of the corresponding protocol from the device storage unit and load it into the memory.
[0045] Allocate memory space: Create input buffer and output buffer for the protocol task to store the data frames to be processed.
[0046] Initialization thread: Assign independent threads to protocol tasks, and set thread priorities dynamically based on the protocol's real-time requirements. For example, the Modbus RTU protocol has a higher priority than the MQTT protocol because it requires real-time response.
[0047] In some implementations, in order to further improve the stability of data transmission, the device allocates a unique Socket ID to each protocol task. Generally, a Socket ID is an identifier used to identify a network connection, and its main functions include: Determine the source of data: The input buffer of each protocol task receives data packets based on the Socket ID, thereby tracing the source of the data.
[0048] Routing data to the target: The output buffer of each protocol task embeds the Socket ID in the data packet to specify the target device or platform.
[0049] As an option, the device adopts a dynamic management strategy for Socket ID allocation. Specifically, when a protocol task is activated, the device allocates a free ID from the Socket ID pool; when the task is closed or released, the Socket ID is automatically recycled to the pool for subsequent use.
[0050] In a possible implementation, to ensure the stability of multi-protocol concurrent operation, the task management module will perform resource isolation for each protocol task. Resource isolation includes but is not limited to the following: Network bandwidth isolation: Allocate independent bandwidth resources to each protocol task to avoid interference between tasks. For example, the low bandwidth characteristics of the LoRa task will not be affected by the high-load WiFi task.
[0051] Memory space isolation: The hardware memory management unit (MMU) is used to divide an independent memory area for each task to prevent data overwriting or access conflicts.
[0052] In some implementations, in order to simplify the scheduling and management of tasks, the device designs a task monitoring mechanism. Generally, the task monitoring mechanism includes the following functions: Real-time status monitoring: Regularly check the running status of tasks, including CPU usage, memory usage, etc.
[0053] Abnormal recovery: When a protocol task crashes or becomes unresponsive, the task management module will immediately restart the task.
[0054] Through the above design, the method of the present invention can ensure the independent operation and efficient scheduling of multi-protocol tasks, thereby realizing the stable operation of the air monitor in complex multi-scenarios.
[0055] S4. Realize data exchange between protocol tasks and communication interface tasks through software and hardware data exchange buffer Generally speaking, air monitors need to perform efficient data transmission between multi-protocol tasks and multi-interface tasks to ensure data integrity and real-time transmission. The data exchange buffer combined with software and hardware can not only avoid data competition between tasks, but also improve the resource utilization and operation stability of the system.
[0056] In this embodiment, the data exchange buffer is designed as an independent storage module, which can allocate exclusive input and output buffers for each protocol task and interface task. Specifically, each buffer adopts a first-in-first-out (FIFO) data structure to ensure the order and real-time nature of the data.
[0057] In some implementations, the operation process of the data exchange buffer includes the following steps: The protocol task extracts the data to be sent from the data storage pool and stores it in the output buffer after protocol encoding.
[0058] The interface task reads the encoded data frame from the output buffer of the protocol task and sends the data to the target device through the corresponding physical interface (such as RS485 or WiFi).
[0059] The response data returned by the target device or cloud platform first enters the input buffer of the interface task, and then is stored in the input buffer of the protocol task through protocol decoding.
[0060] The protocol task performs further processing on the decoded data or updates the device status.
[0061] In one possible implementation, the buffer capacity can be dynamically adjusted based on the device operating load. Generally, a larger buffer capacity is allocated to high-priority tasks to ensure real-time performance. For example, the buffer capacity of an MQTT task is usually larger than that of a Modbus RTU task.
[0062] As an option, the buffer design also supports concurrent read and write operations to meet the needs of multiple tasks running simultaneously. Specifically: The read-write lock mechanism is used to ensure that the protocol task and the interface task do not interfere with each other in accessing the buffer.
[0063] With the double buffer design, while one buffer is processing data, the other buffer can be used to receive new data, thereby improving system throughput.
[0064] In some implementations, in order to enhance the reliability of data exchange, the buffer also integrates a data verification function. Specifically: When data enters the buffer, the checksum of the data frame is verified to eliminate erroneous data.
[0065] As data is output from the buffer, the checksum is regenerated and appended to the data frame to ensure data integrity during transmission.
[0066] Generally, the buffer also supports data priority scheduling. For example, when the data of multiple protocol tasks need to be transmitted at the same time, the system will adjust the reading order of the buffer according to the real-time requirements of the protocol and give priority to the data of high-priority tasks.
[0067] In one possible implementation, the implementation of the data exchange buffer relies on a hardware acceleration module. Specifically, the buffer is implemented by an on-chip storage unit (such as SRAM), and the DMA (direct memory access) mechanism is used to accelerate data transmission, further reducing the computational burden of the CPU.
[0068] Through the above design, the method of the present invention can realize efficient and stable data exchange between protocol tasks and interface tasks, and provide reliable guarantee for the parallel operation of multiple protocols and multiple interfaces.
[0069] S5. The processed data is transmitted to the target device or cloud server through the activated communication interface.
[0070] Generally, air monitors need to send monitoring data to designated terminals or platforms through a variety of physical interfaces and protocols according to different application scenarios and user needs to achieve real-time data interaction, storage and analysis. To ensure the reliability and adaptability of data transmission, the present invention designs key mechanisms such as multi-path selection, protocol matching and error checking during the data transmission process.
[0071] In this implementation, the activated communication interfaces may include RS485, WiFi, Ethernet, 4G, LoRa and other types, and different interfaces are suitable for different transmission scenarios. Specifically: The RS485 interface is mainly used for short-distance local data transmission and communication with building automation systems (BAS) or PLC devices; WiFi and Ethernet interfaces are suitable for LAN environments, enabling fast and efficient data upload to the local control center; 4G WiFi and Ethernet interfaces are suitable for remote and wide-area environments, uploading data to cloud servers via public or low-power networks.
[0072] In some implementations, the specific process of data transmission includes the following steps: The protocol task extracts the processed data from the data storage pool and encodes it in the format of the activated protocol (such as Modbus RTU, MQTT or BACnet IP); The interface task reads the encoded data frame from the output buffer of the protocol task and transmits it through the specified physical interface; After receiving the data, the target device or cloud platform returns a response message, and the device's interface task passes the response data to the protocol task for parsing.
[0073] As an option, the device will set the transmission mode according to user requirements when transmitting data. Generally, the following two modes can be supported: Scheduled upload mode: The device sends monitoring data to the target device at regular intervals according to the preset time intervals. It is suitable for scenarios with relatively stable environmental changes. Event trigger mode: When the monitoring data exceeds the set threshold (such as PM2.5 concentration exceeds the standard), the device will immediately send an alarm data, which is suitable for scenarios with high real-time requirements.
[0074] Specifically, during the transmission process, the device will also perform dynamic optimization based on the protocol characteristics and network status. In some implementations, the optimization measures include: For LoRa interfaces with low network bandwidth, CayenneLPP encoding technology is used to reduce the data frame size; For the delay-sensitive Modbus RTU protocol, system resources are allocated preferentially to ensure real-time response.
[0075] In some implementations, the device supports a multi-path data transmission function. For example, when the WiFi signal is unstable, the device will automatically switch to the Ethernet or 4G interface to continue data transmission. Specifically, the implementation of multi-path switching depends on the interface status monitoring module, which monitors the signal strength, packet loss rate, and response time of the current network connection, and selects the best path according to the set priority.
[0076] Through the above design, the present invention can achieve efficient data transmission and reliable interaction, which not only adapts to the needs of multiple scenarios, but also provides accurate environmental data for the target device or cloud platform to ensure the overall performance and stability of the system.
[0077] In a preferred embodiment of the present invention, the air monitor supports the simultaneous operation of multiple communication protocols, and meets the complex requirements of multiple scenarios and multiple users for data transmission through refined task management and efficient data transmission mechanism. In general, the concurrent operation of multiple protocols will involve problems such as resource competition and data conflicts. For this reason, the present invention adopts technical means such as independent task division, socket identification, task scheduling and data isolation to ensure the stability of system operation and the reliability of data transmission.
[0078] In this embodiment, the air monitor implements independent task division of each communication protocol through a real-time operating system (RTOS). Specifically, each activated protocol is divided into an independent task and allocated exclusive resources, including memory space, CPU time slices, and network connections.
[0079] In one possible implementation, each protocol task performs the following operations when it is created: Load the stack code of the corresponding protocol from the device storage unit and initialize it; Assign a unique Socket ID to the protocol task as an identifier of the data source and destination; Allocate input and output buffers to store frames of data to be processed or processed.
[0080] In some implementations, the dynamic allocation of Socket IDs adopts a pooling management mechanism. Generally, when a protocol task is activated, an idle ID is obtained from the Socket ID pool; when the task is closed or released, the Socket ID is recycled to the pool for subsequent use. In this way, the waste of Socket resources can be effectively avoided.
[0081] In a multi-tasking operating system, managing the concurrent operation of various protocol tasks through the task scheduling mechanism is the key to ensuring system stability. Specifically: The system will dynamically adjust the priority based on the real-time requirements of the protocol tasks. For example, the Modbus RTU protocol needs to respond quickly to building control commands, and its priority is usually higher than the non-real-time MQTT protocol.
[0082] Allocate independent resource quotas to each protocol task, including memory, network bandwidth, and CPU time slices, to avoid resource competition between tasks.
[0083] Regularly monitor the running status of the protocol task. If no response or abnormal situation occurs, the system will automatically restart the task and reallocate resources.
[0084] In one possible implementation, data isolation and routing between protocol tasks are implemented based on Socket ID. Specifically: The input buffer of each protocol task receives data frames through the Socket ID to ensure the accuracy of the data source; The output buffer of each protocol task will embed the Socket ID of the target device in the data frame to guide the transmission destination of the data.
[0085] Through this isolation and routing mechanism, data transmission between different protocol tasks can be non-interfering with each other, thus ensuring independence and stability during concurrent runtime.
[0086] In order to further improve the data transmission efficiency, this embodiment realizes data sharing or exchange between the protocol task and the communication interface task through a data exchange buffer combined with software and hardware. Specifically: The protocol task extracts the data to be sent from the data storage pool and stores it in the output buffer after protocol encoding; The communication interface task reads data from the output buffer of the protocol task and sends the data to the target device through the corresponding physical interface (such as WiFi, RS485); The received external command data is written into the input buffer of the protocol task through the interface task, and the protocol task decodes it and updates the device status or configuration.
[0087] In a possible design, the data exchange buffer supports a double buffer mechanism, that is, one buffer is used to process current data and the other buffer is used to receive new data, thereby achieving concurrent processing and efficient scheduling of tasks.
[0088] Through the above design, this implementation can realize the independent operation and efficient management of multi-protocol tasks, providing strong support for the diversified data transmission needs of air monitors in complex scenarios.
[0089] In a further preferred embodiment of the present invention, managing the concurrent operation of each protocol task through a task scheduling mechanism is the core link to achieve stable operation of multiple protocols. Generally, the simultaneous operation of multiple protocol tasks may lead to resource competition and system bottleneck problems. For this reason, the present invention designs a technical solution of dynamic resource allocation, real-time monitoring and priority scheduling to ensure the efficiency of concurrent operation of tasks and the rational use of system resources.
[0090] In this implementation, dynamically allocating system resources associated with each protocol task is the primary step in task scheduling. Specifically: When each protocol task is created, the system will allocate exclusive memory space for it to store task data and operation status. For example, a Modbus RTU protocol task may require a smaller memory space, while an MQTT protocol task usually requires a larger memory allocation due to data buffering and message queue management.
[0091] Each protocol task is assigned an independent Socket connection to identify the data source and destination of the task. Generally, the Socket connection adopts a dynamic allocation mechanism. When a task is activated, the system obtains an idle connection from the Socket connection pool; when the task ends or is closed, the Socket connection will be recycled to the pool.
[0092] Allocate task scheduling resources, including CPU time slices and task priorities. As a choice, protocol tasks with higher real-time requirements (such as Modbus RTU) usually get higher priorities and longer time slices, while non-real-time tasks (such as MQTT) have lower priorities.
[0093] In some implementations, when a protocol task is completed or no longer activated, the system will release the system resources it occupies to improve resource utilization. Specifically: The system will reclaim the memory space occupied by the task and return it to the memory pool for allocation of subsequent tasks.
[0094] Release the socket connection and mark it as idle for use by other tasks.
[0095] Adjust the CPU time slice allocation strategy and reallocate the scheduling resources of the original task to other active tasks.
[0096] In one possible implementation, the device is designed with a real-time resource monitoring mechanism to track the resource usage of each protocol task and dynamically adjust the resource allocation priority. Specifically: The system regularly monitors the running status of tasks, including indicators such as CPU usage, memory usage, and network bandwidth consumption.
[0097] Dynamically adjust resource allocation priorities based on monitoring results. For example, when a task detects high transmission delay or a surge in data traffic, the system will increase the priority of the task and allocate more resources.
[0098] If a task is in a low-load or idle state for a long time, the system will lower its priority and release some resources for other tasks to use.
[0099] When multiple protocol tasks are running concurrently, avoiding resource conflicts through task scheduling mechanism is the guarantee for stable operation of the system. In this implementation, the task scheduling mechanism includes the following strategies: Task isolation strategy: By allocating independent memory space and Socket connections, ensure that data access between tasks does not interfere with each other.
[0100] Priority scheduling strategy: Dynamically adjust the priority based on the real-time nature and load conditions of the task to ensure that high-real-time tasks get priority in resources.
[0101] Deadlock prevention strategy: When resource competition is high, a polling mechanism or a resource preemption mechanism is used to prevent tasks from falling into a deadlock state due to waiting for resources.
[0102] In some implementations, in order to further improve the efficiency of task scheduling, the system adopts a multi-queue scheduling model. Specifically: Tasks of different priorities are divided into different queues, and the system processes tasks queue by queue in order of priority.
[0103] Before the high-priority queue is completely processed, the tasks in the low-priority queue will not be scheduled for execution.
[0104] Through the above design, this implementation can achieve efficient concurrent operation of multi-protocol tasks and optimize resource utilization, providing technical guarantee for the stable operation of air monitors in complex application scenarios.
[0105] In a preferred embodiment of the present invention, in order to further improve the maintainability and intelligence of the air monitor, the method also includes activating a maintenance protocol to implement fault diagnosis, parameter calibration or software upgrade of the device. Generally, during operation, the device may need to remotely check its working status, repair faults or update system software. For this reason, the present invention designs a remote maintenance mechanism to ensure the efficiency, safety and stability of the maintenance process through independent maintenance protocol tasks and dynamic resource management.
[0106] In this implementation, an independent remote maintenance protocol task is reserved when the device is in operation. Specifically: Maintenance protocol tasks are separated from regular communication protocol tasks (such as Modbus RTU, MQTT) to ensure that their operation does not affect normal data collection and transmission.
[0107] Maintenance protocol tasks run in standby mode and are only started when the user explicitly activates the maintenance function, thus saving system resources.
[0108] In some implementations, the maintenance protocol uses a standard network communication protocol (such as MQTT or HTTP) to achieve compatibility with the maintenance server, while supporting customized protocols to meet specific maintenance requirements.
[0109] When users need to perform remote maintenance, they can start the maintenance channel through the configuration interface. Generally, the configuration interface can be accessed through the following ways: Web interface: Accessed through the device's built-in web server, users can start maintenance functions by entering the device's IP address in the browser.
[0110] Bluetooth APP: After users pair with the device via Bluetooth, they can operate and maintain settings in the mobile application.
[0111] Local buttons and display: suitable for on-site emergency maintenance operations. Users trigger maintenance mode by pressing buttons.
[0112] After the communication connection is established, the system dynamically allocates independent Socket IDs and resource pools to provide a dedicated operating environment for maintenance protocol tasks. Specifically: Socket ID allocation: The system allocates an independent Socket ID for maintenance tasks to distinguish maintenance data from regular data, ensuring the accuracy and independence of data transmission.
[0113] Resource pool allocation: The system allocates independent memory space, CPU time slices, and network bandwidth resources for maintenance tasks to meet the high load requirements during the maintenance process.
[0114] Resource isolation: The resources of maintenance tasks are completely isolated from those of regular tasks to avoid resource competition affecting normal operation.
[0115] In some implementations, specific operations of the maintenance function include but are not limited to: Fault diagnosis: The device uploads the operating status (such as sensor data, task logs, etc.) to the maintenance server for technicians to analyze the cause of the problem.
[0116] Parameter calibration: The maintenance server sends calibration instructions to adjust the device's operating parameters (such as sensor sensitivity, communication rate, etc.).
[0117] Software upgrade: The device downloads the upgrade package from the maintenance server and performs a firmware update to fix known issues or add new features.
[0118] After the maintenance operation is completed, the device will automatically close the maintenance channel and release the occupied system resources. Specifically: When the maintenance task is completed, the system reclaims the allocated memory space, Socket ID, and other resources and returns them to the resource pool.
[0119] After the maintenance channel is closed, the system notifies the regular tasks to restore resource priority and checks whether the device status is restored to normal operation mode.
[0120] In some implementations, the system will also generate a maintenance log, including maintenance time, operation content and results, etc., for users to query and record.
[0121] Through the above design, the remote maintenance mechanism of this implementation can efficiently and safely support equipment fault diagnosis, parameter calibration and software upgrade operations, while avoiding interference with normal operation, providing users with convenient maintenance support.
[0122] In a preferred embodiment of the present invention, in order to adapt to the upgrade and expansion requirements of future communication protocols, the method also includes achieving compatibility with newly added communication protocols by updating the protocol stack. Generally, air monitors need to interact with a variety of devices and platforms in different application scenarios, and the diversification and rapid evolution of communication protocols may place higher requirements on device compatibility. To this end, the present invention provides a flexible protocol stack update mechanism, which ensures that the device can efficiently be compatible with newly added protocols through dynamic loading, resource reallocation, and user configuration activation.
[0123] In this implementation, when a new communication protocol is added to the existing communication protocol list, the device will dynamically load the new protocol into the protocol task for execution according to user needs. Specifically: The relevant codes and configuration files of the newly added protocols are imported into the device storage unit by remote download or local loading. As an option, users can upload protocol files through USB devices or push new protocols through remote maintenance servers.
[0124] The system parses the imported protocol file and verifies the integrity and compatibility of the protocol. For example, the checksum mechanism ensures that the protocol file has not been tampered with and checks whether the protocol complies with the communication interface type supported by the device.
[0125] After verification, the device dynamically loads the stack code of the newly added protocol into the memory and generates the corresponding protocol task instance.
[0126] In some implementations, the dynamic loading of the newly added protocol further includes the following optimization steps: Independent task resources are allocated for the newly added protocol, including input buffer, output buffer and Socket connection, to support data interaction of protocol tasks.
[0127] The task management module allocates threads and sets default priorities for newly added protocols. For example, for protocols with high real-time requirements, the system will assign them higher task priorities.
[0128] According to the requirements of the new protocol, the system will reallocate related system resources to ensure that the protocol tasks can run normally. Specifically: Dynamically adjust the memory allocation strategy to allocate appropriate memory space for newly added protocols. For example, large protocols (such as protocols based on XML or JSON format) may require larger memory support, while lightweight protocols (such as binary protocols) require smaller memory.
[0129] Socket connections are allocated according to the network requirements of the newly added protocol and a unique Socket ID is assigned to it to ensure the accuracy of data routing.
[0130] Adjust task priorities to minimize resource competition between new protocols and existing protocol tasks. For example, when the real-time performance of a new protocol takes precedence over that of an existing protocol, the system will lower the priority of non-critical protocols accordingly.
[0131] In one possible implementation, the updated protocol stack is enabled through a configuration interface, and the user can choose to enable or disable the newly added protocol according to needs. Specifically: Users can view detailed information of the newly added protocol through the device's configuration interface (such as the web interface or Bluetooth APP), including the protocol name, supported interface types, and default configuration parameters.
[0132] Users can choose to enable the newly added protocol in the interface and assign the required interface to it. For example, choose to use the WiFi interface for data transmission for the newly added protocol.
[0133] The system enables the newly added protocol task based on the user's configuration and updates the task status to "Activated".
[0134] Through the above design, this implementation can achieve dynamic expansion and efficient compatibility of the communication protocol, providing technical guarantee for the long-term adaptability and functional upgrade of the equipment.
[0135] In general, the present invention realizes efficient management of multi-protocol concurrent operation and multi-interface switching through modular design, independent task operation, dynamic resource allocation and flexible configuration mechanism. The method supports comprehensive collection and processing of environmental data, meets the real-time data transmission requirements in complex application scenarios through dynamic loading of protocol stacks and remote maintenance mechanisms, and ensures the stability of system operation and the reliability of data transmission through priority scheduling and buffer design combining software and hardware.
[0136] The multi-protocol multi-communication interface switching control device for an air monitor described below and the multi-protocol multi-communication interface switching control method for an air monitor described above can be referred to each other.
[0137] Please refer to the attached Figure 2 The present invention also provides a multi-protocol multi-communication interface switching control device for an air monitor, comprising: The sensor module 10 is used to collect environmental parameter data; The communication protocol processing module 20 is used to support independent task operation of multiple communication protocols and encode and parse data; The communication interface module 30 is used to support multiple physical interfaces to realize data transmission and reception; The task management module 40 is used to allocate independent running tasks and resources to each communication protocol, and realize multi-protocol concurrency through dynamic scheduling; Storage module 50, used to store protocol parameters, task configuration and selection information input by the user; The configuration module 60 is used to receive the communication protocol and interface selected by the user, and transmit the selection information to the communication protocol processing module and the task management module to activate the corresponding functions.
[0138] The device of this embodiment can be used to execute the above method embodiment, and its principles and technical effects are similar, which will not be repeated here.
[0139] In order to better understand the present invention, the above method is described in detail below in conjunction with specific embodiments.
[0140] The embodiment of the present invention provides a multi-protocol multi-communication interface switching control method for an air monitor, which realizes comprehensive monitoring of environmental parameters and efficient data transmission through a multi-level system architecture design. This embodiment will describe in detail the specific implementation of the method, including the functions and operation processes of each level, as well as its application in actual application scenarios.
[0141] 1. System Architecture The system architecture of this method is as follows Figure 3 As shown, it is mainly divided into the following levels: 1. Multi-sensor layer Contains a variety of sensors required for environmental monitoring, which are used to collect various environmental parameters, including but not limited to: carbon dioxide (CO2), temperature (Temp), humidity (Humi), total volatile organic compounds (TVOC), inhalable particulate matter (PM2.5, PM10), carbon monoxide (CO), ozone (O3), sulfur dioxide (SO2), nitrogen dioxide (NO2), ambient light (Light), ambient noise (Noise), and atmospheric pressure (Pressure).
[0142] 2. Multiple communication protocol layers Supports multiple communication protocols to meet different application requirements, including: Modbus RTU: A serial communications protocol used in industrial automation and building management systems.
[0143] BACnet MS / TP: A data communications protocol for the building automation and heating, ventilation and air conditioning (HVAC) industries that communicates over the RS-485 physical layer.
[0144] Modbus TCP: Modbus protocol based on TCP / IP, usually used in local area networks (LANs).
[0145] BACnet IP: Communication protocol for building automation systems, based on TCP / IP.
[0146] Tuya protocol: a dedicated protocol for connecting to the Tuya smart cloud platform.
[0147] MQTT: A lightweight, publish / subscribe-based messaging protocol suitable for the Internet of Things (IoT) and other fields.
[0148] Qlear protocol: a dedicated protocol for connecting to the RESET authentication cloud platform.
[0149] LoRaWAN: A low-power, wide-area wireless communication protocol for IoT devices.
[0150] 3.Multi-communication hardware interface layer Contains a variety of physical communication interfaces and supports different transmission media: RS485 interface: used for local serial communication.
[0151] WiFi interface: uses 2.4G frequency band and supports IPv4 protocol.
[0152] Ethernet interface: supports IPv4 protocol.
[0153] 4G interface: Global communication is achieved through 4G LTE modules of different frequency bands.
[0154] LoRa interface: Adopts Semtech's LoRa technology to achieve long-distance, low-power wireless communication.
[0155] 4. Data Link Layer Includes routing equipment for data transmission: Router: A common WiFi and Ethernet router for Internet access.
[0156] LAN Router: used for local LAN communication, supporting Modbus TCP and BACnet IP protocols.
[0157] LoRaWAN Gateway: A terminal device and network server that connects the LoRaWAN network.
[0158] 5. Cloud Platform Cloud services that provide data storage and processing: Tuya Cloud, MQTT Cloud, QLEAR Cloud, AWS (Amazon Web Services), TTN (The Things Network), ChirpStack.
[0159] 6. Application layer User interface: Phone App Web Client 2. Operation Process 1. Data collection and storage At the multi-sensor level, the air monitor integrates a variety of sensors, some of which are self-developed and some of which are the industry's top sensors. The microcontroller (or SoC chip) collects the measurement values of each sensor at a certain period and stores them in the data pool (Data Source).
[0160] 2. Data processing and coding Different communication protocols obtain measurement data from the data pool and encode them according to their respective protocol requirements. In order to support the concurrent operation of multiple protocols, the system encapsulates each protocol as an independent task in the operating system and allocates independent resources to it, including memory space and Socket connection.
[0161] 3. Selection and transmission of communication methods A.RS485 communication Using Modbus RTU or BACnet MS / TP protocol, the encoded data is sent to the building automation system (BAS) or PLC device through the RS485 interface to meet the local data acquisition and control needs of industries and various types of buildings.
[0162] B. LAN communication Use Modbus TCP or BACnet IP protocol to communicate with building automation systems or industrial control software through WiFi or Ethernet interface, replacing traditional RS485 networks, reducing wiring, improving reliability and speed.
[0163] C.LoRaWAN communication In the wild, in agriculture or inside buildings, wireless long-distance transmission can be achieved through the LoRaWAN network, solving the problem of data collection and transmission in areas where WiFi and Ethernet cannot cover. This design uses Semtech's LoRa chip to reduce costs and flexibly adapt to frequency requirements in different countries and regions.
[0164] Users turn on the LoRaWAN protocol through the configuration web page or Bluetooth APP. The device uses CayenneLPP (sensor data encoding format) to encode the measured values and send them to the LoRaWAN gateway through the LoRa chip. The data finally arrives at the cloud server (such as AWS, TTN or private ChirpStack server). Users can obtain the data through mobile phone apps or PC browsers.
[0165] D. Cloud platform communication Through the Internet, using MQTT, Tuya, Qlear and other protocols, data is uploaded to the designated cloud platform to meet the user's needs of real-time reading of measurement values or control of equipment at any time and any place.
[0166] MQTT protocol: suitable for users with a large number of terminals who can build their own servers, exempting them from commercial cloud platform fees.
[0167] Tuya protocol: suitable for users who do not want to build their own servers, reducing server construction and operation costs.
[0168] Qlear Protocol: Meeting the needs of green building RESET certification users.
[0169] 4. Remote maintenance and upgrade The device reserves an additional MQTT network channel to connect to a dedicated service platform. This channel is closed by default. When after-sales service is required, the maintenance channel can be opened to remotely inspect, calibrate, diagnose faults and upgrade software on the device, reducing labor costs and improving service efficiency.
[0170] 3. Specific application scenario examples A large high-tech company has multiple R&D office parks around the world. In order to provide a healthy working environment and achieve on-demand energy allocation, it is necessary to monitor the air parameters of each office area in real time, optimize the indoor air quality accordingly, and control the fresh air and air purification equipment in real time.
[0171] 1. Equipment installation and data collection Air monitors are installed on the walls or ceilings of office buildings to measure and output room air parameters in real time, such as CO2, TVOC, PM2.5, PM10, ozone, temperature and humidity, etc.
[0172] The monitor collects data through multiple sensor layers, and the microcontroller periodically stores the data in a data pool.
[0173] 2. Local Control The building automation system (BAS) or field controller (PLC) communicates with the air quality monitoring equipment via the RS485 bus using Modbus RTU or BACnet MS / TP protocol.
[0174] Obtain data such as CO2, TVOC, temperature and humidity in the monitoring area, and control fresh air valves, air conditioning hot and cold water valves, air purifiers and other equipment in real time.
[0175] 3. LAN data transmission The air monitor sends the measurement data of all rooms to the BAS in the building control room via WiFi or Ethernet using BACnet IP or Modbus TCP protocol.
[0176] BAS controls central air conditioning and fresh air units through comprehensive software analysis to achieve energy saving.
[0177] 4. Remote data upload In order to meet the requirements of green building certification or inclusion in sustainable development systems, air measurement data needs to be uploaded to a designated cloud server.
[0178] Monitoring equipment uploads data in real time via the Internet using the MQTT protocol, which not only ensures the real-time nature of the data but also avoids human modification of the data.
[0179] 5.Data analysis and decision support Through the cloud platform, company managers can keep track of the energy consumption and indoor air quality of each park and building at any time, which serves as a basis for energy conservation and emission reduction or air quality assessment.
[0180] Through remote data transmission and storage, long-term air quality and energy consumption trends can be obtained to assist decision-making.
[0181] 6. Equipment configuration and maintenance The device has multiple built-in communication protocols, each of which has switch control. Through the configuration web page or Bluetooth APP, turn on the required protocol and specify the communication interface (WiFi, Ethernet, 4G or LoRaWAN) for network communication.
[0182] When after-sales service is needed, open the reserved MQTT maintenance channel to remotely inspect and maintain the equipment.
[0183] Through the above-mentioned embodiments, the multi-level system design and innovative technical means of the present invention realize the multi-protocol and multi-communication interface switching control method of the air monitor, which meets the diversified needs of the fields of intelligent buildings, industrial automation, and the Internet of Things. The high compatibility, flexibility, and maintainability of the equipment provide users with an efficient and reliable air quality monitoring solution.
[0184] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A multi-protocol multi-communication interface switching control method for an air monitor, characterized in that: The following steps are involved: Collecting environmental data through sensors and storing the environmental data in a data storage pool; According to user needs, select at least one communication protocol and communication interface to activate; The communication protocol is set to run as an independent task and a unique Socket ID is assigned to manage the source and destination of data; Data exchange between protocol tasks and communication interface tasks is realized through software and hardware data exchange buffers; The processed data is transmitted to the target device or cloud server via the activated communication interface.
2. A multi-protocol multi-communication interface switching control method for an air monitor according to claim 1, characterized in that: The communication protocol includes at least one of the following: Modbus RTU, BACnet MS / TP, Modbus TCP, BACnet IP, MQTT, Tuya protocol, Qlear protocol or LoRaWAN protocol.
3. A multi-protocol multi-communication interface switching control method for an air monitor according to claim 1, characterized in that: The communication interface includes at least one of the following: RS485 interface, WiFi interface, Ethernet interface, 4G interface or LoRa interface.
4. A multi-protocol multi-communication interface switching control method for an air monitor according to claim 1, characterized in that: The air monitor supports multiple communication protocols to run simultaneously, including the following steps: Each communication protocol is divided into tasks to run independently, and each protocol task is assigned a unique Socket ID to identify the source and destination of data; In a multi-tasking operating system, the concurrent running of each protocol task is managed through the task scheduling mechanism to ensure that the resources between tasks are reasonably allocated and do not interfere with each other; Data isolation and routing between protocols are realized based on Socket ID, ensuring the independence of data processing and transmission of different protocol tasks; Through the software and hardware data exchange buffer, data sharing or exchange is achieved between each protocol task and the communication interface task, ensuring the real-time and accuracy of data processing.
5. A multi-protocol multi-communication interface switching control method for an air monitor according to claim 4, characterized in that: The steps of managing the concurrent operation of each protocol task through the task scheduling mechanism include: Dynamically allocate system resources related to each protocol task, including memory space, socket connections, and task scheduling resources; When a protocol task is completed or no longer activated, the system resources it occupies are released; Through the real-time resource monitoring mechanism, the resource usage of each protocol task is tracked and the resource allocation priority is dynamically adjusted; When multiple protocol tasks run concurrently, resource conflicts are avoided through the task scheduling mechanism.
6. A multi-protocol multi-communication interface switching control method for an air monitor according to claim 1, characterized in that: The configuration process of the user requirements includes: Select the communication protocol and communication interface to be activated through the configuration interface, which includes a web page, a Bluetooth APP or a physical button; According to the selected communication protocol and communication interface information, activate the corresponding protocol task; Initializes the required system resources to support the protocol task execution and applies configuration parameters to the communication interface; The configuration parameters are saved to the device storage unit to maintain the same configuration status during subsequent operation of the device.
7. A multi-protocol multi-communication interface switching control method for an air monitor according to claim 1, characterized in that: The air monitor supports the following three scenarios: Local control scenario: Run Modbus RTU or BACnet MS / TP protocol through RS485 interface to interact with building automation system in real time to control fresh air valves, temperature and humidity control equipment and air purifiers; LAN data transmission scenario: Run BACnet IP or Modbus TCP protocol through WiFi or Ethernet interface to transmit monitoring data to the local building automation system to achieve comprehensive control and data sharing in the whole building; Cloud platform scenario: Run the MQTT / Tuya / Qlear protocol through WiFi, Ethernet or 4G interface to upload monitoring data to the cloud server, providing users with cross-regional remote monitoring, data analysis and device management functions.
8. The multi-protocol multi-communication interface switching control method for an air monitor according to claim 1, characterized in that: The method further includes implementing fault diagnosis, parameter calibration or software upgrade of the equipment by activating the maintenance agreement, as follows: Reserve independent remote maintenance protocol tasks when the equipment is in operation; When the user activates the remote maintenance function, the maintenance channel is started through the configuration interface and an encrypted communication connection is established with the maintenance server; By dynamically allocating independent Socket IDs and resource pools; After the maintenance is completed, the remote maintenance channel will be automatically closed to release the occupied system resources and restore the equipment to normal operation.
9. A multi-protocol multi-communication interface switching control method for an air monitor according to claim 1, characterized in that: The method also includes achieving compatibility of the newly added communication protocol by updating the protocol stack, as follows: Add a new communication protocol to the existing communication protocol list and dynamically load it into the protocol task to run; Reallocate system resources, including memory space, socket connections, and task priorities, according to the requirements of the new protocol; The updated protocol stack is enabled through the configuration interface, and users can choose to use the new protocol to perform data interaction or upload operations.
10. A multi-protocol multi-communication interface switching control device for an air monitor, applied to the method according to any one of claims 1 to 9, characterized in that: include: Sensor module, used to collect environmental parameter data; Communication protocol processing module, used to support independent task operation of multiple communication protocols, and encode and parse data; Communication interface module, used to support multiple physical interfaces to realize data transmission and reception; The task management module is used to allocate independent running tasks and resources to each communication protocol, and realize multi-protocol concurrency through dynamic scheduling; A storage module is used to store protocol parameters, task configurations, and selection information entered by users; The configuration module is used to receive the communication protocol and interface selected by the user, and transmit the selection information to the communication protocol processing module and the task management module to activate the corresponding functions.
Citation Information
Cited By
Laboratory data transmission method, device and system based on Internet of Things, and storage medium
CN120567896A