Method and device for realizing synchronous sound playback of devices based on wireless communication
By transmitting frame header data and serial numbers between devices for pairing and data transmission, the problem of easy link breakage in BLE wireless communication technology is solved, and stable and reliable data transmission is achieved, avoiding the risk of disconnection.
Patent Information
- Application Number
- CN202410907014.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2044-07-08
AI Technical Summary
The link between the existing BLE wireless communication technology between the host and the slave is susceptible to external interference and disconnection, affecting the stability of data transmission, and re-establishing the link channel.
By transmitting frame header data and serial numbers between devices, device pairing and data transmission are realized, and a special link channel is avoided. 2.4G wireless communication and encrypted data transmission are adopted, and key resolution and CRC verification are used to ensure the data Correctness and uniqueness.
It realizes stable data transmission between devices, avoids the risk of disconnection, and improves the stability and reliability of data transmission.
Smart Images

Figure CN118450486B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of wireless communication technology, and in particular provides a method and device for realizing synchronous sound playback of devices based on wireless communication. Background Art
[0002] Wireless communication is now a standard feature of mobile phone hardware support. Mobile phones can be used to transmit small amounts of data without a controller or a network. In many fields, wireless communication functions are integrated into hardware devices, such as smoke sensors for fire fighting, wireless water and electricity meter reading, wireless selfie sticks, etc. The existing BLE (Broadband Low Energy Communication Technology) wireless communication technology mainly establishes a wireless transmission channel between the host and the slave devices, and the host and the slave transmit data to each other through the wireless transmission channel.
[0003] The wireless transmission channel established between the host and the slave through wireless communication may cause the link between the host and the slave to be disconnected due to external interference, and then the link needs to be re-established. The link between the host and the slave is unstable, affecting the stable transmission of data. Summary of the invention
[0004] The purpose of the present invention is to provide a method for realizing synchronous sound playback of devices based on wireless communication, which does not require the establishment of a link channel for data transmission, and can identify data through frame header data and sequence numbers, thereby realizing stable data transmission.
[0005] In order to achieve the above purpose, this application provides the following technical solutions:
[0006] A method for realizing synchronous sound playback of devices based on wireless communication, wherein data is transmitted between devices by wireless communication, comprising the steps of:
[0007] The first device and the second device are paired by transmitting pairing data by wireless communication, including:
[0008] The first device sends first pairing data, and the first pairing data carries frame header data; the second device receives the first pairing data by scanning, and the data obtained by parsing the first pairing data includes the frame header data;
[0009] The second device sends second pairing data, and the second pairing data carries frame header data; the first device receives the second pairing data by scanning, and the data obtained by parsing the second pairing data includes the frame header data;
[0010] If the frame header data obtained by parsing the first pairing data is consistent with the frame header data obtained by parsing the second pairing data, the first device and the second device are paired successfully;
[0011] After the first device and the second device are successfully paired, sending and receiving data includes:
[0012] Adding frame header data and sequence number to the data sent by the second device;
[0013] The second device sends encrypted data at a predetermined time interval; the first device scans and obtains the encrypted data, the first device parses the encrypted data with a key, verifies the parsed data through CRC, and obtains a serial number in the encrypted data;
[0014] The first device determines whether the received encrypted data includes the frame header data;
[0015] If the received encrypted data does not include the frame header data, the first device filters out the received encrypted data;
[0016] If the received encrypted data includes the frame header data, further determining whether the first device has recorded the serial number in the encrypted data; if the first device has recorded the serial number in the encrypted data, it indicates that the data is repeated, and the first device filters out the encrypted data;
[0017] Otherwise, the encrypted data received by the first device is valid data; the first device records the serial number in the encrypted data and receives the encrypted data;
[0018] The first device and the second device implement synchronous sound playback, including:
[0019] Step S31: The first device sends a play command to the second device; the play command indicates that the first device starts timing from 0 milliseconds and plays the sound after timing to N milliseconds;
[0020] Step S32: The second device receives the play command from the first device, the second device starts timing from 0 milliseconds, and replies to the first device;
[0021] Step S33: The first device receives a reply from the second device. At this time, the timing time of the first device has accumulated from 0 milliseconds to N1 milliseconds, and the first time delay for the first device to send data to the second device is N1 milliseconds;
[0022] Determine whether the first time delay is greater than the first preset time delay, and if the first time delay is greater than the first preset time delay, restart the process from step S31;
[0023] Otherwise, the first device replies the first time delay of N1 milliseconds to the second device;
[0024] Step S34: The second device receives the first time delay data N1 milliseconds replied by the first device; at this time, the timing time of the second device accumulates from 0 milliseconds to N2 milliseconds, and it is determined that the second time delay of the first device replying to the second device is N2 milliseconds;
[0025] Determine whether the second time delay is greater than the second preset time delay, if the second time delay is greater than the second preset time delay, restart from step S31;
[0026] Otherwise, for the second device, play the sound after the timer reaches N milliseconds minus N2 milliseconds.
[0027] Preferably, the first device and the second device that are successfully paired simultaneously send the encrypted data at a predetermined time interval, and the first device automatically filters out the data sent by itself when scanning data to obtain the encrypted data sent by the second device and when the second device scans data to obtain the encrypted data sent by the first device.
[0028] Preferably, the first device and the second device simultaneously send the encrypted data at a predetermined time interval, and the predetermined time interval is 10ms;
[0029] The method for encrypting data is that the first device and the second device respectively use keys to encrypt the original data to be sent to obtain encrypted data.
[0030] Preferably, the first device automatically filters out the data sent by itself when scanning data to obtain the encrypted data sent by the second device and the second device automatically filters out the data sent by itself when scanning data to obtain the encrypted data sent by the first device, specifically:
[0031] The wireless communication method adopted is 2.4G wireless communication; the protocol stack will determine whether it is itself or another device based on the MAC address of each device. When it is the device itself, the first device and the second device will filter out the data sent by themselves accordingly.
[0032] Preferably, the first device scans and obtains the encrypted data, the first device parses the encrypted data with a key, verifies the parsed data through CRC, and obtains the serial number in the encrypted data, wherein the parsing of the encrypted data with a key is specifically as follows:
[0033] The second device encrypts the original data with a key to obtain encrypted data. After the first device obtains the encrypted data, the first device parses the encrypted data with the key used by the second device to encrypt the data to obtain the original data.
[0034] Preferably, the first device scans and obtains the encrypted data, the first device parses the encrypted data with a key, verifies the parsed data through CRC, and obtains a serial number in the encrypted data, wherein obtaining the serial number in the encrypted data is specifically:
[0035] The encrypted data sent all carry a corresponding serial number, and after parsing the encrypted data, the first device obtains the frame header data, the original data and the corresponding serial number.
[0036] On the other hand, a device for realizing synchronous sound playback of devices based on wireless communication, wherein data is transmitted between devices by wireless communication, includes:
[0037] a device pairing module, configured to enable the first device to send first pairing data, wherein the first pairing data includes frame header data; the second device receives the first pairing data by scanning, and the data obtained by parsing the first pairing data includes the frame header data;
[0038] The second device sends second pairing data, and the second pairing data carries frame header data; the first device receives the second pairing data by scanning, and the data obtained by parsing the second pairing data includes the frame header data;
[0039] If the frame header data obtained by parsing the first pairing data is consistent with the frame header data obtained by parsing the second pairing data, the first device and the second device are paired successfully;
[0040] The data receiving and parsing module is used to send and receive data after the first device and the second device are successfully paired, including:
[0041] Adding frame header data and sequence number to the data sent by the second device;
[0042] The second device sends encrypted data at a predetermined time interval; the first device scans and obtains the encrypted data, the first device parses the encrypted data with a key, verifies the parsed data through CRC, and obtains a serial number in the encrypted data;
[0043] The first device determines whether the received encrypted data includes the frame header data;
[0044] If the received encrypted data does not include the frame header data, the first device filters out the received encrypted data;
[0045] If the received encrypted data includes the frame header data, further determining whether the first device has recorded the serial number in the encrypted data; if the first device has recorded the serial number in the encrypted data, it indicates that the data is repeated, and the first device filters out the encrypted data;
[0046] Otherwise, the encrypted data received by the first device is valid data; the first device records the serial number in the encrypted data and receives the encrypted data;
[0047] The synchronous playback module is used to achieve synchronous playback of sound by the first device and the second device, including: step S31: the first device sends a playback command to the second device; the playback command indicates that the first device starts timing from 0 milliseconds and plays the sound after timing to N milliseconds;
[0048] Step S32: The second device receives the play command from the first device, the second device starts timing from 0 milliseconds, and replies to the first device;
[0049] Step S33: The first device receives a reply from the second device. At this time, the timing time of the first device has accumulated from 0 milliseconds to N1 milliseconds, and the first time delay for the first device to send data to the second device is N1 milliseconds;
[0050] Determine whether the first time delay is greater than the first preset time delay, and if the first time delay is greater than the first preset time delay, restart the process from step S31;
[0051] Otherwise, the first device replies the first time delay of N1 milliseconds to the second device;
[0052] Step S34: The second device receives the first time delay data N1 milliseconds replied by the first device; at this time, the timing time of the second device accumulates from 0 milliseconds to N2 milliseconds, and it is determined that the second time delay of the first device replying to the second device is N2 milliseconds;
[0053] Determine whether the second time delay is greater than the second preset time delay, if the second time delay is greater than the second preset time delay, restart from step S31;
[0054] Otherwise, for the second device, play the sound after the timer reaches N milliseconds minus N2 milliseconds.
[0055] The beneficial effects of the present invention are as follows:
[0056] The format of data transmitted between devices is "fixed frame header + sequence number + data". When two devices communicate, they only need to exchange fixed-format frame header data for the first time. When the frame header data of the two devices match, the two devices can communicate without establishing a special link channel. Data transmission is completely based on 2.4G wireless communication. There is no need to establish a link channel for data transmission, so there is no risk of disconnection and the data transmission is stable.
[0057] During data transmission, one device sends data and other devices scan the sent data. After the two devices are paired through frame header data and the fixed data transmission method is determined to be "fixed frame header + serial number + data", the device receiving the data can identify the data through the frame header data and the serial number of the data. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 A flowchart of a method for synchronously playing sound based on wireless communication of the present invention;
[0059] Figure 2 A flow chart of steps for implementing synchronous sound playback for the first device and the second device.
[0060] Figure 3 Flowchart of an example that plays sounds synchronously for two devices. DETAILED DESCRIPTION
[0061] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. The described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.
[0062] This embodiment provides a method for realizing synchronous sound playback of devices based on wireless communication. Devices communicate with each other by sending data through wireless communication. In this embodiment, the first device or the second device obtains encrypted data sent by other devices by scanning 2.4G wireless data.
[0063] Reference Figure 1 ,The method includes the following steps S1, S2 and S3.
[0064] A method for realizing synchronous sound playback of devices based on wireless communication, wherein data is transmitted between devices by wireless communication, comprising the steps of:
[0065] Step S1: The first device and the second device are paired by transmitting pairing data through wireless communication, including:
[0066] The first device sends first pairing data, and the first pairing data carries frame header data; the second device receives the first pairing data by scanning, and the data obtained by parsing the first pairing data includes the frame header data;
[0067] The second device sends second pairing data, and the second pairing data carries frame header data; the first device receives the second pairing data by scanning, and the data obtained by parsing the second pairing data includes the frame header data;
[0068] If the frame header data obtained by parsing the first pairing data is consistent with the frame header data obtained by parsing the second pairing data, the first device and the second device are paired successfully;
[0069] Step S2: after the first device and the second device are successfully paired, sending and receiving data, including:
[0070] Adding frame header data and sequence number to the data sent by the second device;
[0071] The second device sends encrypted data at a predetermined time interval; the first device scans and obtains the encrypted data, the first device parses the encrypted data with a key, verifies the parsed data through CRC, and obtains a serial number in the encrypted data;
[0072] The first device determines whether the received encrypted data includes the frame header data;
[0073] If the received encrypted data does not include the frame header data, the first device filters out the received encrypted data;
[0074] If the received encrypted data includes the frame header data, further determining whether the first device has recorded the serial number in the encrypted data; if the first device has recorded the serial number in the encrypted data, it indicates that the data is repeated, and the first device filters out the encrypted data;
[0075] Otherwise, the encrypted data received by the first device is valid data; the first device records the serial number in the encrypted data and receives the encrypted data.
[0076] Reference Figure 2 Step S3: The first device and the second device play sound synchronously, including:
[0077] Step S31: The first device sends a play command to the second device; the play command indicates that the first device starts timing from 0 milliseconds and plays the sound after timing to N milliseconds;
[0078] Step S32: The second device receives the play command from the first device, the second device starts timing from 0 milliseconds, and replies to the first device;
[0079] Step S33: The first device receives a reply from the second device. At this time, the timing time of the first device has accumulated from 0 milliseconds to N1 milliseconds, and the first time delay for the first device to send data to the second device is N1 milliseconds;
[0080] Determine whether the first time delay is greater than the first preset time delay, and if the first time delay is greater than the first preset time delay, restart the process from step S31;
[0081] Otherwise, the first device replies the first time delay of N1 milliseconds to the second device;
[0082] Step S34: The second device receives the first time delay data N1 milliseconds replied by the first device; at this time, the timing time of the second device accumulates from 0 milliseconds to N2 milliseconds, and it is determined that the second time delay of the first device replying to the second device is N2 milliseconds;
[0083] Determine whether the second time delay is greater than the second preset time delay, if the second time delay is greater than the second preset time delay, restart from step S31;
[0084] Otherwise, for the second device, play the sound after the timer reaches N milliseconds minus N2 milliseconds.
[0085] Reference Figure 2 , about two devices playing sound synchronously, as shown in the following example:
[0086] First, device A records the time of node 1 0MS and sends the data to device B;
[0087] Second, after receiving the data sent by device A, device B immediately replies to A and uses local timing to calculate the time as node 2, corresponding to 10MS.
[0088] Third, at time node 3, device A receives the reply information from device B. By subtracting the node 1 time 0MS from the node 3 time 20MS, it can be calculated that the first time delay of device A sending data to device B is within 20MS.
[0089] If the first time delay is greater than the first preset time delay, the process starts again from the first step.
[0090] Device A then replies to device B with the first time delay of 20MS.
[0091] Fourth, after device B at time node 4 receives the reply from device A, we can calculate the delay of A replying to B data within 20MS by subtracting the time of node 2 10MS from the time of node 4 30MS. And from the third point, we know that the delay of A sending commands to B is within 20MS.
[0092] Device A sends a start play command to device B, and starts playing white noise after a countdown of 200MS. After receiving the command, device B starts playing white noise after a countdown of 200MS-20MS (delay time) = 180MS. Therefore, the error is only 10MS, and the ear sense cannot distinguish them, so the purpose of simultaneous playback can be achieved; if the calculated delay during the period is high, device A will resend the data and count down again for 200MS, and the corresponding device B will also start the countdown again, so as to avoid the jamming caused by continuous resending and restarting of playback.
[0093] The first device and the second device that are successfully paired simultaneously send the encrypted data at a predetermined time interval, and the first device automatically filters out the data sent by itself when scanning data to obtain the encrypted data sent by the second device and when the second device scans data to obtain the encrypted data sent by the first device to avoid interference.
[0094] The first device and the second device simultaneously send the encrypted data at a predetermined time interval, and the predetermined time interval is 10ms.
[0095] The data encryption method is that the first device and the second device respectively use a key to encrypt the original data to be sent to obtain encrypted data.
[0096] This embodiment adopts the encryption technology of AES128 ECD. For example, the first device encrypts the original data "6666" with the key "12345678" to obtain "FD2FE35B623D79AD9B7F87A9264784CC", and then sends the encrypted data. The second device scans the sent data and obtains the encrypted data "FD2FE35B623D79AD9B7F87A9264784CC", and then the second device decrypts the received encrypted data with the key "12345678" to obtain the original data "6666".
[0097] When the first device scans data to obtain the encrypted data sent by the second device and the second device scans data to obtain the encrypted data sent by the first device, the data sent by itself will be automatically filtered out, specifically:
[0098] The wireless communication method adopted is 2.4G wireless communication; the protocol stack will determine whether it is itself or another device based on the MAC address of each device. When it is the device itself, the first device and the second device will filter out the data sent by themselves accordingly.
[0099] The first device scans and obtains the encrypted data, the first device parses the encrypted data with a key, verifies the parsed data through CRC, and obtains a serial number in the encrypted data, wherein the parsing of the encrypted data with a key is specifically as follows:
[0100] The second device encrypts the original data with a key to obtain encrypted data. After the first device obtains the encrypted data, the first device parses the encrypted data with the key used by the second device to encrypt the data to obtain the original data.
[0101] Among them, parsing the 2.4G wireless communication transmission packet information and verifying the parsed data through CRC are existing technologies in this field and will not be described in detail here.
[0102] The first device scans and obtains the encrypted data, the first device parses the encrypted data with a key, verifies the parsed data through CRC, and obtains a serial number in the encrypted data, wherein obtaining the serial number in the encrypted data is specifically:
[0103] The encrypted data sent all carry a corresponding serial number, and after parsing the encrypted data, the first device obtains the frame header data, the original data and the corresponding serial number.
[0104] Each encrypted data corresponds to a specific serial number, and the serial numbers of different encrypted data are different. When the first device or the second device receives the encrypted data, if the serial number has been recorded, it means that the data corresponding to the serial number has been received, and the first device or the second device will filter out the data corresponding to the serial number to avoid repeated reception of the data.
[0105] For example, the first device sends a data "serial number is 1, the original data is 123456", the second device scans the above data sent by the first device, and records the serial number of the data as 1. Afterwards, the first device will filter out the data with serial number 1 when it receives it again.
[0106] The format of data transmitted between devices is "fixed frame header + sequence number + data". When two devices communicate, they only need to exchange fixed-format frame header data for the first time. When the frame header data of the two devices match, the two devices can communicate without the need to establish a special link channel. It is completely based on wireless communication. In this embodiment, 2.4G wireless communication is used to send data, so there is no risk of disconnection, and the stability of data transmission is good.
[0107] During data transmission, one device sends data and other devices scan the sent data. After the two devices are paired through frame header data and the fixed data transmission method is determined to be "fixed frame header + serial number + data", the device receiving the data can identify the data through the frame header data and the serial number of the data.
[0108] In this embodiment, the preset time interval is 10MS, and data is sent once every preset time interval. When the sent data needs to be updated, the sequence number and data in the data format of "frame header data + sequence number + data" are modified, and then the first device sends the modified data in the format of "frame header data + sequence number + data".
[0109] After the second device and the first device are successfully paired, the second device compares the serial number of the received data with the previously recorded serial number.
[0110] If the serial number of the data most recently received by the second device is consistent with a serial number previously recorded by the second device, it means that the second device has previously received the data corresponding to the serial number, indicating that the data is duplicated, and the second device filters out the data corresponding to the serial number.
[0111] If the second device has not recorded the serial number before, it means that the data corresponding to the serial number is new data, and the second device receives the data corresponding to the serial number, and the first device transmits the new data to the second device.
[0112] On the other hand, a device for realizing synchronous sound playback of devices based on wireless communication is provided, wherein data is transmitted between devices by wireless communication, including:
[0113] a device pairing module, configured to enable the first device to send first pairing data, wherein the first pairing data includes frame header data; the second device receives the first pairing data by scanning, and the data obtained by parsing the first pairing data includes the frame header data;
[0114] The second device sends second pairing data, and the second pairing data carries frame header data; the first device receives the second pairing data by scanning, and the data obtained by parsing the second pairing data includes the frame header data;
[0115] If the frame header data obtained by parsing the first pairing data is consistent with the frame header data obtained by parsing the second pairing data, the first device and the second device are paired successfully;
[0116] The data receiving and parsing module is used to send and receive data after the first device and the second device are successfully paired, including:
[0117] Adding frame header data and sequence number to the data sent by the second device;
[0118] The second device sends encrypted data at a predetermined time interval; the first device scans and obtains the encrypted data, the first device parses the encrypted data with a key, verifies the parsed data through CRC, and obtains a serial number in the encrypted data;
[0119] The first device determines whether the received encrypted data includes the frame header data;
[0120] If the received encrypted data does not include the frame header data, the first device filters out the received encrypted data;
[0121] If the received encrypted data includes the frame header data, further determining whether the first device has recorded the serial number in the encrypted data; if the first device has recorded the serial number in the encrypted data, it indicates that the data is repeated, and the first device filters out the encrypted data;
[0122] Otherwise, the encrypted data received by the first device is valid data; the first device records the serial number in the encrypted data and receives the encrypted data;
[0123] The synchronous playback module is used to achieve synchronous playback of sound by the first device and the second device, including: step S31: the first device sends a playback command to the second device; the playback command indicates that the first device starts timing from 0 milliseconds and plays the sound after timing to N milliseconds;
[0124] Step S32: The second device receives the play command from the first device, the second device starts timing from 0 milliseconds, and replies to the first device;
[0125] Step S33: The first device receives a reply from the second device. At this time, the timing time of the first device has accumulated from 0 milliseconds to N1 milliseconds, and the first time delay for the first device to send data to the second device is N1 milliseconds;
[0126] Determine whether the first time delay is greater than the first preset time delay, and if the first time delay is greater than the first preset time delay, restart the process from step S31;
[0127] Otherwise, the first device replies the first time delay of N1 milliseconds to the second device;
[0128] Step S34: The second device receives the first time delay data N1 milliseconds replied by the first device; at this time, the timing time of the second device accumulates from 0 milliseconds to N2 milliseconds, and it is determined that the second time delay of the first device replying to the second device is N2 milliseconds;
[0129] Determine whether the second time delay is greater than the second preset time delay, if the second time delay is greater than the second preset time delay, restart from step S31;
[0130] Otherwise, for the second device, play the sound after the timer reaches N milliseconds minus N2 milliseconds.
[0131] In addition, the method of the present application for realizing synchronous sound playback of devices based on wireless communication is not limited to the mutual transmission of data between two devices, but can also be used to transmit data between multiple devices.
[0132] Working principle:
[0133] The format of data transmitted between devices is "fixed frame header + serial number SN + data DATA". When two devices communicate, they only need to exchange the frame header data of the fixed frame header for the first time. When the frame header data of the two devices match, the two devices can communicate without establishing a special link channel. During data transmission, one device sends data, and the other device scans the sent data. The data can be identified by the frame header data and the serial number of the data. It is completely based on BLE (low-power wireless communication technology) wireless communication to send low-latency transmission data. There is no need to establish a link channel for data transmission, so there is no risk of disconnection.
[0134] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for realizing synchronous sound playback of devices based on wireless communication, in which data is transmitted between devices by wireless communication. Features , including the steps of: The first device and the second device are paired by transmitting pairing data by wireless communication, including: The first device sends first pairing data, and the first pairing data carries frame header data; the second device receives the first pairing data by scanning, and the data obtained by parsing the first pairing data includes the frame header data; The second device sends second pairing data, and the second pairing data carries frame header data; the first device receives the second pairing data by scanning, and the data obtained by parsing the second pairing data includes the frame header data; If the frame header data obtained by parsing the first pairing data is consistent with the frame header data obtained by parsing the second pairing data, the first device and the second device are paired successfully; After the first device and the second device are successfully paired, sending and receiving data includes: Adding frame header data and sequence number to the data sent by the second device; The second device sends encrypted data at a predetermined time interval; the first device scans and obtains the encrypted data, the first device parses the encrypted data with a key, verifies the parsed data through CRC, and obtains a serial number in the encrypted data; The first device determines whether the received encrypted data includes the frame header data; If the received encrypted data does not include the frame header data, the first device filters out the received encrypted data; If the received encrypted data includes the frame header data, further determining whether the first device has recorded the serial number in the encrypted data; if the first device has recorded the serial number in the encrypted data, it indicates that the data is repeated, and the first device filters out the encrypted data; Otherwise, the encrypted data received by the first device is valid data; the first device records the serial number in the encrypted data and receives the encrypted data; The first device and the second device implement synchronous sound playback, including: Step S31: The first device sends a play command to the second device; the play command indicates that the first device starts timing from 0 milliseconds and plays the sound after timing to N milliseconds; Step S32: The second device receives the play command from the first device, the second device starts timing from 0 milliseconds, and replies to the first device; Step S33: The first device receives a reply from the second device. At this time, the timing time of the first device has accumulated from 0 milliseconds to N1 milliseconds, and the first time delay for the first device to send data to the second device is N1 milliseconds; Determine whether the first time delay is greater than the first preset time delay, if the first time delay is greater than the first preset time delay, restart from step S31; Otherwise, the first device replies the first time delay of N1 milliseconds to the second device; Step S34: The second device receives the first time delay data N1 milliseconds replied by the first device; at this time, the timing time of the second device accumulates from 0 milliseconds to N2 milliseconds, and it is determined that the second time delay of the first device replying to the second device is N2 milliseconds; Determine whether the second time delay is greater than the second preset time delay, if the second time delay is greater than the second preset time delay, restart from step S31; Otherwise, for the second device, play the sound after the timer reaches N milliseconds minus N2 milliseconds.
2. According to the method for realizing synchronous sound playback of devices based on wireless communication according to claim 1, Features , the first device and the second device that are successfully paired send the encrypted data at the same time at a predetermined time interval, and the first device automatically filters out the data sent by itself when scanning data to obtain the encrypted data sent by the second device and the second device scans data to obtain the encrypted data sent by the first device.
3. According to the method for realizing synchronous sound playback of devices based on wireless communication according to claim 2, Features , the first device and the second device simultaneously send the encrypted data at a predetermined time interval, the predetermined time interval being 10ms; The method for encrypting data is that the first device and the second device respectively use keys to encrypt the original data to be sent to obtain encrypted data.
4. According to the method for realizing synchronous sound playback of devices based on wireless communication according to claim 3, Features , the first device scans data to obtain the encrypted data sent by the second device and the second device scans data to obtain the encrypted data sent by the first device and automatically filters out the data sent by itself, specifically: The wireless communication method adopted is 2.4G wireless communication; the protocol stack will determine whether it is itself or another device based on the MAC address of each device. When it is the device itself, the first device and the second device will filter out the data sent by themselves accordingly.
5. According to the method for realizing synchronous sound playback of devices based on wireless communication according to claim 1, Features , the first device scans and obtains the encrypted data, the first device parses the encrypted data with a key, verifies the parsed data through CRC, and obtains the serial number in the encrypted data, wherein the encryption data is parsed with a key, specifically: The second device encrypts the original data with a key to obtain encrypted data. After the first device obtains the encrypted data, the first device parses the encrypted data with the key used by the second device to encrypt the data to obtain the original data.
6. According to the method for realizing synchronous sound playback of devices based on wireless communication according to claim 5, Features , the first device scans and obtains the encrypted data, the first device parses the encrypted data with a key, verifies the parsed data through CRC, and obtains the serial number in the encrypted data, wherein obtaining the serial number in the encrypted data is specifically: The encrypted data sent all carry a corresponding serial number, and after parsing the encrypted data, the first device obtains the frame header data, the original data and the corresponding serial number.
7. A device that enables devices to play sound synchronously based on wireless communication. Data is transmitted between devices by wireless communication. Features ,include: A device pairing module, used to enable a first device to send first pairing data, wherein the first pairing data carries frame header data; a second device receives the first pairing data by scanning, and the data obtained by parsing the first pairing data includes the frame header data; The second device sends second pairing data, and the second pairing data carries frame header data; the first device receives the second pairing data by scanning, and the data obtained by parsing the second pairing data includes the frame header data; If the frame header data obtained by parsing the first pairing data is consistent with the frame header data obtained by parsing the second pairing data, the first device and the second device are paired successfully; The data receiving and parsing module is used to send and receive data after the first device and the second device are successfully paired, including: Adding frame header data and sequence number to the data sent by the second device; The second device sends encrypted data at a predetermined time interval; the first device scans and obtains the encrypted data, the first device parses the encrypted data with a key, verifies the parsed data through CRC, and obtains a serial number in the encrypted data; The first device determines whether the received encrypted data includes the frame header data; If the received encrypted data does not include the frame header data, the first device filters out the received encrypted data; If the received encrypted data includes the frame header data, further determining whether the first device has recorded the serial number in the encrypted data; if the first device has recorded the serial number in the encrypted data, it indicates that the data is repeated, and the first device filters out the encrypted data; Otherwise, the encrypted data received by the first device is valid data; the first device records the serial number in the encrypted data and receives the encrypted data; The synchronous playback module is used to achieve synchronous playback of sound by the first device and the second device, including: step S31: the first device sends a playback command to the second device; the playback command indicates that the first device starts timing from 0 milliseconds and plays the sound after timing to N milliseconds; Step S32: The second device receives the play command from the first device, the second device starts timing from 0 milliseconds, and replies to the first device; Step S33: The first device receives a reply from the second device. At this time, the timing time of the first device has accumulated from 0 milliseconds to N1 milliseconds, and the first time delay for the first device to send data to the second device is N1 milliseconds; Determine whether the first time delay is greater than the first preset time delay, and if the first time delay is greater than the first preset time delay, restart the process from step S31; Otherwise, the first device replies the first time delay of N1 milliseconds to the second device; Step S34: The second device receives the first time delay data N1 milliseconds replied by the first device; at this time, the timing time of the second device accumulates from 0 milliseconds to N2 milliseconds, and it is determined that the second time delay of the first device replying to the second device is N2 milliseconds; Determine whether the second time delay is greater than the second preset time delay, if the second time delay is greater than the second preset time delay, restart from step S31; Otherwise, for the second device, play the sound after the timer reaches N milliseconds minus N2 milliseconds.
Citation Information
Patent Citations
Pairing method for Bluetooth equipment and television, television and readable storage medium
CN107155123A
Bluetooth pairing mutual authentication method and device
CN107969001A
An audio and video synchronization method and apparatus
CN109275008A
Synchronous multicast and video forwarding method and system
CN110177293A
Pairing method based on WiFi detection request frame, remote control method, system and device thereof
CN111277980A
