Bluetooth communication method, device and system
阅读说明:本技术 一种蓝牙通信方法、装置和系统 (Bluetooth communication method, device and system ) 是由 罗凤军 揭卓 吴仲春 于 2019-11-21 设计创作,主要内容包括:本申请提供了一种蓝牙通信方法、装置和系统。所述蓝牙通信方法,应用于接收设备中,所述方法包括:在蓝牙协议栈的应用层中接收数据协议单元;基于所述数据协议单元中的字段确定所述数据协议单元的有效载荷是包括音频数据或控制指令;若确定所述数据协议单元的所述有效载荷包括音频数据,基于所述有效载荷的音频数据执行音频处理;若确定所述数据协议单元的所述有效载荷包括控制指令,基于所述有效载荷的控制指令执行操作处理。使得通过蓝牙协议交互的双方,不仅能传输音频数据,还能传输特定的控制指令。(The application provides a Bluetooth communication method, device and system. The Bluetooth communication method is applied to a receiving device, and comprises the following steps: receiving a data protocol unit in an application layer of a Bluetooth protocol stack; determining, based on a field in the data protocol unit, that a payload of the data protocol unit includes audio data or a control instruction; if the effective load of the data protocol unit comprises audio data, executing audio processing based on the audio data of the effective load; and if the payload of the data protocol unit is determined to comprise the control instruction, executing operation processing based on the control instruction of the payload. Therefore, the two parties interacting through the Bluetooth protocol can not only transmit audio data, but also transmit specific control instructions.)
1. A bluetooth communication method, applied to a receiving device, the method comprising:
receiving a data protocol unit in an application layer of a Bluetooth protocol stack;
determining, based on a field in the data protocol unit, that a payload of the data protocol unit includes audio data or a control instruction;
if the effective load of the data protocol unit comprises audio data, executing audio processing based on the audio data of the effective load;
and if the payload of the data protocol unit is determined to comprise the control instruction, executing operation processing based on the control instruction of the payload.
2. The method of claim 1, further comprising:
after the step of receiving a data protocol unit in an application layer of a bluetooth protocol stack, performing the following steps:
judging whether the data protocol unit is complete or not based on the cyclic redundancy check code written in the tail part of the data protocol unit;
if the data protocol unit is determined to be complete, executing the step of determining that the payload of the data protocol unit comprises audio data or control instructions based on the field in the data protocol unit;
if the data protocol unit is determined to be incomplete, discarding the received incomplete data protocol unit, and informing the sending equipment to resend the data protocol unit.
3. The method of claim 1, wherein the audio processing comprises:
generating processed digital audio data from the audio data;
generating the processed digital audio data into an audio analog signal;
the audio analog signal is output to a transducer with which an output signal is generated.
4. The method of claim 3, wherein the step of generating processed digital audio data from the audio data comprises:
decompressing the audio data;
decoding the audio data; and/or the presence of a gas in the gas,
converting the audio data into audio data in a format that can be further processed by the receiving device.
5. The method of claim 3, wherein the output signal is a signal that can be perceived as sound.
6. The method of claim 1, wherein the operational processing comprises:
generating control instructions executable by an application program and/or control analog signals executable by a physical device by the control instructions;
sending the control instruction to the corresponding application program to execute corresponding operation; and/or sending the analog signal to a corresponding physical device to perform a corresponding operation.
7. A bluetooth communication method, applied to a transmitting device, the method comprising:
writing the audio data or the control instruction into the effective load of the data protocol unit;
if the control instruction is written in the payload, setting a command type bit in the data protocol unit to indicate the payload of the data protocol unit as the control instruction;
if the audio data is written in the payload, abandoning the setting of the command type bit in the data protocol unit;
the data protocol unit is sent to a receiving device using a bluetooth network connection.
8. The method of claim 7, further comprising:
receiving an audio analog signal from a source;
determining a type of audio processing to be performed on the audio analog signal for generating a digital output to be pre-sent to the receiving device;
performing the audio processing to generate the digital output from the audio analog signal, wherein the digital output is for audio data written into the payload of the data protocol unit.
9. The method of claim 7, further comprising:
and writing a cyclic redundancy check code at the tail part of the data protocol unit.
10. The method of claim 7, further comprising:
setting a device type bit in the data protocol unit to inform the receiving device that the transmitting device is an electronic device or an intelligent Bluetooth audio device.
11. A method of bluetooth communication, the method comprising:
in the case of the transmitting device,
writing the audio data or the control instruction into the effective load of the data protocol unit;
if the control instruction is written in the payload, setting a command type bit in the data protocol unit to indicate the payload of the data protocol unit as the control instruction;
if the audio data is written in the payload, abandoning the setting of the command type bit in the data protocol unit;
transmitting the data protocol unit to a receiving device using a bluetooth network connection;
in the receiving device, it is possible to,
receiving a data protocol unit in an application layer of a Bluetooth protocol stack;
determining, based on a field in the data protocol unit, that a payload of the data protocol unit includes audio data or a control instruction;
if the effective load of the data protocol unit comprises audio data, executing audio processing based on the audio data of the effective load;
and if the payload of the data protocol unit is determined to comprise the control instruction, executing operation processing based on the control instruction of the payload.
12. A bluetooth communication apparatus, loaded in a receiving device, the apparatus configured to:
receiving a data protocol unit in an application layer of a Bluetooth protocol stack;
determining, based on a field in the data protocol unit, that a payload of the data protocol unit includes audio data or a control instruction;
if the effective load of the data protocol unit comprises audio data, executing audio processing based on the audio data of the effective load;
and if the payload of the data protocol unit is determined to comprise the control instruction, executing operation processing based on the control instruction of the payload.
13. A bluetooth communication apparatus, loaded in a transmitting device, the apparatus configured to:
writing the audio data or the control instruction into the effective load of the data protocol unit;
if the control instruction is written in the payload, setting a command type bit in the data protocol unit to indicate the payload of the data protocol unit as the control instruction;
if the audio data is written in the payload, abandoning the setting of the command type bit in the data protocol unit;
the data protocol unit is sent to a receiving device using a bluetooth network connection.
14. A Bluetooth communication system, comprising a transmitting device and a receiving device;
the transmitting device is configured to:
writing the audio data or the control instruction into the effective load of the data protocol unit;
if the control instruction is written in the payload, setting a command type bit in the data protocol unit to indicate the payload of the data protocol unit as the control instruction;
if the audio data is written in the payload, abandoning the setting of the command type bit in the data protocol unit;
transmitting the data protocol unit to a receiving device using a bluetooth network connection;
the receiving device is configured to:
receiving a data protocol unit in an application layer of a Bluetooth protocol stack;
determining, based on a field in the data protocol unit, that a payload of the data protocol unit includes audio data or a control instruction;
if the effective load of the data protocol unit comprises audio data, executing audio processing based on the audio data of the effective load;
and if the payload of the data protocol unit is determined to comprise the control instruction, executing operation processing based on the control instruction of the payload.
Technical Field
The present application relates to the field of communications, and in particular, to a bluetooth communication method, apparatus, and system.
Background
Bluetooth is a wireless communication technology that ensures reliable reception and information security at a short distance.
In 1994, the communication department of ericsson, sweden, determined that wireless interconnection between mobile phones and surrounding devices is achieved with low cost and low power consumption using radio frequency technology, and named Bluetooth (r) as the technical specification of interconnection. In 1998, the bluetooth SIG group was established, mainly responsible for making bluetooth specifications and promoting bluetooth technology, making bluetooth technology a great advance. In particular, bluetooth specification versions, such as bluetooth 1.0 to bluetooth 5.0, are proposed, which mainly include technical indexes and system parameters corresponding to the respective versions.
With the advance of bluetooth technology, bluetooth audio devices, such as wireless bluetooth headsets, wireless bluetooth speakers, etc., are often seen in people's daily lives. Among the application models defined by SIG, the model mainly used by bluetooth audio devices is the "headset model", which is used as a speech input/output interface for mobile communication terminals and personal computers in bluetooth technology, and allows users to get rid of the constraints of call cables. In the related art, after the bluetooth audio device and the mobile communication device establish a bluetooth connection, the SCO transmission rule is often adopted to perform audio data stream transmission between the two devices. Then, an intelligent bluetooth audio device is created, which not only establishes bluetooth connection with the mobile communication device, but also can access the mobile communication network through the mobile communication device, and pick up a voice instruction to execute corresponding operations, such as weather query, cloud audio playing, and the like. However, after the intelligent bluetooth audio device is connected with the mobile communication device, in the existing protocols in the classic bluetooth protocol stack or the low-power-consumption bluetooth protocol stack, when the mobile communication device makes an incoming call, only voice communication data transmission can be performed, and control instruction recognition cannot be performed.
Disclosure of Invention
The application provides a Bluetooth communication method, a Bluetooth communication device and a Bluetooth communication system, which are used for solving the problem that after an intelligent Bluetooth audio device is connected with a mobile communication device through Bluetooth, when the mobile communication device is in an incoming call, only voice communication data transmission can be carried out, and control instruction identification cannot be carried out.
A first aspect of the present application provides a bluetooth communication method applied in a receiving device, the method including:
receiving a data protocol unit in an application layer of a Bluetooth protocol stack;
determining, based on a field in the data protocol unit, that a payload of the data protocol unit includes audio data or a control instruction;
if the effective load of the data protocol unit comprises audio data, executing audio processing based on the audio data of the effective load;
and if the payload of the data protocol unit is determined to comprise the control instruction, executing operation processing based on the control instruction of the payload.
A second aspect of the present application provides another bluetooth communication method applied to a transmitting device, the method including:
writing the audio data or the control instruction into the effective load of the data protocol unit;
if the control instruction is written in the payload, setting a command type bit in the data protocol unit to indicate the payload of the data protocol unit as the control instruction;
if the audio data is written in the payload, abandoning the setting of the command type bit in the data protocol unit;
the data protocol unit is sent to a receiving device using a bluetooth network connection.
A third aspect of the present application provides a method of bluetooth communication, the method comprising:
in the case of the transmitting device,
writing the audio data or the control instruction into the effective load of the data protocol unit;
if the control instruction is written in the payload, setting a command type bit in the data protocol unit to indicate the payload of the data protocol unit as the control instruction;
if the audio data is written in the payload, abandoning the setting of the command type bit in the data protocol unit;
transmitting the data protocol unit to a receiving device using a bluetooth network connection;
in the receiving device, it is possible to,
receiving a data protocol unit in an application layer of a Bluetooth protocol stack;
determining, based on a field in the data protocol unit, that a payload of the data protocol unit includes audio data or a control instruction;
if the effective load of the data protocol unit comprises audio data, executing audio processing based on the audio data of the effective load;
and if the payload of the data protocol unit is determined to comprise the control instruction, executing operation processing based on the control instruction of the payload.
A fourth aspect of the present application provides a bluetooth communication apparatus, loaded in a receiving device, the apparatus configured to:
receiving a data protocol unit in an application layer of a Bluetooth protocol stack;
determining, based on a field in the data protocol unit, that a payload of the data protocol unit includes audio data or a control instruction;
if the effective load of the data protocol unit comprises audio data, executing audio processing based on the audio data of the effective load;
and if the payload of the data protocol unit is determined to comprise the control instruction, executing operation processing based on the control instruction of the payload.
A fifth aspect of the present application provides another bluetooth communication apparatus, loaded in a transmitting device, the apparatus configured to:
writing the audio data or the control instruction into the effective load of the data protocol unit;
if the control instruction is written in the payload, setting a command type bit in the data protocol unit to indicate the payload of the data protocol unit as the control instruction;
if the audio data is written in the payload, abandoning the setting of the command type bit in the data protocol unit;
the data protocol unit is sent to a receiving device using a bluetooth network connection.
A sixth aspect of the present application provides still another bluetooth communication system, including a transmitting device and a receiving device;
the transmitting device is configured to:
writing the audio data or the control instruction into the effective load of the data protocol unit;
if the control instruction is written in the payload, setting a command type bit in the data protocol unit to indicate the payload of the data protocol unit as the control instruction;
if the audio data is written in the payload, abandoning the setting of the command type bit in the data protocol unit;
transmitting the data protocol unit to a receiving device using a bluetooth network connection;
the receiving device is configured to:
receiving a data protocol unit in an application layer of a Bluetooth protocol stack;
determining, based on a field in the data protocol unit, that a payload of the data protocol unit includes audio data or a control instruction;
if the effective load of the data protocol unit comprises audio data, executing audio processing based on the audio data of the effective load;
and if the payload of the data protocol unit is determined to comprise the control instruction, executing operation processing based on the control instruction of the payload.
Compared with the prior art, the method has the following advantages:
in the sending equipment, when a protocol data unit is generated, if the payload written into the protocol data unit is a control instruction, a command type bit in the data protocol unit is set to indicate that the payload of the newly generated data protocol unit carries the control instruction; and if the payload written into the protocol data unit is audio data, abandoning to set a command type bit in the protocol data unit to indicate that the payload of the newly generated data protocol unit carries the audio data. In a receiving device, after a data protocol unit is received, decapsulating in an application layer, analyzing a field in the data protocol unit, when a command type bit is analyzed, determining that a payload of the data protocol unit carries a control instruction when the command type bit is set, and executing corresponding operation based on the control instruction; when the command type bit is not set, it is determined that the payload of the data protocol unit carries audio data, and audio processing is performed based on the audio data. The sending device configures information (audio data or control instructions) carried by a payload of a data protocol unit to be transmitted in the command type bit of the protocol data unit, so that the receiving device can identify the information carried by the payload of the protocol data unit according to the command type bit of the protocol data unit after receiving the protocol data unit. Therefore, the two parties interacting through the Bluetooth protocol can not only transmit audio data, but also transmit specific control instructions.
The technical scheme disclosed by the application is applied to mobile communication equipment and intelligent Bluetooth audio equipment which establish Bluetooth connection, and obviously, even if the mobile equipment has an incoming call, namely, conversation audio (audio data) transmission is carried out between the mobile communication equipment and the intelligent Bluetooth audio equipment, the mobile equipment can still write a specific control instruction into a payload of a protocol data unit through a data protocol unit described in the application, and simultaneously set a command type bit of the protocol data unit. That is to say, after the mobile communication device and the intelligent bluetooth audio device establish the bluetooth communication connection, even if the mobile communication device is in an incoming call state, the intelligent bluetooth audio device can also identify whether the mobile device is still transmitting the control instruction to the intelligent bluetooth audio device, and execute corresponding operation processing according to the transmitted control instruction.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
Fig. 1 is a model diagram of a bluetooth protocol stack as described in an embodiment of the present application;
FIG. 2 is a model diagram of a classic Bluetooth protocol stack as described in an embodiment of the present application;
FIG. 3 is a model diagram of a Bluetooth Low energy protocol stack as described in an embodiment of the present application;
FIG. 4 is a block diagram of a mobile communication device as described in embodiments of the present application;
fig. 5 is a schematic structural diagram of an intelligent bluetooth speaker described in the embodiments of the present application;
FIG. 6 is a schematic diagram of a data protocol unit as described in an embodiment of the present application;
FIG. 7 is a format diagram of the data protocol unit shown in FIG. 6;
FIG. 8 is a flow chart of steps of a method of communication described in embodiments of the present application;
FIG. 9 is a flow chart of steps of another method of communication described in embodiments of the present application;
FIG. 10 is a diagram of an actual interaction of an example application described in embodiments of the present application.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, the present application is described in further detail with reference to the accompanying drawings and the detailed description.
Referring to fig. 1, a bluetooth protocol stack is shown, divided into four levels: a Physical Layer (Physical Layer), a Logical Layer (Logical Layer), a Logical link control and adaptation Layer (L2CAP Layer), and an application Layer (APP Layer).
The physical layer is responsible for providing physical channels (generally referred to as channels) for data transmission, and in general, several different types of channels exist in a communication system, such as a control channel, a data channel, a voice channel, and the like; a logical layer that provides a logical transmission path (also referred to as a logical link) between two or more devices that is physically independent on the basis of a physical layer; the system comprises an L2CAP layer, a Logical link Adaptation and control layer, wherein the L2CAP is an abbreviation of a Logical link control and Adaptation Protocol (Logical Link control and Adaptation Protocol) and is responsible for managing the Logical link provided by the Logical layer, multiplexing of channels and dividing and recombining upper Application data so as to meet the requirement of user data transmission on delay and facilitate the realization of subsequent mechanisms such as retransmission and flow control; the APP layer and the Application layer realize various Application functions based on a Channel (Channel) provided by the L2CAP, the service (Profile) is a specific concept of a Bluetooth protocol, in order to realize interconnection and intercommunication of different devices under different platforms, the Bluetooth protocol not only specifies a core specification (called Bluetooth core), but also defines various Application specifications for various Application scenes, and the Application layer specifications are called Bluetooth profiles.
The same protocol is used for encapsulation/de-encapsulation of each layer between two Bluetooth devices, and finally only effective information in transmission data is concerned in a Bluetooth App layer. The technical solution described in this application may be applied to a classic bluetooth protocol stack (such as the classic bluetooth protocol stack shown in fig. 2), or may be applied to a bluetooth low energy protocol stack (such as the bluetooth low energy protocol stack shown in fig. 3), and the above brief introduction about the bluetooth protocol stack is to help those skilled in the art to understand the technical solution of this application, and the more specific technical standard about the bluetooth protocol stack refers to the related prior art, such as the bluetooth version specification specified by the GIS, or may be obtained through the website www.bluetooth.com, and therefore, details are not described herein again.
In the following description of more specific embodiments, for simplicity and clarity of description, the bluetooth network connection established by the electronic device as a mobile communication device and the intelligent bluetooth audio device as an intelligent bluetooth speaker is described. When the mobile communication equipment is used as sending equipment, the intelligent Bluetooth sound box is used as receiving equipment; on the contrary, when the intelligent Bluetooth sound box is used as sending equipment, the mobile communication equipment is used as receiving equipment; that is, both the mobile communication device (or the electronic device) and the smart bluetooth speaker (or the smart bluetooth audio device) in the present application can simultaneously have the communication apparatus loaded in the transmitting device and the communication apparatus loaded in the receiving device, which are described in the following embodiments, in other words, in the embodiment illustrated in the present application, both the mobile communication device (or the electronic device) and the smart bluetooth speaker (or the smart bluetooth audio device) have the bluetooth transceiving function. One end (usually, a mobile communication device end or an electronic device end) may be provided with the communication device described in the embodiments below and installed in the transmitting device, and the other end (usually, an intelligent bluetooth speaker or an intelligent bluetooth audio device) may be provided with the communication device described in the embodiments below and installed in the receiving device; in other words, one end serves as a master and has only a transmitting function, and the other end serves as a slave and has only a receiving function. However, this is not a limitation of the present application, and it should be clear to those skilled in the art that in a communication system established by bluetooth technology, a plurality of bluetooth devices may exist, and connection may be performed according to a Piconet (Piconet) or a Scatternet (scatter net), and flexible setting may be performed.
The mobile communication device may also be equivalently replaced by other electronic devices with bluetooth communication function, for example: a desktop computer, laptop computer, server, media player, home appliance, mini-notebook/netbook, tablet computer, smart phone, test device, network device, set-top box, personal digital assistant PDA, smart phone, toy, controller, or other device; the intelligent bluetooth speaker can also be equivalently replaced by other intelligent bluetooth audio devices, for example: is a hearing aid, cochlear implant, vibrating device, speaker, earpiece or other device.
Referring to fig. 4, a schematic structural diagram of a mobile communication device (Phone)400 is shown, which includes a
Referring to fig. 5, a schematic structural diagram of an intelligent bluetooth speaker (AI)500 is shown, which includes a
The AI500 and the Phone400 establish Bluetooth communication connection with each other through respective Bluetooth communication modules.
It should be noted that, in the present application, only the mobile communication device (or the electronic device) is described as having a voice recognition module and having a voice recognition function, but it is not excluded that the smart bluetooth speaker (or the smart bluetooth audio device) is also accompanied by a voice recognition module and has a voice recognition function, and only the voice recognition module is not shown in the exemplary embodiments of the present application.
Referring to fig. 6, a data protocol unit (PDU) of the present application is shown. The method comprises the following fields: header (Head) bit 601, located in the first field of the PDU, 32 bits, and occupying 4 bytes (Byte), e.g., 0xF1F2F3F 4; a device type bit 602, which is located in the second field of the PDU and occupies 1 Byte for a total of 8 bits; and a command type bit 603, located in the third field of the PDU, having 8 bits, occupying 1 Byte. The field immediately following the command type bit is the payload of the PDU, for a total of 4 fields, which payload comprises: a
In some embodiments, a second field in the PDU, device type bit 602, is used to indicate the device type of the transmitting device, occupying one bit; the third field, command type bit 603, is used to indicate that the payload of the PDU carries control instructions or audio data (or contains some other data), occupying one bit. Fig. 7 shows the format of the data protocol unit shown in fig. 6.
In some embodiments, for example, the device type bit 602 is indicated as:
1-Phone;
0-AI;
in this embodiment, the device type bit 602 indicates 1 to transmit the PDU, and 0 to transmit the PDU, which is the smart bluetooth speaker. In some embodiments, when a plurality of bluetooth communication devices are in a bluetooth network, for example, the bluetooth communication devices include 1 Phone400 and a plurality of
In some embodiments, for example, the command type bit 603 is indicated as:
1-audio data;
0-control command;
the field (command type bit 603) defaults to 1, which indicates that the payload of the pre-transmitted PDU carries audio data, and when the payload of the pre-transmitted PDU carries control commands, the field is set to 0 in reverse phase when the PDU is encapsulated, so as to indicate that the payload of the pre-transmitted PDU carries control commands.
Referring to fig. 8, a flowchart of the steps of a bluetooth communication method applied in a transmitting device is shown. The Bluetooth communication method comprises the following steps:
and S800, writing the audio data or the control command into the effective load of the data protocol unit.
When the transmitting device needs to transmit the audio data (or other data), the audio data is written into the data field part of the PDU; when the sending equipment needs to send the control instruction, the control instruction is written into a first command bit field of the PDU, and if two control instructions need to be sent together, the other control instruction is written into a second command bit field of the PDU. When the sending device is Phone400, the control command may be a control instruction instructing the AI500 to perform a corresponding operation, such as "control the AI to answer or hang up the incoming call", "control the AI to play local music", "control the AI volume", and so on.
S801, if the payload is written with audio data, abandoning setting of the command type bit in the data protocol unit.
When audio data is written in the payload of the PDU, a default value of "1" of the command type bit of the PDU is reserved.
S802, if the payload is written with a control command, setting a command type bit in the data protocol unit to indicate that the payload of the data protocol unit is the control command.
When a control command is written in the payload of the PDU, the default value "1" of the command type bit of the PDU is inverted to "0" to indicate that a control command is written in the PDU.
And S803, transmitting the data protocol unit to a receiving device by using Bluetooth network connection.
In some embodiments, the method further comprises:
s804, writing a cyclic redundancy check code in the tail part of the data protocol unit.
And writing a Cyclic Redundancy Check (CRC) code at the tail part of the PDU so that when the PDU is received by the receiving equipment, the CRC is used for checking to check the integrity of the received PDU.
In some embodiments, the method further comprises:
s805, setting a device type bit in the data protocol unit to notify the receiving device that the sending device is an electronic device or an intelligent bluetooth audio device.
If the sending device is Phone400, setting the device type bit of the PDU to be '1'; if the transmitting device is AI500, then the device type bit of the PDU is set to "0". In some embodiments, the method further comprises:
s806, an audio analog signal is received from a source.
When the sending device is a Phone400, the source to be sent is audio data, and the source is the audio processing module 403 built in the Phone400, the
Similarly, when the sending device is the AI500, the source to be sent is the audio data, and the source here is the audio processing module 502 built in the Phone400, and the audio processing module 502 may obtain the external audio data input from the MIC503 directly from the ADC504, or obtain the decoded audio data obtained from the memory 597 by the
S807, determining a type of audio processing to be performed on the audio analog signal for generating a digital output to be pre-transmitted to the receiving device.
S808, performing the audio processing to generate the digital output from the audio analog signal, wherein the digital output is for audio data written into the payload of the data protocol unit.
After receiving the audio analog signal, it needs to perform certain preprocessing, such as noise reduction and filtering to remove noise from the externally input audio data; also for example, audio data retrieved from internal memory, the format of which needs to be decoded, which may be CD format, WAVE (·. WAV), AIFF, AU, MP3, MIDI, WMA, RealAudio, VQF, ogvorbis, AAC, APE, etc.; for example, the audio data may be compressed to reduce the total required size of the audio data, among other various audio processing operations. Finally, the recoding modulation is carried out to form a digital output, which can be G.711, G.722, G.722.1 and/or G.726 coding, MP3 coding, AAC-ELD coding and the like.
Referring to fig. 9, a flowchart of steps of another bluetooth communication method applied to a receiving device is shown. The Bluetooth communication method comprises the following steps:
and S900, receiving the data protocol unit in the application layer of the Bluetooth protocol stack.
And receiving the PDU defined by any embodiment in the App layer, starting parsing and executing subsequent steps.
In some embodiments, the following steps are performed after step S900:
and S9001, judging whether the data protocol unit is complete or not based on the cyclic redundancy check code written in the tail part of the data protocol unit.
And checking the received PDU from the header bit to the data bit through a CRC code at the tail part of the PDU so as to check the integrity of the PDU.
S9002, if it is determined that the data protocol unit PDU is complete, execute step S901.
S9003, if it is determined that the PDU is not complete, discarding the received incomplete PDU, and notifying the sending device to resend the PDU.
S901, determining that the payload of the data protocol unit comprises audio data or a control instruction based on the field in the data protocol unit.
When the receiving device analyzes the PDU, whether the payload of the PDU carries audio data or a control instruction is judged according to the command type bit of the PDU.
S902, if it is determined that the payload of the data protocol unit includes audio data, performing audio processing based on the audio data of the payload.
And if the command type bit of the received PDU is 1, determining that the payload of the PDU carries audio data, and executing audio processing based on the audio data carried by the payload of the PDU.
S903, if it is determined that the payload of the data protocol unit includes a control instruction, perform operation processing based on the control instruction of the payload.
And if the command type bit of the received PDU is 0, determining that the payload of the PDU carries a control instruction, and executing operation processing based on the control instruction carried by the payload of the PDU.
In some embodiments, the audio processing comprises:
s9021, generating processed digital audio data from the audio data. In generating the processed digital audio data from the audio data, one of the following steps may also be performed:
s9022, decompressing the audio data;
s9023, decoding the audio data;
s9024, convert the audio data into audio data in a format that can be further processed by the receiving device.
The audio data in the payload of the PDU may be decompressed, decoded, transcoded, converted, amplified, normalized, shaped, attenuated, reconfigured, customized, and/or otherwise processed.
S9025, generating the processed digital audio data into an audio analog signal.
The processed digital audio data, such as CD format, WAVE (· WAV), AIFF, AU, MP3, MIDI, WMA, RealAudio, VQF, ogvorbis, AAC, APE, etc., is modulated and demodulated into audio analog signals for corresponding processing by a subsequent physical device, such as a transducer.
And S9026, outputting the audio analog signal to a transducer, and generating an output signal by using the transducer. The surround energy converter converts the audio analog signal into an output signal that can be perceived as sound, for example, a sound signal in the form of sound waves, or a sound signal in the form of bone conduction, etc.
In some embodiments, the operational process comprises:
and S9031, generating a control instruction executable by the application program and/or a control analog signal executable by the physical device according to the control instruction.
S9032, sending the control instruction to the corresponding application program to execute corresponding operation; and/or sending the control analog signal to a corresponding physical device to perform a corresponding operation.
After receiving the control instruction sent by the sending device, the receiving device executes different processing according to the difference of the control instruction, if the control instruction is used for controlling the software of the receiving device to execute operation, the control instruction generates the control instruction which can be executed by the corresponding application program, and sends the control instruction to the corresponding application program to execute the corresponding operation; if the hardware for controlling the receiving device executes the operation, the control instruction generates a control analog signal which can be executed by the corresponding physical device, and the control analog signal is sent to the corresponding physical device to execute the corresponding operation.
For example, the Phone400 instructs the AI500 to perform corresponding operations, such as "control AI to answer or hang up a call", "control AI to play local music", "control AI volume increase/decrease", and the like, wherein when the AI500 receives a PDU which is sent by the Phone400 and carries a control instruction of "control AI to answer or hang up a call" or "control AI to play local music", the control instruction of "control AI to answer or hang up a call" is sent to the call application to perform an operation of hanging up the call, and the control instruction of "control AI to play local music" is sent to the audio playing application to perform an operation of playing local music of the
The present application also provides another bluetooth communication method, which is applied in a bluetooth communication system, and the method includes:
first, in a transmitting device, the following steps are performed:
s1000, writing the audio data or the control command into the effective load of the data protocol unit;
s1001, if the payload is written with a control command, setting a command type bit in a header of the data protocol unit to indicate that the payload of the data protocol unit is the control command;
s1002, if the audio data is written in the payload, abandoning the setting of the command type bit in the data protocol unit;
s1003, the data protocol unit is sent to a receiving device by using Bluetooth network connection;
then, in the receiving device, receiving the data protocol unit, and executing the following steps:
s1004, receiving a data protocol unit in an application layer of a Bluetooth protocol stack;
s1005, determining that the payload of the data protocol unit comprises audio data or a control instruction based on the field in the data protocol unit;
s1006, if it is determined that the payload of the data protocol unit includes audio data, performing audio processing based on the audio data of the payload;
s1007, if it is determined that the payload of the data protocol unit includes a control instruction, performing operation processing based on the control instruction of the payload.
The middle bluetooth communication method applied to the bluetooth communication system is basically similar to any of the other embodiments described above, so that the description is simple, and the relevant points can be referred to the partial description of the method embodiment.
In the sending equipment, when a protocol data unit is generated, if the payload written into the protocol data unit is a control instruction, a command type bit in the data protocol unit is set to indicate that the payload of the newly generated data protocol unit carries the control instruction; and if the payload written into the protocol data unit is audio data, abandoning to set a command type bit in the protocol data unit to indicate that the payload of the newly generated data protocol unit carries the audio data. In a receiving device, after a data protocol unit is received, decapsulating in an application layer, analyzing a field in the data protocol unit, when a command type bit is analyzed, determining that a payload of the data protocol unit carries a control instruction when the command type bit is set, and executing corresponding operation based on the control instruction; when the command type bit is not set, it is determined that the payload of the data protocol unit carries audio data, and audio processing is performed based on the audio data. The sending device configures information (audio data or control instructions) carried by a payload of a data protocol unit to be transmitted in the command type bit of the protocol data unit, so that the receiving device can identify the information carried by the payload of the protocol data unit according to the command type bit of the protocol data unit after receiving the protocol data unit. Therefore, the two parties interacting through the Bluetooth protocol can not only transmit audio data, but also transmit specific control instructions.
The technical scheme disclosed by the application is applied to mobile communication equipment and intelligent Bluetooth audio equipment which establish Bluetooth connection, and obviously, even if the mobile equipment has an incoming call, namely, conversation audio (audio data) transmission is carried out between the mobile communication equipment and the intelligent Bluetooth audio equipment, the mobile equipment can still write a specific control instruction into a payload of a protocol data unit through a data protocol unit described in the application, and simultaneously set a command type bit of the protocol data unit. That is to say, after the mobile communication device and the intelligent bluetooth audio device establish the bluetooth communication connection, even if the mobile communication device is in an incoming call state, the intelligent bluetooth audio device can also identify whether the mobile device is still transmitting the control instruction to the intelligent bluetooth audio device, and execute corresponding operation processing according to the transmitted control instruction.
Referring to fig. 10, the following description will take an example that the mobile communication device (Phone400) establishes a bluetooth communication connection with the intelligent bluetooth speaker (AI500), and the Phone400 is in an incoming call state, and the user hangs up the incoming call through voice indication. It should be noted that the present application is not limited thereto, and the technical solutions claimed in the present application are only exemplary to facilitate understanding for those skilled in the art.
The Phone400 and the AI500 have established a bluetooth communication connection, and the Phone400 is in an incoming call state (the Phone400 is in a called but not answered state), and the Phone400 and the AI500 have interacted with the "incoming call" state information of the Phone400 between them. The user makes a voice "hang up", and the MIC503 of the AI500 picks up the voice "hang up", converts the voice "hang up" into an audio analog signal through the DAC504, and sends the audio analog signal to the audio processing module 502 for processing, such as noise reduction and filtering, and converts the audio analog signal of the "hang up" into a digital signal of the "hang up", and then sends the digital signal of the "hang up" to the
The Phone400 receives the first PDU through the
The
TABLE 1
(for details of the fields please refer to the description of PDU above and the following explanation of the fields.)
The AI500 receives the second PDU through the
TABLE 2
And analyzing to obtain that the payload of the second PDU carries a hang-up control instruction, sending the hang-up control instruction into an answering application, executing hang-up operation, and simultaneously responding to the operation by the communication baseband of the Phone400 to hang up the incoming call.
The above example describes in detail a specific process in which the AI500 acquires voice and then sends the voice to the Phone400, the Phone400 recognizes the voice to determine whether the voice command is included, and if the voice command is included, the AI500 is instructed to perform a corresponding operation through the bluetooth connection, which not only illustrates the transmission of audio data (or some other data), but also illustrates the transmission and recognition of control commands, but also does not exclude the transmission of other data or commands, and refer to the following description about other types of PDUs.
In the communication method provided by the present application, when a PDU is encapsulated, each field may further include the following information (it should be noted that, based on the above example, the following description is relatively brief, and a person skilled in the art may directly and unambiguously confirm the meaning of the PDU according to the above example, and therefore, the details are not described):
ore pocket for equipment type enum DevType
Specifically, when encapsulating the PDU, the following PDUs may be used:
1. AI voice data transmission (AI transmits voice data to Phone), see table 3.
TABLE 3
Field interpretation:
device type AI: please refer to enum DevType above.
Command type SOUND: please refer to enum AICmdType above.
2. The OS type of Phone informs the AI, see table 4.
TABLE 4
Field interpretation:
device type PHONE: please refer to enum DevType above.
Command type ossype: please refer to enum PhoneCmdType above.
Command 1:
enum OSType{
ANDROID=1,
IOS
};
3. phone informs the AI device to answer and hang up the Phone, please see table 5.
TABLE 5
Wrapping head
Type of device
Type of Command 1
Command 2
Data length
Data of
CRC
PHEAD
PHONE
PTEL
CMD1
0
Crc16
Field interpretation:
device type AI: please refer to enum DevType above.
Command type PTEL: please refer to enum PhoneCmdType above.
Command CMD 1: please refer to enum TelCmd, supra.
4. The AI device sends/acknowledges the handshake, see table 6.
TABLE 6
Field interpretation:
device type AI: please refer to enum DevType above.
Command type HANDSHAKE: please refer to enum AiCmdType above. Command CMD 1: please refer to SppHandshake above.
Specifically, the method comprises the following steps:
a. initiating a handshake request, and waiting for the response of the Phone;
the Phone receives the request and then responds;
c. responding to the Phone after receiving the Phone response; after three-time handshake confirmation, the handshake is successful.
5. Phone sends/acknowledges the handshake, see table 7.
TABLE 7
Field interpretation:
device type AI: please refer to enum DevType above.
Command type HANDSHAKE: please refer to enum PhoneCmdType above.
Command CMD 1: please refer to SppHandshake above.
Specifically, the method comprises the following steps:
a. initiating a handshake request, and waiting for AI response;
responding after the AI receives the request;
c. responding to AI after receiving AI response; after three times of handshake, the success of handshake is calculated.
6. Phone navigates APP status notifications, see table 8.
TABLE 8
Wrapping head
Type of device
Type of Command 1
Command 2
Data length
Data of
CRC
PHEAD
PHONE
PNAVI
AppState
0
Is free of
Crc16
Field interpretation:
device type PHONE: please refer to enum DevType above.
Command type ossype: please refer to enum PhoneCmdType above.
Command 1: AppState: please refer to the enum AppState above.
7. Phone music APP status notification, see table 9.
TABLE 9
Wrapping head
Type of device
Type of Command 1
Command 2
Data length
Data of
CRC
PHEAD
PHONE
PMUSIC
AppState
Ignore
0
Is free of
Crc16
Field interpretation:
device type PHONE: please refer to enum DevType above.
Command type PMUSIC: please refer to enum PhoneCmdType above.
Command 1: AppState: please refer to the enum AppState above.
8. FM APP status notification by Phone, see table 10.
Watch 10
Wrapping head
Type of device
Type of Command 1
Command 2
Data length
Data of
CRC
PHEAD
PHONE
PFM
AppState
0
Is free of
Crc16
Field interpretation:
device type PHONE: please refer to enum DevType above.
Command type PFM: please refer to enum PhoneCmdType above.
Command 1: AppState: please refer to the enum AppState above.
9. Phone controls AI local music, see table 11.
TABLE 11
Wrapping head
Type of device
Type of Command 1
Command 2
Data length
Data of
CRC
PHEAD
PHONE
AIMUSIC
AiCmd
0
Is free of
Crc16
Field interpretation:
device type PHONE: please refer to enum DevType above.
Command type AIMUSIC: please refer to enum PhoneCmdType above.
Command type AiCmd: please refer to enum AiCmd above.
10. Phone controls the FM of AI, see Table 12.
TABLE 12
Wrapping head
Type of device
Type of Command 1
Command 2
Data length
Data of
CRC
PHEAD
PHONE
AIFM
AiCmd
0
Is free of
Crc16
Field interpretation:
device type PHONE: please refer to enum DevType above.
Command type AIMUSIC: please refer to enum PhoneCmdType above.
Command type AiCmd: please refer to enum AiCmd above.
11. Phone controls the AI MIC, see Table 13.
Watch 13
Wrapping head
Type of device
Type of Command 1
Command 2
Data length
Data of
CRC
PHEAD
PHONE
AIMIC
AiCmd
0
Is free of
Crc16
Field interpretation:
device type PHONE: please refer to enum DevType above.
Command type AIMIC: please refer to enum PhoneCmdType above.
Command type AiCmd: please refer to enum AiCmd above.
12. Phone sets the AI parameters, see table 14.
TABLE 14
Field interpretation:
device type PHONE: please refer to enum DevType above.
Command type AICFG: please refer to enum PhoneCmdType above.
Command type AiCfg: please refer to enum AiCfg supra.
enum AiCfg{
SET_CFG=1,
GET_CFG,
};
enum CfgType{
Retention
}。
13. Phone obtains the AI parameters, see Table 15.
Watch 15
Field interpretation:
device type PHONE: please refer to enum DevType above.
Command type AICFG: please refer to enum PhoneCmdType above.
Command type AiCfg: please refer to enum AiCfg supra.
enum AiCfg{
SET_CFG=1,
GET_CFG,
};
enum CfgType{
Retention
}。
14. AI FIRMWARE, see table 16.
TABLE 16
Field interpretation:
device type PHONE: please refer to enum DevType above.
Command type AIUPDATE: please refer to enum PhoneCmdType above.
PkgNo-high: the packet sequence number is high byte.
Pkgn no _ Low: the section of the sequence number of the sub-packet is high and low.
A Phone can control an AI according to the PDU, or an AI control Phone can realize various functions, and perform data interaction with each other, and those skilled in the art can clearly obtain specific functions according to the "hang up" incoming call example and various instructions or data in the PDU, which are not described herein again. It should be noted that the above-mentioned exemplary PDU is neither a limitation of the present application nor an exhaustive list of control commands and data that the PDU of the present application may carry, and those skilled in the art can directly and unambiguously confirm that other more specific commands or data are possible, and they are not further detailed herein.
The application provides a bluetooth communication apparatus, load in receiving equipment, the apparatus is configured as:
receiving a data protocol unit in an application layer of a Bluetooth protocol stack;
determining, based on a field in a header of the data protocol unit, that a payload of the data protocol unit includes audio data or a control instruction;
if the effective load of the data protocol unit comprises audio data, executing audio processing based on the audio data of the effective load;
and if the payload of the data protocol unit is determined to comprise the control instruction, executing operation processing based on the control instruction of the payload.
The present application further provides another bluetooth communication apparatus, loaded in a transmitting device, the apparatus configured to:
writing the audio data or the control instruction into the effective load of the data protocol unit;
if audio data is written in the payload, abandoning setting a command type bit in a header of the data protocol unit;
if a control instruction is written in the payload, setting a command type bit in a header of the data protocol unit to indicate that the payload of the data protocol unit is a control instruction;
the data protocol unit is sent to a receiving device using a bluetooth network connection.
The application provides a bluetooth communication system, including sending apparatus and receiving arrangement;
the transmitting device is configured to:
writing the audio data or the control instruction into the effective load of the data protocol unit;
if audio data is written in the payload, abandoning setting a command type bit in a header of the data protocol unit;
if a control instruction is written in the payload, setting a command type bit in a header of the data protocol unit to indicate that the payload of the data protocol unit is a control instruction;
transmitting the data protocol unit to a receiving device using a bluetooth network connection;
the receiving device is configured to:
receiving a data protocol unit in an application layer of a Bluetooth protocol stack;
determining, based on a field in a header of the data protocol unit, that a payload of the data protocol unit includes audio data or a control instruction;
if the effective load of the data protocol unit comprises audio data, executing audio processing based on the audio data of the effective load;
and if the payload of the data protocol unit is determined to comprise the control instruction, executing operation processing based on the control instruction of the payload.
For the apparatus and system embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference may be made to some descriptions of the method embodiments for relevant points.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
The above detailed description is given to a bluetooth communication method, apparatus and system, and specific examples are applied in this document to explain the principle and implementation of the present application, and the description of the above embodiments is only used to help understand the method and core ideas of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.