Time synchronization method, device 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 time synchronization is performed, which solves the problem of time interruption of the vehicle in the scenario of signal restricted, and improves the time accuracy and driving safety of the vehicle terminal.

CN120358587BActive Publication Date: 2025-09-02CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510821996.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-19
Publication Date
2025-09-02
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 the network time delay fluctuates greatly, resulting in inaccurate time on the vehicle side, affecting the advanced driving assistance system and user experience.

Method used

The trustworthiness source data of the paired mobile terminal is obtained through Bluetooth connection, evaluate the clock credibility of the mobile terminal and the vehicle terminal, determine the master-slave role, and perform time synchronization based on the time offset to ensure the time accuracy of the vehicle terminal.

Benefits of technology

In the case of poor network stability, time synchronization across devices is achieved, time accuracy of vehicle-machine terminals is improved, driving safety and user experience are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120358587B_ABST
    Figure CN120358587B_ABST
Patent Text Reader

Abstract

The present application provides a time synchronization method, device and medium, the method comprising: in response to completing a Bluetooth connection with a paired mobile terminal, obtaining first credibility source data corresponding to the paired mobile terminal via the Bluetooth connection; determining the credibility of the mobile terminal based on the first credibility source data, and determining the credibility of the vehicle terminal based on the second credibility source data of the vehicle terminal; determining the master-slave role of the vehicle terminal based on the credibility of the mobile terminal and the credibility of the vehicle terminal; in response to the vehicle terminal being a slave role, determining the time offset between the paired mobile terminal and the vehicle terminal, and performing time synchronization on the vehicle terminal based on the time offset. Through the technical solution of the present application, cross-device time synchronization is achieved when the vehicle terminal network is unstable and cannot rely on an external signal source for time synchronization, thereby improving driving safety and user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of time synchronization technology, and in particular to a time synchronization method, device, and medium. Background Art

[0002] With the development of intelligent and connected vehicles, the vehicle's time synchronization function has become the key to improving driving safety, optimizing user experience and realizing assisted driving functions.

[0003] Currently, vehicle time synchronization suffers from an over-reliance on external signal sources. This means it's highly dependent on external timing signals such as GPS (Global Positioning System) and 4G (The 4th Generation Mobile Communication Technology). However, in signal-restricted scenarios like tunnels and underground garages, time synchronization services are completely interrupted. Furthermore, network timing is affected by factors like base station load and channel congestion, resulting in large fluctuations in timing delays. Furthermore, some scenarios require operator authorization. If a local vehicle clock is used, its reliance on a quartz crystal oscillator can lead to cumulative errors of up to seconds after long-term operation due to its reliance on temperature and aging. Inaccurate vehicle-side time can lead to problems such as the inability of advanced driver assistance systems to wake up, confusion in vehicle log timestamps, failure of vehicle-cloud collaborative services, and decreased performance of time-sensitive functions. Summary of the Invention

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

[0005] The present invention provides a time synchronization method, which is applied to a vehicle terminal. The method includes:

[0006] In response to completing the Bluetooth connection with the paired mobile terminal, obtaining first credibility source data corresponding to the paired mobile terminal through the Bluetooth connection;

[0007] Determining the credibility of the mobile terminal based on the first credibility source data, and determining the credibility of the vehicle terminal based on the second credibility source data of the vehicle terminal;

[0008] Determining the master and slave roles of the vehicle-side terminal according to the credibility of the mobile terminal and the credibility of the vehicle-side terminal;

[0009] In response to the vehicle terminal being in a slave role, a time offset between the paired mobile terminal and the vehicle terminal is determined, and time synchronization is performed on the vehicle terminal according to the time offset.

[0010] According to the technical solution provided in the embodiment of the present application, optionally, 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;

[0011] Determining the credibility of the mobile terminal according to the first credibility source data, and determining the credibility of the vehicle terminal according to the second credibility source data of the vehicle terminal, including:

[0012] According to each first weight coefficient corresponding to the paired mobile terminal, weighted summation is performed on the first external time source state, the inverse of the first local clock drift rate, and the first hardware clock level to obtain the mobile terminal credibility;

[0013] According to the second weight coefficients corresponding to the vehicle computer end, the second external time source state, the inverse of the second local clock drift rate, and the second hardware clock level are weighted and summed to obtain the vehicle computer end credibility.

[0014] According to the technical solution provided in the embodiment of the present application, optionally, before obtaining the mobile terminal credibility by performing weighted summation of the first external time source state, the inverse of the first local clock drift rate, and the first hardware clock level according to each first weight coefficient corresponding to the paired mobile terminal, the method further includes:

[0015] Inputting the device type, first external time source status, 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-built dynamic weight model to obtain first weight coefficients corresponding to the paired mobile terminal;

[0016] 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 vehicle-side into the dynamic weight model to obtain the second weight coefficients corresponding to the vehicle-side;

[0017] The dynamic weight model is a neural network model with two fully connected layers as hidden layers.

[0018] According to the technical solution provided in the embodiment of the present application, optionally, the first credibility source data includes a first external time source state, a first local clock drift rate, and a first hardware clock level;

[0019] Obtaining first credibility source data corresponding to the paired mobile terminal includes:

[0020] In response to the paired mobile terminal synchronizing with the external time source within a preset synchronization time, determining that the first external time source state is 1; otherwise, determining that the first external time source state is 0;

[0021] Based on the Kalman filter algorithm, the state quantity at the current moment is determined according to the state quantity at the previous moment, the observation quantity at the current moment, a preset first state transfer matrix, a preset process noise matrix, a preset second state transfer matrix, and a preset measurement noise matrix; wherein the state quantity includes a time offset and a relative frequency offset;

[0022] Determine the relative frequency deviation in the state quantity at the current moment as the first local clock drift rate;

[0023] The first hardware clock level is determined according to the hardware clock type corresponding to the paired mobile terminal.

[0024] According to the technical solution provided in the embodiment of the present application, optionally, determining the master-slave role of the vehicle terminal according to the credibility of the mobile terminal and the credibility of the vehicle terminal includes:

[0025] Determine the absolute value of the difference between the vehicle-side credibility and the mobile-side credibility as the credibility difference;

[0026] In response to the credibility difference being greater than a preset threshold, determining the master and slave roles of the vehicle-side terminal according to the credibility of the mobile terminal and the credibility of the vehicle-side terminal;

[0027] In response to the credibility difference being less than or equal to the preset threshold, the master-slave role of the vehicle terminal is determined according to the first hardware clock level of the mobile terminal and the second hardware clock level of the vehicle terminal.

[0028] According to the technical solution provided in the embodiment of the present application, optionally, determining the time offset between the paired mobile terminal and the vehicle terminal includes:

[0029] Receiving a synchronization request message and a first sending timestamp sent by the paired mobile terminal;

[0030] Determine a first arrival timestamp, determine a response message corresponding to the synchronization request message based on the first arrival timestamp, and send the response message and the second sending timestamp to the paired mobile terminal, so that the paired mobile terminal determines the second arrival timestamp when receiving the response message and the second sending timestamp, and determines a time offset based on the first sending timestamp, the first arrival timestamp, the second sending timestamp, and the second arrival timestamp, and sends the time offset to the vehicle terminal;

[0031] Receive the time offset sent by the paired mobile terminal.

[0032] According to the technical solution provided in the embodiment of the present application, optionally, after responding that the vehicle-mounted terminal is in the slave role, the method further includes:

[0033] In response to receiving a heartbeat packet sent by the paired mobile terminal, determining a local timestamp; wherein the heartbeat packet includes a current timestamp;

[0034] Determining an instantaneous offset according to the local timestamp and the current timestamp;

[0035] In response to the instantaneous offset being greater than the calibration timestamp difference for a consecutive preset number of times, the process returns to the step of obtaining the first credibility source data corresponding to the paired mobile terminal.

[0036] According to the technical solution provided in the embodiment of the present application, optionally, after responding that the vehicle-mounted terminal is in the slave role, the method further includes:

[0037] In response to the Bluetooth connection being disconnected, the vehicle computer time is updated according to the local clock cache, and the Bluetooth connection is re-established. If the Bluetooth connection is not established within a preset time, the vehicle computer time is updated based on the vehicle crystal oscillator clock, and a Bluetooth disconnection warning message is generated;

[0038] In response to not receiving a heartbeat packet sent by the paired mobile terminal within a preset number of consecutive cycles, returning to the step of determining a time offset between the paired mobile terminal and the vehicle terminal, and performing time synchronization on the vehicle terminal according to the time offset; if time synchronization is not completed, determining that the vehicle terminal is the master role;

[0039] In response to receiving the resynchronization information sent by the paired mobile terminal, the process returns to executing the step of determining the time offset between the paired mobile terminal and the vehicle terminal, and performing time synchronization on the vehicle terminal according to the time offset; wherein the resynchronization information is generated when there is a time jump in the paired mobile terminal.

[0040] An embodiment of the present application further provides an electronic device, comprising:

[0041] processor and memory;

[0042] The processor is configured to execute the steps of the time synchronization method as described in any embodiment by calling the program or instructions stored in the memory.

[0043] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a program or instructions, wherein the program or instructions enable a computer to execute the steps of the time synchronization method as described in any embodiment.

[0044] In summary, the present application proposes a time synchronization method, which, in response to completing a Bluetooth connection with a paired mobile terminal, obtains the first credibility source data corresponding to the paired mobile terminal through the Bluetooth connection, determines the credibility of the mobile terminal based on the first credibility source data, and determines the credibility of the vehicle terminal based on the second credibility source data of the vehicle terminal, so as to judge the clock effects of the paired mobile terminal and the vehicle terminal respectively, and then, according to the credibility of the mobile terminal and the credibility of the vehicle terminal, determines the master-slave role of the vehicle terminal, that is, determines whether the paired mobile terminal can be used to provide time for the vehicle terminal, and in response to the vehicle terminal being a slave role, determines the time offset between the paired mobile terminal and the vehicle terminal, and synchronizes the vehicle terminal according to the time offset, so as to achieve the following: when the vehicle terminal network stability is poor and cannot rely on an external signal source for time synchronization, the credibility of the clocks of the paired mobile terminal and the vehicle terminal is evaluated through the Bluetooth connection, and when the credibility of the clock of the paired mobile terminal is better, cross-device time synchronization is performed, thereby improving the time accuracy of the vehicle terminal, driving safety and user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 This is a flowchart of a time synchronization method provided by an embodiment of the present application;

[0046] Figure 2 This is a flowchart of another time synchronization method provided by an embodiment of the present application;

[0047] Figure 3 This is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0048] The present application will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely for the purpose of explaining the relevant invention and are not intended to limit the invention. It should also be noted that, for ease of description, only portions relevant to the invention are shown in the accompanying drawings.

[0049] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in this application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0050] As mentioned in the background technology, in response to the problems in the existing technology, this application proposes a time synchronization method, which is suitable for ensuring the accuracy of the vehicle-side time when the vehicle-side network stability is poor and it is impossible to rely on an external signal source for time synchronization. The time synchronization method provided in each embodiment of this application can be executed by an electronic device.

[0051] Figure 1This is a flow chart of a time synchronization method provided by an embodiment of the present application. Figure 1 ,This time synchronization method is applied to the vehicle side, specifically including:

[0052] S110 : In response to completing the Bluetooth connection with the paired mobile terminal, obtaining first credibility source data corresponding to the paired mobile terminal through the Bluetooth connection.

[0053] The paired mobile terminal is a mobile terminal that has been paired with the vehicle terminal, which can be a mobile phone, tablet computer, etc. The first credibility source data is data used to determine the time reliability of the paired mobile terminal, and can include the external clock source status, local clock status, and hardware clock status of the paired mobile terminal.

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

[0055] It should be noted that when the car computer is started, the GPS / 4G timing status can be detected first. 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), a Bluetooth connection is established with the paired mobile terminal via Bluetooth connection.

[0056] S120: Determine the credibility of the mobile terminal based on the first credibility source data, and determine the credibility of the vehicle terminal based on the second credibility source data.

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

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

[0059] It should be noted that the preset credibility calculation formula corresponding to the paired mobile terminal and the preset credibility calculation formula corresponding to the vehicle-mounted terminal can be the same or different. Accordingly, the credibility model corresponding to the paired mobile terminal and the credibility model corresponding to the vehicle-mounted terminal can be the same or different. When determining the mobile terminal credibility of the paired mobile terminal, other methods different from the methods used to determine the vehicle-mounted terminal credibility of the vehicle-mounted terminal can be used. There is no limitation here. It is sufficient that the credibility of the paired mobile terminal and the vehicle-mounted terminal can be accurately measured on the same basis, that is, the two can be effectively compared.

[0060] S130 : Determine the master and slave roles of the vehicle-side according to the credibility of the mobile terminal and the credibility of the vehicle-side.

[0061] The master-slave roles include the master role and the slave role. Usually, the clock credibility of the master role is higher than that of the slave role.

[0062] Specifically, the credibility of the mobile terminal and the credibility of the vehicle terminal are compared. If the credibility of the mobile terminal is greater than that of the vehicle terminal, the master-slave role of the vehicle terminal is the slave role; if the credibility of the vehicle terminal is greater than or equal to the credibility of the mobile terminal, the master-slave role of the vehicle terminal is the master role.

[0063] S140 : In response to the vehicle terminal being in a slave role, determining a time offset between the paired mobile terminal and the vehicle terminal, and performing time synchronization on the vehicle terminal according to the time offset.

[0064] The time offset is the time phase difference between the paired mobile terminal and the vehicle terminal.

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

[0066] Optionally, in response to the vehicle computer side being the master, the time of the vehicle computer side is updated based on the vehicle-mounted crystal oscillator clock.

[0067] Specifically, if the vehicle-mounted terminal plays the master role, it means that the clock accuracy of the paired mobile terminal is poor, and the paired mobile terminal cannot be used to synchronize time for the vehicle-mounted terminal. Therefore, the vehicle-mounted terminal uses its own hardware, that is, the on-board crystal oscillator clock to update the time, and can continuously calculate and compare the credibility of the mobile terminal and the credibility of the vehicle-mounted terminal, update the master-slave role, or continue to look for other paired mobile terminals to determine the master-slave role.

[0068] Based on the above example, after the vehicle terminal is in the slave role, it is also possible to continuously monitor whether the synchronization effect with the paired mobile terminal is stable, specifically:

[0069] In response to receiving a heartbeat packet sent by the paired mobile terminal, determining a local timestamp;

[0070] Determine the instantaneous offset based on the local timestamp and the current timestamp;

[0071] In response to the instantaneous offset being greater than the calibration timestamp difference for a consecutive preset number of times, the process returns to the step of obtaining the first credibility source data corresponding to the paired mobile terminal.

[0072] 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 terminal sends the heartbeat packet. The paired mobile terminal periodically sends heartbeat packets to the vehicle terminal. The local timestamp is the timestamp in the vehicle terminal when the vehicle terminal 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 used to assess whether time synchronization has failed, such as 3 times. The calibrated timestamp difference is a pre-calibrated value used to measure whether the time synchronization of the current cycle is valid, such as 50μs.

[0073] Specifically, since the paired mobile terminal periodically sends heartbeat packets to the vehicle terminal, when the vehicle terminal receives the heartbeat packet sent by the paired mobile terminal, it records the timestamp when the heartbeat packet is received as the local timestamp. Parse the timestamp carried in the heartbeat packet, that 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, add one to the number of failures. When the number of failures reaches the preset number, it means that the current time synchronization effect has failed and it is necessary to re-perform the master-slave role judgment and time synchronization, that is, return to execute the step of obtaining the first credibility source data corresponding to the paired mobile terminal. When the number of failures does not reach the preset number, it means that it is necessary to continue continuous monitoring, that is, continue to execute the step of determining the local timestamp in response to receiving the heartbeat packet sent by the paired mobile terminal; if not, set the number of failures 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 terminal.

[0074] Based on the above example, after responding to the vehicle-side being in the slave role, it is necessary to handle various abnormal situations in the time synchronization process, which can be:

[0075] In response to a Bluetooth connection being disconnected, the vehicle computer time is updated based on the local clock cache and the Bluetooth connection is reestablished. If the Bluetooth connection is not established within a preset time, the vehicle computer time is updated based on the vehicle crystal oscillator clock and a Bluetooth disconnection warning message is generated;

[0076] In response to not receiving a heartbeat packet sent by the paired mobile terminal within a preset number of consecutive cycles, returning to the step of determining a time offset between the paired mobile terminal and the vehicle terminal, and performing time synchronization on the vehicle terminal based on the time offset. If time synchronization is not completed, determining that the vehicle terminal is the master role;

[0077] In response to receiving the resynchronization information sent by the paired mobile terminal, the process returns to executing the step of determining the time offset between the paired mobile terminal and the vehicle terminal, and performing time synchronization on the vehicle terminal according to the time offset.

[0078] Among them, the local clock cache is a method for maintaining the time base on the vehicle-side software. The on-board crystal oscillator clock is the hardware that maintains the time base on the vehicle-side hardware. The preset time is the maximum time set in advance for attempting automatic Bluetooth reconnection. The Bluetooth disconnection alarm message is used to prompt the user that time synchronization cannot be performed via Bluetooth and Bluetooth needs to retry the connection. The preset number is a pre-set number of cycles used to measure the failure of the paired mobile terminal, such as 3 times. The resynchronization information is information used to prompt that time resynchronization is needed. The resynchronization information is generated when there is a time jump on the paired mobile terminal.

[0079] Specifically, if a Bluetooth connection is detected to be disconnected, the paired mobile terminal cannot be used for time synchronization to update the vehicle computer time. Therefore, the local clock cache is first used to maintain the time reference, update the vehicle computer time, and retry the Bluetooth connection. If the Bluetooth connection is successfully established, the steps of determining the time offset between the paired mobile terminal and the vehicle computer and synchronizing the vehicle computer time based on the time offset can be continued. If the Bluetooth connection is not established within a preset time, the vehicle computer time is updated based on the vehicle's crystal oscillator clock, and a Bluetooth disconnection warning message is generated to remind the user that Bluetooth has been disconnected and that the automatic Bluetooth connection attempt was unsuccessful, and to request manual verification. If no heartbeat packets sent by the paired mobile terminal are received within a preset number of consecutive cycles, it indicates that the preset number of heartbeat packets have been lost, and time synchronization needs to be attempted again. In other words, the steps of determining the time offset between the paired mobile terminal and the vehicle computer and synchronizing the vehicle computer time based on the time offset can be returned to. If time synchronization is also unsuccessful after the second attempt, the vehicle computer is determined to be the master, and the vehicle computer time is updated using its own clock. Optionally, when a new paired mobile terminal joins, the first credibility source data of the new paired mobile terminal can be received again, the credibility of the mobile terminal can be calculated, and the master-slave roles and time synchronization steps can be re-elected. It can be understood that when the paired mobile terminal detects a time jump (if the change is greater than 1ms, etc.), it is necessary to initiate a global resynchronization, broadcast the time update time, and send a resynchronization message to the vehicle terminal. When the vehicle terminal receives the resynchronization message sent by the paired mobile terminal, it determines that the time needs to be resynchronized, that is, it returns to the step of determining the time offset between the paired mobile terminal and the vehicle terminal, and performing time synchronization on the vehicle terminal according to the time offset.

[0080] The time synchronization method provided in the embodiment of the present application, in response to completing a Bluetooth connection with a paired mobile terminal, obtains the first credibility source data corresponding to the paired mobile terminal through the Bluetooth connection, determines the credibility of the mobile terminal based on the first credibility source data, and determines the credibility of the vehicle terminal based on the second credibility source data of the vehicle terminal, so as to judge the clock effects of the paired mobile terminal and the vehicle terminal respectively, and then, according to the credibility of the mobile terminal and the credibility of the vehicle terminal, determines the master-slave role of the vehicle terminal, that is, determines whether the paired mobile terminal can be used to provide time for the vehicle terminal, and in response to the vehicle terminal being the slave role, determines the time offset between the paired mobile terminal and the vehicle terminal, and synchronizes the vehicle terminal based on the time offset, so as to achieve the following: when the vehicle terminal network stability is poor and cannot rely on an external signal source for time synchronization, the credibility of the clocks of the paired mobile terminal and the vehicle terminal is evaluated through the Bluetooth connection, and when the credibility of the clock of the paired mobile terminal is better, cross-device time synchronization is performed, thereby improving the time accuracy of the vehicle terminal, driving safety and user experience.

[0081] Figure 2 This is a flowchart of another time synchronization method provided by an embodiment of the present application. Based on the above embodiments, the process of obtaining the first credibility source data, the process of determining the credibility of the mobile terminal and the vehicle terminal, the process of judging the master and slave roles of the vehicle terminal, and the process of determining the time offset are all exemplarily described. Figure 2 , the time synchronization method specifically includes:

[0082] S210: In response to completing the Bluetooth connection with the paired mobile terminal, obtaining first credibility source data corresponding to the paired mobile terminal through the Bluetooth connection.

[0083] Based on the above example, the first trustworthy source data includes the first external time source status, the first local clock drift rate, and the first hardware clock level. The first trustworthy source data corresponding to the paired mobile terminal can be obtained in the following manner:

[0084] In response to the paired mobile terminal synchronizing with the external time source within the preset synchronization time, determining the first external time source state to be 1; otherwise, determining the first external time source state to be 0;

[0085] Based on the Kalman filter algorithm, the state quantity at the current moment is determined according to the state quantity at the previous moment, the observation quantity at the current moment, the preset first state transfer matrix, the preset process noise matrix, the preset second state transfer matrix and the preset measurement noise matrix;

[0086] Determine the relative frequency deviation in the state quantity at the current moment as the first local clock drift rate;

[0087] A first hardware clock level is determined according to a hardware clock type corresponding to the paired mobile terminal.

[0088] Among them, the state quantity includes time offset and relative frequency deviation. Relative frequency deviation is the rate of change of time offset over time. The observation quantity is the measured time offset and relative frequency deviation. The first external time source state is a binary variable used to describe whether synchronization with the external time source is within the 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 maximum duration of the preset synchronization time with the external time source and the current time. The preset first state transfer matrix, the preset process noise matrix, the preset second state transfer matrix and the preset measurement noise matrix are the matrices pre-calibrated in the Kalman filter algorithm.

[0089] Specifically, if the paired mobile terminal synchronizes with the external time source within a preset synchronization time, the state of the first external time source is determined to be 1; otherwise, the state of the first external time source is determined to be 0. Based on a Kalman filter algorithm, the state quantity at the previous moment and the observed quantity at the current moment are used as a basis. The state quantity at the previous moment is transferred using a preset first state transfer matrix and a preset process noise matrix to obtain a predicted value at the current moment. The predicted value at the current moment is corrected using a preset second state transfer matrix and a preset measurement noise matrix to obtain the state quantity at the current moment. 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 terminal is compared with a pre-established correspondence between hardware clock types and hardware clock levels to determine the hardware clock level corresponding to the hardware clock type corresponding to the paired mobile terminal, namely, 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 a standard crystal oscillator, the corresponding hardware time level is determined to be 0.5.

[0090] Optionally, the relative frequency offset can be estimated indirectly by linear fitting the time offset sequence of the historical records. The specific method is as follows: record the time offsets of N consecutive synchronizations, and record them as ΔT1, ΔT2…ΔT N , and their corresponding timestamps t1, t2…t n N is a pre-set number of times, which can be set according to actual needs. A linear regression model is used for fitting, ΔT = a*t + b, where the slope a represents the rate of change of ΔT over time, i.e., the relative frequency drift rate (relative frequency deviation) Δf (Δf = a × 10° ppm), and b is the bias.

[0091] For example, a Kalman filter algorithm can be used to obtain the first local clock drift rate. First, a state space model is performed, and 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:

[0092]

[0093]

[0094] in, is the state quantity at the kth moment, is the state quantity at the k-1th moment, with a dimension of 2×1, and F is the preset first state transfer matrix, with a dimension of 2×2, which indicates how the state evolves over time. It is the result of the state transfer of the state quantity at the k-1th moment. ,The above shows that the linear relationship between the time offset and the relative frequency deviation is obtained by fitting the linear regression model. Therefore, the state transfer 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, express It obeys a Gaussian distribution with a mean of 0 and a covariance of Q, which represents the uncertainty of the model. Q is the process noise covariance, which is a pre-calibrated covariance matrix. Specifically:

[0095]

[0096] in, is the process noise variance of the clock offset (caused by environmental perturbations), is the process noise variance relative to the frequency deviation (caused by frequency instability), is the cross noise (assuming the noise is independent).

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

[0098]

[0099]

[0100] in, is the observation quantity at the kth moment, with a dimension of 2×1, and H is the preset second state transfer matrix, with a dimension of 2×2, which indicates how the observation state evolves over time. is the preset measurement noise matrix with a dimension of 2×1, express It obeys a Gaussian distribution with a mean of 0 and a covariance of R, which represents the uncertainty of the model. R is the measurement noise covariance, which is a pre-calibrated covariance matrix. Specifically:

[0101]

[0102] in, is the measurement noise variance of the clock offset (caused by environmental perturbations), is the measurement noise variance relative to the frequency offset (caused by frequency instability), is the cross noise of the measurement process (assuming the noises are independent).

[0103] The specific calculation process is as follows:

[0104] First, the system is initialized, including the initial state estimation and the initial state covariance matrix setting. Initial state estimation:

[0105]

[0106] in, is an estimate of the initial clock offset, is the estimate of the initial relative frequency offset. This is the state quantity at the beginning of filtering, usually given by the first observation or prior knowledge.

[0107] Initial state covariance matrix:

[0108]

[0109] in, is the variance (uncertainty) of the initial clock offset estimate, is the variance (uncertainty) of the initial relative frequency offset estimate, which can be determined a priori. The initial state covariance matrix represents the uncertainty of the initial state estimate. Typically, large initial uncertainties lead to larger variance values. Off-diagonal elements of 0 indicate no correlation between the two variables in the initial state.

[0110] Secondly, enter the prediction stage, which is to update the time.

[0111] State prediction equation:

[0112]

[0113] in, It is the prior state estimator at time k, that is, the estimate (i.e., prediction) of the state quantity at time k based on the state quantity at time k-1 and before. is the a posteriori state estimate at time k-1, that is, obtained after the state update at time k-1. As mentioned above, F is the preset first state transition matrix. Its meaning is: based on the state estimate at the previous time, the state transition matrix F is used to predict the state at the current time, i.e., the predicted value. Specifically, the predicted clock offset ΔT is the clock offset at the previous time plus the offset caused by the frequency offset. The predicted frequency offset Δf remains unchanged (because the frequency offset is assumed to be constant over a short period of time).

[0114] Covariance prediction equation:

[0115]

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

[0117]

[0118] in, is the process noise variance of the clock offset, is the process noise variance relative to the frequency offset. The process noise covariance Q represents the uncertainty in the estimated state at the current moment. It represents the uncertainty caused by model imperfections (for example, the frequency offset may not be strictly constant) and external interference during the state transition process.

[0119] Next, we enter the update phase, which is to perform measurement updates.

[0120] Calculate the Kalman gain:

[0121]

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

[0123]

[0124] in, is the measurement noise variance of the clock offset, is the measurement noise variance relative to the frequency offset. The measurement noise covariance R means that the Kalman gain determines the influence of the observation on the state update. When the measurement noise covariance R is large, the Kalman gain will become smaller, that is, the prediction will be more trusted; when the uncertainty of the prediction is large, the Kalman gain will become smaller. When it is large, the Kalman gain will become larger, that is, the observation will be more trusted.

[0125] State update equation:

[0126]

[0127] in, is the posterior state estimate at time k (i.e., the state estimate after integrating the observations at the current moment), is the observed quantity at time k. To measure the residual, also called innovation, is the difference between the actual observation and the estimated value of the predicted state. The meaning of is to use the current observation to correct the estimated value (predicted value) of the state quantity. By weighting the measurement residual to update the predicted value through the Kalman gain, a more accurate estimate of the state quantity can be obtained.

[0128] Covariance update equation:

[0129]

[0130] in, is the covariance matrix of the posterior state estimate at time k, is a 2×2 identity matrix, The meaning of is to update the uncertainty of the state estimate. Due to the introduction of observations, the uncertainty of the state is usually reduced.

[0131] Finally, the filtered output is performed.

[0132] Drift rate after filtering: (i.e., the second term in the a posteriori state estimate at time k), which is also the required first local clock drift rate; the filtered clock offset: (i.e., the first item in the posterior state estimate at time k).

[0133] Based on this, time-lapse iteration can be continuously performed to obtain the first local clock drift rate at each moment.

[0134] It is understandable that the second external time source state, the second local clock drift rate and the second hardware clock level of the vehicle terminal can also be determined through the same steps as above, which will not be described in detail here.

[0135] S220 : Perform weighted summation on 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 terminals to obtain mobile terminal credibility.

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

[0137] Specifically, the first weight coefficients corresponding to the paired mobile terminals are multiplied by the first external time source state, the inverse of the first local clock drift rate, and the first hardware clock level, and the sum of the products is used as the mobile terminal credibility.

[0138] For example, the mobile terminal credibility is calculated using the following formula:

[0139]

[0140] in, For mobile credibility, is the state of the first external time source, is the first local clock drift rate, is the first hardware clock level, 、 as well as are the first weight coefficients corresponding to the paired mobile terminals, 、 as well as Both are evaluation values ​​and can be used to evaluate the credibility of mobile terminals.

[0141] S230 , performing weighted summation on the second external time source state, the inverse of the second local clock drift rate, and the second hardware clock level according to the second weight coefficients corresponding to the vehicle-side, to obtain the vehicle-side credibility.

[0142] 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.

[0143] Specifically, the second weight coefficients corresponding to the vehicle side are 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 vehicle side credibility.

[0144] For example, the vehicle-side credibility is calculated using the following formula:

[0145]

[0146] in, For the credibility of the car machine, For the second external time source state, is the second local clock drift rate, For 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.

[0147] Based on the above example, before obtaining the mobile terminal credibility by performing weighted summation on 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, the first weight coefficients and the second weight coefficients may be dynamically determined. Specifically, the weight coefficients may be:

[0148] Inputting the device type, first external time source status, 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-built dynamic weight model to obtain first weight coefficients corresponding to the paired mobile terminal;

[0149] 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.

[0150] Device types include mobile devices and vehicle-mounted devices. The first short-term clock jitter variance is the variance of the fluctuation or change of the clock signal of the paired mobile device relative to its ideal position over a preset short period of time. The first signal strength is the signal strength of the clock signal of the paired mobile device. The second short-term clock jitter variance is the variance of the fluctuation or change of the clock signal of the vehicle-mounted device relative to its ideal position over a preset short period of time. The second signal strength is the signal strength of the clock signal of the vehicle-mounted device. The dynamic weight model is a pre-established neural network model used to calculate weight coefficients. The dynamic weight model is a neural network model with two fully connected layers as hidden layers. The training data for the dynamic weight model includes data from simulated scenarios (tunnels, urban canyons, and high-speed traffic). The labels are manually annotated optimal master and slave roles. Furthermore, the model can be compressed, for example, by quantizing it to 8-bit integers using TensorFlow Lite (an open source deep learning framework), so that the model size is less than a preset size (e.g., 50KB). To meet the real-time requirements of the vehicle, the inference latency must be less than a preset latency (e.g., 5ms).

[0151] Optionally, when the weight update cycle is reached or the environment suddenly changes, data can be retrieved, the dynamic weight model can be run, and the first weight coefficients and the second weight coefficients can be updated.

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

[0153] The reliability difference is the absolute value of the difference between the reliability of the vehicle terminal and the reliability of the mobile terminal. The preset threshold is used to determine whether there is a significant difference in the reliability of the clocks of the vehicle terminal and the paired mobile terminal.

[0154] S250 , determining the master and slave roles of the vehicle-side according to the credibility of the mobile terminal and the credibility of the vehicle-side, and executing S270 .

[0155] Specifically, if the credibility difference is greater than the preset threshold, it means that there is a significant difference in the clock credibility of the vehicle terminal and the paired mobile terminal. Therefore, the master-slave role can be determined according to the credibility. That is, if the credibility of the vehicle terminal is greater than the credibility of the mobile terminal, the master-slave role of the vehicle terminal is determined to be the master role. If the credibility of the vehicle terminal is less than the credibility of the mobile terminal, the master-slave role of the vehicle terminal is determined to be the slave role.

[0156] S260 , determining the master-slave role of the vehicle-side according to the first hardware clock level of the mobile terminal and the second hardware clock level of the vehicle-side, and executing S270 .

[0157] Specifically, if the credibility difference is not greater than the preset threshold, it means that the clocks of the vehicle terminal and the paired mobile terminal have little difference in short-term dynamic performance. Therefore, the hardware clock level is used as the core indicator of long-term stability, and the end with a higher hardware clock level is used as the master role, and the other end as the slave role. That is, if the first hardware clock level is greater than or equal to the second hardware clock level, the master-slave role of the vehicle terminal is determined to be the master role; if the first hardware clock level is less than the second hardware clock level, the master-slave role of the vehicle terminal is determined to be the slave role.

[0158] S270 : In response to the vehicle terminal being in a slave role, receiving a synchronization request message and a first sending timestamp sent by the paired mobile terminal, and determining a first arrival timestamp.

[0159] The synchronization request message is a message sent by the paired mobile terminal to the vehicle terminal for time synchronization. The first sending timestamp is the timestamp when the paired mobile terminal sends the synchronization request message. The first arrival timestamp is the timestamp when the synchronization request message arrives at the vehicle terminal.

[0160] Specifically, if the vehicle-side is in a slave role, it needs to synchronize time with the vehicle-side through the paired mobile terminal. Therefore, the paired mobile terminal will send the synchronization request message and the first sending timestamp to the vehicle-side, and the vehicle-side also needs to record the first arrival timestamp when the synchronization request message is received.

[0161] S280. Determine a response message corresponding to the synchronization request message based on the first arrival timestamp, and send the response message and the second sending timestamp to the paired mobile terminal, so that the paired mobile terminal determines the second arrival timestamp when receiving the response message and the second sending timestamp, and determines the time offset based on the first sending timestamp, the first arrival timestamp, the second sending timestamp and the second arrival timestamp, and sends the time offset to the vehicle terminal.

[0162] The response message is a response to the synchronization request message and includes a first arrival timestamp. The second sending timestamp is the timestamp when the vehicle-side sends the response message. The second arrival timestamp is the timestamp when the response message arrives at the paired mobile terminal.

[0163] Specifically, at the vehicle computer end, the first arrival timestamp is written into the response message corresponding to the synchronization request message, and the response message and the second sending timestamp when the response message is sent are sent to the paired mobile terminal. When the paired mobile terminal receives the response message and the second sending timestamp, it records the second arrival timestamp of the received response message. The difference between the second arrival timestamp and the first sending timestamp can be used as the full time, the difference between the second sending time and the first arrival timestamp can be used as the message generation time, and the difference between the full time and the message generation time can be used as the round-trip time. The difference between the first arrival timestamp and the first sending timestamp and then half of the round-trip time is subtracted from the first arrival timestamp to obtain the time offset, and the time offset is sent to the vehicle computer end.

[0164] For example, the paired mobile terminal sends a synchronization request message and records the first sending timestamp T m1 ; The vehicle receives the synchronization request message and records the first arrival timestamp T s1 The vehicle terminal responds with a response message (including T s1 ), record the second sending timestamp T s2 ; The paired mobile terminal receives the response message and records the second arrival timestamp T m2 The round trip time R can be calculated by the following formula tt :R tt =(T m2 -T m1 )-(T s2 -T s1 ). Then, the time offset is calculated by the following formula : =T s1 -T m1 -R tt / 2.

[0165] S290: Receive the time offset sent by the paired mobile terminal, and synchronize the time of the vehicle terminal according to the time offset.

[0166] Existing vehicle time synchronization solutions are prone to interruption in special scenarios. This solution ensures the proper functioning of safety systems like ADAS in complex environments like tunnels and underground garages, avoiding risks such as delayed automatic emergency braking due to loss of the time reference. This effectively reduces the incidence of traffic accidents, ensures the safety of drivers and passengers, and improves driving safety. Furthermore, it resolves the issue of timestamp confusion in vehicle log systems, making accident evidence collection more accurate and convenient. Furthermore, it ensures the stability of vehicle-cloud collaborative services, allowing users to enjoy more efficient and reliable intelligent connected car services, such as remote diagnostics, thereby improving user satisfaction and trust.

[0167] Current synchronization solutions struggle to meet the millisecond-level synchronization requirements of high-level autonomous driving. The aforementioned technology provides a precise time synchronization foundation for functions such as ADAS and vehicle-cloud collaboration, helping advance intelligent driving technology towards a more accurate and reliable stage, accelerating its widespread application and driving industry development. Furthermore, a dynamic switching logic for multiple time bases is designed, utilizing multiple redundant timing solutions, such as a stable clock source from a passenger's mobile phone. This eliminates the risk of a single point of failure causing global time synchronization failure, improves the reliability of vehicle subsystem collaboration, and ensures stable vehicle functionality during long-term operation and complex environments. A unified local synchronization protocol is provided to resolve timestamp inconsistencies between the vehicle's computer and onboard devices such as mobile phones and T-Boxes, improve the accuracy of multi-sensor fusion algorithms, and promote interoperability among diverse devices within the automotive industry. This will drive technological upgrades and innovation across the industry, laying the foundation for building a smart car ecosystem. This automated and intelligent vehicle time synchronization eliminates the need for manual user intervention or awareness, further enhancing vehicle intelligence and user experience. During vehicle operation, the time synchronization system automatically adapts to various environmental and network conditions, performing real-time and accurate time calibration and synchronization, ensuring the normal operation and coordination of various vehicle functions and providing strong support for the development of intelligent driving and the Internet of Vehicles.

[0168] Contactless time synchronization technology not only optimizes current vehicle functions but also provides technical support for a wider range of future intelligent transportation system applications. For example, in scenarios such as vehicle-road collaboration and Internet of Vehicles (IoV), precise time synchronization is key to efficient data exchange and coordinated control. Through contactless time synchronization, vehicles can seamlessly synchronize time and share data with roadside infrastructure and other vehicles, improving traffic efficiency, reducing congestion, and enhancing the operational efficiency and safety of the entire transportation system, creating greater value for the development of intelligent transportation.

[0169] The time synchronization method provided in the embodiment of the present application obtains the mobile terminal credibility by weightedly 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, and obtains the vehicle terminal credibility by weightedly summing the second external time source state, the inverse of the second local clock drift rate and the second hardware clock level according to the second weight coefficients corresponding to the vehicle terminal, so as to consider multiple factors to evaluate the clock credibility of both ends, and then determine the absolute value of the difference between the vehicle terminal credibility and the mobile terminal credibility as the credibility difference, and judge whether the credibility difference is greater than a preset threshold. If so, determine the master and slave roles of the vehicle terminal according to the mobile terminal credibility and the vehicle terminal 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 higher hardware clock level is used as the master role and the other end is used as the slave role. In response to the vehicle-machine end being a slave role, it receives the synchronization request message and the first sending timestamp sent by the paired mobile end, determines the first arrival timestamp, determines the response message corresponding to the synchronization request message based on the first arrival timestamp, and sends the response message and the second sending timestamp to the paired mobile end, so that the paired mobile end determines the second arrival timestamp when receiving the response message and the second sending timestamp, and determines the time offset based on the first sending timestamp, the first arrival timestamp, the second sending timestamp and the second arrival timestamp, and sends the time offset to the vehicle-machine end, receives the time offset sent by the paired mobile end, and synchronizes the vehicle-machine end according to the time offset, so as to more accurately synchronize the time across devices, thereby achieving an accurate assessment of the reliability of the clocks at both ends, and having more levels of consideration for the determination of the master-slave roles, and being able to accurately calculate the time offset, effectively improving the accuracy of the vehicle-machine end time synchronization.

[0170] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 3 As shown, the electronic device 300 includes one or more processors 301 and a memory 302 .

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

[0172] The memory 302 may include one or more computer program products, which 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. The non-volatile memory may include, for example, read-only memory (ROM), a hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 301 may execute 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 external parameters and thresholds may also be stored in the computer-readable storage medium.

[0173] In one example, electronic device 300 may further include an input device 303 and an output device 304, which are interconnected via a bus system and / or other connection mechanisms (not shown). Input device 303 may include, for example, a keyboard, a mouse, etc. Output device 304 may output various information to the outside, including warning information, braking force, etc. Output device 304 may include, for example, a display, a speaker, a printer, a communication network, and remote output devices connected thereto.

[0174] Of course, to simplify, Figure 3 Only some of the components related to the present application in the electronic device 300 are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, the electronic device 300 may further include any other appropriate components according to specific application scenarios.

[0175] 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, which, when executed by a processor, enable the processor to execute the steps of the time synchronization method provided by any embodiment of the present application.

[0176] The computer program product may be written in any combination of one or more programming languages ​​to implement the program code for performing the operations of the embodiments of the present application, including object-oriented programming languages ​​such as Java, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0177] In addition, an embodiment of the present application may also be a computer-readable storage medium having computer program instructions stored thereon. When the computer program instructions are executed by a processor, the processor executes the steps of the time synchronization method provided by any embodiment of the present application.

[0178] The computer-readable storage medium may be any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may include, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media 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 thereof.

[0179] It should be noted that the terms used in this application are only for describing specific embodiments and are not intended to limit the scope of this application. As shown in the specification and claims of this application, unless the context clearly indicates an exception, the words "one", "an", "a kind of" and / or "the" do not specifically refer to the singular and may also include the plural. The terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method or device. In the absence of further restrictions, the elements defined by the sentence "comprise a..." do not exclude the presence of other identical elements in the process, method or device comprising the elements.

[0180] It should also be noted that the terms "center", "up", "down", "left", "right", "vertical", "horizontal", "inside", "outside", etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on this application. Unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", etc. should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or an indirect connection through an intermediate medium, or it can be a communication between the internal parts of two elements. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood according to specific circumstances.

[0181] This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core ideas of this application. The above is only the preferred implementation method of this application. It should be pointed out that due to the limitations of textual expression, there are objectively infinite specific structures. For ordinary technicians in this technical field, without departing from the principles of the present invention, they can also make several improvements, modifications or changes, and can also combine the above technical features in an appropriate manner; these improvements, modifications, changes or combinations, or the direct application of the inventive concept and technical solution to other occasions without improvement, should be regarded as the scope of protection of this application.

Claims

1. A time synchronization method, characterized in that: Applied to the vehicle side, including: In response to completing the Bluetooth connection with the paired mobile terminal, obtaining first credibility source data corresponding to the paired mobile terminal through the Bluetooth connection; Determining the credibility of the mobile terminal based on the first credibility source data, and determining the credibility of the vehicle terminal based on the second credibility source data of the vehicle terminal; Determining the master and slave roles of the vehicle-side terminal according to the credibility of the mobile terminal and the credibility of the vehicle-side terminal; In response to the vehicle terminal being in a slave role, determining a time offset between the paired mobile terminal and the vehicle terminal, and performing time synchronization on the vehicle terminal according to the time offset; The first credibility source data includes a first external time source state, a first local clock drift rate, and a first hardware clock level; Obtaining first credibility source data corresponding to the paired mobile terminal includes: In response to the paired mobile terminal synchronizing with the external time source within the preset synchronization time, determining the first external time source state to be 1; otherwise, determining the first external time source state to be 0; Based on the Kalman filter algorithm, the state quantity at the current moment is determined according to the state quantity at the previous moment, the observation quantity at the current moment, the preset first state transfer matrix, the preset process noise matrix, the preset second state transfer matrix and the preset measurement noise matrix; the state quantity includes time offset and relative frequency deviation; Determine the relative frequency deviation in the state quantity at the current moment as the first local clock drift rate; A first hardware clock level is determined according to a hardware clock type corresponding to the paired mobile terminal.

2. The method according to claim 1, characterized in that The second credibility source data includes a second external time source state, a second local clock drift rate, and a second hardware clock level; Determining the credibility of the mobile terminal according to the first credibility source data, and determining the credibility of the vehicle terminal according to the second credibility source data of the vehicle terminal, including: According to each first weight coefficient corresponding to the paired mobile terminal, weighted summation is performed on the first external time source state, the inverse of the first local clock drift rate, and the first hardware clock level to obtain the mobile terminal credibility; According to the second weight coefficients corresponding to the vehicle computer end, the second external time source state, the inverse of the second local clock drift rate, and the second hardware clock level are weighted and summed to obtain the vehicle computer end credibility.

3. The method according to claim 2, characterized in that Before obtaining the mobile terminal credibility, the method further includes: performing weighted summation of 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 terminals to obtain the mobile terminal credibility; Inputting the device type, first external time source status, 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-built dynamic weight model to obtain 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 vehicle-side into the dynamic weight model to obtain the second weight coefficients corresponding to the vehicle-side; 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 Determining the master and slave roles of the vehicle-side terminal according to the credibility of the mobile terminal and the credibility of the vehicle-side terminal includes: Determine the absolute value of the difference between the vehicle-side credibility and the mobile-side credibility as the credibility difference; In response to the credibility difference being greater than a preset threshold, determining the master and slave roles of the vehicle-side terminal according to the credibility of the mobile terminal and the credibility of the vehicle-side terminal; In response to the credibility difference being less than or equal to the preset threshold, the master-slave role of the vehicle terminal is determined according to the first hardware clock level of the mobile terminal and the second hardware clock level of the vehicle terminal.

5. The method according to claim 1, characterized in that Determining the time offset between the paired mobile terminal and the vehicle terminal includes: Receiving a synchronization request message and a first sending timestamp sent by the paired mobile terminal; Determine a first arrival timestamp, determine a response message corresponding to the synchronization request message based on the first arrival timestamp, and send the response message and the second sending timestamp to the paired mobile terminal, so that the paired mobile terminal determines the second arrival timestamp when receiving the response message and the second sending timestamp, and determines a time offset based on the first sending timestamp, the first arrival timestamp, the second sending timestamp, and the second arrival timestamp, and sends the time offset to the vehicle terminal; Receive the time offset sent by the paired mobile terminal.

6. The method according to claim 1, characterized in that After responding that the vehicle-mounted terminal is in a slave role, the method further includes: In response to receiving a heartbeat packet sent by the paired mobile terminal, determining a local timestamp; wherein the heartbeat packet includes a current timestamp; Determining an instantaneous offset according to the local timestamp and the current timestamp; In response to the instantaneous offset being greater than the calibration timestamp difference for a consecutive preset number of times, the process returns to the step of obtaining the first credibility source data corresponding to the paired mobile terminal.

7. The method according to claim 1, characterized in that After responding that the vehicle machine end is in a slave role, the method further includes: In response to the Bluetooth connection being disconnected, the vehicle computer time is updated according to the local clock cache, and the Bluetooth connection is re-established. If the Bluetooth connection is not established within a preset time, the vehicle computer time is updated based on the vehicle crystal oscillator clock, and a Bluetooth disconnection warning message is generated; In response to not receiving a heartbeat packet sent by the paired mobile terminal within a preset number of consecutive cycles, returning to the step of determining a time offset between the paired mobile terminal and the vehicle terminal, and performing time synchronization on the vehicle terminal according to the time offset; if time synchronization is not completed, determining that the vehicle terminal is the master role; In response to receiving the resynchronization information sent by the paired mobile terminal, the process returns to executing the step of determining the time offset between the paired mobile terminal and the vehicle terminal, and performing time synchronization on the vehicle terminal according to the time offset; wherein the resynchronization information is generated when there is a time jump in the paired mobile terminal.

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

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a program or instructions, which enable a computer to execute the steps of the time synchronization method according to any one of claims 1 to 7.

Citation Information

Patent Citations

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

    CN114244465A