Time synchronization method, equipment and medium

Through Bluetooth connection, the clock credibility of the mobile terminal and the vehicle terminal is evaluated, the master-slave role is determined and the time offset is calculated, which solves the problem of time synchronization of the vehicle in the scenario of signal-constrained, improves the time accuracy and driving safety of the vehicle terminal, and supports the stability of the vehicle-cloud collaborative service and the normal operation of the intelligent driving function.

CN120358587AActive Publication Date: 2025-07-22CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202510821996.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-19
Publication Date
2025-07-22
Estimated Expiration
2045-06-19

AI Technical Summary

Technical Problem

The time synchronization of the vehicle is interrupted in scenarios such as tunnels and underground garages, and network timing is affected by base station load and channel congestion, resulting in inaccurate time on the vehicle terminal, affecting the normal operation of advanced driving assistance systems and vehicle-cloud collaborative services.

Method used

The trustworthiness source data of the paired mobile terminals is obtained through Bluetooth connection, the clock credibility of the mobile terminal and the vehicle terminal is evaluated, the master-slave role is determined based on the credibility, the time offset is calculated for time synchronization, and the hardware clock is used to backup when the network is unstable.

Benefits of technology

In the case of poor network stability, cross-device time synchronization is achieved, improve the time accuracy of the vehicle-machine terminal, ensure driving safety and user experience, and support the stability of vehicle-cloud collaborative services and the normal operation of intelligent driving functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120358587A_ABST
    Figure CN120358587A_ABST
Patent Text Reader

Abstract

The invention provides a time synchronization method and device and a medium, and the method comprises the steps: obtaining first credibility source data corresponding to a paired mobile terminal through Bluetooth connection in response to the completion of Bluetooth connection with the paired mobile terminal; determining the credibility of the mobile terminal according to the first credibility source data, and determining the credibility of the vehicle-mounted terminal according to the second credibility source data of the vehicle-mounted terminal; according to the credibility of the mobile terminal and the credibility of the vehicle-mounted terminal, determining a master-slave role of the vehicle-mounted terminal; and determining the time offset of the paired mobile terminal and the vehicle-mounted terminal in response to the fact that the vehicle-mounted terminal is in the slave role, and performing time synchronization on the vehicle-mounted terminal according to the time offset. Through the technical scheme of the invention, cross-device time synchronization is carried out under the condition that time synchronization cannot be carried out by depending on an external signal source due to poor network stability of the vehicle terminal, and the driving safety and the user experience are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of time synchronization, and particularly to a time synchronization method, device, and medium. Background Art

[0002] With the development of vehicle intelligence and networking, the time synchronization function of vehicles has become crucial for improving driving safety, optimizing user experience, and realizing assisted driving functions.

[0003] Currently, there is a problem of over-reliance on external signal sources in vehicle time synchronization, that is, it highly depends on external timing signals such as GPS (Global Positioning System) / 4G (The 4th Generation Mobile Communication Technology). However, in scenarios with limited signals such as tunnels and underground garages, the time synchronization service will be completely interrupted. Moreover, network timing is affected by base station load, channel congestion, etc., with large fluctuations in timing delay, and some scenarios require operator authorization. If an in-vehicle local clock is used, due to its dependence on quartz crystal oscillators, it is affected by factors such as temperature and aging, and the cumulative error can reach the second level after long-term operation. Inaccurate time on the in-vehicle device side will lead to problems such as the inability to wake up the advanced driver assistance system, chaotic vehicle log timestamps, failure of vehicle-cloud collaboration services, and degradation of time-sensitive function performance. Summary of the Invention

[0004] In view of the above-mentioned defects or deficiencies in the prior art, this application aims to provide a time synchronization method, device, and medium to achieve cross-device time synchronization when the network stability on the in-vehicle device side is poor and it is impossible to rely on external signal sources for time synchronization, thereby improving driving safety and user experience.

[0005] An embodiment of this application provides a time synchronization method applied to the in-vehicle device side, and the method includes: Upon responding to the completion of a Bluetooth connection with a paired mobile device, obtain the first credibility source data corresponding to the paired mobile device through the Bluetooth connection; Determine the credibility of the mobile device according to the first credibility source data, and determine the credibility of the in-vehicle device according to the second credibility source data of the in-vehicle device side; Determine the master-slave role of the in-vehicle device according to the credibility of the mobile device and the credibility of the in-vehicle device; Upon responding to the in-vehicle device being in the slave role, determine the time offset between the paired mobile device and the in-vehicle device, and synchronize the time of the in-vehicle device according to the time offset.

[0006] According to the technical solution provided by the embodiment of the present application, optionally, the first credibility source data includes the first external time source status, the first local clock drift rate, and the first hardware clock level, and the second credibility source data includes the second external time source status, the second local clock drift rate, and the second hardware clock level; Determining the mobile terminal credibility according to the first credibility source data and determining the in-vehicle terminal credibility according to the second credibility source data of the in-vehicle terminal includes: Performing weighted summation on the first external time source status, the reciprocal of the first local clock drift rate, and the first hardware clock level respectively according to the first weight coefficients corresponding to the paired mobile terminal to obtain the mobile terminal credibility; Performing weighted summation on the second external time source status, the reciprocal of the second local clock drift rate, and the second hardware clock level respectively according to the second weight coefficients corresponding to the in-vehicle terminal to obtain the in-vehicle terminal credibility.

[0007] According to the technical solution provided by the embodiment of the present application, optionally, before performing weighted summation on the first external time source status, the reciprocal of the first local clock drift rate, and the first hardware clock level respectively according to the first weight coefficients corresponding to the paired mobile terminal to obtain the mobile terminal credibility, it further includes: Inputting the device type, the first external time source status, the first local clock drift rate, the first hardware clock level, the first short-term clock jitter variance, and the first signal strength of the paired mobile terminal into a pre-constructed dynamic weight model to obtain the first weight coefficients corresponding to the paired mobile terminal; Inputting the device type, the second external time source status, the second local clock drift rate, the second hardware clock level, the second short-term clock jitter variance, and the second signal strength of the in-vehicle terminal into the dynamic weight model to obtain the second weight coefficients corresponding to the in-vehicle terminal; Wherein, the dynamic weight model is a neural network model with two fully connected layers as hidden layers.

[0008] According to the technical solution provided by the embodiment of the present application, optionally, the first credibility source data includes the first external time source status, the first local clock drift rate, and the first hardware clock level; Obtaining the first credibility source data corresponding to the paired mobile terminal includes: In response to the paired mobile terminal synchronizing with an external time source within a preset synchronization time, determining that the first external time source status is 1, otherwise, determining that the first external time source status is 0; Based on the Kalman filtering algorithm, determine the state quantity at the current moment according to the state quantity at the previous moment, the observed quantity at the current moment, a preset first state transition matrix, a preset process noise matrix, a preset second state transition matrix, and a preset measurement noise matrix; wherein, the state quantity includes a time offset and a relative frequency offset. Determine the relative frequency offset in the state quantity at the current moment as the first local clock drift rate. Determine the first hardware clock level according to the hardware clock type corresponding to the paired mobile terminal.

[0009] According to the technical solution provided in the embodiment of the present application, optionally, determine the master-slave role of the in-vehicle terminal according to the credibility of the mobile terminal and the credibility of the in-vehicle terminal, including: Determine the absolute value of the difference between the credibility of the in-vehicle terminal and the credibility of the mobile terminal as the credibility difference. In response to the credibility difference being greater than a preset threshold, determine the master-slave role of the in-vehicle terminal according to the credibility of the mobile terminal and the credibility of the in-vehicle terminal. In response to the credibility difference being less than or equal to the preset threshold, determine the master-slave role of the in-vehicle terminal according to the first hardware clock level of the mobile terminal and the second hardware clock level of the in-vehicle terminal.

[0010] According to the technical solution provided in the embodiment of the present application, optionally, determine the time offset between the paired mobile terminal and the in-vehicle terminal, including: Receive a synchronization request message and a first transmission timestamp sent by the paired mobile terminal. Determine a first arrival timestamp, determine a response message corresponding to the synchronization request message according to the first arrival timestamp, and send the response message and a second transmission timestamp to the paired mobile terminal, so that when the paired mobile terminal receives the response message and the second transmission timestamp, it determines a second arrival timestamp, and determines the time offset according to the first transmission timestamp, the first arrival timestamp, the second transmission timestamp, and the second arrival timestamp, and sends the time offset to the in-vehicle terminal. Receive the time offset sent by the paired mobile terminal.

[0011] According to the technical solution provided in the embodiment of the present application, optionally, after responding that the in-vehicle terminal is in the slave role, further include: In response to receiving a heartbeat packet sent by the paired mobile terminal, determine a local timestamp; wherein, the heartbeat packet includes a current timestamp. Determine an instantaneous offset according to the local timestamp and the current timestamp. In response to the instantaneous offsets in a continuous preset number of times being all greater than the calibrated timestamp difference, return to execute the step of obtaining the first credibility source data corresponding to the paired mobile terminal.

[0012] According to the technical solution provided by the embodiment of the present application, optionally, after responding to the in-vehicle device being in the slave role, it further includes: In response to the Bluetooth connection being disconnected, update the in-vehicle device time according to the local clock cache, and re-perform the Bluetooth connection. If the Bluetooth connection is not established within the preset time, update the in-vehicle device time based on the on-vehicle crystal oscillator clock, and generate a Bluetooth disconnection warning message; In response to no heartbeat packet being received from the paired mobile terminal in a continuous preset number of periods, return to execute the step of determining the time offset between the paired mobile terminal and the in-vehicle device, and synchronize the time of the in-vehicle device according to the time offset. If the time synchronization is not completed, determine that the in-vehicle device is the master role; In response to receiving the resynchronization information sent by the paired mobile terminal, return to execute the step of determining the time offset between the paired mobile terminal and the in-vehicle device, and synchronize the time of the in-vehicle device according to the time offset; wherein, the resynchronization information is generated when there is a time jump in the paired mobile terminal.

[0013] The embodiment of the present application further provides an electronic device, and the electronic device includes: A processor and a memory; The processor is configured to execute the steps of the time synchronization method as described in any one of the embodiments by calling the program or instruction stored in the memory.

[0014] The embodiment of the present application further provides a computer-readable storage medium, and the computer-readable storage medium stores a program or instruction, and the program or instruction enables a computer to execute the steps of the time synchronization method as described in any one of the embodiments.

[0015] In summary, the present application proposes a time synchronization method. By responding to the completion of a Bluetooth connection with a paired mobile device, the first credibility source data corresponding to the paired mobile device is obtained through the Bluetooth connection. According to the first credibility source data, the credibility of the mobile device is determined, and according to the second credibility source data of the in-vehicle device, the credibility of the in-vehicle device is determined to respectively judge the clock effects of the paired mobile device and the in-vehicle device. Furthermore, according to the credibility of the mobile device and the credibility of the in-vehicle device, the master-slave role of the in-vehicle device is determined, that is, it is judged whether the paired mobile device can be used to time the in-vehicle device. In response to the in-vehicle device being in the slave role, the time offset between the paired mobile device and the in-vehicle device is determined, and the in-vehicle device is time-synchronized according to the time offset. When the network stability of the in-vehicle device is poor and it is impossible to rely on an external signal source for time synchronization, the credibility of the clocks of the paired mobile device and the in-vehicle device is evaluated through a Bluetooth connection. When the credibility of the clock of the paired mobile device is better, cross-device time synchronization is performed to improve the time accuracy of the in-vehicle device, and the driving safety and user experience are improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 is a flowchart of a time synchronization method provided by an embodiment of the present application; Figure 2 is a flowchart of another time synchronization method provided by an embodiment of the present application; Figure 3 is a schematic structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0017] The present application will be further described in detail below with reference to the drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the related invention, rather than limiting the invention. In addition, it should be noted that, for the sake of description, only the parts related to the invention are shown in the drawings.

[0018] It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. The present application will be described in detail below with reference to the drawings and embodiments.

[0019] As mentioned in the background art, in view of the problems in the prior art, the present application proposes a time synchronization method, which is applicable to the situation where the network stability of the in-vehicle device is poor and it is impossible to rely on an external signal source for time synchronization to ensure the time accuracy of the in-vehicle device. The time synchronization methods provided by the embodiments of the present application can be executed by an electronic device.

[0020] Figure 1 is a flowchart of a time synchronization method provided by an embodiment of the present application. Refer to Figure 1 , this time synchronization method is applied to the in-vehicle device and specifically includes: S110. In response to completing a Bluetooth connection with a paired mobile device, obtain first credibility source data corresponding to the paired mobile device through the Bluetooth connection.

[0021] The paired mobile device is a mobile device that has completed pairing with the in-vehicle device and can be a mobile phone, a tablet computer, etc. The first credibility source data is data used to determine the time reliability of the paired mobile device and can include the external clock source status, local clock status, and hardware clock status of the paired mobile device, etc.

[0022] Specifically, when the in-vehicle device completes a Bluetooth connection with the paired mobile device, the in-vehicle device can receive the first credibility source data sent by the paired mobile device through the communication link of the Bluetooth connection.

[0023] It should be noted that it can also be that when the in-vehicle device starts up, first detect the timing status of GPS / 4G. If the timing status is normal, GPS / 4G external timing can be used. If the timing status is abnormal (for example, the signal strength is lower than the strength threshold, such as -90dBm, etc.), a Bluetooth connection is established with the paired mobile device through the Bluetooth connection.

[0024] S120. Determine the credibility of the mobile device according to the first credibility source data, and determine the credibility of the in-vehicle device according to the second credibility source data of the in-vehicle device.

[0025] The second credibility source data is data used to determine the time reliability of the in-vehicle device and can include the external clock source status, local clock status, and hardware clock status of the in-vehicle device, etc. The credibility of the mobile device is a value used to measure the reliability of the clock of the paired mobile device and can be determined by calculating and processing the first credibility source data. The credibility of the in-vehicle device is a value used to measure the reliability of the clock of the in-vehicle device and can be determined by calculating and processing the second credibility source data.

[0026] Specifically, based on a preset credibility calculation formula corresponding to the paired mobile device or a pre-trained credibility model, process the first credibility source data, and the calculated or output result is the credibility of the mobile device. Similarly, based on a preset credibility calculation formula corresponding to the in-vehicle device or a pre-trained credibility model, process the second credibility source data, and the calculated or output result is the credibility of the in-vehicle device.

[0027] It should be noted that the preset credibility calculation formulas corresponding to the paired mobile device and the in-vehicle device can be the same or different. Correspondingly, the credibility models corresponding to the paired mobile device and the in-vehicle device can be the same or different. When determining the credibility of the paired mobile device, other methods different from those used to determine the credibility of the in-vehicle device can be used, which are not limited here, as long as the credibility of the paired mobile device and the in-vehicle device can be accurately measured on the same basis, that is, the two can be effectively compared.

[0028] S130. Determine the master-slave role of the in-vehicle device according to the credibility of the mobile device and the credibility of the in-vehicle device.

[0029] Among them, the master-slave role includes the master role (master) and the slave role (slave). Generally, the clock credibility of the master role is higher than that of the slave role.

[0030] Specifically, compare the magnitude relationship between the credibility of the mobile device and the credibility of the in-vehicle device. If the credibility of the mobile device is greater than the credibility of the in-vehicle device, the master-slave role of the in-vehicle device is the slave role; if the credibility of the in-vehicle device is greater than or equal to the credibility of the mobile device, the master-slave role of the in-vehicle device is the master role.

[0031] S140. In response to the in-vehicle device being the slave role, determine the time offset between the paired mobile device and the in-vehicle device, and synchronize the time of the in-vehicle device according to the time offset.

[0032] Among them, the time offset is the phase difference in time between the paired mobile device and the in-vehicle device.

[0033] Specifically, if the in-vehicle device is the slave role, it is determined that the paired mobile device can be used to time the in-vehicle device, that is, the time signal of the paired mobile device is used as the external timing signal for the in-vehicle device. Therefore, it is necessary to calculate the time offset between the paired mobile device and the in-vehicle device through time synchronization, and superimpose the time offset on the basis of the time signal of the paired mobile device to synchronize the time of the in-vehicle device.

[0034] Optionally, in response to the in-vehicle device being the master role, update the time of the in-vehicle device based on the in-vehicle crystal oscillator clock.

[0035] Specifically, if the in-vehicle device is the master role, it means that the clock accuracy of the paired mobile device is poor and the paired mobile device cannot be used to time the in-vehicle device. Therefore, the in-vehicle device uses its own hardware, that is, the in-vehicle crystal oscillator clock, to update the time, and can continuously calculate and compare the credibility of the mobile device and the credibility of the in-vehicle device, update the master-slave role or continue to find other paired mobile devices to judge the master-slave role.

[0036] Based on the above example, after the vehicle-mounted device acts as the slave role, it is also possible to continuously monitor whether the synchronization effect with the paired mobile device is stable. Specifically, it can be as follows: In response to receiving a heartbeat packet sent by the paired mobile device, determine the local timestamp; Determine the instantaneous offset based on the local timestamp and the current timestamp; In response to the instantaneous offset being greater than the calibrated timestamp difference for a continuous preset number of times, return to execute the step of obtaining the first credibility source data corresponding to the paired mobile device.

[0037] Among them, the heartbeat packet is a data packet used to maintain the time synchronization status. The heartbeat packet includes the current timestamp, which is the timestamp when the paired mobile device sends the heartbeat packet. The paired mobile device periodically sends heartbeat packets to the vehicle-mounted device. The local timestamp is the timestamp in the vehicle-mounted device when the vehicle-mounted device receives the heartbeat packet. The instantaneous offset is the absolute value of the difference between the local timestamp and the current timestamp. The preset number of times is a pre-set number of times used to evaluate whether the time synchronization fails, such as 3 times, etc. The calibrated timestamp difference is a pre-calibrated value used to measure whether the time synchronization of the current cycle is effective, such as 50 μs, etc.

[0038] Specifically, since the paired mobile device periodically sends heartbeat packets to the vehicle-mounted device, when the vehicle-mounted device receives the heartbeat packet sent by the paired mobile device, record the timestamp when the heartbeat packet is received as the local timestamp. Parse the timestamp carried in the heartbeat packet, which is the local timestamp. Take the absolute value of the difference between the local timestamp and the current timestamp as the instantaneous offset. Determine whether the instantaneous offset is greater than the calibrated timestamp difference. If so, increment the failure count. When the failure count reaches the preset number of times, it means that the current time synchronization effect has failed, and it is necessary to re-judge the master-slave role and perform time synchronization, that is, return to execute the step of obtaining the first credibility source data corresponding to the paired mobile device. When the failure count does not reach the preset number of times, it means that continuous monitoring is still required, that is, continue to execute the step of determining the local timestamp in response to receiving the heartbeat packet sent by the paired mobile device; if not, set the failure count to zero and continue to execute the step of determining the local timestamp in response to receiving the heartbeat packet sent by the paired mobile device.

[0039] Based on the above example, after the vehicle-mounted device acts as the slave role, it is also necessary to handle various abnormal situations during the time synchronization process. Specifically, it can be as follows: In response to the Bluetooth connection being disconnected, update the vehicle-mounted time according to the local clock cache, and re-establish the Bluetooth connection. If the Bluetooth connection cannot be established within the preset time, update the vehicle-mounted time based on the on-vehicle crystal oscillator clock, and generate a Bluetooth disconnection warning message; In response to the failure to receive the heartbeat packet sent by the paired mobile device within a continuous preset number of cycles, return to execute the step of determining the time offset between the paired mobile device and the in-vehicle device, and perform time synchronization on the in-vehicle device according to the time offset. If the time synchronization is not completed, determine the in-vehicle device as the main role. In response to receiving the resynchronization information sent by the paired mobile device, return to execute the step of determining the time offset between the paired mobile device and the in-vehicle device, and perform time synchronization on the in-vehicle device according to the time offset.

[0040] Among them, the local clock cache is a method for maintaining the time reference on the in-vehicle device software. The on-vehicle crystal oscillator clock is the hardware for maintaining the time reference on the in-vehicle device hardware. The preset time is the longest time preset for attempting automatic Bluetooth reconnection. The Bluetooth disconnection warning message is used to prompt the user that time synchronization cannot be performed via Bluetooth and that Bluetooth needs to attempt to reconnect. The preset number is the number of cycles preset for measuring the failure of the paired mobile device, such as 3 times, etc. The resynchronization information is used to prompt that time synchronization needs to be performed again, and the resynchronization information is generated when there is a time jump in the paired mobile device.

[0041] Specifically, if the Bluetooth connection is detected to be disconnected, the paired mobile device cannot be used to update the in-vehicle unit time through time synchronization temporarily. Therefore, first, the local clock cache is used to maintain the time reference, update the in-vehicle unit time, and retry the Bluetooth connection. If the Bluetooth connection is successfully established, the steps of determining the time offset between the paired mobile device and the in-vehicle unit and synchronizing the in-vehicle unit time according to the time offset can be continued. If the Bluetooth connection is not established within the preset time, the in-vehicle unit time is updated based on the on-vehicle crystal oscillator clock, and a Bluetooth disconnection warning message is generated to remind the user that the Bluetooth has been disconnected and the automatic attempt to connect to the Bluetooth was unsuccessful. Please check manually, etc. If the heartbeat packets sent by the paired mobile device are not received continuously for a preset number of cycles, it means that a preset number of heartbeat packets have been lost continuously, and time synchronization needs to be attempted again, that is, return to execute the steps of determining the time offset between the paired mobile device and the in-vehicle unit and synchronizing the in-vehicle unit time according to the time offset. If the time synchronization attempt is not completed again, the in-vehicle unit is determined as the master role to update the in-vehicle unit time through the in-vehicle unit's own clock. Optionally, when a new paired mobile device joins, the first credibility source data of the new paired mobile device can be received again, the mobile device credibility can be calculated, and the master-slave role and time synchronization steps can be re-elected. It can be understood that when the paired mobile device detects a time jump (if the change amount > 1ms, etc.), it needs to initiate a global resynchronization, broadcast the time update time, and send a resynchronization message to the in-vehicle unit. When the in-vehicle unit receives the resynchronization message sent by the paired mobile device, it determines that time synchronization needs to be performed again, that is, return to execute the steps of determining the time offset between the paired mobile device and the in-vehicle unit and synchronizing the in-vehicle unit time according to the time offset.

[0042] The time synchronization method provided by the embodiment of the present application, by responding to the completion of the Bluetooth connection with the paired mobile device, obtains the first credibility source data corresponding to the paired mobile device through the Bluetooth connection, determines the mobile device credibility according to the first credibility source data, and determines the in-vehicle unit credibility according to the second credibility source data of the in-vehicle unit, so as to respectively judge the clock effects of the paired mobile device and the in-vehicle unit. Furthermore, according to the mobile device credibility and the in-vehicle unit credibility, the master-slave role of the in-vehicle unit is determined, that is, it is judged whether the paired mobile device can be used to time the in-vehicle unit. In response to the in-vehicle unit being the slave role, the time offset between the paired mobile device and the in-vehicle unit is determined, and the in-vehicle unit time is synchronized according to the time offset, realizing that in the case where the network stability of the in-vehicle unit is poor and it is impossible to rely on an external signal source for time synchronization, the credibility of the clocks of the paired mobile device and the in-vehicle unit is evaluated through the Bluetooth connection. In the case where the credibility of the clock of the paired mobile device is better, cross-device time synchronization is performed to improve the time accuracy of the in-vehicle unit and improve driving safety and user experience.

[0043] Figure 2 This is a flowchart of another time synchronization method provided by an embodiment of the present application. On the basis of the above embodiments, an exemplary description is given for the process of obtaining the first credibility source data, the process of determining the credibility of the mobile terminal and the in-vehicle terminal, the process of judging the master-slave role of the in-vehicle terminal, and the process of determining the time offset. Refer to Figure 2 , the time synchronization method specifically includes: S210. In response to completing a Bluetooth connection with a paired mobile terminal, obtain the first credibility source data corresponding to the paired mobile terminal through the Bluetooth connection.

[0044] On the basis of the above example, the first credibility source data includes the first external time source status, the first local clock drift rate, and the first hardware clock level. The first credibility source data corresponding to the paired mobile terminal can be obtained in the following manner: If the paired mobile terminal synchronizes with an external time source within a preset synchronization time, determine that the first external time source status is 1; otherwise, determine that the first external time source status is 0. Based on the Kalman filter algorithm, determine the state quantity at the current moment according to the state quantity at the previous moment, the observed quantity at the current moment, a preset first state transition matrix, a preset process noise matrix, a preset second state transition matrix, and a preset measurement noise matrix. Determine the relative frequency offset in the state quantity at the current moment as the first local clock drift rate. Determine the first hardware clock level according to the hardware clock type corresponding to the paired mobile terminal.

[0045] Among them, the state quantity includes the time offset and the relative frequency offset. The relative frequency offset is the change rate of the time offset with time. The observed quantity is the measured time offset and relative frequency offset. The first external time source status is a binary variable used to describe whether it synchronizes with an external time source within a preset synchronization time. The first local clock drift rate is the clock drift rate after Kalman filtering. The first hardware clock level is a value determined according to different hardware clock types. The preset synchronization time is the longest duration between the preset synchronization time with an external time source and the current time. The preset first state transition matrix, the preset process noise matrix, the preset second state transition matrix, and the preset measurement noise matrix are the matrices pre-calibrated in the Kalman filter algorithm.

[0046] Specifically, if the paired mobile device synchronizes with an external time source within the preset synchronization time, the status of the first external time source is determined to be 1; otherwise, the status of the first external time source is determined to be 0. Based on the Kalman filtering algorithm, using the state quantity at the previous moment and the observed quantity at the current moment as the basis, the state quantity at the previous moment is transferred using the preset first state transition matrix and the preset process noise matrix to obtain the predicted value at the current moment. The predicted value at the current moment is corrected using the preset second state transition matrix and the preset measurement noise matrix to obtain the state quantity at the current moment, and the relative frequency offset in the state quantity at the current moment is determined as the first local clock drift rate. The hardware clock type corresponding to the paired mobile device is used to determine the hardware clock level corresponding to the hardware clock type corresponding to the paired mobile device according to the pre-established correspondence between the hardware clock type and the hardware clock level, that is, the first hardware clock level. For example, if the hardware clock type is a temperature-compensated crystal oscillator (TCXO), the corresponding hardware time level is determined to be 1; if the hardware clock type is an ordinary crystal oscillator, the corresponding hardware time level is determined to be 0.5.

[0047] Optionally, the relative frequency offset can be indirectly estimated by linear fitting of the historical time offset sequence. The specific method is as follows: Record the time offsets of N consecutive synchronizations, denoted as ΔT1, ΔT2…ΔT N , and their corresponding timestamps t1, t2…t n . N is a preset number, which can be set according to actual needs. Through the linear regression model, ΔT = a*t + b for fitting, where the slope a represents the change rate of ΔT with time, that is, the relative frequency drift rate (relative frequency offset) Δf (Δf = a×10°ppm), and b is the offset.

[0048] Exemplarily, the Kalman filtering algorithm can be used to obtain the first local clock drift rate. First, perform state space modeling. The state quantity is: X = [ΔT, Δf] T . Where ΔT is the time offset in the state quantity, and Δf is the relative frequency offset in the state quantity. The system state equation is as follows:

[0049]

[0050] Where is the state quantity at the kth moment, is the state quantity at the (k - 1)th moment, with a dimension of 2×1, F is the preset first state transition matrix, with a dimension of 2×2, indicating how the state evolves over time, is the result of the state transition of the state quantity at the (k - 1)th moment, , as shown above, the linear relationship between the time offset and the relative frequency offset is obtained by fitting with a linear regression model. Therefore, state transition can be performed. Δt is the time interval between two adjacent state updates. is the preset process noise matrix, with a dimension of 2×1. represents follows a Gaussian distribution with a mean of 0 and a covariance of Q, representing the uncertainty of the model. Q is the process noise covariance, which is a pre-calibrated covariance matrix. Specifically:

[0051] where is the process noise variance of the clock offset (caused by environmental disturbances). is the process noise variance of the relative frequency offset (caused by frequency instability). is the cross noise (assuming independent noise).

[0052] The observed quantity is: Z = [ΔT mean , Δf mean T . Among them, ΔT mean is the time offset in the observed quantity, and Δf mean is the relative frequency offset in the observed quantity. The observation equation is:

[0053]

[0054] where is the observed quantity at the k-th moment, with a dimension of 2×1. H is the preset second state transition matrix, with a dimension of 2×2, indicating how the observed state evolves over time. is the preset measurement noise matrix, with a dimension of 2×1. represents follows a Gaussian distribution with a mean of 0 and a covariance of R, representing the uncertainty of the model. R is the measurement noise covariance, which is a pre-calibrated covariance matrix. Specifically:

[0055] where is the measurement noise variance of the clock offset (caused by environmental disturbances). is the measurement noise variance of the relative frequency offset (caused by frequency instability). is the cross noise of the measurement process (assuming independent noise).

[0056] The specific calculation process is shown as follows: ​First, perform system initialization, including initial state estimation and initial state covariance matrix setting. Initial state estimation:

[0057] Among them, is the estimated value of the initial clock offset, is the estimated value of the initial relative frequency offset. These are the state quantities at the start of filtering, usually given by the first observed quantity or prior knowledge.

[0058] Initial state covariance matrix:

[0059] Among them, is the variance (uncertainty) of the initial clock offset estimation, is the variance (uncertainty) of the initial relative frequency offset estimation, both of which can be determined by prior knowledge. The initial state covariance matrix represents the uncertainty of the initial state estimation. Usually, the initial uncertainty is large, so a relatively large variance value will be set. The non - diagonal elements being 0 indicates that there is no correlation between the two variables of the initial state.

[0060] Secondly, enter the prediction stage, that is, perform time update.

[0061] State prediction equation:

[0062] Among them, is the prior state estimation quantity at time k, that is, the estimated quantity (i.e., the predicted quantity) of the state quantity at time k based on the state quantities at time k - 1 and before. is the posterior state estimation quantity at time k - 1, which is obtained after the state update at time k - 1. F is the preset first state transition matrix as described above, and its meaning is: according to the state estimation quantity at the previous moment, the state quantity at the current moment is predicted through the state transition matrix F, that is, the predicted quantity. Specifically, the prediction of the clock offset ΔT is the clock offset at the previous moment plus the offset caused by the frequency offset, and the prediction of the relative frequency offset Δf remains unchanged (because it is assumed that the frequency offset does not fluctuate in a short period).

[0063] Covariance prediction equation:

[0064] Among them, is the covariance matrix of the prior state estimation at time k (prediction uncertainty), is the covariance matrix of the posterior state estimation at time k - 1. The process noise covariance Q can be simplified to a diagonal matrix in this process:

[0065] Among them, is the process noise variance of the clock offset, is the process noise variance of the relative frequency offset. The meaning of the process noise covariance Q is the uncertainty of the state quantity estimation at the current moment, representing the uncertainty caused by the imperfect model (for example, the frequency offset may not be strictly constant) and external interference during the state transition process.

[0066] Next, enter the update stage, that is, perform measurement update.

[0067] Calculate the Kalman gain:

[0068] Among them, is the Kalman gain at time k, with a dimension of 2×2, used to weigh the confidence of the state quantity estimation value and the observed value in the prediction process. H is the preset second state transition matrix, that is, the observation matrix, which is set as the identity matrix here. The measurement noise covariance R can be simplified as a diagonal matrix in this process:

[0069] Among them, is the measurement noise variance of the clock offset, is the measurement noise variance of the relative frequency offset. The meaning of the measurement noise covariance R is that the Kalman gain determines the magnitude of the influence of the observed quantity on the state update. When the measurement noise covariance R is large, the Kalman gain will become small, that is, more trust in the predicted value; when the uncertainty of the prediction is large, the Kalman gain will become large, that is, more trust in the observed quantity.

[0070] State update equation:

[0071] Among them, is the posterior state quantity estimation at time k (that is, the state estimation after fusing the observed quantity at the current moment), is the observed quantity at time k. is the measurement residual, also known as the innovation, that is, the difference between the actual observed quantity and the estimated value of the predicted state quantity. The meaning of is the state quantity after using the current observed quantity to correct the estimated value (predicted value) of the state quantity. By weighting and updating the measurement residual to the predicted value through the Kalman gain, a more accurate estimated value of the state quantity can be obtained.

[0072] Covariance update equation:

[0073] Among them, is the covariance matrix of the posterior state estimate at time k, is the 2×2 identity matrix, means updating the uncertainty of the state quantity estimate. Since the observed quantity is introduced, the uncertainty of the state quantity usually decreases.

[0074] Finally, the filtered output is performed.

[0075] The filtered drift rate: (i.e., the second term in the posterior state quantity estimate at time k), which is the required first local clock drift rate; the filtered clock offset: (i.e., the first term in the posterior state quantity estimate at time k).

[0076] Accordingly, the time shift iteration can be continuously performed to obtain the first local clock drift rate at each moment.

[0077] It can be understood that the state of the second external time source, the second local clock drift rate, and the second hardware clock level at the in-vehicle device end can also be determined through the same steps as above, which will not be elaborated here.

[0078] S220. According to the respective first weight coefficients corresponding to the paired mobile devices, perform weighted summation on the first external time source state, the reciprocal of the first local clock drift rate, and the first hardware clock level respectively to obtain the mobile device credibility.

[0079] Among them, the first weight coefficients include three weight coefficients, and each first weight coefficient is a weight coefficient pre-configured for the first external time source state, the reciprocal of the first local clock drift rate, and the first hardware clock level respectively.

[0080] Specifically, multiply the first external time source state, the reciprocal of the first local clock drift rate, and the first hardware clock level respectively by the respective first weight coefficients corresponding to the paired mobile devices, and use the sum of the products as the mobile device credibility.

[0081] Exemplarily, calculate the mobile device credibility through the following formula:

[0082] Among them, is the mobile device credibility, is the first external time source state, is the first local clock drift rate, is the first hardware clock level, , and are the respective first weight coefficients corresponding to the paired mobile devices, , and They are all evaluation values and can be used to evaluate the credibility of mobile terminals.

[0083] S230 . According to the second weight coefficients corresponding to the vehicle terminal, weighted sums are respectively performed on the second external time source state, the inverse of the second local clock drift rate, and the second hardware clock level to obtain the vehicle terminal credibility.

[0084] The second weight coefficient includes three weight coefficients, and each second weight coefficient is a weight coefficient pre-configured for the second external time source state, the inverse of the second local clock drift rate, and the second hardware clock level.

[0085] Specifically, the second weight coefficients corresponding to the vehicle terminal are respectively multiplied by the second external time source state, the inverse of the second local clock drift rate and the second hardware clock level, and the sum of the products is used as the credibility of the vehicle terminal.

[0086] Exemplarily, the vehicle-side credibility is calculated by the following formula:

[0087] in, For the credibility of the vehicle side, For the second external time source state, is the second local clock drift rate, is the second hardware clock level, , as well as are the second weight coefficients corresponding to the vehicle side, , as well as Both are evaluation values and can be used to evaluate the credibility of the vehicle computer.

[0088] Based on the above example, before weighted summing the first external time source state, the inverse of the first local clock drift rate, and the first hardware clock level according to the first weight coefficients corresponding to the paired mobile terminal to obtain the mobile terminal credibility, the first weight coefficients and the second weight coefficients may be dynamically determined, which may be: Input the device type, the first external time source state, the first local clock drift rate, the first hardware clock level, the first short-term clock jitter variance, and the first signal strength of the paired mobile terminal into a pre-built dynamic weight model to obtain first weight coefficients corresponding to the paired mobile terminal; The device type of the vehicle terminal, the second external time source status, the second local clock drift rate, the second hardware clock level, the second short-term clock jitter variance and the second signal strength are input into the dynamic weight model to obtain the second weight coefficients corresponding to the vehicle terminal.

[0089] Among them, the device types include the mobile terminal and the vehicle-mounted terminal. The first short-term clock jitter variance is the variance of the fluctuation or change of the clock signal of the paired mobile terminal relative to its ideal position within a preset short period of time. The first signal strength is the signal strength of the clock signal of the paired mobile terminal. The second short-term clock jitter variance is the variance of the fluctuation or change of the clock signal of the vehicle-mounted terminal relative to its ideal position within a preset short period of time. The second signal strength is the signal strength of the clock signal of the vehicle-mounted terminal. The dynamic weight model is a pre-established neural network model for calculating weight coefficients. The dynamic weight model is a neural network model with two fully connected layers as hidden layers. The training data of the dynamic weight model includes various data under simulated multi-scenarios (tunnels, urban canyons, high-speed movement), and the labels are the manually labeled optimal master-slave roles. Moreover, the model can be compressed, for example, quantized to 8-bit integers using TensorFlow Lite (an open-source deep learning framework), so that the model size < preset size (such as 50KB), and the inference latency < preset latency (such as 5ms) is required to meet the real-time requirements of the vehicle.

[0090] Optionally, when the weight update period is reached or the environment changes suddenly, data can be re-obtained, the dynamic weight model can be run, and each first weight coefficient and each second weight coefficient can be updated.

[0091] S240. Determine the absolute value of the difference between the vehicle-mounted terminal credibility and the mobile terminal credibility as the credibility difference, and determine whether the credibility difference is greater than a preset threshold. If so, execute S250; if not, execute S260.

[0092] Among them, the credibility difference is the absolute value of the difference between the vehicle-mounted terminal credibility and the mobile terminal credibility. The preset threshold is a value used to determine whether there is a significant difference in the clock reliability between the vehicle-mounted terminal and the paired mobile terminal.

[0093] S250. Determine the master-slave role of the vehicle-mounted terminal according to the mobile terminal credibility and the vehicle-mounted terminal credibility, and execute S270.

[0094] Specifically, if the credibility difference is greater than the preset threshold, it means that there is a significant difference in the clock credibility between the vehicle-mounted terminal and the paired mobile terminal. Therefore, the master-slave role can be determined according to the credibility level, that is, if the vehicle-mounted terminal credibility is greater than the mobile terminal credibility, determine the master-slave role of the vehicle-mounted terminal as the master role; if the vehicle-mounted terminal credibility is less than the mobile terminal credibility, determine the master-slave role of the vehicle-mounted terminal as the slave role.

[0095] S260. Determine the master-slave role of the vehicle-mounted terminal according to the first hardware clock level of the mobile terminal and the second hardware clock level of the vehicle-mounted terminal, and execute S270.

[0096] Specifically, if the credibility difference is not greater than the preset threshold, it indicates that there is little difference in the short-term dynamic performance of the clock between the in-vehicle device and the paired mobile device. Therefore, the hardware clock level is used as the core indicator of long-term stability, and the end with the higher hardware clock level is taken as the main role, while the other end is taken as the slave role. That is, if the first hardware clock level is greater than or equal to the second hardware clock level, the main-slave role of the in-vehicle device is determined as the main role; if the first hardware clock level is less than the second hardware clock level, the main-slave role of the in-vehicle device is determined as the slave role.

[0097] S270. In response to the in-vehicle device being in the slave role, receive the synchronization request message and the first transmission timestamp sent by the paired mobile device, and determine the first arrival timestamp.

[0098] Among them, the synchronization request message is a message sent by the paired mobile device to the in-vehicle device for time synchronization. The first transmission timestamp is the timestamp when the paired mobile device sends the synchronization request message. The first arrival timestamp is the timestamp when the synchronization request message arrives at the in-vehicle device.

[0099] Specifically, if the in-vehicle device is in the slave role, it is necessary to perform time calibration on the in-vehicle device through the paired mobile device. Therefore, the paired mobile device will send the synchronization request message and the first transmission timestamp to the in-vehicle device, and the in-vehicle device also needs to record the first arrival timestamp when it receives the synchronization request message.

[0100] S280. According to the first arrival timestamp, determine the response message corresponding to the synchronization request message, and send the response message and the second transmission timestamp to the paired mobile device, so that when the paired mobile device receives the response message and the second transmission timestamp, it can determine the second arrival timestamp, and determine the time offset according to the first transmission timestamp, the first arrival timestamp, the second transmission timestamp, and the second arrival timestamp, and send the time offset to the in-vehicle device.

[0101] Among them, the response message is a response to the synchronization request message, and the response message contains the first arrival timestamp. The second transmission timestamp is the timestamp when the in-vehicle device sends the response message. The second arrival timestamp is the timestamp when the response message arrives at the paired mobile device.

[0102] Specifically, on the in-vehicle device side, the first arrival timestamp is written into the response message corresponding to the synchronization request message, and the response message and the second transmission timestamp when sending the response message are sent to the paired mobile device. When the paired mobile device receives the response message and the second transmission timestamp, it records the second arrival timestamp when receiving the response message. The difference between the second arrival timestamp and the first transmission timestamp can be used as the full journey time, the difference between the second transmission time and the first arrival timestamp can be used as the message generation time, and the difference between the full journey time and the message generation time can be used as the round-trip time. Subtract the first transmission timestamp from the first arrival timestamp and then subtract half of the round-trip time, and the obtained difference is the time offset, and the time offset is sent to the in-vehicle device side.

[0103] Exemplarily, the paired mobile device sends a synchronization request message and records the first transmission timestamp T m1 ; the in-vehicle device side receives the synchronization request message and records the first arrival timestamp T s1 . The in-vehicle device side replies with a response message (including T s1 ) and records the second transmission timestamp T s2 ; the paired mobile device receives the response message and records the second arrival timestamp T m2 . The round-trip time R tt can be calculated through the following formula: R tt = (T m2 - T m1 ) - (T s2 - T s1 ). Furthermore, the time offset is calculated through the following formula : = T s1 - T m1 - R tt / 2.

[0104] S290. Receive the time offset sent by the paired mobile device, and perform time synchronization on the in-vehicle device side according to the time offset.

[0105] Existing vehicle time synchronization solutions are prone to interruption in special scenarios. Through the above content, it can ensure the normal operation of safety systems such as ADAS in complex environments such as tunnels and underground garages, avoid risks such as automatic emergency braking delay caused by the loss of the time reference, effectively reduce the incidence of traffic accidents, ensure the safety of the driver and passengers, and improve driving safety. Moreover, it can solve the problem of chaotic timestamps in the in-vehicle log system, making accident evidence collection more accurate and convenient. At the same time, it ensures the stability of the vehicle-cloud collaboration service, allowing users to enjoy more efficient and reliable intelligent connected vehicle services such as remote diagnosis, etc., and improving user satisfaction and trust.

[0106] The current synchronization solutions are difficult to meet the millisecond-level synchronization requirements of high-level autonomous driving. The above content provides a precise time synchronization foundation for functions such as ADAS and vehicle-cloud collaboration, helping intelligent driving technology to move towards a more precise and reliable stage, accelerating its popularization and application, and promoting the development of the industry. Moreover, a dynamic switching logic for multi-source time references is designed, and various redundant time dissemination schemes are utilized, such as the stable clock source of the passenger's mobile phone, to eliminate the risk of global time synchronization collapse caused by a single failure point, improve the reliability of the collaborative work of vehicle subsystems, ensure the stable functioning of the vehicle under long-term operation and complex environments, provide a unified local synchronization protocol, solve the problem of inconsistent timestamps between in-vehicle devices such as in-vehicle infotainment systems and mobile phones, T-Boxes, etc., improve the accuracy of multi-sensor fusion algorithms, promote the interconnection and interoperability of different devices in the automotive industry, drive the technological upgrading and innovative development of the entire industry, and lay a foundation for building an intelligent vehicle ecosystem. The automation and intelligence of vehicle time synchronization are realized, without the need for manual intervention or awareness by the user, further enhancing the intelligence level and user experience of the vehicle. During vehicle driving, the time synchronization system can automatically adapt to various environmental and network conditions, perform time calibration and synchronization in real time and accurately, ensure the normal operation and collaborative work of various vehicle functions, and provide strong support for the development of intelligent driving and vehicle networking.

[0107] The seamless time synchronization technology can not only be used for the optimization of current vehicle functions but also provide technical support for more application scenarios of future intelligent transportation systems. For example, in scenarios such as vehicle-road collaboration and vehicle networking communication, precise time synchronization is the key to achieving efficient data interaction and collaborative control. Through seamless time synchronization, vehicles can perform seamless time synchronization and data sharing with roadside infrastructure, other vehicles, etc., improve traffic efficiency, reduce congestion, enhance the operation efficiency and safety of the entire traffic system, and create more value for the development of intelligent transportation.

[0108] The time synchronization method provided by the embodiments of the present application obtains the mobile device credibility by respectively performing weighted summation on the first external time source state, the reciprocal of the first local clock drift rate, and the first hardware clock level according to the respective first weight coefficients corresponding to the paired mobile devices. The in-vehicle device credibility is obtained by respectively performing weighted summation on the second external time source state, the reciprocal of the second local clock drift rate, and the second hardware clock level according to the respective second weight coefficients corresponding to the in-vehicle device, so as to evaluate the clock credibility of both ends considering various factors. Furthermore, the absolute value of the difference between the in-vehicle device credibility and the mobile device credibility is determined as the credibility difference, and it is determined whether the credibility difference is greater than a preset threshold. If so, the master-slave role of the in-vehicle device is determined according to the mobile device credibility and the in-vehicle device credibility, that is, the end with higher credibility is used as the master role, and the end with lower credibility is used as the slave role. If not, the end with a higher hardware clock level is used as the master role, and the other end is used as the slave role. In response to the in-vehicle device being the slave role, a synchronization request message and a first transmission timestamp sent by the paired mobile device are received, a first arrival timestamp is determined, a response message corresponding to the synchronization request message is determined according to the first arrival timestamp, and the response message and a second transmission timestamp are sent to the paired mobile device, so that when the paired mobile device receives the response message and the second transmission timestamp, a second arrival timestamp is determined, and a time offset is determined according to the first transmission timestamp, the first arrival timestamp, the second transmission timestamp, and the second arrival timestamp, and the time offset is sent to the in-vehicle device. The time offset sent by the paired mobile device is received, and the in-vehicle device is time-synchronized according to the time offset, so as to perform more accurate cross-device time synchronization, realize accurate evaluation of the clock reliability of both ends, and furthermore, have more hierarchical considerations for the determination of the master-slave role, and can also accurately calculate the time offset, effectively improving the accuracy of in-vehicle device time synchronization.

[0109] Figure 3 It is a schematic structural diagram of an electronic device provided by the embodiments of the present application. As Figure 3 shown, the electronic device 300 includes one or more processors 301 and a memory 302.

[0110] The processor 301 may be a central processing unit (CPU) or other forms of processing units with data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 300 to perform desired functions.

[0111] The memory 302 may include one or more computer program products, and the computer program products may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory, etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage media, and the processor 301 may run the program instructions to implement the time synchronization method of any embodiment of the present application described above and / or other desired functions. Various contents such as initial extrinsic parameters, thresholds, etc. may also be stored in the computer-readable storage media.

[0112] In one example, the electronic device 300 may further include: an input device 303 and an output device 304, and these components are interconnected through a bus system and / or other forms of connection mechanisms (not shown). The input device 303 may include, for example, a keyboard, a mouse, etc. The output device 304 may output various information to the outside, including warning prompt information, braking force, etc. The output device 304 may include, for example, a display, a speaker, a printer, and a communication network and its connected remote output devices, etc.

[0113] Of course, for simplicity, Figure 3 only some of the components related to the present application in the electronic device 300 are shown, and components such as buses, input / output interfaces, etc. are omitted. In addition, according to specific application scenarios, the electronic device 300 may further include any other appropriate components.

[0114] In addition to the above methods and devices, an embodiment of the present application may also be a computer program product, which includes computer program instructions that cause the processor to execute the steps of the time synchronization method provided by any embodiment of the present application when the computer program instructions are run by the processor.

[0115] The computer program product may be written in any combination of one or more programming languages to write program code for performing the operations of the embodiments of the present application. The programming languages include object-oriented programming languages, such as Java, C++, etc., and also include conventional procedural programming languages, such as the "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, executed as an independent software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0116] In addition, an embodiment of the present application may also be a computer-readable storage medium storing computer program instructions, which, when run by a processor, cause the processor to execute the steps of the time synchronization method provided in any embodiment of the present application.

[0117] The computer-readable storage medium may be any combination of one or more readable media. The readable media may be a readable signal medium or a readable storage medium. The readable storage medium may, for example, include but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0118] It should be noted that the terms used in the present application are only for describing specific embodiments and do not limit the scope of the present application. As shown in the specification and claims of the present application, unless the context clearly indicates otherwise, words such as "a", "an", "one", and / or "the" are not specifically singular and may also include the plural. The term "comprising", "including", or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, or device including a series of elements not only includes those elements but also includes other elements not explicitly listed, or further includes elements inherent to such a process, method, or device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, or device including the said element.

[0119] It should also be noted that the orientation or positional relationship indicated by terms such as "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. is based on the orientation or positional relationship shown in the drawings, and is only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and thus should not be construed as a limitation of the present application. Unless otherwise clearly specified and defined, terms such as "installed", "connected", "coupled" should be understood in a broad sense. For example, it may be a fixed connection, a detachable connection, or an integral connection; it may be a mechanical connection or an electrical connection; it may be directly connected or indirectly connected through an intermediate medium, and it may be the internal communication of two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to specific circumstances.

[0120] In this article, specific examples are used to elaborate on the principles and implementation manners of this application. The description of the above embodiments is only used to help understand the method and its core idea of this application. The above is only the preferred implementation manner of this application. It should be noted that due to the limitation of literal expression and objectively infinite specific structures, for those of ordinary skill in the art, without departing from the principle of this invention, several improvements, refinements or changes can be made, or the above technical features can be combined in an appropriate manner; these improvements, refinements, changes or combinations, or directly applying the concept and technical solution of the invention to other occasions without improvement, shall all be regarded as the protection scope of this application.

Claims

1. A time synchronization method, characterized in that, Applied to the in-vehicle device terminal, including: In response to completing a Bluetooth connection with a paired mobile terminal, obtain first credibility source data corresponding to the paired mobile terminal through the Bluetooth connection; Determine the mobile terminal credibility according to the first credibility source data, and determine the in-vehicle device terminal credibility according to the second credibility source data of the in-vehicle device terminal; Determine the master-slave role of the in-vehicle device terminal according to the mobile terminal credibility and the in-vehicle device terminal credibility; In response to the in-vehicle device terminal being a slave role, determine the time offset between the paired mobile terminal and the in-vehicle device terminal, and synchronize the time of the in-vehicle device terminal according to the time offset.

2. The method according to claim 1, characterized in that, The first credibility source data includes a first external time source state, a first local clock drift rate, and a first hardware clock level, and the second credibility source data includes a second external time source state, a second local clock drift rate, and a second hardware clock level; Determine the mobile terminal credibility according to the first credibility source data, and determine the in-vehicle device terminal credibility according to the second credibility source data of the in-vehicle device terminal, including: Perform weighted summation on the first external time source state, the reciprocal of the first local clock drift rate, and the first hardware clock level respectively according to the respective first weight coefficients corresponding to the paired mobile terminal to obtain the mobile terminal credibility; Perform weighted summation on the second external time source state, the reciprocal of the second local clock drift rate, and the second hardware clock level respectively according to the respective second weight coefficients corresponding to the in-vehicle device terminal to obtain the in-vehicle device terminal credibility.

3. The method according to claim 2, characterized in that, Before performing weighted summation on the first external time source state, the reciprocal of the first local clock drift rate, and the first hardware clock level respectively according to the respective first weight coefficients corresponding to the paired mobile terminal to obtain the mobile terminal credibility, it further includes: Input the device type, first external time source state, first local clock drift rate, first hardware clock level, first short-term clock jitter variance, and first signal strength of the paired mobile terminal into a pre-constructed dynamic weight model to obtain the respective first weight coefficients corresponding to the paired mobile terminal; Input the device type, second external time source state, second local clock drift rate, second hardware clock level, second short-term clock jitter variance, and second signal strength of the in-vehicle device terminal into the dynamic weight model to obtain the respective second weight coefficients corresponding to the in-vehicle device terminal; Among them, the dynamic weight model is a neural network model with two fully connected layers as hidden layers.

4. The method according to claim 1, wherein The first credibility source data includes a first external time source state, a first local clock drift rate, and a first hardware clock level; Obtain the first credibility source data corresponding to the paired mobile terminal, including: In response to the paired mobile terminal synchronizing with an external time source within a preset synchronization time, determine that the first external time source state is 1, otherwise, determine that the first external time source state is 0; Based on the Kalman filter algorithm, determine the state quantity at the current moment according to the state quantity at the previous moment, the observed quantity at the current moment, a preset first state transition matrix, a preset process noise matrix, a preset second state transition matrix, and a preset measurement noise matrix; wherein, the state quantity includes a time offset and a relative frequency offset. Determine the relative frequency offset in the state quantity at the current moment as the first local clock drift rate. Determine the first hardware clock level according to the hardware clock type corresponding to the paired mobile device.

5. The method according to claim 1, wherein Determine the master-slave role of the in-vehicle device according to the credibility of the mobile device and the credibility of the in-vehicle device, including: Determine the absolute value of the difference between the credibility of the in-vehicle device and the credibility of the mobile device as the credibility difference. In response to the credibility difference being greater than a preset threshold, determine the master-slave role of the in-vehicle device according to the credibility of the mobile device and the credibility of the in-vehicle device. In response to the credibility difference being less than or equal to the preset threshold, determine the master-slave role of the in-vehicle device according to the first hardware clock level of the mobile device and the second hardware clock level of the in-vehicle device.

6. The method according to claim 1, characterized in that, Determine the time offset between the paired mobile device and the in-vehicle device, including: Receive a synchronization request message and a first transmission timestamp sent by the paired mobile device. Determine a first arrival timestamp, determine a response message corresponding to the synchronization request message according to the first arrival timestamp, and send the response message and a second transmission timestamp to the paired mobile device, so that when the paired mobile device receives the response message and the second transmission timestamp, it determines a second arrival timestamp, and determines the time offset according to the first transmission timestamp, the first arrival timestamp, the second transmission timestamp, and the second arrival timestamp, and sends the time offset to the in-vehicle device. Receive the time offset sent by the paired mobile device.

7. The method according to claim 1, wherein After responding that the in-vehicle device is in the slave role, it further includes: In response to receiving a heartbeat packet sent by the paired mobile device, determine a local timestamp; wherein, the heartbeat packet includes a current timestamp. Determine an instantaneous offset according to the local timestamp and the current timestamp. In response to the instantaneous offset being greater than the calibrated timestamp difference for a continuous preset number of times, return to execute the step of obtaining the first credibility source data corresponding to the paired mobile device.

8. The method according to claim 1, characterized in that After responding that the in-vehicle device is in the slave role, it further includes: In response to the Bluetooth connection being disconnected, update the in-vehicle time according to the local clock cache, and re-establish the Bluetooth connection. If the Bluetooth connection cannot be established within a preset time, update the in-vehicle time based on the on-vehicle crystal oscillator clock, and generate a Bluetooth disconnection warning message. In response to not receiving the heartbeat packet sent by the paired mobile device for a continuous preset number of cycles, return to execute the step of determining the time offset between the paired mobile device and the in-vehicle device, and synchronize the in-vehicle device according to the time offset. If the time synchronization is not completed, determine that the in-vehicle device is in the master role. In response to receiving the resynchronization information sent by the paired mobile device, return to execute the step of determining the time offset between the paired mobile device and the in-vehicle device, and synchronize the time of the in-vehicle device according to the time offset; wherein, the resynchronization information is generated when there is a time jump in the paired mobile device.

9. An electronic device, characterized in that, The electronic device includes: a processor and a memory; The processor is configured to execute the steps of the time synchronization method according to any one of claims 1 to 8 by calling the programs or instructions stored in the memory.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores programs or instructions that cause a computer to execute the steps of the time synchronization method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • IEEE1588 clock synchronization method based on disturbance observation control technology

    CN106160914A

  • Main equipment determination method, device and equipment and medium

    CN111835446A

  • Cascade system main equipment selection method and device and cascade system

    CN114244465A

  • PTP clock synchronization optimization method and application

    CN114362873A

  • Communication method, device and system

    CN115226195A