Clock correction method, device, computer equipment and storage medium
By obtaining the system time and timing rate ratio of the device for calibration, the problem of inaccurate clock after the smart device wakes up is solved, and high-precision clock correction is achieved, which is suitable for the daily use of smart devices.
Patent Information
- Application Number
- CN202011466731.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-14
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2040-12-14
AI Technical Summary
After the smart device wakes up from deep sleep, due to the sleep clock error inside the chip, the real-time clock after the device wakes up is inaccurate, affecting the user experience.
By obtaining the system time when the device enters the sleep state from the running state and from the sleep state to the running state, calculate and calibrate the system time at wake-up using pre-calculated or stored timing rate ratios to ensure the accuracy of the clock.
The system time is calibrated in time when the device wakes up, which solves the problem of clock inaccuracy caused by sleep, provides high time accuracy, and is suitable for daily use scenarios of smart devices.
Smart Images

Figure CN112462846B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a clock correction method, device, computer equipment and storage medium. Background Art
[0002] When users use smart products, they have certain requirements for time accuracy during the interaction process, such as recording the action of an event at a certain time point. In actual use, due to the need to save power and energy, the device will enter a deep sleep state during a certain idle time. When waking up from deep sleep, due to the error of the sleep clock inside the chip, the current real-time clock of the device will be inaccurate after waking up, which will affect the user experience. Summary of the invention
[0003] Based on this, it is necessary to propose a clock correction method, device, computer equipment and storage medium that can accurately calibrate the clock to address the above problems.
[0004] To achieve the above object, the present invention provides a clock correction method in a first aspect, comprising:
[0005] Obtain the system time corresponding to when the device enters the sleep state from the running state as the first system time;
[0006] Obtaining a second system time corresponding to when the device enters a running state from a sleep state;
[0007] Obtaining a calibration coefficient, the calibration coefficient being used to indicate a ratio of a timing rate of the device in a running state to a timing rate of the device in a sleeping state;
[0008] The second system time is calibrated according to the first system time, the second system time and the calibration coefficient to obtain a calibrated time.
[0009] To achieve the above object, the second aspect of the present invention provides a clock correction device, comprising:
[0010] A first acquisition module, used to acquire a first system time corresponding to when the device enters a dormant state from a running state;
[0011] A second acquisition module is used for a second system time corresponding to when the device enters a running state from a sleep state;
[0012] A third acquisition module, used to acquire a calibration coefficient, where the calibration coefficient is used to indicate a timing rate ratio of the device in a running state to a timing rate ratio of the device in a sleeping state;
[0013] The calibration module is used to calibrate the second system time according to the first system time, the second system time and the calibration coefficient to obtain the calibrated time.
[0014] To achieve the above-mentioned purpose, the third aspect of the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps in the method described in the first aspect.
[0015] To achieve the above objective, a fourth aspect of the present invention provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the steps in the method described in the first aspect.
[0016] The clock correction method, device, computer equipment and storage medium mentioned above, wherein the clock correction method includes the following steps: obtaining the first system time corresponding to when the device enters the sleep state from the running state; obtaining the second system time corresponding to when the device enters the running state from the sleep state; obtaining a calibration coefficient, the calibration coefficient is used to indicate the timing rate ratio of the device in the running state to the sleep state; calibrating the second system time according to the first system time, the second system time and the calibration coefficient to obtain the calibrated time. The clock calibration method uses the timing rate ratio of the device in the running state to the sleep state calculated or stored in advance as the calibration coefficient, and when the device is awakened, calibrates the second system time when the device is awakened to obtain the calibrated time. This method calibrates the system time in time when the device is awakened, solving the problem of inaccurate clock caused by sleep. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] in:
[0019] Figure 1 is a flow chart of a clock correction method in one embodiment;
[0020] Figure 2 is a flow chart of a clock calibration method in another embodiment;
[0021] Figure 3 is a flow chart of a clock correction method in another embodiment;
[0022] Figure 4 is a structural block diagram of a clock correction device in an embodiment;
[0023] Figure 5 is a structural block diagram of a clock correction device in another embodiment;
[0024] Figure 6 is a structural block diagram of a clock correction device in another embodiment;
[0025] Figure 7 The figure is a diagram of the internal structure of a computer device in an embodiment. DETAILED DESCRIPTION
[0026] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0027] like Figure 1 As shown, a clock correction method is proposed, which can be applied to a terminal. This embodiment is illustrated by applying to a terminal. The clock correction method specifically includes the following steps:
[0028] Step 102: Obtain a first system time corresponding to when the device enters a sleep state from a running state.
[0029] Among them, system time refers to the time displayed by the system, also known as "RTC (Real Time Clock) time". When the device is running, that is, in the running state, the device can obtain the UTC time of the NTP server through network communication, and use the obtained UTC time as the current system time. NTP (Network Time Protocol) server is a server used for time synchronization. UTC (Coordinated Universal Time) time can be understood as standard time. The first system time is the system time when the device enters the sleep state from the running state. At this time, the system time is the accurate time.
[0030] Among them, the triggering condition for the device to enter the sleep state from the running state can be, for example: when the device is in the turned-on state, the user does not perform any operation on the device for a certain period of time, and the device enters the sleep state; or a specific operation instruction is set for the device to enter the sleep state from the running state. When the operation instruction is executed, the device enters the sleep state, such as closing the display, pressing a specific button, etc.
[0031] The triggering condition for the device to enter the running state from the sleep state may be, for example: when the device is in the sleep state, the user operates a physical button or a virtual button of the device, and the device enters the running state; or a specific instruction is set for the device to enter the running state from the sleep state, such as setting a sleep time for the device, after which the device enters the running state from the sleep state.
[0032] Step 104, obtaining a second system time corresponding to when the device enters the running state from the sleep state.
[0033] Among them, when the device is awakened from the sleep state, that is, when it is detected that the device enters the running state from the sleep state, the device system time is obtained, which is called the "second system time" for the purpose of distinction. Since the timing rate in the sleep state (also known as the "timing frequency") is different from the timing rate in the running state, when the device enters the running state from the sleep state, the second system time obtained at this time has an error.
[0034] Step 106, obtaining a calibration coefficient, where the calibration coefficient is used to indicate the timing rate ratio of the device in the running state to the timing rate ratio in the sleeping state.
[0035] Among them, the calibration coefficient is used to calibrate the second system time. Since the calibration needs to be performed immediately after the second system time is obtained, in order to increase the calibration speed, the calibration coefficient needs to be pre-calculated or pre-stored. The timing rate ratio can be regarded as fixed over a period of time, and the calibration coefficient is used to indicate the timing rate ratio of the device in the running state and the sleep state. In one embodiment, the timing rate ratio of the device in the running state and the sleep state calculated the last time the device entered the running state from the sleep state can be used as the current calibration coefficient; in another embodiment, a fixed calibration coefficient can also be pre-calculated and stored in the system.
[0036] Step 108, calibrating the second system time according to the first system time, the second system time and the calibration coefficient to obtain the calibrated time.
[0037] The clock correction method mentioned above first obtains the first system time corresponding to when the device enters the sleep state from the running state; then obtains the second system time corresponding to when the device enters the running state from the sleep state; further obtains the calibration coefficient, and the calibration coefficient is used to indicate the timing rate ratio of the device in the running state to the sleep state; finally, the second system time is calibrated according to the first system time, the second system time and the calibration coefficient to obtain the calibrated time. This clock calibration method uses the timing rate ratio of the device in the running state to the sleep state calculated last time as the calibration coefficient. When the device enters the sleep state from the running state, the second system time of the device is calibrated to obtain the calibrated time. This method calibrates the system time in time when the device enters the running state from the sleep state, and solves the problem of inaccurate clock caused by sleep.
[0038] The clock correction method of the present invention is further described as follows.
[0039] In one embodiment, for step 108, calibrating the second system time according to the first system time, the second system time and the calibration coefficient to obtain the calibrated time includes: calculating the first time difference between the second system time and the first system time; calculating a time adjustment value according to the first time difference and the calibration coefficient; and determining the calibrated time according to the time adjustment value and the first system time.
[0040] Among them, the first time difference between the second system time and the first system time is calculated, and the calculated first time difference is the duration calculated according to the timing rate in the sleep state. Since the timing rate in the sleep state is different from the timing rate in the running state, it is necessary to calculate the duration of the conversion to the running state according to the time difference and the calibration coefficient, and calculate the duration in the running state according to the product of the time difference and the calibration coefficient, that is, the time adjustment value, and then determine the calibrated time according to the time adjustment value and the first system time.
[0041] Specifically, the calibrated time is calculated using the following formula: T = (T2-T1)*K+T1, where T represents the calibrated time, K represents the calibration coefficient, T1 represents the first system time, and T2 represents the second system time. This clock correction method can be used for devices with a sleep function, and can satisfy users' need to obtain a higher-precision system time without adding an additional real-time clock chip circuit. This method has a dynamic calibration function and is suitable for the use of daily smart devices.
[0042] It should be noted that the calibration coefficient K is obtained through step 106. In one embodiment, the obtaining of the calibration coefficient further includes: when the device enters the running state from the sleep state for the first time, obtaining a preset value as the calibration coefficient, and when the device enters the running state from the sleep state for the Nth time, the calibration coefficient is the timing rate ratio corresponding to the N-1th time when the device enters the running state from the sleep state, and N is a positive integer greater than 1.
[0043] Among them, when it is not the first calculation, the calibration coefficient is the timing rate ratio calculated when the device entered the running state from the sleep state for the last time. However, when the device enters the running state from the sleep state for the first time, since there is no last time, a preset value needs to be set, and then the preset value is used as the calibration coefficient for calibration calculation.
[0044] After calculating the calibrated time, it is also necessary to calculate the timing rate ratio between the running state and the sleeping state corresponding to this time, so as to serve as the calibration coefficient for the next time.
[0045] For example, when the device enters the operating state from the sleep state for the fifth time, its calibration coefficient should be the timing rate ratio corresponding to the fourth time the device enters the operating state from the sleep state.
[0046] The timing rate ratio when the device enters the running state from the sleep state for the Mth time is calculated in the following way. When the device enters the running state from the sleep state for the Mth time, M is a positive integer, such as Figure 2 As shown, the calculation method of the timing rate ratio corresponding to the Mth time when the device enters the running state from the sleep state includes the following steps:
[0047] Step 202, obtaining the first system time corresponding to the Mth time when the device enters the sleep state from the running state.
[0048] Step 204, obtaining the second system time corresponding to the Mth time when the device enters the running state from the sleep state.
[0049] Step 206, calculating a first time difference between the second system time corresponding to the Mth time and the first system time corresponding to the Mth time.
[0050] The time difference between the second system time and the first system time is called the “first time difference.” The first time difference can be understood as the time difference obtained by statistics at the timing rate in the sleep state.
[0051] Step 208, obtaining the Universal Coordinated Time (UTC) time corresponding to when the device enters the running state from the sleep state for the Mth time and the network time consumption corresponding to the UTC time acquisition process.
[0052] Among them, UTC time is the standard time. When the device enters the running state from the sleep state, it obtains the UTC time from the NTP server. It takes time to obtain the time from the NTP server through the network (for example, through WiFi or Bluetooth, etc.). Therefore, for the accuracy of subsequent calculations, the network time must be determined here, that is, the time required to obtain the UTC time from the NTP server.
[0053] Step 210: Calculate a second time difference according to the UTC time, the network time and the first system time.
[0054] The second time difference is calculated based on the acquired UTC time, the network time and the first system time, that is, the acquired UTC time is subtracted from the network time, and then subtracted from the first system time to obtain the second time difference. The second time difference can be understood as the time difference obtained by statistics at the timing rate of the running state.
[0055] Specifically, the second time difference is expressed by the following formula: T0 = T UTC -T offset -T1, T UTC Indicates the obtained UTC time, T offset Indicates the network time consumed by the UTC time acquisition process, T1 indicates the first system time, and T0 indicates the second time difference.
[0056] Step 212, calculate the timing rate ratio corresponding to the Mth time the device enters the running state from the sleep state according to the first time difference and the second time difference corresponding to the Mth time.
[0057] Among them, for the same period of time, the first time difference refers to the time difference obtained according to the timing rate statistics in the sleep state, and the second time difference refers to the time difference obtained according to the timing rate statistics in the running state. The ratio of the second time difference to the first time difference is calculated to obtain the timing rate ratio calculated this time, and the timing rate ratio is used as the calibration coefficient for calibrating the second system time when the device enters the running state from the sleep state next time. According to the calibration coefficient, the second system time that enters the running state from the sleep state can be accurately corrected, thereby solving the time error problem caused by sleep.
[0058] In another embodiment, the timing rate ratio corresponding to the Mth time the device enters the running state from the sleep state is calculated based on the first time difference and the second time difference corresponding to the Mth time, including: calculating the first timing rate ratio based on the ratio of the second time difference to the first time difference; obtaining the historical timing rate ratio obtained by historical calculation; and calculating the timing rate ratio by using a smoothing algorithm to the first timing rate ratio and the historical timing rate ratio.
[0059] In order to make the calculated timing rate ratio more accurate, a weighted average algorithm is used for further correction. The ratio of the second time difference to the first time difference is used as the first timing rate ratio, and the historical timing rate ratio is obtained. Then, the timing rate ratio is calculated using a weighted smoothing algorithm based on the first timing rate ratio and the historical timing rate ratio.
[0060] It should be noted that the timing rate ratio can also be calculated by using an exponential weighted smoothing algorithm on the first timing rate ratio and the historical timing rate ratio to obtain the timing rate ratio. The specific formula is as follows: L = a*L M +b*L M-1 , where a+b=1, L is the required timing rate ratio corresponding to the calibration coefficient. M Represents the first timing rate ratio, L M-1 Indicates the historical timing rate ratio.
[0061] The historical timing rate ratio refers to the timing rate ratio calculated previously. In one embodiment, the historical timing rate ratio includes: the timing rate ratio calculated when the device enters the running state from the sleep state M-1 times. In another embodiment, the historical timing rate ratio includes: the timing rate ratio calculated when the device enters the running state from the sleep state M-1 times and the timing rate ratio calculated when the device enters the running state from the sleep state M-2 times. The historical timing rate ratio can be customized as needed. Generally, the timing rate ratio calculated when the device enters the running state from the sleep state M-1 times is selected as the historical timing rate ratio.
[0062] Before obtaining the historical timing rate ratio, first determine whether there is one or more historical timing rate ratios (ie, whether M is greater than 1). If so, obtain the historical timing rate ratio. If not, use the first timing rate ratio directly as the timing rate ratio.
[0063] In order to calculate the timing rate ratio, the following method may also be used.
[0064] like Figure 3 As shown, in one embodiment, before obtaining the calibration coefficient, the method further includes:
[0065] Step 302: Measure the first RTC count within a preset time in the running state of the device by using an external precise clock connected thereto.
[0066] Among them, the external precise clock is an external device, which can be an external MCU timing input, or a 555 timer, etc. The external precise clock is used to count the RTC count under the timing of the clock. The RTC count can be understood as counting the clock frequency in the running state or the sleep state within a preset time. Specifically, the RTC count in the running state (non-sleep state) within a preset time (for example, 1 second) is measured by the external precise clock. In order to distinguish it from the sleep state below, it is called the "first RTC count" here.
[0067] Step 304: measure the second RTC count of the device in the sleep state within a preset time through the connected external precise clock.
[0068] In the same way, the "second RTC count" in the sleep state is measured using an external precision clock.
[0069] Step 306: Calculate a timing rate ratio according to the first RTC count and the second RTC count.
[0070] The ratio of the first RTC count to the second RTC count is calculated, and the ratio is the timing rate ratio. Specifically, it can be expressed by the following formula: L=CNT1 / CNT2, where L represents the timing rate ratio, CNT1 represents the first RTC count, and CNT2 represents the second RTC count.
[0071] In another embodiment, the clock correction method further includes: measuring the first RTC count and the second RTC count within multiple preset times by the external precise clock, and calculating the ratio of the first RTC count to the second RTC count within each preset time to obtain multiple groups of data; and applying a smoothing algorithm to the multiple groups of data to obtain a timing rate ratio.
[0072] In order to obtain an accurate timing rate ratio, when measuring by connecting to an external clock, it is advisable to perform multiple repeated calculations to obtain multiple sets of data, and then use the multiple sets of data to perform smoothing calculations to obtain the timing rate ratio. The timing rate ratio is used as a calibration coefficient. The smoothing algorithm can be a weighted average algorithm or an exponential weighted smoothing algorithm.
[0073] Since the calibration coefficient is obtained based on the measurement of an external precise clock and is relatively accurate, it does not need to be adjusted dynamically. The timing rate ratio is used as the calibration coefficient for each calibration.
[0074] like Figure 4 As shown, a clock correction device is proposed, comprising:
[0075] The first acquisition module 402 is used to acquire a first system time corresponding to when the device enters a dormant state from a running state;
[0076] The second acquisition module 404 is used to acquire a second system time corresponding to when the device enters the running state from the sleep state;
[0077] A third acquisition module 406, used to acquire a calibration coefficient, where the calibration coefficient is used to indicate a timing rate ratio between a device in a running state and a device in a sleeping state;
[0078] The calibration module 408 is configured to calibrate the second system time according to the first system time, the second system time and the calibration coefficient to obtain a calibrated time.
[0079] In one embodiment, the calibration module 408 is further used to calculate a first time difference between the second system time and the first system time; calculate a time adjustment value based on the first time difference and the calibration coefficient; and determine a calibrated time based on the time adjustment value and the first system time.
[0080] In one embodiment, the third acquisition module 406 is also used to obtain a preset value as the calibration coefficient when the device enters the running state from the sleep state for the first time. When the device enters the running state from the sleep state for the Nth time, the calibration coefficient is the timing rate ratio corresponding to the N-1th time the device enters the running state from the sleep state, and N is a positive integer greater than 1.
[0081] like Figure 5 As shown, in one embodiment, the clock correction device further includes:
[0082] A first calculation module 410 is configured to calculate a first time difference between the second system time corresponding to the Mth time and the first system time corresponding to the Mth time when the device enters the running state from the sleep state for the Mth time, where M is a positive integer;
[0083] The fourth acquisition module 412 is used to acquire the Universal Coordinated Time (UTC) time corresponding to the Mth time when the device enters the running state from the sleep state and the network time consumption corresponding to the UTC time acquisition process;
[0084] A second calculation module 414, configured to calculate a second time difference according to the UTC time, the network time and the first system time;
[0085] The third calculation module 416 is used to calculate the timing rate ratio corresponding to the Mth time the device enters the running state from the sleep state according to the first time difference and the second time difference corresponding to the Mth time.
[0086] In one embodiment, the third calculation module 416 is also used to calculate a first timing rate ratio based on the ratio of the first time difference to the second time difference; obtain a historical timing rate ratio obtained by historical calculation; and calculate the timing rate ratio by using a smoothing algorithm for the first timing rate ratio and the historical timing rate ratio.
[0087] like Figure 6 As shown, in one embodiment, the clock correction device further includes:
[0088] The first measurement module 418 is used to measure the first RTC count within a preset time in the running state of the device through the connected external precision clock;
[0089] The second measurement module 420 is used to measure the second RTC count of the device in a sleep state within a preset time through an external accurate clock connected thereto;
[0090] The ratio calculation module 422 is used to calculate the timing rate ratio according to the first RTC count and the second RTC count.
[0091] In one embodiment, the first measurement module 418 and the second measurement module 420 are also used to repeatedly measure the first RTC count and the second RTC count through the external precise clock, and the ratio calculation module is also used to calculate the ratio of the first RTC count and the second RTC count in each preset time to obtain multiple groups of data; and a smoothing algorithm is used to obtain the timing rate ratio for the multiple groups of data.
[0092] Figure 7 FIG. 1 shows an internal structure diagram of a computer device in an embodiment. The computer device may specifically be a terminal. Figure 7 As shown, the computer device includes a processor, a memory and a network interface connected via a system bus. The memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program. When the computer program is executed by the processor, the processor may implement the above-mentioned clock correction method. The internal memory may also store a computer program. When the computer program is executed by the processor, the processor may implement the above-mentioned clock correction method. Those skilled in the art will understand that Figure 7 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0093] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above clock correction method.
[0094] In one embodiment, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the processor executes the steps of the above-mentioned clock correction method.
[0095] The above description is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field, within the technical scope disclosed by the present invention, shall make equivalent replacements or changes according to the technical solution and inventive concept of the present invention, which shall be covered within the protection scope of the present invention. In addition, although some specific terms are used in this specification, these terms are only for the convenience of explanation and do not constitute any limitation to the present invention.
Claims
1. A clock correction method, characterized in that: include: Obtain the first system time corresponding to when the device enters the sleep state from the running state; Obtaining a second system time corresponding to when the device enters a running state from a sleep state; Obtaining a calibration coefficient, the calibration coefficient being used to indicate a ratio of a timing rate of the device in a running state to a timing rate of the device in a sleeping state; Calibrate the second system time according to the first system time, the second system time and the calibration coefficient to obtain a calibrated time; Wherein, obtaining the calibration coefficient includes: When the device enters the running state from the sleep state for the first time, a preset value is obtained as the calibration coefficient, When the device enters the running state from the sleep state for the Nth time, the calibration coefficient is the timing rate ratio corresponding to the N-1th time when the device enters the running state from the sleep state, where N is a positive integer greater than 1; or, The obtaining of the calibration coefficient comprises: The first RTC count within a preset time in the running state of the device is measured by an external precise clock connected thereto, The second RTC count of the device in the sleep state within the preset time is measured by the connected external precision clock, A timing rate ratio is calculated according to the first RTC count and the second RTC count as a calibration coefficient; Wherein, when the device enters the running state from the sleep state for the Mth time, M is a positive integer; The method further comprises: Calculate a first time difference between the second system time corresponding to the Mth time and the first system time corresponding to the Mth time; Obtaining the Universal Coordinated Time (UTC) time corresponding to when the device enters the running state from the sleep state for the Mth time and the network time consumption corresponding to the UTC time acquisition process; Calculate a second time difference according to the UTC time, the network time and the first system time; The timing rate ratio corresponding to the Mth time the device enters the running state from the sleep state is calculated according to the first time difference and the second time difference corresponding to the Mth time.
2. The method according to claim 1, characterized in that The step of calibrating the second system time according to the first system time, the second system time and the calibration coefficient to obtain the calibrated time includes: Calculating a first time difference between the second system time and the first system time; Calculate a time adjustment value according to the first time difference and the calibration coefficient; A calibrated time is determined according to the time adjustment value and the first system time.
3. The method according to claim 2, characterized in that The calibrated time is calculated using the following formula: T=(T2-T1)*K+T1 Wherein, T represents the time after calibration, K represents the calibration coefficient, T1 represents the first system time, and T2 represents the second system time.
4. The method according to claim 1, characterized in that: The second time difference is expressed by the following formula: T0 = T UTC -T offset -T1, T UTC Indicates the obtained UTC time, T offset Indicates the network time consumed by the UTC time acquisition process, T1 indicates the first system time, and T0 indicates the second time difference.
5. The method according to claim 1, characterized in that The calculating, according to the first time difference and the second time difference corresponding to the Mth time, a timing rate ratio corresponding to the Mth time when the device enters the running state from the sleep state includes: Calculating a first timing rate ratio according to a ratio of the first time difference to the second time difference; Obtain the historical timing rate ratio obtained by historical calculation; The timing rate ratio is calculated by using a smoothing algorithm on the first timing rate ratio and the historical timing rate ratio to obtain the timing rate ratio.
6. The method according to claim 5, characterized in that Before obtaining the historical timing rate ratio, the method further includes: Determine whether there is one or more historical timing rate ratios. If so, obtain the historical timing rate ratio. If not, use the first timing rate ratio directly as the timing rate ratio.
7. The method according to claim 1, characterized in that The method further comprises: Measuring the first RTC count and the second RTC count within a plurality of preset times by using the external precise clock, calculating the ratio of the first RTC count to the second RTC count within each preset time, and obtaining a plurality of groups of data; A smoothing algorithm is applied to the plurality of sets of data to obtain the timing rate ratio.
8. A clock correction device, characterized in that: include: A first acquisition module, used to acquire a first system time corresponding to when the device enters a dormant state from a running state; A second acquisition module is used to acquire a second system time corresponding to when the device enters a running state from a sleep state; A third acquisition module is used to acquire a calibration coefficient, where the calibration coefficient is used to indicate the timing rate ratio of the device in the running state and the sleep state; A calibration module, configured to calibrate the second system time according to the first system time, the second system time and the calibration coefficient to obtain a calibrated time; Wherein, the third acquisition module is specifically used for: When the device enters the running state from the sleep state for the first time, a preset value is obtained as the calibration coefficient. When the device enters the running state from the sleep state for the Nth time, the calibration coefficient is the timing rate ratio corresponding to the N-1th time when the device enters the running state from the sleep state, where N is a positive integer greater than 1. or, The third acquisition module includes: The first measurement module is used to measure the first RTC count within a preset time in the running state of the device through an external precise clock connected thereto, The second measurement module is used to measure the second RTC count of the device in a sleep state within a preset time through an external precise clock connected thereto, a ratio calculation module, configured to calculate a timing rate ratio as a calibration coefficient according to the first RTC count and the second RTC count; Wherein, when the device enters the running state from the sleep state for the Mth time, M is a positive integer; Then the clock correction device also includes: A first calculation module, used for calculating a first time difference between the second system time corresponding to the Mth time and the first system time corresponding to the Mth time; A fourth acquisition module is used to acquire the Universal Coordinated Time (UTC) time corresponding to when the device enters the running state from the sleep state for the Mth time and the network time consumption corresponding to the UTC time acquisition process; A second calculation module, configured to calculate a second time difference according to the UTC time, the network time consumption and the first system time; The third calculation module is used to calculate the timing rate ratio corresponding to the Mth time that the device enters the running state from the sleep state according to the first time difference and the second time difference corresponding to the Mth time.
9. A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the steps of the clock correction method according to any one of claims 1 to 7.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the clock correction method according to any one of claims 1 to 7.
