Communication switching method, communication switching system and smart meter

By adopting a basic query cycle and a multi-level offline confirmation process in smart meters, the problems of high computing resource consumption and frequent switching during smart meter communication switching are solved, thereby improving stability and anti-interference capabilities.

CN122395030APending Publication Date: 2026-07-14SHENZHEN STAR INSTR

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN STAR INSTR
Filing Date
2026-05-26
Publication Date
2026-07-14

Smart Images

  • Figure CN122395030A_ABST
    Figure CN122395030A_ABST
Patent Text Reader

Abstract

This application discloses a communication switching method, a communication switching system, and a smart meter, relating to the field of smart meter technology. The method includes: reading a pre-configured basic query cycle and sending a status query command to a first communication module according to the basic query cycle; receiving a status response containing only online or offline responses. When an offline response is received, a multi-level offline confirmation process is initiated, i.e., multiple confirmations are performed using a timer. Only when offline responses are continuously received and the cumulative number of confirmations reaches a preset number is the communication path switched from the first communication module to the second communication module. This solution eliminates the dependence on channel quality parameters; the switching decision is based solely on continuous offline verification. A single instantaneous interference will not trigger the switching, thus effectively solving the problem of frequent back-and-forth switching and communication instability caused by channel quality fluctuations near a threshold in the prior art, and improving communication stability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of smart meter technology, and in particular to a communication switching method, a communication switching system, and a smart meter. Background Technology

[0002] Smart meters generally adopt a dual-mode communication scheme, which means that they are equipped with both a wireless public network communication module and a power line carrier communication module, and the communication reliability is ensured by switching the communication path.

[0003] In existing adaptive switching decisions, the main control chip of the smart meter continuously collects multi-dimensional channel quality parameters such as signal-to-noise ratio, latency, packet loss rate, and received signal strength. After filtering and weighting each parameter, it comprehensively evaluates the channel quality of the current communication module. When the evaluation result is lower than a preset threshold, switching is triggered.

[0004] In the above scheme, the handover decision relies on the acquisition and calculation of multiple consecutive channel quality parameters, which places high demands on the computing and storage resources of the main control chip. Furthermore, when channel quality fluctuates around a threshold, frequent handovers are easily triggered, leading to communication instability. Summary of the Invention

[0005] Based on this, this application provides a communication switching method, a communication switching system, and a smart meter to solve the problem in the prior art that frequent back-and-forth switching is easily triggered when the channel quality fluctuates near a threshold, leading to unstable communication.

[0006] In a first aspect, embodiments of this application provide a communication switching method applied to a smart meter, the smart meter including a first communication module and a second communication module, the method comprising: Read the pre-configured base query cycle; According to the basic query cycle, a status query command is sent to the first communication module currently used for communication, and a status response is received from the first communication module. When the status response is an offline response, the offline counter is set to 1, and a multi-level offline confirmation process is initiated. The multi-level offline confirmation process includes: starting a first timer; during the timer's countdown, sending the status confirmation command to the first communication module at a preset confirmation interval; when the first timer reaches a first preset duration, and all continuously received status responses are offline responses, incrementing the offline counter by 1 and restarting the first timer, wherein the preset confirmation interval is less than or equal to the first preset duration; wherein, during the timer's countdown, if any received status response is an online response, the offline counter is cleared and the multi-level offline confirmation process is stopped. When the offline count value is greater than or equal to the preset number of confirmations, the communication path is switched from the first communication module to the second communication module.

[0007] Secondly, embodiments of this application provide a communication switching system applied to a smart meter. The communication switching system includes a main control chip, a first communication module, and a second communication module. The main control chip is used for: Read the pre-configured base query cycle; According to the basic query cycle, a status query command is sent to the first communication module currently used for communication, and a status response is received from the first communication module. When the status response is an offline response, the offline counter is set to 1, and a multi-level offline confirmation process is initiated. The multi-level offline confirmation process includes: starting a first timer; during the timer's countdown, sending the status confirmation command to the first communication module at a preset confirmation interval; when the first timer reaches a first preset duration, and all continuously received status responses are offline responses, incrementing the offline counter by 1 and restarting the first timer, wherein the preset confirmation interval is less than or equal to the first preset duration; wherein, during the timer's countdown, if any received status response is an online response, the offline counter is cleared and the multi-level offline confirmation process is stopped. When the offline count value is greater than or equal to the preset number of confirmations, the communication path is switched from the first communication module to the second communication module.

[0008] Thirdly, embodiments of this application provide a smart meter, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the communication switching method described above.

[0009] Based on this, the beneficial effects of a technical solution provided in this application embodiment are as follows: The communication switching method provided in this application reads a pre-configured basic query cycle and sends a status query command to the first communication module according to the cycle. It receives status responses containing only online or offline responses. Upon receiving an offline response, the offline count is set to 1 and a first timer is started. During the first timer's duration, status confirmation commands are repeatedly sent at preset confirmation intervals. The offline count is incremented by 1 and the first timer is restarted only when the first timer reaches a first preset duration and all consecutively received status responses are offline responses. If an online response is received at any time, the count is cleared and the confirmation process stops. Communication path switching is only performed when the offline count reaches a preset number of confirmations. Therefore, switching only occurs after continuous offline verification through multiple confirmation cycles. A single momentary interference or brief fluctuation in channel quality will not trigger switching, effectively avoiding frequent back-and-forth switching caused by fluctuations near the threshold and improving communication stability. Attached Figure Description

[0010] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0011] Figure 1 This is an example diagram of a communication switching system according to an embodiment of this application; Figure 2 This is an example diagram of a communication switching method in one embodiment of this application; Figure 3 This is an example diagram of a smart meter in one embodiment of this application. Detailed Implementation

[0012] To make the technical problems, technical solutions, and beneficial effects solved by this application clearer, the following detailed description is provided in conjunction with embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0013] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0014] The communication switching method provided in this application embodiment can be applied to, for example, Figure 1The application environment shown is illustrated. Specifically, this communication switching method is applied in a communication switching system, which includes a main control chip 101, a first communication module 102, and a second communication module 103. The first communication module can be a wireless communication module, such as a GPRS module, a 4G module, or a 5G module, and the second communication module can be a power line carrier communication module, such as a G3-PLC module. The main control chip 101 is connected to both the first and second communication modules 102 and 103. The main control chip 101 can send instructions / commands to the first and second communication modules 102 and 103 via a serial communication interface such as a universal asynchronous transceiver interface or a serial peripheral interface, and receive data returned from both.

[0015] It should be noted that in this embodiment, both the first communication module 102 and the second communication module 103 are purely execution-type communication modules without autonomous decision-making capabilities. That is, the first communication module 102 does not have the function of measuring channel quality parameters and does not have a built-in handover decision algorithm. Similarly, the second communication module 103 also does not have the function of measuring channel quality parameters and does not have a built-in handover decision algorithm. The first communication module 102 and the second communication module 103 are only used to respond to instructions / commands issued by the main control chip 101, execute the corresponding operations, and return the execution results to the main control chip 101. All logic for the handover decision is executed by the main control chip 101; the first communication module 102 and the second communication module 103 only serve as instruction / command execution units and queried objects. By downgrading the first communication module 102 and the second communication module 103 to purely instruction-response-type modules, hardware costs can be reduced.

[0016] For ease of reading the embodiments of this application, the main control chip 101, the first communication module 102 and the second communication module 103 will not be labeled thereafter.

[0017] Firstly, such as Figure 2 As shown in the figure, this application provides a communication switching method that can be applied to smart meters. A specific smart meter may include a main control chip, a first communication module, and a second communication module. Taking the main control chip of a smart meter as an example, the method includes the following steps: S201: Read the pre-configured base query cycle.

[0018] As an example, the basic query cycle can be a parameter value pre-stored in non-volatile memory. The non-volatile memory can be electrically erasable programmable read-only memory or flash memory, integrated inside the main control chip or located externally and connected to the main control chip via a bus. The basic query cycle controls the time interval for sending status query commands to the first communication module under normal conditions.

[0019] Before the smart meter leaves the factory or during on-site deployment, maintenance personnel can issue configuration commands to the smart meter via host computer software or a remote master station, writing the basic query cycle into non-volatile memory. When the main control chip executes this method, it can read the basic query cycle from the non-volatile memory and load it into random access memory for use as a working parameter. The default value for the basic query cycle can be set to 15 seconds, 30 seconds, 40 seconds, or 60 seconds, etc., and is not limited here.

[0020] For example, when deploying smart meters, maintenance personnel configure the basic query cycle to 30 seconds. After the main control chip powers on and initializes, it can read the values ​​for those 30 seconds from non-volatile memory and store them in the operating parameter area. Subsequently, the main control chip can send status query commands to the first communication module at a frequency of once every 30 seconds.

[0021] As can be seen, this embodiment pre-configures the basic query cycle in non-volatile memory, allowing the main control chip to directly read and use it each time it starts up, without needing to reset it. Furthermore, the basic query cycle is a configurable parameter, allowing maintenance personnel to flexibly adjust it according to different field environments. For example, in urban areas with good signal coverage, the basic query cycle can be set to a longer 60 seconds to reduce query frequency and power consumption; in mountainous areas with poor signal coverage, the basic query cycle can be set to a shorter 15 seconds to increase query frequency and detect offline status more quickly.

[0022] S202: According to the basic query cycle, send a status query command to the first communication module currently used for communication, and receive the status response returned by the first communication module.

[0023] As an example, the main control chip periodically sends a status query command to the first communication module currently used for communication, with a basic query cycle as the time interval. The status query command is used to request the first communication module to report its current network registration status. The status query command can be a preset instruction word, such as the CMD_STA instruction. The CMD_STA instruction can be encapsulated according to the protocol specified by the first communication module manufacturer; this is not limited here.

[0024] The main control chip internally maintains a periodic timer, the duration of which is equal to the basic query cycle. When the periodic timer starts and reaches the basic query cycle, the main control chip sends a status query command frame to the first communication module via the serial communication interface. Upon receiving the status query command frame, the first communication module parses it, queries its current network registration status, and encapsulates the query result into a response frame, returning it to the main control chip. The main control chip receives and parses the response frame to obtain the status response.

[0025] The status response includes only two types: online response and offline response. An online response indicates that the first communication module is currently in network registration status, has successfully registered to the public wireless network, and can communicate normally with the master station. An offline response indicates that the first communication module is not currently registered to the network and cannot communicate with the master station. It should be noted that the status response only indicates the presence or absence of network registration status and does not include any channel quality parameters. Channel quality parameters refer to continuous numerical parameters used to measure channel communication quality, such as signal-to-noise ratio, latency, packet loss rate, and received signal strength indication. In this method, the main control chip does not collect, receive, or process any channel quality parameters; it only makes subsequent decisions based on the binary status of online or offline response.

[0026] For example, assuming the basic query period is 30 seconds, and the first communication module is currently online, the main control chip starts a periodic timer. After 30 seconds, the timer expires, and the main control chip sends a CMD_STA command to the first communication module. The first communication module checks its own registration status, finds that it has successfully registered with the base station, and returns an online response. The main control chip receives the online response, confirms that the first communication module is still online, restarts the periodic timer, and waits for the next 30-second cycle. This process repeats, with the main control chip obtaining the online or offline status of the first communication module every 30 seconds.

[0027] As can be seen, by acquiring only online or offline binary status responses, the main control chip does not need to collect and process multi-dimensional continuous parameters such as signal-to-noise ratio, latency, and packet loss rate, reducing the computational load by more than 90%. Furthermore, since the status query command only needs to return simple network status information, the communication module does not need to have complex channel quality measurement functions, significantly reducing both the hardware cost and software complexity of the communication module.

[0028] S203: When the status response is an offline response, the offline count value of the offline counter is set to 1, and a multi-level offline confirmation process is started; the multi-level offline confirmation process includes: starting a first timer; during the first timer's timing period, sending a status confirmation command to the first communication module according to a preset confirmation interval; when the first timer reaches a first preset duration, and all continuously received status responses are offline responses, the offline count value is incremented by 1 and the first timer is restarted, and the preset confirmation interval is less than or equal to the first preset duration; wherein, during the first timer's timing period, if any received status response is an online response, the offline count value is cleared to zero and the multi-level offline confirmation process is stopped.

[0029] As an example, the offline count value is used to record the number of times the offline status is continuously confirmed in the multi-level offline confirmation process. The initial value of the offline count value is 0. When the main control chip receives an offline response in step S202, the main control chip determines that an offline event may have occurred. However, in order to avoid misjudgment caused by momentary interference or temporary signal fluctuations, the main control chip does not immediately perform a switch, but instead starts a multi-level offline confirmation process to verify the offline status multiple times.

[0030] The specific process of the multi-level offline confirmation procedure is as follows: The first step is for the main control chip to set the offline counter value to 1. This is because an offline response has already been received, and this response is counted as the first confirmation. For example, suppose that after the main control chip sends a status query command according to the basic query cycle in step S202, it receives an offline response from the first communication module. In this case, the main control chip will set the offline counter value from zero to 1.

[0031] The second step involves the main control chip starting the first timer. The duration of the first timer is a first preset duration. This first preset duration is a pre-configured time value used to limit the length of the time window for each offline confirmation. The default value for the first preset duration is 5 seconds. The first timer defines an confirmation period, during which the main control chip will perform one or more status queries to verify whether the first communication module remains offline.

[0032] Third, during the first timer's countdown, the main control chip does not wait for the basic query cycle, but instead repeatedly sends status confirmation commands to the first communication module at a preset confirmation interval. The preset confirmation interval is a pre-configured time value, which can be less than or equal to a first preset duration. When the preset confirmation interval is less than the first preset duration, the main control chip can perform multiple status queries within one confirmation cycle. For example, if the first preset duration is 5 seconds and the preset confirmation interval is 1 second, the main control chip can send five status query commands within one confirmation cycle. When the preset confirmation interval is equal to the first preset duration, the main control chip sends only one status confirmation command within one confirmation cycle. In this embodiment, the status confirmation command and the status query command sent according to the basic query cycle in step S202 can be the same instruction, for example, both being the CMD_STA instruction, which is not limited here.

[0033] Fourth, when the first timer reaches the first preset duration, i.e., when the first timer times out, the main control chip checks all status responses received during the current timing period. If all status responses received during this timing period are offline responses, meaning that all status query commands sent within this confirmation cycle have received offline responses and no online responses have occurred, then the main control chip determines that the first communication module remains offline during this confirmation cycle. At this time, the main control chip increments the offline count by 1 and restarts the first timer to enter the next confirmation cycle. For example, at the end of the first confirmation cycle, the offline count increases from 1 to 2, at the end of the second confirmation cycle it increases to 3, and so on.

[0034] Fifth, during the first timer's countdown, if the main control chip receives an online response at any time, it indicates that the first communication module has recovered its online status within this confirmation cycle. At this point, the main control chip determines that the previous offline status has been recovered, and this offline status may be a temporary offline status caused by momentary interference. The main control chip resets the offline counter value to zero, stops the first timer, and stops sending status confirmation commands to the first communication module, exiting the multi-level offline confirmation process. After exiting, the main control chip resumes its normal state of querying according to the basic query cycle and continues to use the first communication module for communication.

[0035] For example, suppose the basic query cycle is 30 seconds, the first preset duration is 5 seconds, the preset confirmation interval is 1 second (the preset confirmation interval is less than the first preset duration), and the preset number of confirmations is 3. After the main control chip sends a status query command in a certain basic query cycle, it receives an offline response. At this time, the main control chip sets the offline count to 1 and starts the first timer (5 seconds). During the first timer's count, the main control chip sends a status query command every 1 second. Assuming that all five queries return an offline response, the first timer times out, the main control chip increments the offline count to 2 and restarts the first timer. In the second confirmation cycle, all five queries still return an offline response, the first timer times out, and the offline count is incremented to 3. At this time, the offline count reaches the preset number of confirmations of 2, and the main control chip determines that the first communication module is confirmed to be in an offline state, and will subsequently perform a switchover operation.

[0036] Assuming that a third query returns an online response within the second confirmation cycle, the main control chip immediately resets the offline counter to 0, stops the first timer, and exits the multi-level offline confirmation process. The main control chip returns to normal operation and continues to send status query commands to the first communication module according to a basic query cycle of 30 seconds, maintaining communication using the first communication module.

[0037] For example, suppose the first preset duration is 5 seconds, and the preset confirmation interval is also 5 seconds (the preset confirmation interval equals the first preset duration). The main control chip starts the first timer (timed for 5 seconds), sending a status confirmation command every 5 seconds. If the query returns an offline response, the first timer times out, the main control chip determines that the status response within this confirmation cycle is an offline response, increments the offline count by 1, and restarts the first timer. If the query returns an online response, the main control chip clears the offline count to zero and stops the multi-level offline confirmation process.

[0038] As can be seen, this embodiment employs a multi-level offline confirmation process, where a single offline response does not immediately trigger a switchover; instead, it requires continuous offline verification through multiple confirmation cycles. The preset number of confirmations can be set to an integer greater than or equal to 2, meaning that at least two consecutive offline confirmation cycles are needed to trigger a switchover. During the confirmation process, once an online response is detected, the count is immediately reset and the process exits without waiting for the confirmation cycle to end. This interruptible cumulative counting mechanism fundamentally solves the ping-pong effect problem. In existing technologies, when channel quality fluctuates around a threshold, the system may frequently switch back and forth between two communication paths, leading to communication instability. In this method, however, the switchover only occurs after continuous offline confirmation; instantaneous fluctuations in channel quality or single interference will not cause a switchover, significantly improving communication stability. The multi-level offline confirmation mechanism, combined with multiple queries within the confirmation cycle, reduces the false switchover rate by more than 70% compared to a single-trigger scheme.

[0039] S204: When the offline count value is greater than or equal to the preset number of confirmations, the communication path is switched from the first communication module to the second communication module.

[0040] As an example, the preset number of confirmations can be an integer greater than or equal to 2. The preset number of confirmations limits how many consecutive offline confirmation cycles are required before the first communication module is determined to be in an offline state. The default value for the preset number of confirmations can be 3, and is not limited here.

[0041] In the multi-level offline confirmation process, the offline counter is incremented by 1 for each completed confirmation cycle and consecutive offline responses received within that cycle. When the offline counter accumulates to or exceeds a preset number of confirmations, it indicates that the first communication module has undergone continuous offline verification for multiple confirmation cycles. The main control chip then determines that the first communication module is offline and generates a switching command. The main control chip switches the communication path from the first communication module to the second communication module, and subsequent data transmission and reception are conducted through the second communication module. For example, when the smart meter needs to report electricity consumption data to the master station, the main control chip sends the data through the second communication module (power line carrier communication module).

[0042] For example, suppose the preset confirmation count is configured to be 3. In the multi-level offline confirmation process, the offline count starts from 1 and accumulates to 3 after three consecutive offline confirmation cycles. When the offline count reaches 3, the main control chip determines that the first communication module is in an offline state and controls the RF switch or data router to switch the communication path from the first communication module to the second communication module. Afterward, the smart meter interacts with the master station through the second communication module.

[0043] As can be seen, this embodiment ensures that switching is only performed when multiple consecutive confirmation cycles determine that the user is offline, by setting a preset number of confirmations greater than or equal to 2. This effectively prevents unnecessary switching caused by a single or short-term false offline determination. The value of the preset number of confirmations can be flexibly configured according to the actual application scenario. In scenarios requiring rapid switching, the preset number of confirmations can be configured to a smaller value (such as 2), while in scenarios requiring stable communication, the preset number of confirmations can be configured to a larger value (such as 4 or even 8).

[0044] In summary, the beneficial effects of a technical solution provided by the embodiments of this application are as follows: by reading a pre-configured basic query cycle and sending a status query command to the first communication module according to the cycle, receiving a status response containing only online or offline responses, setting the offline count value to 1 and starting a first timer when an offline response is received, repeatedly sending the status query command at a preset confirmation interval during the first timer's timing period, and only incrementing the offline count value by 1 and restarting the timer when the timer reaches a first preset duration and all consecutively received status responses are offline responses, and clearing the count value and stopping the confirmation process when an online response is received at any time, until the offline count value reaches a preset number of confirmations before performing a communication path switch. Therefore, the handover decision relies solely on the binary state information of online and offline, eliminating the need to collect any continuous channel quality parameters such as signal-to-noise ratio, latency, and packet loss rate. This fundamentally eliminates the computational resource consumption caused by multi-dimensional parameter collection, filtering, and weighted calculation. Furthermore, since the handover is only triggered after continuous offline verification through multiple confirmation cycles, a single instantaneous interference or brief fluctuation in channel quality will not cause a handover action. This effectively avoids the problem of frequent back-and-forth handovers caused by fluctuations near the threshold, thus improving communication stability.

[0045] In one embodiment, specifically step S202, which involves sending a status query command to the first communication module currently used for communication according to the basic query cycle and receiving the status response returned by the first communication module, the following steps are also included: S221A: Obtain the first statistical result of the historical status response within the first historical preset sliding window. The first historical preset sliding window is the time period obtained by tracing back the first preset statistical duration from the current query execution time as the endpoint. The historical status response is the historical status response obtained by sending and receiving according to the basic query cycle within the first historical preset sliding window. S222A: Based on the first statistical results, determine the first offline frequency of offline response; S223A: When the first offline frequency is greater than or equal to the preset frequency threshold, the basic query cycle is shortened according to the preset shortening adjustment coefficient to obtain a shortened basic query cycle; S224A: In accordance with shortening the basic query cycle, send a status query command to the first communication module currently used for communication, and receive the status response returned by the first communication module.

[0046] As an example, the first historical preset sliding window is a relatively long time window obtained by looking back 50 minutes from the current query execution time. For instance, the first preset statistical duration can be set to 50 minutes, meaning the statistical window is 50 minutes backward from the current time. The historical status response is the status response obtained by the main control chip during the sending and receiving processes according to the basic query cycle within this first historical preset sliding window.

[0047] Based on the first statistical results, the main control chip determines the first offline frequency (i.e., the long-term offline frequency) of offline responses. The first offline frequency is calculated as follows: count the number of offline responses within a first historical preset sliding window, divide this number by the total number of status responses within the first historical preset sliding window, and the resulting ratio is the first offline frequency. The first offline frequency represents the ratio of offline responses occurring within a longer statistical window, and is used to measure the persistence of the offline state of the first communication module.

[0048] When the first offline frequency is greater than or equal to a preset frequency threshold (i.e., a long-term ratio threshold), the main control chip can shorten the basic query period according to a preset shortening adjustment coefficient, thus obtaining a shortened basic query period. The preset shortening adjustment coefficient can range from 0.5 to 1.0. For example, the preset frequency threshold can be set to 0.5, and the preset shortening adjustment coefficient can be set to 0.7; this is merely an example and not a limitation. When the first offline frequency reaches or exceeds 0.5, it indicates that the first communication module has a high offline ratio over a relatively long period, the offline behavior is persistent, and the first communication module may be in an unstable state. The main control chip multiplies the basic query period by the preset shortening adjustment coefficient of 0.7 to obtain a shortened basic query period. Assuming the original basic query period is 30 seconds, it is shortened to 21 seconds. The main control chip sends a status query command to the first communication module currently used for communication according to the shortened basic query period.

[0049] For example, suppose the basic query cycle is 30 seconds, the first preset statistical duration is 50 minutes, the preset frequency threshold is 0.5, and the adjustment coefficient is 0.7. At a certain moment, the main control chip analyzes the historical status responses over the past 50 minutes and finds that 50 out of 100 queries are offline responses, with a first offline frequency of 0.5, equal to the preset frequency threshold of 0.5. The main control chip immediately shortens the basic query cycle to 21 seconds. After shortening, the main control chip sends a status query command every 21 seconds, enabling it to detect status changes in the first communication module more quickly and accelerate its response when the risk of offline activity increases.

[0050] As can be seen, this embodiment dynamically adjusts the basic query cycle based on the first offline frequency. Under normal communication conditions, the main control chip operates with a longer basic query cycle, reducing query frequency and power consumption. When an increase in the first offline frequency is detected, the query cycle is automatically shortened, accelerating the status detection speed, thereby detecting offline events earlier and initiating a multi-level offline confirmation process. This adaptive adjustment mechanism balances low power consumption under normal conditions with rapid response under abnormal conditions.

[0051] It should be noted that when the subsequent first offline frequency is less than the preset frequency threshold, the basic query period can be increased by a preset adjustment coefficient to obtain an increased basic query period. A status query command is sent to the first communication module currently used for communication according to the increased basic query period, and a status response is received from the first communication module. This allows for dynamic adjustment of the basic query period, which is not limited here. The preset adjustment coefficient can range from 1.0 to 2.0; for example, it can be set to 1.2 or 1.5, etc. This is merely an example and does not constitute a limitation of the present invention.

[0052] In one embodiment, specifically step S202, which involves sending a status query command to the first communication module currently used for communication according to the basic query cycle and receiving the status response returned by the first communication module, the following steps are also included: S221: If no status response is received from the first communication module within the preset timeout period after sending the status query command, the status query command is resent to the first communication module according to the preset retry interval. S222: If no status response is received within the preset maximum number of retries, a suspected offline signal is generated, and the first preset duration is shortened to a preset fast confirmation duration.

[0053] As an example, after the main control chip sends a status query command, it starts a timeout timer with a preset timeout duration. The preset timeout duration can be set to two seconds. If the main control chip does not receive any response from the first communication module within the preset timeout duration, i.e., the communication interface does not receive any data frames, the main control chip determines that the query is invalid.

[0054] The main control chip resends the status query command to the first communication module at a preset retry interval. The preset retry interval can be set to 1 second. That is, the main control chip waits 1 second before sending the same status query command again. The main control chip records the number of retries. If the main control chip receives a status response from the first communication module within the preset maximum number of retries, the retry is successful, and the main control chip continues subsequent processing based on the status response. The preset maximum number of retries can be set to 3.

[0055] If the main control chip does not receive a status response within the preset maximum number of retries (i.e., no response after three consecutive retries), the main control chip generates a suspected offline signal. The main control chip then shortens the first preset duration to a preset fast confirmation duration. The preset fast confirmation duration is shorter than the first preset duration. For example, if the first preset duration was originally 5 seconds, the preset fast confirmation duration can be set to 2 seconds. By shortening the first preset duration, the main control chip accelerates the multi-level offline confirmation process in suspected offline situations, more quickly confirming whether the first communication module is truly offline.

[0056] For example, after the main control chip sends the CMD_STA status query command, it receives no response within a 2-second timeout period. The main control chip waits 1 second and resends the CMD_STA command, still receiving no response; it waits another 1 second and sends it a third time, still receiving no response. After all three retries fail, the main control chip generates a suspected offline signal and shortens the first preset timeout from 5 seconds to 1 second. Subsequently, if a multi-level offline confirmation process is initiated, with each confirmation cycle lasting only 1 second, the main control chip can complete multiple confirmations in a shorter time, accelerating the switching decision.

[0057] As can be seen, this embodiment, through a query timeout retry mechanism, allows the main control chip to distinguish between temporary communication failures and genuine offline status of the first communication module. A single unresponsive query may be due to momentary interference or busy communication modules; multiple retries can filter out temporary failures. Only when multiple retries fail to elicit a response is a suspected offline signal generated, and the subsequent confirmation process is accelerated by shortening the first preset time. This mechanism effectively avoids accidental switching due to temporary failures and speeds up the switching response when a device is truly offline.

[0058] In one embodiment, the preset number of confirmations is dynamically adjusted in the following manner: The system obtains the current system time and the second statistical result of the second historical status response within the second historical preset sliding window. The second historical preset sliding window is the time period obtained by tracing back the second preset statistical duration from the current query execution time as the endpoint. The second historical status response is the historical status response obtained by sending and receiving according to the basic query cycle within the second historical preset sliding window. The second preset statistical duration is less than the first preset statistical duration. Based on the second statistical results, the second offline frequency of offline response is determined; The preset number of confirmations is dynamically adjusted based on at least one of the current system time, the first offline frequency, and the second offline frequency.

[0059] As an example, the main control chip can obtain the current system time, the first statistical result of the first historical state response within a first historical preset sliding window, and the second statistical result of the second historical state response within a second historical preset sliding window. The first historical preset sliding window corresponds to a first preset statistical duration, i.e., a relatively long time window, such as 50 minutes, used to statistically analyze the first offline frequency (i.e., long-term offline frequency). The second historical preset sliding window corresponds to a second preset statistical duration, i.e., a relatively short time window, such as 5 minutes, used to statistically analyze the second offline frequency (i.e., short-term offline frequency). The second preset statistical duration is shorter than the first preset statistical duration. The current system time can be obtained through the real-time clock inside the main control chip or synchronized from the master station via a network time protocol.

[0060] The main control chip determines a first offline frequency based on a first statistical result and a second offline frequency based on a second statistical result. The main control chip can dynamically adjust the preset number of confirmations based on any one or more of the current system time, the first offline frequency, and the second offline frequency. Through dynamic adjustment based on multi-dimensional information, the preset number of confirmations can adapt to different communication environments and time period characteristics, automatically improving anti-interference capabilities in interference environments, accelerating handover when truly offline, and reducing sensitivity during low-demand periods.

[0061] The implementation of this dynamic adjustment can include at least one of the following methods: dynamically adjusting the preset number of confirmations based on at least one of the current system time, the first offline frequency, and the second offline frequency; and can include at least one of the following implementation methods: Implementation method 1: Dynamically adjust based on the first offline frequency.

[0062] When the first offline frequency is greater than or equal to the first preset threshold, the preset confirmation count is reduced to the first preset value. The first preset threshold can be set to 0.4, and the first preset value can be set to 2. When the first offline frequency remains high, it indicates that the first communication module has a high offline rate over a long period of time, and the offline behavior is persistent. In this case, reducing the preset confirmation count can accelerate the switching decision and shorten the communication interruption time.

[0063] For example, the first preset statistical duration is 50 minutes, the basic query cycle is 30 seconds, and the first preset historical sliding window contains one hundred status queries. Among them, 45 are offline responses, with a first offline frequency of 0.45, exceeding the first preset threshold of 0.4. The main control chip reduces the preset confirmation count from the default value of 3 to 2, reducing the required confirmation cycle and accelerating the switching.

[0064] It should be noted that the first preset threshold can be the same as the preset frequency threshold mentioned above, and this does not constitute a limitation on this application.

[0065] Method 2: Dynamically adjust based on the second offline frequency.

[0066] When the second offline frequency is greater than or equal to the second preset threshold, and the offline duration of the first communication module is always less than the first preset duration, the preset confirmation count is increased by 1. The second preset threshold can be set to 0.7. The offline duration refers to the duration from when the first communication module returns an offline response until the first communication module returns an online response next time. If the offline duration is always less than the first preset duration, it indicates that the duration of each offline event is very short, which is consistent with the characteristics of transient interference. The main control chip determines that it is currently in an environment with frequent transient interference and increases the preset confirmation count by 1, for example, from the default value of 3 to 4, to enhance anti-interference capability.

[0067] For example, the second preset statistical duration can be 5 minutes, the basic query cycle is 30 seconds, and the second preset sliding window contains ten status queries. Eight of these are offline responses, resulting in a second offline frequency of 0.8, exceeding the second preset threshold of 0.7. Further inspection by the main control chip revealed that each offline duration was less than the first preset duration of 5 seconds. The main control chip increased the preset confirmation count from 3 to 4, effectively preventing erroneous switching caused by momentary interference.

[0068] Method 3: Dynamically adjust based on the current system time.

[0069] When the current system time falls within a preset low communication demand period, the preset number of confirmations is increased to a second preset value. The preset low communication demand period can be a preset nighttime period, such as 11 PM to 5 AM the next day. The second preset value is greater than the first preset value but less than the maximum allowed number of confirmations. For example, the first preset value is 2, the maximum allowed value is 10, and the second preset value can be set to 5 or 6. This implementation reduces handover sensitivity during low communication demand periods such as nighttime, effectively avoiding unnecessary communication rebuilding.

[0070] For example, if the current system time is 2:00 AM, which falls within the preset nighttime period, the main control chip increases the preset number of confirmations from the default value of 3 to 6. In this case, if the first communication module responds offline, it will require 6 consecutive offline confirmation cycles before a switchover will be executed, reducing the possibility of unnecessary switchovers triggered by temporary signal fluctuations at night.

[0071] Implementation Method 4: Dynamically adjust based on the combination of the first offline frequency and the current system time.

[0072] When the first offline frequency is greater than or equal to the first preset threshold, and the current system time is within a preset low communication demand period, the main control chip prioritizes dynamic adjustment based on the current system time, increasing the preset confirmation count to a second preset value. When the first offline frequency is greater than or equal to the first preset threshold, but the current system time is not within a preset high communication demand period, the main control chip prioritizes dynamic adjustment based on the first offline frequency, decreasing the preset confirmation count to the first preset value.

[0073] For example, the first preset threshold is 0.4, the first preset value is 2, and the second preset value is 5. The main control chip detects a first offline frequency of 0.45, exceeding the first preset threshold of 0.4, and the current system time is 2:00 AM, falling within a preset low communication demand period. According to the priority rules, the main control chip prioritizes the adjustment result from the nighttime period, increasing the preset confirmation count from the default value of 3 to 5, reducing the sensitivity of nighttime handover. If the above conditions occur at 10:00 AM (a preset high communication demand period), the main control chip prioritizes the adjustment result of the first offline frequency, decreasing the preset confirmation count from 3 to 2, accelerating the handover and shortening the communication interruption time.

[0074] It should be noted that the above are merely examples and do not constitute a limitation on the present invention.

[0075] In one embodiment, the first preset duration can be dynamically adjusted as follows: when the first offline rate is greater than or equal to the first preset threshold, the first preset duration is shortened to a preset quick confirmation duration, wherein the preset quick confirmation duration is less than the first preset duration.

[0076] It should be noted that the adjustment process for the first preset duration can refer to the adjustment method of Method 1 in the preset confirmation count. To avoid repetition, it will not be repeated here.

[0077] In one embodiment, specifically in step S203, when the status response is an offline response, the offline counter value is set to 1, and the multi-level offline confirmation process is initiated, including the following steps: S231: When two consecutive status responses are received as offline responses, the offline counter is set to 1 and a multi-level offline confirmation process is initiated.

[0078] As an example, in step S202, the main control chip periodically sends status query commands according to the basic query cycle. When a query returns an offline response, the main control chip does not immediately initiate the multi-level offline confirmation process, but continues to wait for the next basic query cycle and sends the status query command again. Only when the status query command is sent twice consecutively according to the basic query cycle, and both received status responses are offline responses, does the main control chip determine that the first communication module may have entered an offline state, execute the setting of the offline counter value to 1, and initiate the multi-level offline confirmation process. If the first query returns an offline response and the second query returns an online response, the main control chip treats the first offline response as a single random error or transient interference, maintains the current state, and does not initiate the multi-level offline confirmation process.

[0079] For example, suppose the basic query cycle is 30 seconds. In the first query cycle, the main control chip sends a CMD_STA command and receives an offline response. The main control chip does not immediately initiate a multi-level offline acknowledgment process, but waits 30 seconds and sends the CMD_STA command again. If an offline response is received the second time, the main control chip initiates the multi-level offline acknowledgment process. If an online response is received the second time, it indicates that the first offline response was merely a momentary interference or signal fluctuation, and the main control chip ignores the first offline response and continues normal communication.

[0080] As can be seen, this embodiment effectively filters out single random errors or transient interference by using two consecutive offline confirmations. In wireless communication environments, due to signal reflection, multipath effects, or momentary obstruction, a single query may return an offline status, but actual communication may not be interrupted. If a multi-level offline confirmation process is initiated for each offline response, the confirmation process will be frequently started, increasing unnecessary signaling overhead and power consumption. By adding a precondition of two consecutive offline confirmations, most transient interference can be filtered out, ensuring that the multi-level offline confirmation process is only triggered when the offline state has persistent characteristics.

[0081] In one embodiment, after initiating the multi-level offline confirmation process, the following steps are also included: S203A1: Obtain the historical status response sequence of the first communication module; S203B1: Based on the historical state response sequence, using a first-order Markov chain model, calculate the predicted probability that the first communication module will remain online for a preset duration starting from the current moment. The transition probability matrix of the first-order Markov chain model is dynamically updated according to the historical state response sequence. S203C3: When the predicted probability is lower than the preset warm-up threshold, a pre-wake command is sent to the second communication module to control the second communication module to switch from deep sleep to light sleep. S203D4: If the status responses returned by the first communication module are all online responses within the preset observation period after the pre-wake-up command is sent, then a deep sleep command is sent to the second communication module to control the second communication module to return to the deep sleep state.

[0082] As an example, the historical state response sequence is a series of state responses obtained by the main control chip during the sending and receiving processes according to the basic query cycle before the multi-level offline confirmation process is initiated. Each historical state response in the sequence is either an online response or an offline response. The main control chip stores this historical state response sequence in its memory for the construction and updating of the first-order Markov chain model.

[0083] Based on the historical state response sequence of the first communication module, the main control chip uses a first-order Markov chain model to calculate the predicted probability that the first communication module will remain online for a preset duration starting from the current moment. The state space of the first-order Markov chain model contains two states: online and offline. The transition probability matrix contains four transition probabilities: the probability of transitioning from online to online, from online to offline, from offline to online, and from offline to offline. The main control chip counts the number of state transitions between two adjacent state responses based on the historical state response sequence and calculates each transition probability. Whenever a new state response is generated, the main control chip dynamically updates the transition probability matrix based on the newly generated state response. The preset duration can be set to 5 minutes.

[0084] When the calculated predicted probability is lower than the preset warm-up threshold, the main control chip sends a wake-up command to the second communication module to control it to switch from deep sleep to light sleep. The preset warm-up threshold can be set to 50%. This warms up the second communication module to a light sleep state, preparing for a possible switchover. In light sleep, the radio frequency circuit of the second communication module is turned off, but the baseband processor and serial communication interface remain active, enabling it to wake up quickly within 20 milliseconds.

[0085] If, within the preset observation period after sending the wake-up command, the first communication module returns only online responses and does not trigger a communication path switch, the main control chip sends a deep sleep command to the second communication module to control it to return to deep sleep mode. The preset observation period can be set to 30 seconds. That is, if the first communication module remains online without switching within 30 seconds after warm-up, it indicates that the warm-up judgment was incorrect, and the second communication module will be returned to deep sleep mode to save power.

[0086] For example, after the multi-level offline confirmation process is initiated, the main control chip obtains the historical status response sequence of the first communication module. Using a first-order Markov chain model, it calculates that the predicted probability of the first communication module remaining online for 5 minutes from the current moment is 40%, which is lower than the preset warm-up threshold of 50%. The main control chip sends a wake-up command to the second communication module, controlling it to switch from deep sleep to light sleep. After 30 seconds, the first communication module continues to return an online response without triggering a switchover. The main control chip then sends a deep sleep command to the second communication module, controlling it to return to deep sleep. Assuming that the first communication module goes offline and triggers a switchover 20 seconds after warm-up, the second communication module is already in a light sleep state and can be quickly woken up to working status and complete the communication path switchover within 20 milliseconds, effectively reducing the switchover latency.

[0087] As can be seen, this embodiment uses a first-order Markov chain model to predict the future online probability of the first communication module. When the prediction result indicates a high probability of a switchback, the second communication module is preheated from deep sleep to light sleep in advance, enabling it to quickly enter the working state when the switchover occurs. If the preheating judgment is incorrect, the second communication module is promptly restored to deep sleep to avoid unnecessary power consumption. This preheating-confirmation-rollback closed-loop mechanism ensures both fast switchback response and power consumption control.

[0088] In one embodiment, after initiating the multi-level offline confirmation process, the following steps are also included: S203A2: Send a heartbeat detection command to the first communication module; S203B3: If no target response to the heartbeat detection command is received within the preset response time, and the first communication module still returns an offline response, then the current offline type is determined to be network offline. S203C4: If no target response to the heartbeat detection command is received within the preset response time, and no status response is received from the first communication module, the current offline type is determined to be a module failure, and the first communication module is marked as an unavailable module.

[0089] As an example, the heartbeat probe command can be a lightweight probe command used to test whether the hardware communication link between the main control chip and the first communication module is normal. The heartbeat probe command does not depend on the connectivity of the network protocol stack; it only tests the serial communication interface between the main control chip and the first communication module and the basic response capability of the first communication module.

[0090] After sending a heartbeat detection command, the main control chip waits for a target response from the first communication module within a preset response time. If no response to the heartbeat detection command is received within the preset response time, but the first communication module still returns an offline response, the main control chip determines that the current offline type is network offline. Network offline indicates that the hardware of the first communication module is working normally, and the communication link between the main control chip and the first communication module is unobstructed, but the first communication module has failed to register with the public wireless network and cannot establish a network connection with the master station. In this case, the first communication module itself is not faulty; it is just that the current network signal is unavailable, and a switchback can be attempted later.

[0091] If no target response to the heartbeat detection command is received within the preset response time, and no status response is received from the first communication module, the main control chip determines the current offline type as a module failure. A module failure indicates that the hardware of the first communication module may be damaged or in a frozen state, unable to respond to any commands from the main control chip. The main control chip marks the first communication module as an unavailable module. In the subsequent handover process, the main control chip will skip the first communication module marked as unavailable.

[0092] For example, after the multi-level offline confirmation process is initiated, the main control chip sends a heartbeat detection command to the first communication module. Assume the first communication module's RF circuit is functioning normally, but the current network signal is extremely weak, preventing registration with the base station. The first communication module can normally receive and respond to the main control chip's serial commands, returning an offline response. The main control chip determines the current offline type as network offline. Alternatively, suppose the first communication module's power circuit is damaged and completely inoperable. After sending the heartbeat detection command, the main control chip receives no response within the preset response time, and subsequent status query commands also receive no response. The main control chip determines the current offline type as module failure and marks the first communication module as unavailable.

[0093] As can be seen, this embodiment distinguishes between two offline types—network offline and module failure—using heartbeat detection commands, providing a more accurate basis for subsequent switchback decisions. For network offline, the module hardware is normal, and a switchback can be attempted after the signal is restored. For module failure, the module hardware is damaged, and the module should be skipped to avoid invalid switchback attempts.

[0094] In one embodiment, that is, after step S204, i.e. after switching the communication path from the first communication module to the second communication module, the following steps are also included: S205A: Obtain the target number of successful back-switches from the preset number of back-switches completed before the current back-switching attempt; wherein, if the first communication module remains online for more than a preset stable time after the back-switching, the back-switching attempt is counted as a successful back-switching. S206A: The ratio of the number of successful attempts to the preset number of attempts is used as the historical back-cut success rate; S207A: When the historical back-switch success rate is higher than the first success rate threshold, the communication path is switched back from the second communication module to the first communication module using the active detection mode. S208A: When the historical back-off success rate is lower than the second success rate threshold, the communication path is switched back from the second communication module to the first communication module using the exponential backoff mode. S209A: When the historical back-switch success rate is between the second success rate threshold and the first success rate threshold, the communication path is switched back from the second communication module to the first communication module using a fixed-period keep-alive mode. Among them, the first success rate threshold is greater than the second success rate threshold.

[0095] As an example, the main control chip obtains the target number of successful back-switch attempts from a preset number of back-switch attempts completed before the current back-switch attempt. The preset number can be set to 20, meaning it counts the results of the 20 most recent back-switch attempts before the current one. The main control chip maintains a back-switch record queue of a preset number of lengths, storing the result (success or failure) of each back-switch attempt in chronological order. When a new back-switch attempt is completed, the main control chip adds the new back-switch result to the queue and removes the oldest record from the queue to maintain a constant queue length of the preset number of attempts.

[0096] The main control chip counts the number of successful switchbacks in the switchback record queue; this number is the target number of successful switchbacks. The main control chip uses the ratio of the target number of successful switchbacks to the preset number as the historical switchback success rate. For example, if the preset number is 20 and the number of successful switchbacks in the switchback record queue is 16, then the historical switchback success rate is 80%.

[0097] The criteria for determining a successful switchback are as follows: if the first communication module remains online for a preset stabilization period after the switchback, the main control chip counts the switchback attempt as successful. The preset stabilization period can be set to 120 seconds. If the first communication module goes offline again within 120 seconds after the switchback, the switchback is considered a failure. By setting the preset stabilization period, the main control chip can filter out unstable situations where the module immediately goes offline again after the switchback. Only when the first communication module can operate stably for a period of time after the switchback is the switchback considered truly successful.

[0098] The main control chip compares the historical switchback success rate with a first success rate threshold and a second success rate threshold. The first success rate threshold can be set to 70%, and the second success rate threshold can be set to 30%, with the first success rate threshold being greater than the second success rate threshold.

[0099] When the historical switchback success rate is higher than the first success rate threshold, the main control chip uses an active detection mode to switch the communication path back from the second communication module to the first communication module. When the historical switchback success rate is lower than the second success rate threshold, the main control chip uses an exponential backoff mode to switch the communication path back from the second communication module to the first communication module. When the historical switchback success rate is between the second and first success rate thresholds, the main control chip uses a fixed-period keep-alive mode to switch the communication path back from the second communication module to the first communication module.

[0100] For example, with a preset number of attempts of 20, a preset stable duration of 120 seconds, a first success rate threshold of 70%, and a second success rate threshold of 30%, the main control chip analyzes the most recent 20 switchback attempts. In 16 of these attempts, the first communication module remained online for more than 120 seconds after the switchback, while in 4 attempts, it went offline again within 120 seconds. The target number of successful switchbacks is 16, and the historical switchback success rate is 80%, higher than the first success rate threshold of 70%. In this case, the main control chip uses an active probing mode to perform the switchback. If, in another time period, only 4 of the most recent 20 switchback attempts are successful, the target number of successful switchbacks is 4, and the historical switchback success rate is 20%, lower than the second success rate threshold of 30%, the main control chip uses an exponential backoff mode to perform the switchback. If 10 of the most recent 20 switchback attempts are successful, the target number of successful attempts is 10, and the historical switchback success rate is 50%, falling between 30% and 70%, the main control chip uses a fixed-period keep-alive mode to perform the switchback.

[0101] As can be seen, this embodiment calculates the historical back-cut success rate by statistically analyzing the target success rate in a preset number of back-cut attempts, and adaptively selects the back-cut mode based on the comparison results of the historical back-cut success rate with the first success rate threshold and the second success rate threshold. When the historical back-cut success rate is high, an active probing mode is used for rapid back-cut; when the historical back-cut success rate is low, an exponential backoff mode is used to reduce the back-cut frequency; when the historical back-cut success rate is moderate, a fixed-period keep-alive mode is used for stable attempts. This adaptive back-cut management mechanism enables the back-cut strategy to dynamically adapt to changes in the channel quality of the first communication module, balancing back-cut response speed and avoiding invalid back-cut attempts.

[0102] In one embodiment, the fixed-period keep-alive mode includes: starting a second timer; when the second timer reaches a second preset duration, switching the communication path back from the second communication module to the first communication module; if the switchback is successful, exiting the fixed-period keep-alive mode; if the switchback fails, restarting the second timer until the switchback is successful.

[0103] As an example, the main control chip starts a second timer with a preset duration (e.g., 10 minutes). When the second timer reaches the preset duration, the main control chip switches the communication path back from the second communication module to the first communication module. If the switchback is successful, the fixed-cycle keep-alive mode is exited. If the switchback fails—that is, the first communication module fails to establish stable communication or immediately goes offline again after the switchback—the main control chip restarts the second timer and enters the next keep-alive waiting cycle, repeating this process until the switchback is successful.

[0104] For example, the second preset duration is 10 minutes. After switching to the second communication module, the main control chip starts a second timer. After 10 minutes, the second timer expires, and the main control chip attempts to switch the communication path back to the first communication module. If the switchback fails, the second timer is restarted, and the chip waits for the next 10-minute cycle to try again. This fixed-cycle keep-alive mode is suitable for situations with a moderate historical switchback success rate, ensuring a certain switchback frequency while avoiding too many invalid attempts.

[0105] In one embodiment, the active detection mode includes: sending a status query command to the first communication module at a preset detection interval and receiving a status response returned by the first communication module; when the status response is an online response, switching the communication path back from the second communication module to the first communication module; if the switchback is successful, exiting the active detection mode; if the switchback fails, continuing to send a status query command to the first communication module at a preset detection interval until the switchback is successful.

[0106] As an example, the main control chip sends status query commands to the first communication module at preset detection intervals (e.g., 30 seconds) and receives the returned status responses. When an online response is received, the main control chip switches the communication path back from the second communication module to the first communication module. If the switchback is successful, it exits the active detection mode. If the switchback fails, the main control chip continues to send status query commands at preset detection intervals to continuously monitor the status of the first communication module until the switchback is successful.

[0107] For example, the preset detection interval can be 30 seconds. The main control chip sends CMD_STA to the first communication module every 30 seconds. If an offline response is received for the first five attempts and an online response is received on the sixth, the main control chip immediately performs a switchback. If the switchback fails, it continues to probe every 30 seconds until successful. This active detection mode is suitable for situations with a high historical switchback success rate, allowing for rapid detection of recovery opportunities.

[0108] In one embodiment, the exponential backoff mode includes: starting a third timer; when the third timer reaches the basic backoff duration, switching the communication path back from the second communication module to the first communication module; if the initial backoff is successful, exiting the exponential backoff mode; if the initial backoff fails, recording the number of backoff failures, setting the initial value of the number of backoff failures to 1, and repeating the following steps until the backoff is successful: Based on the number of failed back-cuts, determine the target retreat time and restart the third timer; When the third timer reaches the target backoff duration, the communication path will be switched back from the second communication module to the first communication module; If the pullback is successful, exit the index retreat mode; If the back-cut fails, the number of back-cut failures is incremented by 1, and the target retreat time is determined based on the incremented number of back-cut failures. The target retreat time is determined according to the following formula: ; in, Duration of retreat to target Based on the retreat duration (e.g., 5 minutes). The preset retreat time limit is set (e.g., 60 minutes), and k represents the number of failed switchback attempts. The random jitter value is within a preset range (e.g., a random jitter value between -10% and +10%). The purpose of introducing the random jitter value is that when a large number of smart meters switch over within the same time period, their switchback attempt times will be naturally dispersed due to the random jitter value, effectively avoiding a large number of smart meters launching switchback attempts at the same time, which would cause a momentary signaling impact on the main station.

[0109] Among them, the exponential backoff mode is a backoff strategy that gradually extends the retry waiting time after a backoff failure. When backoff attempts fail consecutively, the main control chip believes that the channel conditions of the first communication module may not be able to return to normal temporarily. Therefore, it reduces the frequency of invalid backoff attempts by gradually increasing the waiting time, thereby saving signaling resources and avoiding impact on the main station.

[0110] As an example, the main control chip first starts a third timer, the duration of which is the base backoff duration. The base backoff duration can be set to 300 seconds. When the third timer reaches the base backoff duration, the main control chip switches the communication path back from the second communication module to the first communication module. If this switchback is successful, the main control chip exits the exponential backoff mode.

[0111] If the current backoff fails, the main control chip records the number of backoff failures, k, and sets the initial value of k to 1. Afterward, the main control chip repeats the following steps until the backoff is successful: First, it determines the target backoff duration based on the current number of backoff failures, k, which increases progressively with the number of failures. Second, the main control chip restarts the third timer, updating its duration to the target backoff duration. Third, when the third timer reaches the target backoff duration, the main control chip switches the communication path back from the second communication module to the first communication module. Fourth, it determines whether the backoff was successful. If successful, it exits the exponential backoff mode; if unsuccessful, it increments k by 1 and returns to step one. The target backoff duration is determined according to the formula described above.

[0112] For example, the base backoff time is 300 seconds, the maximum backoff time is 3600 seconds, and the jitter value ranges from -10% to +10%. The main control chip starts the third timer and waits 300 seconds before performing the first switch. If the first switchback fails, the initial value of k is set to 1. The main control chip calculates the target backoff time according to the formula: Assuming If the value is -0.1, the target retreat time is 270 seconds. The main control chip restarts the third timer and waits 270 seconds before performing the second switch. If it fails again, k is incremented to 2, and the target retreat time is recalculated. This process continues, with the backoff time doubling and adding random jitter after each failure, until the maximum backoff time of 3600 seconds is reached. When a successful switchback occurs, and the first communication module returns an online response in a preset number of consecutive queries, the main control chip exits the exponential backoff mode.

[0113] As can be seen, the exponential backoff mode in this embodiment reduces the frequency of backoff attempts as the number of backoff failures increases by doubling the backoff duration with each successive doubling, thus avoiding the waste of signaling resources caused by repeated backoff attempts under poor channel conditions. Introducing a random jitter value disperses the backoff attempts of a large number of smart meters, effectively preventing simultaneous concentrated backoff attempts from causing a momentary impact on the main station.

[0114] In one embodiment, that is, after step S204, i.e. after switching the communication path from the first communication module to the second communication module, the following steps are also included: S205B: Records the duration of continuous offline operation of the first communication module; S206B: When the continuous offline time reaches the first duration threshold, a shallow sleep command is sent to the first communication module to control the first communication module to enter a shallow sleep state in which the radio frequency is turned off and the baseband is maintained. S207B: When the continuous offline duration reaches the second duration threshold, a deep sleep command is sent to the first communication module to control the first communication module to enter a deep sleep state that only retains the wake-up pin. The second duration threshold is greater than the first duration threshold.

[0115] As an example, the main control chip records the continuous offline duration of the first communication module. The continuous offline duration is the duration from the moment the first communication module is determined to be offline and a switch is executed until the current moment. When the continuous offline duration reaches a first duration threshold (e.g., 5 minutes), the main control chip sends a shallow sleep command to the first communication module, controlling the first communication module to enter a shallow sleep state where the radio frequency is turned off and the baseband is maintained. In the shallow sleep state, the radio frequency circuit of the first communication module is turned off, and it no longer transmits or receives wireless signals. The power consumption is reduced to less than one milliamp, but the baseband processor and serial communication interface remain active, able to receive and respond to the commands of the main control chip. The time to wake up from the shallow sleep state to the active state is less than 20 milliseconds.

[0116] When the continuous offline time further reaches a second duration threshold (e.g., 10 minutes), the main control chip sends a deep sleep command to the first communication module, controlling the first communication module to enter a deep sleep state with only the wake-up pin retained. In the deep sleep state, the power supply to the first communication module is cut off or only the wake-up pin is powered, and the power consumption is reduced to below 10 microamps, but the time to wake up from the deep sleep state to the working state is greater than or equal to 500 milliseconds. The second duration threshold is greater than the first duration threshold.

[0117] For example, the first duration threshold is 5 minutes, and the second duration threshold is 10 minutes. After the main control chip switches the communication path to the second communication module, it begins recording the continuous offline duration of the first communication module. After 5 minutes, the continuous offline duration reaches the first duration threshold, and the main control chip sends a light sleep command to the first communication module. After 10 minutes, the continuous offline duration reaches the second duration threshold, and the main control chip sends a deep sleep command to the first communication module.

[0118] As can be seen, this embodiment employs a two-tiered management system of light sleep and deep sleep. During offline periods, the sleep depth gradually increases based on the duration of offline activity, achieving refined power consumption management. In the initial stage of offline operation, the module remains operational for rapid recovery; in the middle stage, it enters light sleep to conserve power while maintaining rapid wake-up capability; and in the later stage, it enters deep sleep to minimize power consumption. Overall power consumption can be reduced by over 90%, while ensuring rapid wake-up when needed.

[0119] In one embodiment, that is, after step S204, i.e. after switching the communication path from the first communication module to the second communication module, the following steps are also included: S205C: Records the cumulative number of communication path switching operations performed within the third historical preset sliding window; the third historical preset sliding window is the time period obtained by tracing back the third preset statistical duration from the current query execution time as the endpoint; S206C: When the cumulative number of handovers is greater than or equal to the handover suppression threshold, the fourth timer is started; S207C: During the fourth timer's timing period, even if the offline count value is greater than or equal to the preset number of acknowledgments, the switching operation will not be performed.

[0120] The handover suppression mechanism is used to prevent communication instability caused by frequent handovers within a short period. The main control chip records the cumulative number of communication path handovers within a third historical preset sliding window. The third historical preset sliding window is a time period obtained by tracing back a third preset statistical duration from the current query execution time as the endpoint. For example, the third preset statistical duration can be set to 10 minutes. The main control chip maintains a handover record queue, recording the timestamp of each handover. When it is necessary to calculate the cumulative number of handovers, the main control chip subtracts the third preset statistical duration from the current time to obtain a starting time, and counts the number of handover records in the handover record queue whose timestamps are later than this starting time; this is the cumulative number of handovers.

[0121] When the cumulative number of handovers exceeds or equals the handover suppression threshold, the main control chip starts a fourth timer. The handover suppression threshold can be set to 3 times. The duration of the fourth timer can be set to 5 minutes. During the fourth timer's count, i.e., the suppression period, even if the offline count is greater than or equal to the preset acknowledgment count, the main control chip will not perform a handover operation and may generate an alarm event recorded in the log or reported to the main station. When the fourth timer expires, the suppression period ends, the main control chip resets the cumulative handover count to zero, and restores normal handover functionality.

[0122] For example, the third preset statistical duration is 10 minutes, the switching suppression threshold is 3 times, and the fourth timer's duration is 5 minutes. Within the last 10 minutes, the main control chip has performed 3 communication path switching operations. At this point, the main control chip detects that the offline count has reached the preset confirmation count and prepares to perform the 4th switch. The main control chip checks that the cumulative switching count is 3 times, reaching the switching suppression threshold of 3 times, and starts the fourth timer (5 minutes). For the next 5 minutes, even if the switching conditions are met, the main control chip will not perform a switch and will issue an alarm. After 5 minutes, the fourth timer expires, the main control chip resets the switching count to zero, and normal switching functionality is restored.

[0123] As can be seen, the handover suppression mechanism in this embodiment is used to prevent communication instability caused by frequent handovers within a short period of time. When excessive handovers are detected within a short period of time, the handover operation is temporarily stopped and resumed after a period of time to avoid a vicious cycle caused by frequent handovers.

[0124] In one embodiment, the method further includes the following steps: S301: In a first cycle shorter than the basic query cycle, alternately send status query commands to the first communication module and the second communication module, and receive the corresponding status response; S301: When the communication module currently used for communication returns an offline response K times consecutively, and another communication module returns an offline response at least once within the most recent preset time period, enter emergency mode; S302: In emergency mode, it is prohibited to send deep sleep commands to the first communication module and the second communication module; S303: In emergency mode, status query commands are sent alternately to the first communication module and the second communication module in a second cycle; S304: When any communication module returns an online response twice consecutively, exit the emergency mode and lock that communication module as the current communication module used for communication; In emergency mode, the second cycle is adjusted as follows: if no online response is received after sending status query commands alternately in the second cycle for P consecutive times, the second cycle is gradually increased until the preset maximum detection cycle is reached; once an online response is received, the second cycle is restored to the initial detection cycle.

[0125] The emergency mode is used to handle extreme situations where both the first and second communication modules fail to communicate normally. The main control chip alternately sends status query commands to the first and second communication modules in a first cycle shorter than the basic query cycle, and receives corresponding status responses. The first cycle can be set to 2 seconds, meaning the main control chip sends a status query command every 2 seconds, first to the first communication module, then to the second, alternating between the two.

[0126] The main control chip enters emergency mode when the currently used communication module returns an offline response K times consecutively, and another communication module returns an offline response at least once within the most recent preset time period. K can be set to 3 times, and the most recent preset time period can be set to 1 minute. That is, if the currently used communication module is offline for 3 consecutive queries, and another communication module is also determined to be offline at least once within the most recent 1 minute, it indicates that both communication modules may be offline.

[0127] In emergency mode, the main control chip prohibits sending deep sleep commands to the first and second communication modules. Both communication modules remain in at least a light sleep or active state to ensure they can respond to the main control chip's query commands at any time. The main control chip alternately sends status query commands to the first and second communication modules in a second cycle, the initial value of which can be set to 10 seconds. When either communication module returns an online response twice consecutively, the main control chip exits emergency mode and locks that communication module as the currently used communication module. It then sends an exit request from the emergency mode to the main station through that communication module, restoring normal policy configuration and sleep management.

[0128] In emergency mode, the second cycle adaptively adjusts as follows: If no online response is received after P consecutive alternating status query commands in the second cycle, the main control chip gradually increases the second cycle until it reaches the preset maximum detection cycle. P can be set to 5 times, meaning that if no online response is received after 5 consecutive alternating queries, the main control chip extends the second cycle from 10 seconds to 20 seconds; after another 5 consecutive no responses, it extends to 40 seconds, and so on, with a maximum of 60 seconds. Once an online response is received for a query, the main control chip immediately restores the second cycle to the initial detection cycle of 10 seconds.

[0129] For example, the basic query cycle is 30 seconds, the first cycle is 2 seconds, K is 3 times, the most recent preset time period is 1 minute, the initial value of the second cycle is 10 seconds, P is 5 times, and the maximum detection cycle is 60 seconds. At a certain moment, the main control chip detects that the currently used first communication module returns an offline response 3 times consecutively, and the second communication module also returned an offline response once within the last minute, thus entering emergency mode. In emergency mode, the main control chip alternately queries the two modules every 10 seconds. After the first 5 alternating queries fail to receive an online response, the main control chip extends the second cycle to 20 seconds. In the first query after the extension, the first communication module returns an online response, and the main control chip immediately restores the second cycle to 10 seconds. Then, the first communication module returns an online response again. After two consecutive online responses, the main control chip exits emergency mode and locks the first communication module for communication.

[0130] During a preset monitoring period after exiting emergency mode, the main control chip continuously monitors the online status of newly locked communication modules. The preset monitoring period can be set to 300 seconds. If the communication module returns an offline response again within the preset monitoring period, the main control chip increases the value of K required to re-enter emergency mode, for example, increasing K from 3 to 5. By increasing the threshold for entering emergency mode, oscillations caused by frequent entry and exit from emergency mode during periods of communication instability are avoided.

[0131] As can be seen, the emergency mode in this embodiment provides an effective recovery mechanism for extreme situations where both modules are offline. When conventional switching decisions fail, the emergency mode probes the two communication modules alternately. Once either module returns to online, the system quickly exits the emergency mode and resumes communication. The adaptive adjustment mechanism of the probe cycle balances recovery speed and power consumption control: it gradually increases the probe cycle to avoid unnecessary power consumption when recovery is unsuccessful for an extended period; and it immediately shortens the probe cycle to accelerate confirmation when signs of recovery are detected. The health check and threshold enhancement mechanism after exiting the emergency mode effectively prevents oscillations caused by frequent entry and exit from the emergency mode during periods of communication instability.

[0132] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0133] Secondly, embodiments of this application provide a communication switching system, which corresponds one-to-one with the communication switching methods described in the first aspect above. This communication switching system can be applied to smart meters. For example... Figure 1 As shown, the communication switching system may include a main control chip 101, a first communication module 102, and a second communication module 103; The main control chip 101 is used for: Read the pre-configured base query cycle; According to the basic query cycle, a status query command is sent to the first communication module currently used for communication, and a status response is received from the first communication module. When the status response is an offline response, the offline counter is set to 1, and a multi-level offline confirmation process is initiated. The multi-level offline confirmation process includes: starting a first timer; during the timer's countdown, sending the status confirmation command to the first communication module at a preset confirmation interval; when the first timer reaches a first preset duration, and all continuously received status responses are offline responses, incrementing the offline counter by 1 and restarting the first timer, wherein the preset confirmation interval is less than or equal to the first preset duration; wherein, during the timer's countdown, if any received status response is an online response, the offline counter is cleared and the multi-level offline confirmation process is stopped. When the offline count value is greater than or equal to the preset number of confirmations, the communication path is switched from the first communication module to the second communication module.

[0134] In one embodiment, the step of sending a status query command to the first communication module currently used for communication according to the basic query cycle, and receiving a status response returned by the first communication module, further includes: Obtain the first statistical result of the historical status response within the first historical preset sliding window. The first historical preset sliding window is a time period obtained by tracing back the first preset statistical duration from the current query execution time as the endpoint. The historical status response is the historical status response obtained by sending and receiving according to the basic query cycle within the first historical preset sliding window. Based on the first statistical results, the first offline frequency of the offline response is determined; When the first offline frequency is greater than or equal to a preset frequency threshold, the basic query period is shortened according to a preset shortening adjustment coefficient to obtain a shortened basic query period. According to the shortened basic query cycle, a status query command is sent to the first communication module currently used for communication, and a status response is received from the first communication module.

[0135] In one embodiment, the preset number of confirmations is dynamically adjusted in the following manner: The system obtains the current system time and the second statistical result of the second historical status response within the second historical preset sliding window. The second historical preset sliding window is a time period obtained by tracing back the second preset statistical duration from the current query execution time as the endpoint. The second historical status response is the historical status response obtained by sending and receiving according to the basic query cycle within the second historical preset sliding window. The second preset statistical duration is less than the first preset statistical duration. Based on the second statistical results, a second offline frequency of the offline response is determined; The preset number of confirmations is dynamically adjusted based on at least one of the current system time, the first offline frequency, and the second offline frequency.

[0136] In one embodiment, after initiating the multi-level offline confirmation process, the main control chip 101 is further configured to: Obtain the historical status response sequence of the first communication module; Based on the historical state response sequence, a first-order Markov chain model is used to calculate the predicted probability that the first communication module will remain online for a preset duration from the current moment. The transition probability matrix of the first-order Markov chain model is dynamically updated according to the historical state response sequence. When the predicted probability is lower than the preset warm-up threshold, a pre-wake command is sent to the second communication module to control the second communication module to switch from deep sleep to light sleep. If, within a preset observation period after sending the pre-wake-up command, the status responses returned by the first communication module are all online responses, then a deep sleep command is sent to the second communication module to control the second communication module to return to a deep sleep state.

[0137] In one embodiment, after initiating the multi-level offline confirmation process, the main control chip 101 is further configured to: Send a heartbeat detection command to the first communication module; If no target response to the heartbeat detection command is received within the preset response time, and the first communication module still returns the offline response, then the current offline type is determined to be network offline. If no target response to the heartbeat detection command is received within the preset response time, and no status response is received from the first communication module, the current offline type is determined to be a module failure, and the first communication module is marked as an unavailable module.

[0138] In one embodiment, after switching the communication path from the first communication module to the second communication module, the main control chip 101 is further configured to: Get the target number of successful back-switch attempts from the preset number of back-switch attempts completed before the current back-switch attempt; wherein, if the first communication module remains online for more than a preset stable time after the back-switch, the back-switch attempt is counted as a successful back-switch. The ratio of the number of successful attempts to the preset number is used as the historical back-cut success rate. When the historical back-switch success rate is higher than the first success rate threshold, the communication path is switched back from the second communication module to the first communication module using an active detection mode. When the historical back-off success rate is lower than the second success rate threshold, the communication path is back-offed from the second communication module to the first communication module using the exponential backoff mode. When the historical back-switch success rate is between the second success rate threshold and the first success rate threshold, the communication path is switched back from the second communication module to the first communication module using a fixed-period keep-alive mode. Wherein, the first success rate threshold is greater than the second success rate threshold.

[0139] In one embodiment, the fixed-period keep-alive mode includes: starting a second timer; when the second timer reaches a second preset duration, switching the communication path back from the second communication module to the first communication module; if the switchback is successful, exiting the fixed-period keep-alive mode; if the switchback fails, restarting the second timer until the switchback is successful.

[0140] In one embodiment, the active detection mode includes: sending the status query command to the first communication module at a preset detection interval, and receiving the status response returned by the first communication module; when the received status response is the online response, switching the communication path back from the second communication module to the first communication module; if the switchback is successful, exiting the active detection mode; if the switchback fails, continuing to send the status query command to the first communication module at the preset detection interval until the switchback is successful.

[0141] In one embodiment, the exponential backoff mode includes: starting a third timer; when the third timer reaches the basic backoff duration, switching the communication path back from the second communication module to the first communication module; if the initial switchback is successful, exiting the exponential backoff mode; if the initial switchback fails, recording the number of switchback failures, setting the initial value of the number of switchback failures to 1, and repeating the following steps until the switchback is successful: Based on the number of failed back-cuts, determine the target retreat duration and restart the third timer; When the third timer reaches the target backoff duration, the communication path is switched back from the second communication module to the first communication module; If the back-off is successful, exit the exponential backoff mode. If the back-cut fails, the number of back-cut failures is incremented by 1, and the target retreat time is determined based on the incremented number of back-cut failures. The target retreat time is determined according to the following formula: ; in, Duration of retreat to target Based on the retreat duration, To preset the maximum retreat time, k represents the number of failed retreat attempts. The random jitter value is within a preset range.

[0142] In one embodiment, after switching the communication path from the first communication module to the second communication module, the main control chip 101 is further configured to: Record the duration of continuous offline operation of the first communication module; When the continuous offline duration reaches the first duration threshold, a shallow sleep command is sent to the first communication module to control the first communication module to enter a shallow sleep state in which the radio frequency is turned off and the baseband is maintained. When the continuous offline duration reaches the second duration threshold, a deep sleep command is sent to the first communication module to control the first communication module to enter a deep sleep state that only retains the wake-up pin, wherein the second duration threshold is greater than the first duration threshold.

[0143] It should be noted that the specific limitations of the communication switching system can be found in the limitations of the communication switching method mentioned above, and will not be repeated here.

[0144] Thirdly, embodiments of this application provide a smart meter, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it performs the following steps: Read the pre-configured base query cycle; According to the basic query cycle, a status query command is sent to the first communication module currently used for communication, and a status response is received from the first communication module. When the status response is an offline response, the offline counter is set to 1, and a multi-level offline confirmation process is initiated. The multi-level offline confirmation process includes: starting a first timer; during the timer's countdown, sending the status confirmation command to the first communication module at a preset confirmation interval; when the first timer reaches a first preset duration, and all continuously received status responses are offline responses, incrementing the offline counter by 1 and restarting the first timer, wherein the preset confirmation interval is less than or equal to the first preset duration; wherein, during the timer's countdown, if any received status response is an online response, the offline counter is cleared and the multi-level offline confirmation process is stopped. When the offline count value is greater than or equal to the preset number of confirmations, the communication path is switched from the first communication module to the second communication module.

[0145] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the following steps: Read the pre-configured base query cycle; According to the basic query cycle, a status query command is sent to the first communication module currently used for communication, and a status response is received from the first communication module. When the status response is an offline response, the offline counter is set to 1, and a multi-level offline confirmation process is initiated. The multi-level offline confirmation process includes: starting a first timer; during the timer's countdown, sending the status confirmation command to the first communication module at a preset confirmation interval; when the first timer reaches a first preset duration, and all continuously received status responses are offline responses, incrementing the offline counter by 1 and restarting the first timer, wherein the preset confirmation interval is less than or equal to the first preset duration; wherein, during the timer's countdown, if any received status response is an online response, the offline counter is cleared and the multi-level offline confirmation process is stopped. When the offline count value is greater than or equal to the preset number of confirmations, the communication path is switched from the first communication module to the second communication module.

[0146] It should be noted that the functions or steps that can be achieved by the computer-readable storage medium or smart meter mentioned above can be found in the limitations of the communication switching method above, and will not be repeated here.

[0147] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A communication handover method, characterized in that, Applied to smart meters, the smart meter including a first communication module and a second communication module, the method includes: Read the pre-configured base query cycle; According to the basic query cycle, a status query command is sent to the first communication module currently used for communication, and a status response is received from the first communication module. When the status response is an offline response, the offline counter is set to 1, and a multi-level offline confirmation process is initiated. The multi-level offline confirmation process includes: starting a first timer; during the timer's countdown, sending the status confirmation command to the first communication module at a preset confirmation interval; when the first timer reaches a first preset duration, and all continuously received status responses are offline responses, incrementing the offline counter by 1 and restarting the first timer, wherein the preset confirmation interval is less than or equal to the first preset duration; wherein, during the timer's countdown, if any received status response is an online response, the offline counter is cleared and the multi-level offline confirmation process is stopped. When the offline count value is greater than or equal to the preset number of confirmations, the communication path is switched from the first communication module to the second communication module.

2. The method according to claim 1, characterized in that, The step of sending a status query command to the first communication module currently used for communication according to the basic query cycle, and receiving the status response returned by the first communication module, further includes: Obtain the first statistical result of the historical status response within the first historical preset sliding window. The first historical preset sliding window is a time period obtained by tracing back the first preset statistical duration from the current query execution time as the endpoint. The historical status response is the historical status response obtained by sending and receiving according to the basic query cycle within the first historical preset sliding window. Based on the first statistical results, the first offline frequency of the offline response is determined; When the first offline frequency is greater than or equal to a preset frequency threshold, the basic query period is shortened according to a preset shortening adjustment coefficient to obtain a shortened basic query period. According to the shortened basic query cycle, a status query command is sent to the first communication module currently used for communication, and a status response is received from the first communication module.

3. The method according to claim 2, characterized in that, The preset number of confirmations is dynamically adjusted in the following manner: The system obtains the current system time and the second statistical result of the second historical status response within the second historical preset sliding window. The second historical preset sliding window is a time period obtained by tracing back the second preset statistical duration from the current query execution time as the endpoint. The second historical status response is the historical status response obtained by sending and receiving according to the basic query cycle within the second historical preset sliding window. The second preset statistical duration is less than the first preset statistical duration. Based on the second statistical results, a second offline frequency of the offline response is determined; The preset number of confirmations is dynamically adjusted based on at least one of the current system time, the first offline frequency, and the second offline frequency.

4. The method according to claim 1, characterized in that, After initiating the multi-level offline confirmation process, the following is also included: Obtain the historical status response sequence of the first communication module; Based on the historical state response sequence, a first-order Markov chain model is used to calculate the predicted probability that the first communication module will remain online for a preset duration from the current moment. The transition probability matrix of the first-order Markov chain model is dynamically updated according to the historical state response sequence. When the predicted probability is lower than the preset warm-up threshold, a pre-wake command is sent to the second communication module to control the second communication module to switch from deep sleep to light sleep. If, within a preset observation period after sending the pre-wake-up command, the status responses returned by the first communication module are all online responses, then a deep sleep command is sent to the second communication module to control the second communication module to return to a deep sleep state.

5. The method according to claim 1, characterized in that, After initiating the multi-level offline confirmation process, the following is also included: Send a heartbeat detection command to the first communication module; If no target response to the heartbeat detection command is received within the preset response time, and the first communication module still returns the offline response, then the current offline type is determined to be network offline. If no target response to the heartbeat detection command is received within the preset response time, and no status response is received from the first communication module, the current offline type is determined to be a module failure, and the first communication module is marked as an unavailable module.

6. The method according to claim 1, characterized in that, After switching the communication path from the first communication module to the second communication module, the method further includes: Get the target number of successful back-switch attempts from the preset number of back-switch attempts completed before the current back-switch attempt; wherein, if the first communication module remains online for more than a preset stable time after the back-switch, the back-switch attempt is counted as a successful back-switch. The ratio of the number of successful attempts to the preset number is used as the historical back-cut success rate. When the historical back-switch success rate is higher than the first success rate threshold, the communication path is switched back from the second communication module to the first communication module using an active detection mode. When the historical back-off success rate is lower than the second success rate threshold, the communication path is back-offed from the second communication module to the first communication module using the exponential backoff mode. When the historical back-switch success rate is between the second success rate threshold and the first success rate threshold, the communication path is switched back from the second communication module to the first communication module using a fixed-period keep-alive mode. Wherein, the first success rate threshold is greater than the second success rate threshold.

7. The method according to claim 6, characterized in that: The fixed-period keep-alive mode includes: starting a second timer; when the second timer reaches a second preset duration, switching the communication path back from the second communication module to the first communication module; if the switchback is successful, exiting the fixed-period keep-alive mode; if the switchback fails, restarting the second timer until the switchback is successful. The active detection mode includes: sending the status query command to the first communication module at a preset detection interval, and receiving the status response returned by the first communication module; when the received status response is the online response, switching the communication path back from the second communication module to the first communication module; if the switchback is successful, exiting the active detection mode; if the switchback fails, continuing to send the status query command to the first communication module at the preset detection interval until the switchback is successful. The exponential backoff mode includes: starting a third timer; when the third timer reaches the basic backoff duration, switching the communication path back from the second communication module to the first communication module; if the initial switchback is successful, exiting the exponential backoff mode; if the initial switchback fails, recording the number of failed switchbacks, setting the initial value of the number of failed switchbacks to 1, and repeating the following steps until the switchback is successful: Based on the number of failed back-cuts, determine the target retreat duration and restart the third timer; When the third timer reaches the target backoff duration, the communication path is switched back from the second communication module to the first communication module; If the back-off is successful, exit the exponential backoff mode. If the back-cut fails, the number of back-cut failures is incremented by 1, and the target retreat time is determined based on the incremented number of back-cut failures. The target retreat time is determined according to the following formula: ; in, Duration of retreat to target Based on the retreat duration, To preset the maximum retreat time, k represents the number of failed retreat attempts. The random jitter value is within a preset range.

8. The method according to claim 1, characterized in that, After switching the communication path from the first communication module to the second communication module, the method further includes: Record the duration of continuous offline operation of the first communication module; When the continuous offline duration reaches the first duration threshold, a shallow sleep command is sent to the first communication module to control the first communication module to enter a shallow sleep state in which the radio frequency is turned off and the baseband is maintained. When the continuous offline duration reaches the second duration threshold, a deep sleep command is sent to the first communication module to control the first communication module to enter a deep sleep state that only retains the wake-up pin, wherein the second duration threshold is greater than the first duration threshold.

9. A communication switching system, characterized in that, Applied to smart meters, the communication switching system includes a main control chip, a first communication module, and a second communication module; the main control chip is used for: Read the pre-configured base query cycle; According to the basic query cycle, a status query command is sent to the first communication module currently used for communication, and a status response is received from the first communication module. When the status response is an offline response, the offline counter value is set to 1, and a multi-level offline confirmation process is initiated. The multi-level offline confirmation process includes: starting a first timer; during the timer's countdown, sending the status confirmation command to the first communication module at a preset confirmation interval; when the first timer reaches a first preset duration and all continuously received status responses are offline responses, incrementing the offline count value by 1 and restarting the first timer, wherein the preset confirmation interval is less than or equal to the first preset duration; wherein, during the timer's countdown, if any received status response is an online response, the offline count value is cleared and the multi-level offline confirmation process is stopped. When the offline count value is greater than or equal to the preset number of confirmations, the communication path is switched from the first communication module to the second communication module.

10. A smart meter, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the communication switching method as described in any one of claims 1 to 8.