Method for Controlling IoT Devices to Actively Exit Loop Reset and Smart Gas Meter
By implementing a cyclic reset detection and processing method in the Internet of Things device, including obtaining the cyclic reset threshold value and adopting corresponding startup strategies, the problem that the device cannot recover independently under the cyclic reset state is solved, and the stability and user experience of the device are improved.
Patent Information
- Application Number
- CN202510479810.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2025-07-01
- Estimated Expiration
- 2045-04-17
AI Technical Summary
After repeated cycle resets of existing IoT devices, there is a lack of a way to actively exit the cycle reset state and restore stable work, resulting in high maintenance costs and poor user experience.
By implementing a method in an IoT device, it includes steps A to C: obtaining the cyclic reset threshold value, determining whether the device enters the cyclic reset state, if it enters, obtains the reason for the last cyclic reset and adopts the corresponding startup strategy to try to exit the cyclic reset state, if it succeeds, it resumes normal operation, and if it fails, it enters the safe startup mode.
It effectively solves the problem that IoT devices cannot recover independently under the cyclic reset state, reduces maintenance costs, and improves the stability and user experience of the equipment.
Smart Images

Figure CN120017491B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of Internet of Things devices, and particularly relates to a method for controlling an Internet of Things device to actively exit loop reset and an intelligent gas meter. Background Art
[0002] Today, with the increasing popularity of low-power Internet of Things devices, especially devices such as intelligent gas meters and water meters, they often adopt low-power communication methods such as NB-IoT and only have the ability to initiate communication with the upper computer by the device, and vice versa is not possible. Only when the device works normally can the interaction between it and the upper computer be ensured. Once the device enters a deadlock or repeated reset state, the upper computer will be permanently disconnected from it and cannot monitor or manage it. Therefore, the software working stability of such Internet of Things devices has become an important indicator to measure their performance. However, due to software program design defects, sudden hardware failures, or even the software program executing undefined instructions or parameters, the device will fall into a repeated loop reset state, resulting in inability to work normally and communicate with the upper computer. At this time, manual intervention must be carried out door-to-door to restore normalcy, including replacing the device, upgrading the software program, etc. This method is inefficient, has huge maintenance costs, and also affects the normal life or production of users.
[0003] The defect of the prior art is that there is a lack of an innovative method to take measures to actively exit the loop reset state and restore stable operation after the Internet of Things device undergoes repeated loop reset. Summary of the Invention
[0004] Aiming at the above deficiencies of the prior art, the technical problem to be solved by the present invention is: how to provide a method for controlling an Internet of Things device to actively exit loop reset, which can take measures to actively exit the loop reset state and restore stable operation after the Internet of Things device undergoes repeated loop reset, and provide opportunities and means for repairing its defects or problems.
[0005] To solve the above technical problem, the present invention adopts the following technical solution: A method for controlling an Internet of Things device to actively exit loop reset, including the following steps:
[0006] Step A: After each reset startup of the Internet of Things device software, obtain the loop reset threshold value, and judge whether it has entered the loop reset state according to the set loop reset threshold value. If it has entered the loop reset state, then enter Step B; otherwise, enter the normal working mode of the Internet of Things device; end;
[0007] Step B: Obtain the reason for the last loop reset, and adopt corresponding startup strategies according to the reason to try to actively exit the loop reset state;
[0008] Step C: Determine whether the startup strategy can cause the software of the IoT device to exit the loop reset. If it can, enter the stable working mode of the IoT device. If not, enter the secure startup mode, and the IoT device enters the secure working mode. End.
[0009] The said Step A includes that after each reset startup, count the number of resets in the most recent set time period, that is, the number of resets within the time length of determining to enter the loop reset state. If the number of resets exceeds the specified loop reset threshold, it is determined that the software has entered the loop reset state. If the number of resets does not exceed the specified loop reset threshold, enter the normal working mode.
[0010] In the said Step B, the reasons for loop reset include watchdog reset, software active reset, and software exception reset. The corresponding startup strategies adopted are: not loading software modules with the risk of dead loop, shielding hardware modules or resources with the risk of reset, and rolling back operation commands.
[0011] When the IoT device enters the stable working mode, the IoT device works under the corresponding startup strategies, including: not loading software modules with the risk of dead loop; or shielding hardware modules or resources with the risk of reset; or rolling back operation commands, and covering the most recent command word and parameters with the previous command word and parameters.
[0012] Before executing Step A, it also includes initial preparation work, and the initial preparation work includes the following steps:
[0013] step1. Startup strategy 1 data table
[0014] Save the number of software modules that can be not loaded and initialized;
[0015] Save the list of names of software modules that can be not loaded and initialized, sorted in descending order of priority;
[0016] step2. Startup strategy 2 data table
[0017] Save the number of hardware modules or resources that can be not loaded and initialized;
[0018] Save the list of names of hardware modules or resources that can be not loaded and initialized, sorted in descending order of priority;
[0019] The software or hardware modules that can be not loaded refer to some functional modules that will not affect the operation of other functional modules when not loaded (not initialized and not used). The not-loading priority of these modules is determined according to the impact on the product's business implementation and the probability of error. The modules with less impact and higher error probability when not loaded have a higher not-loading priority and are ranked in the front; it is determined according to the specific situation of the device.
[0020] step3. Start the strategy 3 data table
[0021] Save the number of commands that can be rolled back;
[0022] Save the list of command names that can be rolled back, sorted in descending order of priority; the commands with less impact and higher error probability after rollback have higher priority; determined according to the specific situation of the device.
[0023] step4. Loop to reset the status flag
[0024] Set the software status flag to identify that the device software enters the loop reset state, and this status flag can be permanently saved after the IoT device loses power;
[0025] step5. Start strategy flag
[0026] Set the start strategy flag to identify the start strategy that needs to be executed after the device software enters the loop reset state, including four values: start strategy 1, start strategy 2, start strategy 3, and start strategy 4. This flag can be permanently saved after the device loses power; start strategy 1 is not to load software modules with dead loop risks, start strategy 2 is to shield hardware modules or resources with reset risks, start strategy 3 is to roll back operation commands; start strategy 4 is to enter the secure boot mode; if the device cannot exit the loop reset state by using the corresponding start strategy 1, start strategy 2, and start strategy 3, it will enter the secure boot mode and enter start strategy 4.
[0027] step6. Judgment indicators for the software loop reset state
[0028] Determine the threshold number of reset times to enter the loop reset state;
[0029] Determine the time length to enter the loop reset state;
[0030] step7. Software reset reason flag
[0031] Set the device software reset reason flag to identify the reason for software reset, including software active reset, software abnormal reset, watchdog reset, and power-on reset. This flag can be permanently saved after the IoT device loses power;
[0032] step8. Software start count counter
[0033] Set a global software start count counter. For any reason other than power-on reset that causes the software to restart, the counter automatically increments by 1 at the start entry and can be permanently saved after the IoT device loses power;
[0034] step9. Operation command word storage stack
[0035] The operation command word storage stack is used to save the executed operation command words and can permanently save them after the IoT device loses power; when the operation command word storage stack is full, if the loop reset status flag indicates that it is not in the loop reset state, the operation command word storage stack is immediately cleared;
[0036] step10, Historical operation command information storage
[0037] The historical operation command information storage is used to save the operation command words and command parameters executed in the previous two times for each command and can permanently save them after the IoT device loses power.
[0038] The key of the method for controlling the IoT device to actively exit the loop reset lies in: when the operation command rollback is required, according to the startup policy 3 data table, the most recently executed corresponding command word is retrieved from the operation command word storage stack, and then the corresponding previously executed command word and its parameters are found from the historical operation command information storage and executed again to overwrite the most recently executed parameters.
[0039] The key of the method for controlling the IoT device to actively exit the loop reset lies in: in the safe working mode, the most basic service functions and communication interaction functions of the IoT device are available to ensure that maintenance personnel can upgrade the software of the IoT device remotely or on-site.
[0040] An intelligent gas meter includes the method for controlling the IoT device to actively exit the loop reset. The key lies in: the IoT device is an intelligent gas meter, and when the intelligent gas meter is in the loop reset state, the method described above is used to actively exit the loop reset.
[0041] For the intelligent gas meter described above, in the safe working mode, the most basic service functions and communication interaction functions include being able to ensure that the trade metering or settlement of the gas meter is not affected, and being able to ensure the basic management capabilities of the local infrared serial port and the IoT air remote communication, including software upgrade and restoring to the default factory configuration.
[0042] Remarkable effect: The present invention provides a method for controlling the IoT device to actively exit the loop reset and an intelligent gas meter. After the IoT device undergoes repeated loop resets, it can take measures to actively exit the loop reset state, resume stable operation, and provide opportunities and means for repairing its defects or problems. Brief description of the drawings
[0043] Figure 1 It is the main method flow chart of the present invention;
[0044] Figure 2 It is the detailed program flow chart of the present invention. Detailed implementation manners
[0045] The present invention will be further described in detail below with reference to the accompanying drawings.
[0046] As Figure 1 - Figure 2 shown, the present invention discloses a method for controlling an Internet of Things device to actively exit the loop reset. The specific implementation solution is as follows:
[0047] I. Initial preparation
[0048] step1. Start the policy 1 data table
[0049] Save the number of software modules that can be not loaded and initialized.
[0050] Save the list of names of software modules that can be not loaded and initialized, sorted in descending order.
[0051] step2. Start the policy 2 data table
[0052] Save the number of hardware modules or resources that can be not loaded and initialized.
[0053] Save the list of names of hardware modules or resources that can be not loaded and initialized, sorted in descending order.
[0054] step3. Start the policy 3 data table
[0055] Save the number of commands that can be rolled back.
[0056] Save the list of names of commands that can be rolled back, sorted in descending order.
[0057] step4. Loop reset status flag
[0058] Set a software status flag to identify that the device software enters the loop reset state, and this status flag can be permanently saved after the device loses power.
[0059] step5. Start policy flag
[0060] Set a start policy flag to identify the start policy that needs to be executed after entering the loop reset state, including four values: policy 1, policy 2, policy 3, and policy 4. This flag can be permanently saved after the device loses power.
[0061] step6. Judgment index for software loop reset status
[0062] Determine the reset times threshold for entering the loop reset state.
[0063] Determine the time length for entering the loop reset state.
[0064] step7. Software reset reason flag
[0065] Set the device software reset reason flag, which is used to identify the reasons for software reset, including active reset, software exception reset, watchdog reset, power-on reset, etc. This flag can be permanently saved after the device loses power;
[0066] step8, Software startup times counter
[0067] Set a global software startup times counter. For any software restart caused by reasons other than power-on reset, the counter will be automatically incremented at the startup entry and can be permanently saved after the device loses power;
[0068] step9, Operation command word storage stack
[0069] Establish a stack data structure to save the executed operation command words. This data structure can be permanently saved after the device loses power;
[0070] When the stack is full, if the loop reset status flag indicates that the device is not in the loop reset state, the stack will be immediately cleared.
[0071] step10, Historical operation command information storage
[0072] Establish a data structure to save the operation command words and command parameters executed in the previous two times for each command. This data structure can be permanently saved after the device loses power;
[0073] When it is necessary to roll back the operation command, take out the most recently executed command word from the operation command word storage stack, then find the corresponding previously executed command word and its parameters from the historical operation command information storage, and execute it again to overwrite the most recently executed parameters.
[0074] II. Method for the device software to judge the loop reset state
[0075] After each reset startup, count the number of resets within the most recent time period (i.e., the time length for determining the entry into the loop reset state, such as 0.5 or 1 hour). If the number of resets exceeds the specified loop reset threshold (i.e., the reset times threshold for determining the entry into the loop reset state, such as 10 times), it is determined that the software has entered the loop reset state.
[0076] III. Implementation solution
[0077] After each reset startup of the device software, it is judged whether it has entered the loop reset state according to the set value.
[0078] If it is determined that the device has entered the loop reset state, then further based on the reason for the last reset, different strategies such as rolling back the most recent operation command, not loading software modules at risk of infinite loop, and not loading hardware modules that may cause the software to malfunction are adopted to try to actively exit the loop reset state and enable the device software to work stably. If these startup strategies still cannot restore the device software to normal, then finally it enters the safe mode startup, that is, ensuring that the most basic business functions and communication interaction functions are available, so that maintenance personnel can have the opportunity and means to upgrade the device software remotely or on-site, thereby fixing the original software defects.
[0079] The detailed program flow of the solution implementation is as Figure 2 shown, including the following steps:
[0080] 1. Reset startup;
[0081] 2. Determine whether it is a power-on reset. If not, go to step 3; if so, go to step 4;
[0082] 3. Increment the reset startup count by 1;
[0083] 4. Determine whether it is in the loop reset state. If not, go to step 5; if so, go to step 11;
[0084] 5. Count the startup times within the set time;
[0085] 6. Whether the loop reset condition is reached; if not, perform normal initialization and run, and end; if so, go to step 7;
[0086] 7. Set the flag for entering the loop reset state;
[0087] Determine whether it is a watchdog reset. If not, go to step 8; if so, set the flag for executing startup strategy 1 and go to step 11;
[0088] 8. Determine whether it is a software-initiated reset. If not, go to step 9; if so, set the flag for executing startup strategy 2 and go to step 11;
[0089] 9. Determine whether it is a software abnormal reset. If not, go to step 10; if so, set the flag for executing startup strategy 3 and go to step 11;
[0090] 10. Set the flag for executing startup strategy 4;
[0091] 11. Determine whether to execute strategy 1. If so, go to step 12; if not, go to step 16;
[0092] 12. Determine whether the device software still cannot be restored to normal after executing strategy 1. If so, go to step 22; if not, cancel the loading of software modules at risk of infinite loop in sequence;
[0093] 13. Perform startup initialization;
[0094] 14. Start the timer;
[0095] 15. When the timing is up, determine whether the number of reset startups within the set time is less than the threshold. If so, clear the cyclic reset state and startup policy flag, and end; if not, perform a no-op and end.
[0096] After canceling a module with potential risks, such as module 5, the device resumes normal operation and no longer performs cyclic reset. Then, clear the cyclic reset state and startup policy flag; otherwise, the next time module 6 is canceled, the other modules are still loaded normally.
[0097] 16. Determine whether to execute Policy 2. If so, go to step 17; if not, go to step 19;
[0098] 17. Determine whether, after executing Policy 2, the device software still cannot return to normal. If so, go to step 22; if not, sequentially mask the hardware modules or resources with potential reset risks;
[0099] 18. Perform startup initialization; go to step 14;
[0100] 19. Determine whether to execute Policy 3. If so, go to step 20; if not, go to step 23;
[0101] 20. Determine whether, after executing Policy 3, the device software still cannot return to normal. If so, go to step 22; if not, sequentially roll back the most recently executed operation commands;
[0102] 21. Perform startup initialization; go to step 14;
[0103] 22. Set the startup policy flag to 4 and go to step 24;
[0104] 23. Determine whether to execute Policy 4. If not, perform a no-op; if so, go to step 24;
[0105] 24. Execute Policy 4 startup;
[0106] 25. Load each module in the safe operating mode and perform startup initialization;
[0107] 26. Start the timer;
[0108] 27. When the timing is up, determine whether the number of reset startups within the set time is less than the threshold. If so, clear the cyclic reset state and startup policy flag, and end; if not, perform a no-op and end.
[0109] In the above program steps, steps 14 and 15 start a timer to determine whether the device can work stably and continuously after canceling the corresponding software module, hardware module, or rollback command. If the number of reset starts within the set time is less than the threshold value and the device can work normally, the cyclic reset state is cleared, indicating that the device can continue to work.
[0110] Step 27 starts a timer to determine whether the IoT device can work normally after starting the secure operating mode. If the number of reset starts within the set time is less than the threshold, the cyclic reset state is cleared, indicating that the device can continue to work in the secure operating mode.
[0111] A no-operation is to do nothing.
[0112] IV. Innovation Points and Features
[0113] 1. Multiple startup strategy tables that can be set and adjusted locally and remotely are built-in. When the device software starts, the current initialization startup strategy is controlled according to the previously recorded reset information and this table.
[0114] 2. Two modes are supported: the normal operating mode and the secure operating mode. The secure operating mode defines the minimum function set (module set) that can ensure reliable startup and maintain normal operation. In this mode, it can ensure that the trade metering or settlement of the gas meter is not affected, and the basic management capabilities of the local infrared serial port and the IoT air remote can be guaranteed, including software upgrade, restoring to the default factory configuration, etc.
[0115] When the device falls into a cyclic reset, after being processed by the preset algorithm, if it still cannot return to normal, it will automatically enter the secure mode, providing maintenance personnel with the opportunity and means to manually intervene to exit the abnormal state.
[0116] 3. For the instructions issued by the upper computer, historical storage is set to record the command word, parameters, and execution time point. It is used to control the device software to roll back the execution results of specific instructions, so as to eliminate the cyclic reset state of the software caused by the execution of these instructions.
[0117] 4. Each time the MCU or single-chip microcomputer is reset, the reason for the reset and the occurrence time are recorded, including software abnormal reset, hardware watchdog reset, active reset, etc.
[0118] 5. Each time the software program starts, the startup time and the cumulative number of startups are recorded.
[0119] By judging whether the number of reset starts within a certain recent time period reaches the specified value, it is determined that the cyclic reset state has been entered.
[0120] 6. After the software program determines to enter the loop reset state, it attempts one by one the methods to actively exit the loop reset state according to the methods in the pre-set or set startup strategy table until finally entering the safe mode startup.
[0121] 7. After restoring to the stable state operation, the IoT device sends a loop reset error report to the host computer; after receiving the loop reset report, the host computer can update the corresponding software or notify the maintenance personnel to come for on-site repair.
[0122] V. Benefits and advantages brought by this innovative solution
[0123] 1. Significantly improve device stability: Through intelligent reset processing and flexible startup strategies, effectively reduce the probability of the device falling into the loop reset state and enhance the device's ability to maintain continuous normal operation.
[0124] 2. Reduce maintenance costs: Through the remote communication ability and the maintenance of key functions, provide time and means for the device to recover from the faulty state to normal, enabling the device to be quickly remotely restored when problems occur, avoiding the costs of maintenance personnel visiting the site and even having to directly replace the device.
[0125] 3. Enhance user experience: Devices such as gas meters are distributed in thousands of households, and faulty meters can be quickly repaired without the users' perception or being disturbed.
[0126] In summary, through a series of intelligent processing mechanisms and flexible methods, this innovative method effectively solves the problem that low-power IoT devices cannot actively exit the loop reset state, enabling maintenance personnel to have means to quickly and low-costly repair device software anomalies, shortening the average fault time of the device, and providing a strong guarantee for the working stability and reliability during the life cycle of the IoT device.
[0127] The above is only the preferred implementation manner of the present invention. It should be noted that for those skilled in the art, without departing from the premise of this technical solution, several deformed and improved technical solutions should also be regarded as falling within the scope protected by this claim book.
Claims
1. A method for controlling an IoT device to actively exit a cyclic reset, characterized in that: The steps include: Step A: After each reset and startup of the IoT device software, the cyclic reset threshold value is obtained, and whether the cyclic reset state has been entered is determined according to the set cyclic reset threshold value. If the cyclic reset state has been entered, step B is entered; otherwise, the IoT device enters the normal working mode; Step B: Obtain the reason for the last cycle reset, and adopt a corresponding startup strategy based on the reason to try to actively exit the cycle reset state; Step C: Determine whether the startup strategy can make the IoT device software exit the loop reset: if it can, enter the stable working mode of the IoT device; if not, enter the safe startup mode, and the IoT device enters the safe working mode; In step B, the reasons for the cyclic reset include watchdog reset, software active reset and software abnormal reset, and the corresponding startup strategy adopted is: do not load software modules with dead loop risk, shield hardware modules or resources with reset risk, and roll back the operation command; Before executing step A, initial preparation work is also included, which includes the following steps: step1, start strategy 1 data table; Save the number of software modules that can be loaded and initialized; Save the list of software modules that can be loaded and initialized, sorted in descending order of priority; step2, start strategy 2 data table; Save the number of hardware modules or resources that can be loaded and initialized; Save the list of names of hardware modules or resources that may not be loaded and initialized, sorted in descending order of priority; step3, start strategy 3 data table; Save the number of commands that can be rolled back; Save a list of command names that can be rolled back, sorted in descending order of priority; Step 4, loop reset status flag; Set the software status flag to indicate that the device software has entered a cyclic reset state. This status flag can be permanently saved after the IoT device loses power. step5, start the strategy flag; Set the startup strategy flag to identify the startup strategy that needs to be executed after the device software enters the cyclic reset state, including startup strategy 1, startup strategy 2, startup strategy 3, and startup strategy 4. This flag can be permanently saved after the IoT device loses power; Startup strategy 1 is to not load software modules with dead loop risk, startup strategy 2 is to shield hardware modules or resources with reset risk, and startup strategy 3 is to roll back operation commands; Startup strategy 4 is to enter the safe boot mode; step6, judgment index of software loop reset state; Determine the reset times threshold value for entering the cyclic reset state; Determine the length of time to enter the loop reset state; step7, software reset reason flag; Set the device software reset reason flag to identify the reason for the software reset, including software active reset, software abnormal reset, watchdog reset, and power-on reset. This flag can be permanently saved after the IoT device loses power; step8, software startup times counter; Set a global software startup counter. When the software is restarted for any reason other than power-on reset, the counter will automatically increase by 1 at the startup entry, and the counter will be permanently saved after the IoT device loses power. step9, operate the command word storage stack; The operation command word storage stack is used to store the executed operation command words, which can be permanently stored after the IoT device loses power. When the operation command word storage stack is full, if the cycle reset state flag shows that it is not in the cycle reset state, the operation command word storage stack is immediately cleared. step10, historical operation command information storage; The historical operation command information storage is used to save the operation command words and command parameters of each command that were executed twice in the past, and can be permanently saved after the IoT device loses power.
2. The method for controlling an IoT device to actively exit a cyclic reset according to claim 1, characterized in that: The step A includes counting the number of resets in the most recent set time period after each reset is started, and if the number of resets exceeds a specified cyclic reset threshold, it is determined that the software has entered a cyclic reset state.
3. The method for controlling an IoT device to actively exit a cyclic reset according to claim 1, characterized in that: When an operation command needs to be rolled back, according to the startup strategy 3 data table, the corresponding command word that was most recently executed is taken out from the operation command word storage stack, and then the corresponding command word and its parameters that were last executed are found from the historical operation command information storage, and re-executed to overwrite the latest executed parameters.
4. The method for controlling an IoT device to actively exit a cyclic reset according to claim 1, characterized in that: In the secure working mode, the business functions and communication interaction functions of the IoT device are available, enabling the software of the IoT device to be upgraded remotely or on-site.
5. A smart gas meter, using the method for controlling an Internet of Things device to actively exit a cycle reset as described in any one of claims 1 to 4, characterized in that: The Internet of Things device is a smart gas meter. When the smart gas meter is in a cyclic reset state, the described method is used to actively exit the cyclic reset.
6. The smart gas meter according to claim 5, characterized in that: In the safe working mode, the business functions and communication interaction functions include the following functional modules: trade measurement or settlement, local infrared serial port and IoT air remote communication, software upgrade and restoration to the default factory configuration.
Citation Information
Patent Citations
Base station software version rollback control method and device, base station and readable storage medium
CN112702183A
Abnormal reset processing method and terminal equipment
CN114500241A