Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that, if not conflicted, the various features of the embodiments of the invention may be combined with each other within the scope of protection of the invention. Additionally, while functional block divisions are performed in apparatus schematics, with logical sequences shown in flowcharts, in some cases, steps shown or described may be performed in sequences other than block divisions in apparatus or flowcharts. The terms "first", "second", "third", and the like used in the present invention do not limit data and execution order, but distinguish the same items or similar items having substantially the same function and action.
The embodiment of the invention provides a Bluetooth data transmission method. Referring to fig. 1, the bluetooth data transmission method S100 includes:
s11, segmenting original data to obtain at least two data segments;
in this step, the original data is the data that the master device needs to transmit to the slave device in each communication cycle. The primary device may segment the original data by any segmentation method to obtain at least two data segments, where a data segment is a segment of data in the original data.
For example, the original data includes data D123, and the master device divides the data D123 to obtain a data segment D1, a data segment D2, and a data segment D3, where the data segment D1, the data segment D2, and the data segment D3 are respectively a segment of data in the data D123.
S12, generating a plurality of data segment sets according to the data segments, wherein two adjacent data segment sets comprise overlapped data segments;
in this step, the data segment set may include one data segment or may include a plurality of data segments, and the overlapping data segment included in two adjacent data segment sets may be one data segment or may include a plurality of data segments.
The master device may generate a plurality of sets of data segments from the data segments according to any generation method. In some embodiments, the master device sorts the plurality of data segments to obtain sequentially arranged data segments, and generates a data segment set according to the sequentially arranged data segments.
For example, as described above, the master device sorts the data segment D1, the data segment D2, and the data segment D3 to obtain the data segment D1, the data segment D2, and the data segment D3 that are sorted in sequence, and the master device obtains the data segment set a including the data segment D1, the data segment set B including the data segment D1 and the data segment D2, and the data segment set C including the data segment D1, the data segment D2, and the data segment set D3 according to the data segment D1, the data segment D2, and the data segment D3 that are sorted in sequence.
The master device may arrange the generated plurality of data segment sets to obtain sequentially arranged data segment sets. For example, as described above, the master device arranges the data segment set a, the data segment set B, and the data segment set C to obtain the data segment set a, the data segment set B, and the data segment set C that are arranged in sequence.
It is understood that the data segment set a and the data segment set B are two adjacent data segment sets, the data segment set B and the data segment set C are also two adjacent data segment sets, the data segment set a and the data segment set B include overlapping data segments D1, and the data segment set B and the data segment set C include overlapping data segments D1 and D2.
In some embodiments, the set of data segments serves as payload data of a data packet to be transmitted, which is transmitted to the slave device by the master device, wherein the data packet to be transmitted is a data packet to be transmitted to the slave device by the master device in each communication cycle.
In some embodiments, the master device generates a to-be-sent data packet corresponding to each data segment set according to a preset link protocol, where each to-be-sent data packet includes load data, the load data includes the data segment set and a data identifier, and the data identifier is used to identify the data segment set or an overlapped data segment.
For example, referring to fig. 2 and fig. 3 together, a data packet to be transmitted according to an embodiment of the present invention is composed of an access code, a header and payload data, wherein the access code is used for data synchronization, offset compensation and packet identification, the header is used for storing link control information, and the payload data is used for carrying voice and data fields of an upper layer. In this embodiment, the payload data is used to carry a data segment set and a data identifier, where the data identifier may be a set identifier, the set identifier is used to identify the data segment set, the data identifier may be a data segment identifier, and the data segment identifier is used to identify an overlapped data segment.
As shown in fig. 2, the payload data includes a data segment set a and a set identifier set a identifier located at the front end of the data segment set, where the set identifier is located at the front end of the data segment set, and it is understood that the set identifier may also be located at other suitable positions of the data segment set, for example, at the back end of the data segment set, as long as each data segment set can be identified. The set identifier may be any suitable identifier, such as a sequence number identifier for each data segment set.
As shown in fig. 3, the payload data includes a data segment D1, a data identifier D1 located at the rear end of the data segment D1, a data segment D2, a data identifier D2 located at the rear end of the data segment D2, a data segment D3, and a data identifier D3 located at the rear end of the data segment D3, where the D1 identifier is used to indicate that the data segment D1 is an overlapped data segment, the D2 identifier is used to indicate that the data segment D2 is an overlapped data segment, and the D3 identifier is used to indicate that the data segment D3 is an overlapped data segment. Here, each data identifier is located at the rear end of the corresponding overlapped data segment, and it is understood that each data identifier may also be located at other suitable positions of the corresponding overlapped data segment, for example, at the front end of the corresponding overlapped data segment, as long as each overlapped data segment can be identified. The data identifier may be any suitable identifier, such as a serial number identifier for each overlapping data segment.
Therefore, the main device adds the data segment identifier of the data segment set or the data segment identifier of each overlapped data segment in the load data of the data packet according to the preset link protocol to generate the data packet to be sent corresponding to each data segment set, which is beneficial to distinguishing the overlapped data segments from the non-overlapped data segments in the later period, or distinguishing different data segment sets, thereby being beneficial to carrying out data processing in the later period.
In some embodiments, the predetermined linking protocol is a custom proprietary SCO (Synchronous Connection ordered) protocol.
And S13, responding to the connection event of the preset communication period, and sending the data segment set to the slave equipment.
In this step, the preset communication period is a period for the master device to transmit a data packet to be transmitted to the slave device, where the preset communication period may be freely defined according to a service requirement, and for example, the preset communication period may be 7.5ms (millisecond), or may be any other integer multiple of 625us (microsecond).
The preset communication period may include one communication period or a plurality of communication periods, each communication period may include a plurality of connection events, and the master device may send the data packet to be sent to the slave device in response to each connection event of the preset communication period. The data packets to be sent to the slave devices may be the same or different in response to different connection events, that is, the data segment sets sent to the slave devices may be the same or different in response to different connection events.
For example, if the preset communication period includes three connection events, as described above, the master device may sequentially respond to the three connection events of the preset communication period and respectively send the data segment set a, the data segment set B, and the data segment set C to the slave device, in which case, the master device responds to different connection events, and the data segment sets sent to the slave device are different; if the preset communication period includes four connection events, the master device may sequentially respond to the first three connection events of the preset communication period, and respectively send the data segment set a, the data segment set B, and the data segment set C to the slave device, and when the master device does not receive the feedback information that the slave device successfully receives the data segment set C in the third connection event, the master device responds to the fourth connection event, and resends the data segment set C to the slave device.
It will be appreciated that in response to two adjacent connection events, the two sets of data segments respectively transmitted by the master device to the slave device comprise overlapping data segments. As described above, the master device sends the data segment set a to the slave device in response to the first connection event of the preset communication cycle, and sends the data segment set B to the slave device in response to the second connection event of the preset communication cycle, where the data segment set a and the data segment set B include the overlapped data segment D1.
Referring to fig. 4, it is assumed that the original data includes data D456 and data D789, the data D456 is data that the master device needs to transmit to the slave device in a communication cycle C1, the data D789 is data that the master device needs to transmit to the slave device in a communication cycle C2, the communication cycle C1 and the communication cycle C2 both include three connection events, and a time duration of each interaction between the master device and the slave device is 2.5ms.
The master device divides data D456 to obtain data segment D4, data segment D5 and data segment D6, divides data D789 to obtain data segment D7, data segment D8 and data segment D9, and generates data segment set D, data segment set E, data segment set F, data segment set G, data segment set H and data segment set I according to data segment D4, data segment D5, data segment D6, data segment D7, data segment D8 and data segment D9, wherein the data segment set D comprises data segment D4, data segment set E comprises data segment D4 and data segment D5, the data segment set F comprises data segment D4, data segment D5 and data segment D6, the data segment set G comprises data segment D5, data segment D6 and data segment D7, the data segment set H comprises data segment D6, data segment D7 and data segment D8, and the data segment set I comprises data segment D7, data segment D8 and data segment D9.
The master device may sequentially respond to the three connection events of the communication cycle C1 and respectively send the data segment set D, the data segment set E, and the data segment set F to the slave device, and sequentially respond to the three connection events of the communication cycle C2 and respectively send the data segment set G, the data segment set H, and the data segment set I to the slave device.
It is understood that in the case of poor communication and no data loss, the slave device receives the data segment set F at the third connection event of the communication cycle C1 and the data segment set I at the third connection event of the communication cycle C2, with a data delay of at most 7.5ms.
In the conventional technology, also in the case of poor communication and no data loss, if the slave device receives the data D456 at the first connection event of the communication cycle C1 and receives the data D789 at the third connection event of the communication cycle C2, since the slave device receives the data D456 at the first connection event of the communication cycle C1, it is necessary to go to the next cycle, i.e., the communication cycle C2, after going to the communication cycle C2, it is necessary to go to the three connection events to receive the data D789 from the slave device, and thus, the data delay is up to 12.5ms.
The main device can divide the original data into a plurality of data segments and recombine the data segments into a plurality of data segment sets for transmission, so that the data delay is reduced under the condition of unsmooth communication, and the tone quality is improved.
It can also be understood that, in the conventional technology, in one communication cycle, data processing can only be performed subsequently when the slave device successfully receives complete data, for example, the slave device receives the data D456 in the first connection event of the communication cycle C1 and receives the data D789 in the second connection event of the communication cycle C2, in this case, after receiving the data D456 from the slave device and performing subsequent processing, it is also necessary to wait for the second connection event of the communication cycle C2 to receive the data D789 and then perform subsequent processing on the data D789, and the data processing delay is large.
However, in this embodiment, the master device divides the original data with a large data volume into a plurality of data segments and reassembles the data segments into a plurality of data segment sets, where adjacent data segment sets include overlapping data segments, and the data volume of the data segment sets is generally smaller than that of the original data, so that when the master device responds to each connection event of a preset period and sends a data segment set to the slave device, the data transmission efficiency can be improved, and the slave device can process part of data of the original data after receiving the data segment set, thereby reducing data processing delay and further improving sound quality.
With continued reference to fig. 4, in the case of poor communication, even if the slave device receives no data segment set at all three connection events of the communication cycle C1, and receives the data segment set G at the first connection event of the communication cycle C2, the data segments (data segment D5 and data segment D6) of the data segment set G overlapping with the data segment set F are not lost, and the data segment D5 and the data segment D6 are partial data of the data D456, so that partial data of the data D456 is retained.
However, in the conventional method, also in the case of poor communication, the data D456 is not received by the slave device in all three connection events of the communication cycle C1, and the data D456 will be lost.
Because the adjacent data segment set sent by the master device to the slave device includes the overlapped data segments, the overlapped data segments can be transmitted for multiple times, and therefore, even if the overlapped data segments are not successfully received by the slave device in one connection event and are successfully received by the slave device in other connection events, the overlapped data segments are not lost, so that compared with the conventional method, the data loss amount can be reduced in the embodiment, and the improvement of the sound quality is facilitated.
In some embodiments, the at least one set of data segments includes at least two data segments (i.e., all data segments) resulting from splitting the original data.
For example, as mentioned above, the master device divides the data D123 into the data segment D1, the data segment D2, and the data segment D3, and the data segment set C includes all the data segments (i.e., the data segment D1, the data segment D2, and the data segment D3) obtained by dividing the original data.
It can be understood that, when the data segment set does not include all the data segments obtained by dividing the original data, for example, the original data includes data D123, the data D123 is data that needs to be transmitted to the slave device by the master device in the current communication cycle, the master device divides the data D123 to obtain data segments D1, D2, and D3, the master device generates a data segment set J, a data segment set K, and a data segment set L according to the data segments D1, D2, and D3, where the data segment set J includes the data segment D1, the data segment set K includes the data segment D1 and D2, and the data segment set L includes the data segment D2 and D3, the master device transmits the data segment set J, the data segment set K, and the data segment set L to the slave device respectively in response to a connection event in the current communication cycle, and if the slave device does not successfully receive the data segment set J and the data segment set K transmitted by the master device, only the data segment set L that is successfully received by the master device, and only the data segment set L includes the data segment set D2 and the data segment set D3, which cannot be received in the current communication cycle.
It can also be understood that, in the case that at least one data segment set includes all data segments obtained by dividing original data, as described above, the master device divides the data D123 to obtain the data segment D1, the data segment D2, and the data segment D3, the master device generates the data segment set a, the data segment set B, and the data segment set C according to the data segment D1, the data segment D2, and the data segment D3, the master device responds to a connection event of a current communication cycle to respectively send the data segment set a, the data segment set B, and the data segment set C to the slave device, and in the case of poor communication, if the slave device does not successfully receive the data segment set a and the data segment set B sent by the master device, only the data segment set C sent by the master device is successfully received, and since the data segment set C includes the data segment D1, the data segment D2, and the data segment D3, the slave device can receive all data of the data D123 in the current communication cycle.
Thus, by doing so, it is beneficial to improve the integrity of the data received from the device.
In some embodiments, referring to fig. 5, step S11 includes:
s111, determining the current communication state of the main equipment;
in this step, the current communication state is a state in which the master device is currently communicating with the slave device, and is used to indicate whether the communication quality is good or bad when the master device is currently communicating with the slave device. The current communication state can be represented by RSSI (Received Signal Strength Indicator), and the master device and the slave device can determine the current communication state of the two parties through the RSSI.
And S112, segmenting the original data according to the current communication state.
Therefore, the embodiment can enable the segmentation result of the original data to better match the current communication state, thereby being capable of adapting to complex communication environment.
In some embodiments, referring to fig. 6, step S112 includes:
s1121, determining a segmentation grade according to the current communication state;
in this step, the segmentation level is a level of segmenting the original data, and different current communication states may correspond to different segmentation levels.
For example, when the master device determines that the current communication state is good according to the RSSI, the master device may determine that the division level is the first division level, when the current communication state is general, the master device may determine that the division level is the second division level, and when the current communication state is poor, the master device may determine that the division level is the third division level.
S1122, according to the segmentation level, segmenting the original data.
In this step, the primary device may segment the original data according to different segmentation levels to obtain different numbers of data segments.
In some embodiments, each segmentation level includes a corresponding segmentation ratio, and the master device may segment the original data according to the segmentation ratio, where the segmentation ratio refers to a ratio of the original data to the number of data segments into which the original data is segmented.
For example, as mentioned above, if the division ratio of the first division level is 1: and 3, the division ratio of the second division level is 1: and 4, the division ratio of the third division level is 1:5, the master device may then divide the ratio by 1: and 3, segmenting the original data to obtain 3 data segments, and similarly, according to the segmentation proportion 1: and 4, segmenting the original data to obtain 4 data segments, and similarly, according to the segmentation proportion 1: and 5, segmenting the original data to obtain 5 data segments.
It can be understood that, when the current communication state of the master device and the slave device is worse, the more the number of data segments obtained by dividing the original data is, the more the number of data segments overlapped by the data segment set sent by the master device to the slave device in the preset communication period is, as described above, since the overlapped data segments can be transmitted for multiple times, the more the number of overlapped data segments is, that is, the more the number of times of transmitting the overlapped data segments is, which is beneficial to reducing the probability of losing the overlapped data segments, and thus, in a complex communication environment, the reduction of the bluetooth data loss amount is beneficial to improving the sound quality.
Therefore, the embodiment can reduce the data loss amount in a complex communication environment, thereby being beneficial to improving the tone quality.
An embodiment of the present invention provides a bluetooth data transmission method, wherein the present embodiment selects a slave device as an execution subject to execute the bluetooth data transmission method provided in the present embodiment. The Bluetooth data transmission method comprises the following steps:
and responding to a connection event of a preset communication period, and receiving a data segment set sent by the main equipment, wherein the data segment set is generated by at least two data segments, two adjacent data segment sets comprise overlapped data segments, and the data segments are obtained by dividing original data by the main equipment.
On the one hand, this embodiment is through carrying out the transmission after segmenting into a plurality of data sections with the original data and recombining into a plurality of data section sets, is favorable to improving data transmission efficiency, reduces follow-up data processing and postpones to be favorable to promoting tone quality, on the other hand, because the adjacent data section set that master equipment sent to slave equipment includes the data segment that overlaps, the data segment that overlaps can be transmitted many times, is favorable to reducing the bluetooth data loss volume, thereby is favorable to further promoting tone quality.
It should be noted that, in the foregoing embodiments, a certain order does not necessarily exist between the foregoing steps, and those skilled in the art can understand, according to the description of the embodiments of the present invention, that in different embodiments, the foregoing steps may have different execution orders, that is, may be executed in parallel, may also be executed interchangeably, and the like.
The embodiment of the invention provides a Bluetooth data transmission device. Referring to fig. 7, the bluetoothdata transmission apparatus 700 includes asegmentation module 71, a generation module 72, and a sending module 73, where thesegmentation module 71 is configured to segment original data to obtain at least two data segments, the generation module 72 is configured to generate a plurality of data segment sets according to the data segments, each two adjacent data segment sets include overlapping data segments, and the sending module 73 is configured to send the data segment sets to a slave device in response to a connection event of a preset communication cycle.
On the one hand, this embodiment is through carrying out the transmission after segmenting into a plurality of data sections with the original data and recombining into a plurality of data section sets, is favorable to improving data transmission efficiency, reduces follow-up data processing and postpones to be favorable to promoting tone quality, on the other hand, because the adjacent data section set that master equipment sent to slave equipment includes the data segment that overlaps, the data segment that overlaps can be transmitted many times, is favorable to reducing the bluetooth data loss volume, thereby is favorable to further promoting tone quality.
In some embodiments, referring to fig. 8, thesegmentation module 71 includes a determination unit 711 and a segmentation unit 712, the determination unit 711 is configured to determine a current communication status of the master device, and the segmentation unit 712 is configured to segment the original data according to the current communication status.
In some embodiments, the segmentation unit 712 is specifically configured to: and determining a segmentation level according to the current communication state, and segmenting the original data according to the segmentation level.
The embodiment of the invention provides a Bluetooth data transmission device. The Bluetooth data transmission device comprises a receiving module, wherein the receiving module is used for responding to a connection event of a preset communication period and receiving a data segment set sent by a main device, the data segment set is generated by at least two data segments, two adjacent data segment sets comprise overlapped data segments, and the data segments are obtained by dividing original data by the main device.
On the one hand, this embodiment is through carrying out the transmission after segmenting into a plurality of data sections with the original data and recombining into a plurality of data section sets, is favorable to improving data transmission efficiency, reduces follow-up data processing and postpones to be favorable to promoting tone quality, on the other hand, because the adjacent data section set that master equipment sent to slave equipment includes the data segment that overlaps, the data segment that overlaps can be transmitted many times, is favorable to reducing the bluetooth data loss volume, thereby is favorable to further promoting tone quality.
It should be noted that the bluetooth data transmission apparatus can execute the bluetooth data transmission method provided by the embodiment of the present invention, and has corresponding functional modules and beneficial effects of the execution method. For details of the bluetooth data transmission method provided in the embodiments of the present invention, reference may be made to the embodiments of the present invention without detailed descriptions.
Referring to fig. 9, fig. 9 is a schematic circuit structure diagram of an electronic device according to an embodiment of the present invention, where the electronic device may be a master device or a slave device. As shown in fig. 9, the electronic device 900 includes one or more processors 91 and memory 92. In fig. 9, one processor 91 is taken as an example.
The processor 91 and the memory 92 may be connected by a bus or other means, and fig. 9 illustrates the connection by a bus as an example.
The memory 92, which is a non-volatile computer-readable storage medium, may be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as program instructions/modules corresponding to the bluetooth data transmission method in the embodiments of the present invention. The processor 91 executes various functional applications and data processing of the bluetooth data transmission apparatus by executing the nonvolatile software program, instructions and modules stored in the memory 92, that is, the functions of the bluetooth data transmission method provided by the above method embodiment and the various modules or units of the above apparatus embodiment are realized.
The memory 92 may include high speed random access memory and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some embodiments, the memory 92 may optionally include memory located remotely from the processor 91, and such remote memory may be connected to the processor 91 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The program instructions/modules are stored in the memory 92 and, when executed by the one or more processors 91, perform the bluetooth data transmission method of any of the method embodiments described above.
Embodiments of the present invention also provide a non-volatile computer storage medium storing computer-executable instructions, which are executed by one or more processors, such as the processor 91 in fig. 9, so that the one or more processors can execute the bluetooth data transmission method in any of the above method embodiments.
Embodiments of the present invention also provide a computer program product, which includes a computer program stored on a non-volatile computer-readable storage medium, where the computer program includes program instructions, and when the program instructions are executed by an electronic device, the electronic device is caused to execute any of the bluetooth data transmission methods.
The above-described embodiments of the apparatus or device are only schematic, where the unit modules described as separate parts may or may not be physically separate, and the parts displayed as module units may or may not be physical units, may be located in one place, or may be distributed on multiple network module units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a general hardware platform, and certainly can also be implemented by hardware. Based on such understanding, the above technical solutions substantially or contributing to the related art may be embodied in the form of a software product, which may be stored in a computer-readable storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments or some parts of the embodiments.
Finally, it is to be understood that the present invention may be embodied in many different forms and is not limited to the embodiments described in the present specification, which are provided as additional limitations to the present disclosure, and which are provided for the purpose of providing a more thorough understanding of the present disclosure. In the context of the present invention, the above features, combined with one another and many other variations of the invention described above in different respects, are to be considered as within the scope of the present description; further, modifications and variations will occur to those skilled in the art in light of the foregoing description, and it is intended to cover all such modifications and variations as fall within the true spirit and scope of the invention as defined by the appended claims.