Disclosure of Invention
Therefore, embodiments of the present invention provide a wireless data communication method, system, device, and storage medium, which solve the technical problems that the existing bluetooth communication protocol cannot implement role differentiation between a master and a slave in bluetooth communication, cannot implement assignment of corresponding interaction rights based on different role differentiations, and the like.
In order to achieve the above object, the embodiments of the present invention provide the following technical solutions:
in a first aspect, an embodiment of the present invention provides a wireless data communication method, where the communication method includes: establishing a communication relationship between the first wireless communication device and the second wireless communication device based on the SWISS communication protocol; registering the SWISS communication service as a master in the first wireless communication equipment, and not registering the SWISS communication service as a slave in the second wireless communication equipment; discovering, at the first wireless communication device, the second wireless communication device in proximity based on SDP and completing pairing; receiving, at the first wireless communication device, an SWISS communication service request of the second wireless communication device that is successfully paired, and establishing a SWISS communication protocol connection based on an RFCOMM channel; and realizing communication interaction of data flow, control flow and state flow between the first wireless communication equipment and the second wireless communication equipment.
Preferably, the communication method further includes: and actively initiating a disconnection request by the first wireless communication device or the second wireless communication device to disconnect the RFCOMM connection.
Further, the SWISS communication protocol is formed based on a bluetooth protocol, and the SWISS communication protocol architecture includes: the base layer, the HCI layer, the L2CAP layer, the SDP layer, the RFCOMM layer, the SPP layer and the SWISS Profile layer are used for defining the base band controller; the bottom layer, the HCI layer, the L2CAP layer, the RFCOMM layer and the SPP layer are sequentially arranged from bottom to top; the SDP layer is arranged above the L2CAP layer and is arranged in parallel with the RFCOMM layer and the SPP layer; the SWISS Profile layer is arranged on the SPP layer, and a set application layer wireless interaction module constructed based on the SPP layer transmits high-quality audio/video signals of the first wireless communication device and the second wireless communication device.
Further, the SWISS communication protocol architecture further includes: LMP layer, AVDTP layer, A2DP layer, HFP layer; the LMP layer is arranged above the HCI layer and is arranged in parallel with the L2CAP layer; the AVDTP layer is arranged above the LMP layer and the L2CAP layer and is arranged in parallel with the RFCOMM layer; the A2DP layer is arranged on the AVDTP layer and is arranged in parallel with the SPP layer and the SWISS Profile layer; the HFP layer is arranged on the SDP layer and the SPP layer and is arranged in parallel with the SWISS Profile layer.
Preferably, the communication method further comprises: establishing a precise synchronization mechanism between the first wireless communication device and a second wireless communication device using the NTP protocol, comprising: obtaining a time offset value t at the second wireless communication device through signaling interactionDeviation of (ii) a Sending data to the second wireless communication equipment through the first wireless communication equipment, and recording the data sending time t of the first wireless communication equipmentSending And a data reception time t of the second wireless communication deviceReceiving (ii) a According to the data transmission time tSending And the data receiving time tReceiving Obtaining data transmission time delay tTime delay Wherein, tTime delay =tReceiving -tSending (ii) a According to the time deviation value tDeviation of And said data transmission delay tTime delay Obtaining a synchronization time adjustment value tRegulating Wherein, tRegulating =tDeviation from +tTime delay (ii) a Using said synchronized time adjustment value tRegulating Time synchronizing data of the second wireless communication device to be the same as the data time of the first wireless communication device.
Further, the obtaining of the time offset value t at the second wireless communication device by signaling interaction is performedDeviation of The method comprises the following steps: sending a first signaling to the second wireless communication device by the first wireless communication device, and recording a first sending time t of the first signaling1 And a first reception time t2 (ii) a Sending a second signaling to the first wireless communication device by the second wireless communication device, and recording a second sending time t of the second signaling3 And a second reception time t4 (ii) a According to the first sending time t1 The first receiving time t2 The second transmission time t3 The second receiving time t4 Is calculated toTo the time offset value tDeviation of (ii) a Wherein the time deviation value tDeviation of The algorithm formula of (1) is as follows:
preferably, the NTP protocol is used to establish a precise synchronization mechanism between the first wireless communication device and the second wireless communication device, further comprising: and comparing the synchronized data time of the second wireless communication device with the data time of the first wireless communication device, and if the synchronized data time of the second wireless communication device is consistent with the data time of the first wireless communication device, executing data at the second wireless communication device according to the synchronized time.
Preferably, the communication method further includes: detecting a buffer level value of data transmission of the first wireless communication device; judging whether the cache level value meets a preset first threshold condition, and if so, reducing the input quantity of a cache queue by changing parameters; and judging whether the cache level value meets a preset second threshold condition, and if so, increasing the input quantity of the cache queue by changing parameters.
Preferably, the first threshold condition is that the size of the cache data of the first wireless communication device is greater than or equal to 3/4 of the total cache data size, and the cache data remaining space of the first wireless communication device is less than or equal to 1/4 of the total cache data space; the second threshold condition is that the size of the cache data of the first wireless communication device is less than or equal to 1/2 of the total cache data size, and the cache data remaining space of the first wireless communication device is greater than or equal to 1/2 of the total cache data space.
Preferably, the communication method further includes: acquiring real-time communication state information of current data transmission, wherein the real-time communication state information comprises: at least one of a real-time communication delay value, a real-time packet loss rate, and a real-time rate; according to the real-time communication state information, calibrating the real-time quality level of the current channel data transmission; and adjusting the communication code rate of the current channel according to the real-time quality grade, and realizing the switching of the working bandwidth and/or the channel number.
In a second aspect, an embodiment of the present invention provides a wireless data communication system, where the communication system includes: the communication establishing module is used for establishing a communication relation between the first wireless communication equipment and the second wireless communication equipment based on the SWISS communication protocol; the communication establishment module comprises: the host communication establishing sub-module loaded in the first wireless communication equipment is used for registering SWISS communication service as a host in the first wireless communication equipment; and a slave communication establishment sub-module, loaded on the second wireless communication device, for unregistering SWISS communication service with the second wireless communication device as a slave; based on the interaction between the master communication establishing submodule and the slave communication establishing submodule, discovering the second wireless communication equipment nearby on the first wireless communication equipment based on SDP and completing pairing; receiving, at the first wireless communication device, an SWISS communication service request of the successfully paired second wireless communication device, and establishing a SWISS communication protocol connection based on an RFCOMM channel; and realizing communication interaction of data flow, control flow and state flow between the first wireless communication equipment and the second wireless communication equipment.
Preferably, the communication establishing module is further configured to: based on the interaction between the master communication establishing submodule and the slave communication establishing submodule, the first wireless communication device or the second wireless communication device actively initiates a disconnection request to disconnect the RFCOMM connection.
Further, the SWISS communication protocol is formed based on a bluetooth protocol, and the SWISS communication protocol architecture includes: the base layer, the HCI layer, the L2CAP layer, the SDP layer, the RFCOMM layer, the SPP layer and the SWISS Profile layer are used for defining the base band controller; the bottom layer, the HCI layer, the L2CAP layer, the RFCOMM layer and the SPP layer are sequentially arranged from bottom to top; the SDP layer is arranged above the L2CAP layer and is arranged in parallel with the RFCOMM layer and the SPP layer; the SWISS Profile layer is arranged on the SPP layer, and a set application layer wireless interaction module constructed based on the SPP layer transmits high-quality audio/video signals of the first wireless communication device and the second wireless communication device.
Further, the SWISS communication protocol architecture further includes: LMP layer, AVDTP layer, A2DP layer, HFP layer; the LMP layer is arranged above the HCI layer and is arranged in parallel with the L2CAP layer; the AVDTP layer is arranged above the LMP layer and the L2CAP layer and is arranged in parallel with the RFCOMM layer; the A2DP layer is arranged on the AVDTP layer and is arranged in parallel with the SPP layer and the SWISS Profile layer; the HFP layer is arranged above the SDP layer and the SPP layer and is arranged in parallel with the SWISS Profile layer.
Preferably, the communication system further comprises: a synchronization communication module configured to establish a precise synchronization mechanism between the first wireless communication device and the second wireless communication device using the NTP protocol, comprising: obtaining a time offset value t at the second wireless communication device by signaling interactionDeviation of (ii) a Sending data to the second wireless communication equipment through the first wireless communication equipment, and recording the data sending time t of the first wireless communication equipmentSending And a data reception time t of the second wireless communication deviceReceiving (ii) a According to the data transmission time tSending And the data receiving time tReceiving Obtaining a data transmission delay tTime delay Wherein, tTime delay =tReceiving -tSending (ii) a According to the time deviation value tDeviation of And said data transmission delay tTime delay Obtaining a synchronization time adjustment value tRegulating Wherein, tRegulating =tDeviation from +tTime delay (ii) a Using said synchronized time adjustment value tRegulating Time synchronizing data of the second wireless communication device to be the same as the data time of the first wireless communication device.
Further, the obtaining of the time offset value t at the second wireless communication device by signaling interaction is performedDeviation from The method comprises the following steps: sending a first signaling to the second wireless communication device by the first wireless communication device, and recording a first sending time t of the first signaling1 And a first reception time t2 (ii) a Sending a second signaling to the first wireless communication device by the second wireless communication device, and recording a second sending time t of the second signaling3 And a second reception time t4 (ii) a According to the first sending time t1 The first receiving time t2 The second transmission time t3 The second receiving time t4 Calculating to obtain the time deviation value tDeviation of (ii) a Wherein the time deviation value tDeviation from The algorithm formula of (1) is as follows:
preferably, the synchronous communication module is further configured to compare the synchronized data time of the second wireless communication device with the data time of the first wireless communication device, and if the synchronized data time of the second wireless communication device is consistent with the data time of the first wireless communication device, perform data execution at the second wireless communication device according to the synchronized time.
Preferably, the communication system further comprises: the real-time communication monitoring module is used for detecting a cache level value of data transmission of the first wireless communication equipment; judging whether the cache level value meets a preset first threshold condition, and if so, reducing the input quantity of a cache queue by changing parameters; and judging whether the cache level value meets a preset second threshold condition, and if so, increasing the input quantity of the cache queue by changing parameters.
Preferably, the first threshold condition is that the size of the cache data of the first wireless communication device is greater than or equal to 3/4 of the total cache data size, and the cache data remaining space of the first wireless communication device is less than or equal to 1/4 of the total cache data space; the second threshold condition is that the size of the cache data of the first wireless communication device is less than or equal to 1/2 of the total cache data size, and the cache data remaining space of the first wireless communication device is greater than or equal to 1/2 of the total cache data space.
Preferably, the real-time communication monitoring module is further configured to: acquiring real-time communication state information of current data transmission, wherein the real-time communication state information comprises: at least one of a real-time communication delay value, a real-time packet loss rate, and a real-time rate; according to the real-time communication state information, calibrating the real-time quality level of the current channel data transmission; and adjusting the communication code rate of the current channel according to the real-time quality grade to realize the switching of the working bandwidth and/or the channel number.
In a third aspect, an embodiment of the present invention provides a synchronization apparatus for a wireless communication apparatus, including: a memory for storing a computer program; a processor adapted to perform the steps of a method of wireless data communication according to any of the above first aspects when said computer program is executed.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of a wireless data communication method as described in any one of the above first aspects.
The embodiment of the invention provides a wireless data communication method, a system, equipment and a storage medium, which are used for establishing a communication relation between first wireless communication equipment and second wireless communication equipment based on an SWISS communication protocol. The first wireless communication device and the second wireless communication device are divided into a host and a slave by judging whether the SWISS communication service is registered or not, and different interaction authorities are respectively given to the host and the slave based on role division. After the master machine and the slave machine are successfully paired, the SWISS communication protocol connection is established based on the RFCOMM channel, the master machine can provide SWISS communication service through registering SWISS communication service for the slave machine to discover, and receives a request initiated by the slave machine in the connection process; the slave is not registered with the SWISS communication service, finds the host with the SWISS communication service through the SDP, and initiates a connection request to the host in the connection process. Therefore, the communication interaction of data flow, control flow and state flow is realized between the host and the slave.
Detailed Description
The present invention is described in terms of specific embodiments, and other advantages and benefits of the present invention will become apparent to those skilled in the art from the following disclosure. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, belong to the protection scope of the present invention.
Referring to fig. 1, an embodiment of the present invention provides a wireless data communication system, which includes: the communication establishing module 1 establishes a communication relationship between the first Wireless communication device and the second Wireless communication device based on a SWISS (Sabine Wireless Internet Stereo System) communication protocol.
The communication establishing module 1 comprises a host communication establishing sub-module 11 and a slave communication establishing sub-module 12, wherein the host communication establishing sub-module 11 is loaded in the first wireless communication equipment and is used for registering SWISS communication service in the first wireless communication equipment to enable the first wireless communication equipment to be used as a host; the slave communication establishing sub-module 12 is loaded in the second wireless communication device, and is configured to make the second wireless communication device act as a slave when the second wireless communication device is not registered with the SWISS communication service.
Based on the interaction between the master communication establishing submodule 11 and the slave communication establishing submodule 12, discovering a nearby second wireless communication device and completing pairing based on SDP at the first wireless communication device; receiving an SWISS communication service request of a second wireless communication device which is successfully paired at a first wireless communication device, and establishing SWISS communication protocol connection based on an RFCOMM channel; and realizing communication interaction of data flow, control flow and state flow between the first wireless communication equipment and the second wireless communication equipment.
The embodiment of the invention establishes a communication relation between the first wireless communication equipment and the second wireless communication equipment based on the SWISS communication protocol. The first wireless communication device and the second wireless communication device are divided into a host computer and a slave computer through whether SWISS communication service is registered or not, and different interaction authorities are respectively given to the host computer and the slave computer based on role division. After the master machine and the slave machine are successfully paired, the SWISS communication protocol connection is established based on the RFCOMM channel, the master machine can provide SWISS communication service through registering SWISS communication service for the slave machine to discover, and receives a request initiated by the slave machine in the connection process; the slave is not registered with the SWISS communication service, finds the host with the SWISS communication service through the SDP, and initiates a connection request to the host in the connection process. Therefore, the communication interaction of data flow, control flow and state flow is realized between the host and the slave.
Preferably, a wireless data communication system provided in an embodiment of the present invention further includes: and the synchronous communication module 2 is used for establishing a precise synchronization mechanism between the first wireless communication device and the second wireless communication device by using the NTP protocol. The synchronous communication module 2 includes a master synchronous communication submodule 21 and a slave synchronous communication submodule 22, the master synchronous communication submodule 21 and the slave synchronous communication submodule 22 are respectively disposed on the first wireless communication device and the second wireless communication device, and data of the first wireless communication device and data of the second wireless communication device are synchronized to be the same in time through interaction between the master synchronous communication submodule 21 and the slave synchronous communication submodule 22.
The embodiment of the invention acquires the time deviation value t through signaling interactionDeviation from And real-time detected data transmission delay tTime delay Obtaining a synchronous time adjustment value tRegulating The data time of the second wireless communication equipment is synchronized to be the same as that of the first wireless communication equipment, so that the problem of synchronization of audio and video data transmission can be solved, data time synchronization among multiple equipment is realized, and user experience is improved.
Preferably, the wireless data communication system provided in the embodiment of the present invention further includes a real-time communication monitoring module 3, configured to detect a buffer level value of data transmission of the first wireless communication device; judging whether the cache level value meets a preset first threshold condition, and if so, reducing the input quantity of the cache queue by changing parameters; and judging whether the cache level value meets a preset second threshold condition, and if so, increasing the input quantity of the cache queue by changing the parameters.
In the embodiment of the invention, the buffer level value of the data transmission of the first wireless communication equipment is detected, and the parameter is adjusted according to the preset first threshold condition and the preset second threshold condition, so that the input quantity of the buffer queue is adaptive to the speed which can be borne by the channel. When the data transmission process is influenced by the surrounding network environment, the input quantity of the cache queue is reduced, the stability of data transmission is ensured, the packet loss is prevented, and the audio-visual experience of a user is improved as much as possible.
Preferably, the real-time communication monitoring module 3 is further configured to: acquiring real-time communication state information of current data transmission, wherein the real-time communication state information comprises: at least one of a real-time communication delay value, a real-time packet loss rate, and a real-time rate; according to the real-time communication state information, calibrating the real-time quality level of the current channel data transmission; and adjusting the communication code rate of the current channel according to the real-time quality grade to realize the switching of the working bandwidth and/or the channel number.
Further, in the data transmission process, the embodiment of the present invention further calibrates the real-time quality level of data transmission of the current channel according to the real-time communication delay value, the real-time packet loss rate, the real-time rate, and the like, and switches the working bandwidth and/or the channel number by adjusting the communication code rate of the current channel. Therefore, by switching the working bandwidth and/or the channel number, the influence of the surrounding network environment on data transmission is reduced, the actual speed of communication transmission is ensured to be adapted to the speed which can be borne by the channel, the stability of data transmission is ensured, the data transmission communication delay and even packet loss are prevented, and the audio-visual experience of a user is improved.
Corresponding to the wireless data communication system, the embodiment of the invention also discloses a wireless data communication method. A wireless data communication method disclosed in the embodiments of the present invention will be described in detail below with reference to a wireless data communication system described above.
Referring to fig. 2, a method for wireless data communication according to an embodiment of the present invention includes: establishing a communication relation between the first wireless communication device and the second wireless communication device through interaction between the master communication establishing sub-module 11 and the slave communication establishing sub-module 12 based on an SWISS communication protocol; the method comprises the steps that SWISS communication service is registered in first wireless communication equipment and serves as a master, and SWISS communication service is not registered in second wireless communication equipment and serves as a slave; discovering, at the first wireless communication device, a second wireless communication device in proximity based on the SDP and completing the pairing; receiving an SWISS communication service request of successfully paired second wireless communication equipment at first wireless communication equipment, and establishing SWISS communication protocol connection based on an RFCOMM channel; and realizing communication interaction of data flow, control flow and state flow between the first wireless communication equipment and the second wireless communication equipment.
The SWISS communication protocol is a communication protocol manufactured by beijing saint technologies ltd based on a bluetooth device protocol, and here, bluetooth defines a communication mode of a bottom layer radio frequency, a definition and discovery mode of a service, a packaging format of a data packet, a connection establishment mode (pairing mode), and the like. The SWISS communication protocol may be extended to other wireless or wired connection protocols. The related packet format definition, application scenario, audio encoding and decoding mode, interaction mode, signal processing method, data transmission method, etc. are not limited to the bluetooth basic protocol.
Referring to fig. 3, the SWISS communication protocol disclosed in the embodiment of the present invention is formed based on a bluetooth protocol, wherein the SWISS communication protocol architecture includes: the base layer, the HCI layer, the L2CAP layer, the SDP layer, the RFCOMM layer, the SPP layer and the SWISS Profile layer are used for defining the base band controller; the bottom layer, the HCI layer, the L2CAP layer, the RFCOMM layer and the SPP layer are sequentially arranged from bottom to top; the SDP layer is arranged above the L2CAP layer and is arranged in parallel with the RFCOMM layer and the SPP layer; the SWISS Profile layer is arranged on the SPP layer, and a set application layer wireless interaction module constructed based on the SPP layer transmits high-quality audio/video signals of the first wireless communication device and the second wireless communication device.
The SWISS communication protocol can be created separately, not relying on the standard bluetooth protocol (such as A2DP, HFP, etc.) that is typically provided with devices. Referring to fig. 4, the swiss communication protocol architecture further includes: LMP layer, AVDTP layer, A2DP layer, HFP layer; the LMP layer is arranged on the HCI layer and is arranged in parallel with the L2CAP layer; the AVDTP layer is arranged above the LMP layer and the L2CAP layer and is arranged in parallel with the RFCOMM layer; the A2DP layer is arranged on the AVDTP layer and is arranged in parallel with the SPP layer and the SWISS Profile layer; the HFP layer is disposed above the SDP layer and the SPP layer, and is juxtaposed with the SWISS Profile layer.
The existing bluetooth headset products support the protocols of A2DP and HFP, and respectively provide the capabilities of listening to music and making a call. The SWISS communication protocol can be perfectly coexistent with the existing A2DP and HFP protocols, providing various scenarios, and interoperability of various data streams. The registration of the SWISS communication protocol and other operations are all in accordance with the service framework of the Bluetooth protocol. What services a device has are registered in SDP as needed, and a device can provide a variety of services such as A2DP, HFP, SWISS, GAP, PBAP, and the like.
In the prior art, the SPP belongs to control stream data, the transmitted real-time audio is low-quality, for example, when the SPP is operated by HFP to realize a telephone function, 64Kb information can be transmitted, the transmission code rate is limited, 48K stereo (1.4 Mb) cannot be transmitted, the transmission is unstable, and audio and video cannot be transmitted. In the prior art, packet loss compensation is performed at a receiving end to solve the problems of unstable data transmission and interference resistance.
In the solution proposed in the embodiment of the present application, the Swiss Profile layer is set to the upper layer of the SPP channel. Because the application layer can only be controlled at most through the APP under the condition of not refreshing the mobile phone, the SWISS profile is set in the application layer, and the high-quality audio and video signal transmission from the first wireless communication equipment to the first wireless communication equipment is carried out on the basis of the set application layer wireless interaction module constructed by the SPP. Thus, high quality stereo, e.g., 48K stereo or 44.1K stereo, can be transmitted over the SPP channel via the SWISS Profile.
The embodiment of the invention divides the first wireless communication equipment and the second wireless communication equipment into the host and the slave by judging whether the SWISS communication service is registered or not based on the SWISS communication protocol, and respectively endows different interaction authorities to the host and the slave based on role division.
The SWISS communication protocol role definition is described in detail as follows:
host (SWISS Master): the SWISS communication service is registered, and other equipment can discover the SWISS communication service through the SDP; in the connection process, receiving a request initiated by a slave;
slave (SWISS Slave): the method comprises the steps that the SWISS communication service is not registered, equipment which is registered with the SWISS communication service is found through an SDP, and a connection request is sent to a host;
the definition of the host and the slave is only used in a connection stage, the host provides SWISS communication service, and the slave requests the SWISS communication service; namely, in the connection establishment phase, the connection request is initiated by the master machine, and the slave machine receives the connection request.
Preferably, the wireless data communication method disclosed in the embodiment of the present invention further includes: and actively initiating a disconnection request by the first wireless communication device or the second wireless communication device to disconnect the RFCOMM connection. That is, in the disconnection phase, either the master or the slave may actively initiate a disconnection request.
In the embodiment of the invention, after the host and the slave are successfully paired, an SWISS communication protocol connection is established based on an RFCOMM channel, the host can provide SWISS communication service by registering SWISS communication service for the slave to find, and receives a request initiated by the slave in the connection process; the slave is not registered with the SWISS communication service, finds the host with the SWISS communication service through the SDP, and initiates a connection request to the host in the connection process. Therefore, communication interaction of data flow, control flow and state flow is realized between the host and the slave.
Specifically, referring to fig. 5 and fig. 6, fig. 5 is an interaction diagram illustrating that a communication relationship is established between a first wireless communication device and a second wireless communication device based on a SWISS communication protocol according to an embodiment of the present invention, where the first wireless communication device and the second wireless communication device are IOS system devices; fig. 6 is an interaction diagram illustrating establishment of a communication relationship between a first wireless communication device and a second wireless communication device based on a SWISS communication protocol according to another embodiment of the present invention, where the first wireless communication device and the second wireless communication device are Android system devices.
In one embodiment, the interaction between the communication devices of the SWISS communication protocol is as follows:
1. pairing procedure
The pairing process is a basic process of bluetooth, and is a process of connecting a bluetooth host (a mobile phone, a tablet computer, a portable notebook computer, a PC and the like) and a bluetooth device (an intelligent sound box, an intelligent earphone, an intelligent handle, an intelligent watch and the like). The pairing process mainly comprises the following steps:
a. the master searches for slave devices (SDP service) which can be found nearby;
b. the master machine selects a certain slave machine and starts a pairing process;
c. exchanging PIN codes and the like to complete secure connection and pairing;
after the above process is completed, a safe Bluetooth connection channel is established between the host and the slave equipment. All data is encrypted, only the paired device can correctly decode the data, and other devices cannot decrypt the transmitted data.
2. Service discovery procedure
a. The service discovery process relies on SDP services;
b. all services registered in the SDP can be searched by nearby equipment;
c. this process is often referred to on the device as a search process;
d. by inquiring the SDP service, the service capability of the equipment can be obtained;
e. the searched service request includes various information such as UUID, channel number, service alias, and the like of the service.
3. Connection establishment procedure
a. Constructing and initiating a connection request according to the information obtained in the service request;
b. the request is established on the previous Bluetooth pairing process, namely, the operation of the step can be carried out only after the pairing is completed;
c. this connection is the connection that makes the RFCOMM channel.
4. Data transmission process
after the connection is established in the RFCOMM channel, data flow and control flow can be sent at any time;
b. the system is divided into data flow, control flow and state flow, and all data are transmitted according to a uniform format;
c. the transmission may be initiated by a Master or a Slave;
5. disconnection process
a. The disconnection process may be initiated by a Master or a Slave;
b. will disconnect the RFCOMM connection;
c. after disconnection, the connection process can be started at any time in a starting state;
difference between IOS and Android systems
In the IOS system, as the system is internally provided with RFCOMM related services, in the IOS system, a mobile phone, a tablet computer, a portable notebook computer, a PC and the like are masters, and an intelligent sound box, an intelligent earphone, an intelligent handle, an intelligent watch and the like are Slave;
in the Android system, the system does not have built-in services related to the RFCOMM, so in the Android system, a mobile phone, a tablet computer, a portable notebook computer, a PC and the like are Slave, and an intelligent sound box, an intelligent earphone, an intelligent handle, an intelligent watch and the like are Master.
At present, in the process of wireless data transmission through Bluetooth, due to the influence of network environment and the influence of data processing in the transmission process, data time asynchronization exists between a data receiving end and a data sending end, and the uniformity and the accuracy of data transmission time are influenced. For example, in the audiovisual field, the requirement for time synchronization of transmission data is high, and if the picture and voice of the video screen cannot be synchronized, the user cannot obtain a good audiovisual experience.
Therefore, how to provide a synchronization scheme for a wireless communication device, which can solve the problem of audio and video synchronization, implement time synchronization among multiple devices, and improve the audiovisual experience of a user is a technical problem to be solved urgently by those skilled in the art.
In order to further solve the above problem, preferably, with reference to fig. 7, a wireless data communication method disclosed in the embodiment of the present invention further includes: establishing a precise synchronization mechanism between the first wireless communication device and a second wireless communication device using the NTP protocol, comprising: obtaining a time offset value t at the second wireless communication device via a signaling interactionDeviation of (ii) a The data transmission time t of the first wireless communication device is recorded by the first wireless communication device transmitting data to the second wireless communication deviceSending And a data reception time t of the second wireless communication deviceReceiving (ii) a According to the data transmission time tSending And a data reception time tReceiving Obtaining a data transmission delay tTime delay Wherein, tTime delay =tReceiving -tSending (ii) a According to the time deviation value tDeviation of And a data transmission delay tTime delay Obtaining a synchronization time adjustment value tRegulating Wherein, tRegulating =tDeviation of +tTime delay (ii) a Using the synchronisation time adjustment value tRegulating Time synchronizing data of a second wireless communication device to be the same as a data time of the first wireless communication device.
In the embodiment of the present invention, to synchronize data between the first wireless communication device and the second wireless communication device, it is necessary to synchronize time, after the first wireless communication device and the second wireless communication device are respectively set as a master device and a slave device (i.e., a master device and a slave device), the second wireless communication device may search for a communication connection broadcast of the first wireless communication device, so as to establish wireless communication between the two devices, and after the wireless communication is established, the two devices may acquire a network delay in a mutual PING manner.
In the embodiment of the invention, a one-to-many communication relationship is established between the first wireless communication device and the second wireless communication device, namely, one first wireless communication device corresponds to a plurality of second wireless communication devices. Taking the time of the first wireless communication device as the standard time, the time of the second wireless communication devices is synchronized to be the same as the time of the first wireless communication device no matter how many second wireless communication devices exist, thereby facilitating the data time between the devices to be kept synchronous.
Referring to fig. 8, further, a time offset value t is obtained at the second wireless communication device through signaling interactionDeviation from The method comprises the following steps: sending a first signaling to a second wireless communication device by a first wireless communication device, and recording a first sending time t of the first signaling1 And a first reception time t2 (ii) a Sending a second signaling to the first wireless communication device by the second wireless communication device, and recording a second sending time t of the second signaling3 And a second reception time t4 (ii) a According to the first transmission time t1 First receiving time t2 A second transmission time t3 A second receiving time t4 Calculating to obtain a time deviation value tDeviation of (ii) a Wherein the time deviation value tDeviation of The algorithm formula of (1) is as follows:
preferably, a wireless data communication method provided in an embodiment of the present invention further includes: the synchronized data time with the second wireless communication apparatus is compared with the data time of the first wireless communication apparatus, and if they coincide, the data is executed at the second wireless communication apparatus at the synchronized time.
In the embodiment of the invention, the communication relation between the host and the slave is established between the first wireless communication equipment and the second wireless communication equipment, and the time deviation value t is acquired through signaling interactionDeviation of And real-time detected data transmission delay tTime delay Obtaining a synchronization time adjustment value tRegulating And the data time of the second wireless communication equipment is synchronized to be the same as that of the first wireless communication equipment, so that the problem of synchronization of audio and video data transmission can be solved, the data time synchronization among a plurality of equipment is realized, and the user experience is improved.
Further, in order to reduce the audiovisual impact of the network delay on the user, in an embodiment of the present invention, the following steps may be performed for data interaction between the first wireless communication device and the second wireless communication device: the second wireless communication device receives the wirelessly transmitted real-time audio-visual data packets; the second wireless communication equipment stores the real-time audio-visual data packets within the preset time length in a preset memory according to the time sequence; and the second wireless communication equipment sends the real-time audio-visual data packet in the last preset time length to the audio-visual processor for processing every preset time length, and the data time of the second wireless communication equipment is synchronized to be the same as the data time of the first wireless communication equipment according to the method.
Specifically, a shared data storage area may be established in the second wireless communication device without a default memory, and audio-visual data packets may be collected, stored and transmitted to the audio-visual processor at regular intervals in this data area. Variations in the arrival time of the data packets, known as jitter, will occur due to network congestion, timing drift or route changes, and when the second wireless communication device receives the data packets, it intentionally time-synchronizes the data to the same data time as the first wireless communication device, so that the end user will experience a clear connection with little sound distortion.
Specifically, when the real-time audio-visual data packet is transmitted, the real-time audio-visual data packet may be set as an RTP data packet to which a real-time timestamp is added. The Real-time Transport Protocol RTP (Real-time Transport Protocol) is a network Transport Protocol, which specifies a standard packet format for transmitting audio and video over the internet. It was originally designed as a multicast protocol but was later used in many unicast applications. The RTP protocol is commonly used in streaming media systems (in conjunction with the RTSP protocol), video conferencing and Push to Talk (Push to Talk) systems (in conjunction with h.323 or SIP), making it the technological base for the IP telephony industry. The RTP protocol is used together with the RTP control protocol RTCP and is built on the user datagram protocol. RTP is widely used for streaming media related communication and entertainment including telephony, video conferencing, television, and network-based push-to-talk services (walkie-talkie-like telephony). The RTP standard defines two sub-protocols, RTP and RTCP. And the data transmission protocol RTP is used for transmitting data in real time. The protocol provides information including time stamps (for synchronization), sequence numbers (for packet loss and reordering detection), and payload formats (for specifying the coding format of the data). Control protocol RTCP, used for QoS feedback and for synchronizing media streams. The bandwidth occupied by RTCP is very small, typically only 5%, relative to RTP.
In addition, in the prior art, data between the audio or video devices needs to maintain real-time performance, and a wireless or limited transmission mode is generally adopted, however, the data transmission may be affected by the surrounding network environment in the data transmission process, which causes data transmission communication delay, even packet loss, and affects the user experience.
In order to ensure that the actual speed of communication transmission is adaptive to the speed which can be borne by the channel, the audio-visual experience of a user is improved as much as possible on the premise of ensuring the stability of data transmission in the data transmission process. Referring to fig. 9, preferably, the method for wireless data communication according to an embodiment of the present invention further includes: the following steps are executed by the real-time communication monitoring module 3: detecting a buffer level value of data transmission of a first wireless communication device; judging whether the cache level value meets a preset first threshold condition, and if so, reducing the input quantity of the cache queue by changing parameters; and judging whether the cache level value meets a preset second threshold condition, and if so, increasing the input quantity of the cache queue by changing the parameters.
In the embodiment of the present invention, first, a cache level value for data transmission of a first wireless communication device needs to be obtained. Preferably, the first threshold condition is that the size of the buffered data of the first wireless communication device is greater than or equal to 3/4 of the total buffered data size, and the remaining space of the buffered data of the first wireless communication device is less than or equal to 1/4 of the total buffered data space; the second threshold condition is that the size of the buffered data of the first wireless communication device is less than or equal to 1/2 of the total buffered data size, and the buffered data headroom of the first wireless communication device is greater than or equal to 1/2 of the total buffered data headroom.
In the embodiment of the invention, the buffer level value of the data transmission of the first wireless communication equipment is detected, and the parameter is adjusted according to the preset first threshold condition and the preset second threshold condition, so that the input quantity of the buffer queue is adaptive to the speed which can be borne by the channel. When the data transmission process is influenced by the surrounding network environment, the input quantity of the cache queue is reduced, the stability of data transmission is ensured, the packet loss is prevented, and the audio-visual experience of a user is improved as much as possible.
Preferably, referring to fig. 10 and fig. 11, a wireless data communication method according to an embodiment of the present invention further includes: the following steps are executed by the real-time communication monitoring module 3: acquiring real-time communication state information of current data transmission, wherein the real-time communication state information comprises: at least one of a real-time communication delay value, a real-time packet loss rate, and a real-time rate; according to the real-time communication state information, calibrating the real-time quality level of the current channel data transmission; and adjusting the communication code rate of the current channel according to the real-time quality grade, and realizing the switching of the working bandwidth and/or the channel number.
Further, in the data transmission process, the embodiment of the present invention further calibrates the real-time quality level of data transmission of the current channel according to the real-time communication delay value, the real-time packet loss rate, the real-time rate, and the like, and switches the working bandwidth and/or the channel number by adjusting the communication code rate of the current channel. Therefore, by switching the working bandwidth and/or the channel number, the influence of the surrounding network environment on data transmission is reduced, the actual speed of communication transmission is ensured to be adaptive to the speed which can be borne by the channel, the stability of data transmission is ensured, the data transmission communication delay is prevented, even packet loss occurs, and the audio-visual experience of a user is improved.
Referring to fig. 12, an embodiment of the present invention further provides a wireless data communication device 4, including:
a memory 41 for storing a computer program;
aprocessor 42 for implementing the steps of any of the wireless data communication methods as described in the first aspect above when executing said computer program. The computer program is stored in a space in the memory 41 for storage of program code, which when executed by theprocessor 42 implements a wireless data communication method according to any of the embodiments of the present invention.
With reference to fig. 13, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of any of the wireless data communication methods according to any of the above-mentioned embodiments.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described apparatuses, devices and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus, device and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a unit is only a logical division, and other divisions may be realized in practice, for example, multiple units or components may be combined or integrated into another device, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application, or portions or all or portions of the technical solutions that substantially contribute to the prior art, may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which may be a personal computer, a function calling device, or a network device) to execute all or part of the steps of the methods according to the embodiments of the present application. Although the invention has been described in detail above with reference to a general description and specific examples, it will be apparent to one skilled in the art that modifications or improvements may be made thereto based on the invention. Accordingly, it is intended that all such modifications and alterations be included within the scope of this invention as defined in the appended claims.