Abstract:
Disclosed are a time synchronization method and system using WiFi-direct. The method comprises: a master control device obtaining from a base station standard date and time information used for time synchronization; establishing a WiFi-Direct connection between the master control device and a slave device; in accordance with an active manner, the slave device obtaining a time synchronization manner or a passive reception time synchronization manner, and obtaining the standard date and time information from the master control device through the WiFi-Direct connection; and the slave device calculating an actual standard date and time with the influence of transmission time delay eliminated using the standard date and time information, and setting a system date and time thereof using the actual standard date and time. The master control device of the present invention transmits to each slave device standard date and time information obtained from a base station through Wi-Fi Direct to enable each slave device to achieve time synchronization.

Description:
TECHNICAL FIELD 
       [0001]    The disclosure relates to time synchronization technology, and more particularly to a method and system for time synchronization by WiFi-direct. 
       BACKGROUND 
       [0002]    With continuous development of wireless communication technology and rapid popularization of smart phones, a mobile phone has been defined as a modern-life necessity. Generally speaking, a mobile phone not only serves for conventional voice communication, but can also provide various information services, including receiving information on the standard date and time from a base station and displaying the received information on the standard date and time via a display device such as an LCD. 
         [0003]    Modern people usually own many digital products such as a notebook computer, a digital camera, a digital photo frame, and the like. The system date and time of such a product has to be set manually. 
         [0004]    As stated, a mobile phone can display information on the standard date and time received from a base station only on a local screen, but cannot pass the standard date and time on to another device. Therefore, to display correct date and time information on each digital device, a user has to manually set system date and time for each digital device, which causes great inconvenience to the user. 
       SUMMARY 
       [0005]    Embodiments of the disclosure provide a method and system for time synchronization by WiFi-direct, capable of setting system date and time of a digital device automatically, simplifying user operation and improving user experience. 
         [0006]    According to an aspect of the disclosure, a method for time synchronization by WiFi-direct includes steps of: 
         [0007]    acquiring, by a master device, information on standard date and time from a base station for time synchronization; 
         [0008]    establishing a WiFi-direct connection between the master device and a slave device; 
         [0009]    acquiring, by the slave device, the information on the standard date and time actively or passively from the master device through the WiFi-direct connection; and 
         [0010]    calculating, by the slave device, actual standard date and time without the impact of a transmission delay using the information on the standard date and time, and setting local system date and time as the actual standard date and time. 
         [0011]    In an embodiment, the step of acquiring, by the slave device, the information on the standard date and time actively may include steps of: 
         [0012]    sending, by the slave device, a time synchronization request to the master device through the WiFi-direct connection to request for the standard date and time, wherein the time synchronization request contains a time stamp of sending the time synchronization request; 
         [0013]    receiving, by the slave device, a time synchronization response sent by the master device in response to the time synchronization request, and acquiring a time stamp of receiving the time synchronization response; and 
         [0014]    analyzing, by the slave device, the time synchronization response, and extracting the information on the standard date and time as well as the time stamp of sending the time synchronization request contained in the time synchronization response. 
         [0015]    In an embodiment, the step of calculating, by the slave device, actual standard date and time without the impact of a transmission delay using the information on the standard date and time may include steps of: 
         [0016]    calculating, by the slave device, the transmission delay according to the time stamp of receiving the time synchronization response and the time stamp of sending the time synchronization request; and 
         [0017]    acquiring, by the salve device, the actual standard date and time by adding the transmission delay to the standard date and time. 
         [0018]    In an embodiment, the step of acquiring, by the slave device, the information on the standard date and time passively may include steps of: 
         [0019]    calculating, by the master device, the transmission delay according to information interaction during establishment of the WiFi-direct connection of the master device with the slave device; 
         [0020]    generating, by the master device, a time synchronization message containing information on the transmission delay and the standard date and time, and sending the time synchronization message to the slave device; and 
         [0021]    after receiving the time synchronization message, extracting, by the slave device, the information on the transmission delay and the standard date and time. 
         [0022]    In an embodiment, the step of calculating, by the slave device, actual standard date and time without the impact of a transmission delay using the information on the standard date and time may include a step of: 
         [0023]    acquiring, by the salve device, the actual standard date and time by adding the transmission delay to the standard date and time. 
         [0024]    In an embodiment, the master device may be a phone mobile, and the slave device may be a digital device. 
         [0025]    According to another aspect of the disclosure, a system for time synchronization by WiFi-direct includes a master device and a slave device connected via a WiFi-direct connection, where 
         [0026]    the master device is configured for acquiring information on standard date and time from a base station for time synchronization; and 
         [0027]    the slave device is configured for: acquiring the information on the standard date and time actively or passively from the master device through the WiFi-direct connection; calculating actual standard date and time without the impact of a transmission delay using the information on the standard date and time; and setting local system date and time as the actual standard date and time. 
         [0028]    In an embodiment, the slave device may include: 
         [0029]    a wireless transceiver configured for sending a time synchronization request to the master device through the WiFi-direct connection to request for the standard date and time, and receiving a time synchronization response sent by the master device in response to the time synchronization request, wherein the time synchronization request contains a time stamp of sending the time synchronization request; 
         [0030]    a time extracting unit configured for acquiring a time stamp of receiving the time synchronization response; and 
         [0031]    an analyzing unit configured for analyzing the time synchronization response to extract the information on the standard date and time as well as the time stamp of sending the time synchronization request contained in the time synchronization response. 
         [0032]    In an embodiment, the slave device may include: 
         [0033]    a time calculating unit configured for calculating the transmission delay according to the time stamp of receiving the time synchronization response and the time stamp of sending the time synchronization request, and acquiring the actual standard date and time by adding the transmission delay to the standard date and time; and 
         [0034]    a time adjusting unit configured for setting the local system date and time as the actual standard date and time. 
         [0035]    In an embodiment, the master device may include: 
         [0036]    a transmission delay calculating unit configured for calculating the transmission delay according to information interaction during establishment of the WiFi-direct connection of the master device with the slave device; 
         [0037]    a message generating unit configured for generating a time synchronization message containing information on the transmission delay and the standard date and time; and 
         [0038]    a wireless transceiver configured for sending the time synchronization message to the slave device. 
         [0039]    In an embodiment, the message generating unit may be further configured for generating the time synchronization response in response to the time synchronization request. 
         [0040]    Based on the method and system for time synchronization by WiFi-direct described herein, a master device transmits information on standard date and time acquired from a base station to a slave device by Wi-Fi Direct, achieving time synchronization among slave devices, simplifying user operation and improving user experience. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0041]      FIG. 1  is a block diagram of a method for time synchronization by WiFi-direct according to an embodiment of the disclosure; 
           [0042]      FIG. 2  is a schematic diagram of a PDU format of a time synchronization response for active time synchronization according to an embedment of the disclosure; 
           [0043]      FIG. 3  is a is a schematic diagram of a PDU format of a time synchronization response for active time synchronization with an additional information field according to an embedment of the disclosure; 
           [0044]      FIG. 4  is a schematic diagram of a PDU format of a time synchronization message for passive time synchronization according to an embedment of the disclosure; 
           [0045]      FIG. 5  is a schematic diagram of a PDU format of a time synchronization message for passive time synchronization with an additional information field according to an embedment of the disclosure; 
           [0046]      FIG. 6  is a flowchart of active time synchronization according to an embodiment of the disclosure; and 
           [0047]      FIG. 7  is a flowchart of passive time synchronization according to an embodiment of the disclosure. 
       
    
    
     DETAILED DESCRIPTION 
       [0048]    Embodiments of the disclosure are elaborated below with reference to drawings. Note that the embodiments described below are merely illustrative and explanative and are not to be construed as limiting the disclosure. 
         [0049]    In embodiments of the disclosure, a master device (e.g. a mobile phone) receives information on standard date and time from a base station and transmits the received information to a plurality of slave devices (i.e. digital devices other than the master device) by WiFi-direct, such that each of the slave devices may modify local date and time as actual standard date and time. 
         [0050]    Embodiments of the disclosure have technical merits as follows. 
         [0051]    First, a mobile phone featured by WiFi-direct may extracts information on local date and time and transmits the extracted information to another digital device such that date and time on the other digital device may be synchronized with those on the mobile phone. 
         [0052]    Second, in sharing time information by two devices, time required for transmitting the time information between the two devices is taken into account, allowing clock calibration to be as accurate as possible. 
         [0053]    As digital devices differ in data processing capacity (for example, data processing capacity of a notebook computer is greater than that of a digital photo frame), time synchronization may be performed actively or passively for a slave device depending on local data processing capacity. 
         [0054]      FIG. 1  is a block diagram of a method for time synchronization by WiFi-direct according to an embodiment of the disclosure. As shown in  FIG. 1 , the method includes steps as follows. 
         [0055]    In Step S 101 , a master device acquires, from a base station, information on standard date and time for time synchronization. 
         [0056]    In Step S 102 , a WiFi-direct connection is established between the master device and a slave device. 
         [0057]    In Step S 103 , the slave device acquires the information on the standard date and time actively or passively from the master device through the WiFi-direct connection. 
         [0058]    The slave device may acquire the information on the standard date and time actively by: sending a time synchronization request to the master device through the WiFi-direct connection to request for the standard date and time, where the time synchronization request contains a time stamp of sending the time synchronization request; receiving a time synchronization response (in a format as shown in  FIG. 2  or  FIG. 3 ) sent by the master device in response to the time synchronization request, and acquiring a time stamp of receiving the time synchronization response; and analyzing the time synchronization response to extract the information on the standard date and time as well as the time stamp of sending the time synchronization request contained in the time synchronization response. 
         [0059]    The slave device may acquire the information on the standard date and time passively by: calculating, by the master device, the transmission delay according to information interaction during establishment of the WiFi-direct connection of the master device with the slave device; generating, by the master device, a time synchronization message (in a format as shown in  FIG. 4  or  FIG. 5 ) containing information on the transmission delay and the standard date and time, and sending the time synchronization message to the slave device; and after receiving the time synchronization message, extracting, by the slave device, the information on the transmission delay and the standard date and time. 
         [0060]    In Step S 104 , the slave device calculates actual standard date and time without the impact of a transmission delay using the information on the standard date and time, and sets local system date and time as the actual standard date and time. 
         [0061]    After acquiring the information on the standard date and time actively, the slave device may calculate the transmission delay according to the time stamp of receiving the time synchronization response and the time stamp of sending the time synchronization request; and acquire the actual standard date and time by adding the transmission delay to the standard date and time. 
         [0062]    After acquiring the information on the standard date and time passively, the slave device may acquire the actual standard date and time by adding the transmission delay to the standard date and time. 
         [0063]    That is, in active time synchronization, a mobile phone receiving information on the standard date and time from a base station serves as a master device while other digital devices serve as slave devices. A WiFi-direct connection is then established between a slave device and the master device; the slave device applies for information on the standard date and time from the master device, and after receiving the information on the standard date and time, calculates the transmission delay and then the actual standard date and time. The slave device then standardizes the local system date and time using the actual standard date and time. In passive time synchronization, a mobile phone receiving information on the standard date and time from a base station serves as a master device while other digital devices serve as slave devices. A WiFi-direct connection is then established between a slave device and the master device; the master device calculates the transmission delay according to information interaction (PDU interaction) during the establishment of the Wi-Fi Direct connection, sends information on the standard date and time as well as that on the transmission delay to the slave device; the slave device calculates actual standard date and time using the information sent by the master device, and sets the local system date and time to be the actual standard date and time. 
         [0064]    In an embodiment, in passive time synchronization, the master device calculates the transmission delay according to PDU interaction during the establishment of the WiFi-direct connection. Information interaction between the master device and the slave device is all based on a request-response mode. The transmission delay may be acquired by calculating the difference between the time of receiving the response PDU and the time of sending the request PDU and then dividing the difference by 2. For example, a premise for performing time synchronization is the establishment of a WiFi-direct connection between the master device and the slave device. In establishing the connection, the master device has to send the slave device a ConnectionEstablishRequest PDU containing any parameter necessary for establishing the connection. The slave device returns a ConnectionEstablishSetup PDU to the master device, indicating successful establishment of the connection. The master device records the time stamp of sending the ConnectionEstablishRequest PDU and the time stamp of receiving the ConnectionEstablishSetup PDU, and acquires the transmission delay by calculating the difference between the two time stamps and then dividing the difference by 2. 
         [0065]      FIG. 2  is a schematic diagram of a PDU format of a time synchronization response for active time synchronization according to an embedment of the disclosure. As shown in  FIG. 2 , the format includes a message type field, a mobile phone date field, a mobile phone time field and a message sending time field. 
         [0066]    The message type field is configured for distinguishing a time synchronization operation from another operation. 
         [0067]    The mobile phone date is the standard date a mobile phone receives from a base station. 
         [0068]    The mobile phone time is the standard time the mobile phone receives from the base station. 
         [0069]    The message sending time field indicates the time when the slave device sends the time synchronization request PDU, and contains the time for calculating the transmission delay for calculating the actual standard time. 
         [0070]      FIG. 3  is a schematic diagram of a PDU format of a time synchronization response for active time synchronization with an additional information field according to an embedment of the disclosure. The format differs from that shown in  FIG. 2  in that the format shown in  FIG. 3  used in active time synchronization may have an additional information field as needed to facilitate synchronizing system date and time. For example, content in the additional information field enables more accurate time synchronization. Such information field addition falls within the protection scope of the disclosure. 
         [0071]      FIG. 4  is a schematic diagram of a PDU format of a time synchronization message for passive time synchronization according to an embedment of the disclosure. As shown in  FIG. 4 , the format includes a message type field, a mobile phone date field, a mobile phone time field and a delay field. 
         [0072]    The message type field is configured for distinguishing a time synchronization operation from another operation. 
         [0073]    The mobile phone date is the standard date a mobile phone receives from a base station. 
         [0074]    The mobile phone time is the standard time the mobile phone receives from the base station. 
         [0075]    The delay field includes the transmission delay in transmitting a PDU in interaction between a master device and a slave device. The transmission delay is calculated by the master device according to PDU interaction during establishment of the WiFi-direct connection. 
         [0076]      FIG. 5  is a schematic diagram of a PDU format of a time synchronization message for passive time synchronization with an additional information field according to an embedment of the disclosure. The format differs from that shown in  FIG. 4  in that the format shown in  FIG. 5  used in passive time synchronization may have an additional information field as needed to facilitate synchronizing system date and time. For example, content in the additional information field enables more accurate time synchronization. Such information field addition falls within the protection scope of the disclosure. 
         [0077]      FIG. 6  is a flowchart of active time synchronization according to an embodiment of the disclosure. As shown in  FIG. 6 , the flow of active time synchronization may include steps as follows. 
         [0078]    In Step S 601 , a master device or a slave device searches for the other device and establishes a WiFi-direct connection with the found device. 
         [0079]    In Step S 602 , the slave device sends the master device a time synchronization request using a time setting application to apply for information on standard date and time. 
         [0080]    In Step S 603 : the slave device detects whether a time synchronization response is received; Step S 604  is performed when a time synchronization response is received, otherwise when no time synchronization response is received, Step S 602  is performed again. 
         [0081]    In Step S 604 , the slave device extracts, from the time synchronization response, a time stamp of sending the time synchronization request PDU, and combines the extracted time stamp with the time stamp of receiving the time synchronization response PDU to calculate a packet transmission delay. 
         [0082]    In Step S 605 , the slave device extracts the standard data and time as well as the packet transmission delay to obtain actual standard date and time. 
         [0083]    In Step S 606 , the slave device standardizes the local system time using information on the actual standard time. 
         [0084]    In Step S 607 , the slave device extracts information on the actual standard date and standardizes the local system date accordingly. 
         [0085]      FIG. 7  is a flowchart of passive time synchronization according to an embodiment of the disclosure. As shown in  FIG. 7 , the flow of passive time synchronization may include steps as follows. 
         [0086]    In Step S 701 , a master device or a slave device searches for the other device and establishes a WiFi-direct connection with the found device. 
         [0087]    In Step S 702 , the master device calculates a packet transmission delay according to PDU interaction during establishment of the WiFi-direct connection. 
         [0088]    In Step S 703 , the master device constructs a time synchronization message PDU by filling standard date and time acquired by the master device from a base station as well as the transmission delay in the time synchronization message PDU. 
         [0089]    In Step S 704 , the salve device receives the time synchronization message PDU, extracts information on the standard date and time as well as that on the transmission delay to acquire actual standard date and time. 
         [0090]    In Step S 705 , the slave device standardizes the local system time using information on the actual standard time. 
         [0091]    In Step S 706 , the slave device extracts information on the standard date and standardizes the local system date accordingly. 
         [0092]    Embodiments of the disclosure further provide a system for time synchronization by WiFi-direct, including a master device and a slave device connected via a WiFi-direct connection. 
         [0093]    The master device is configured for acquiring information on standard date and time from a base station for time synchronization, and may include a transmission delay calculating unit, a message generating unit and a wireless transceiver. 
         [0094]    The slave device is configured for: acquiring the information on the standard date and time actively or passively from the master device through the WiFi-direct connection; calculating actual standard date and time without the impact of a transmission delay using the information on the standard date and time; and setting local system date and time as the actual standard date and time. The slave device may include a wireless transceiver, a time extracting unit, and an analyzing unit. The slave device may further include a time calculating unit and a time adjusting unit. 
         [0095]    In active time synchronization, a mobile phone receiving information on the standard date and time from a base station serves as a master device while other digital devices serve as slave devices. A WiFi-direct connection is then established between a slave device and the master device. The wireless transceiver of the slave device sends a time synchronization request to the master device through the WiFi-direct connection to request for the standard date and time. The time synchronization request contains a time a time stamp of sending the time synchronization request. At the master device, after the wireless transceiver receives the time synchronization request, the message generating unit generates the time synchronization response in response to the time synchronization request, the wireless transceiver sends the generated time synchronization response to the slave device. At the slave device, after the wireless transceiver receives the time synchronization response sent by the master device in response to the time synchronization request, the time extracting unit acquires the time stamp of receiving the time synchronization response, the analyzing unit analyzes the time synchronization response to extract information on the standard date and time as well as that on the time stamp of sending the time synchronization request contained in the time synchronization response; the time calculating unit calculates the transmission delay according to the time stamp of receiving the time synchronization response and the time stamp of sending the time synchronization request, and acquires the actual standard date and time by adding the transmission delay to the standard date and time; the time adjusting unit sets the local system date and time as the actual standard date and time. 
         [0096]    In passive time synchronization, a mobile phone receiving information on the standard date and time from a base station serves as a master device while other digital devices serve as slave devices. A WiFi-direct connection is then established between a slave device and the master device. At the master device, the transmission delay calculating unit calculates the transmission delay according to information interaction during establishment of the WiFi-direct connection of the master device with the slave device; the message generating unit generates a time synchronization message containing information on the transmission delay and the standard date and time; and the wireless transceiver sends the time synchronization message to the slave device. 
         [0097]    In conclusion, embodiments of the disclosure have technical effects as follows. 
         [0098]    After receiving information on standard date and time from a base station, a mobile phone transmits the received information to a digital device by WiFi-direct, such that the digital device modifies the local date and time as standard date and time, thereby synchronizing local date and time on each digital device with standard date and time, such that a user may make each digital device display standard date and time effortlessly. 
         [0099]    The disclosure is not limited to aforementioned elaboration, and various modifications can be devised by those skilled in the art based on the principle of the disclosure. Any such modification thus should be construed as falling in the protection scope of the disclosure.