当前位置:网站首页>Bluetooth development (8) -- avdtp connection process

Bluetooth development (8) -- avdtp connection process

2022-06-11 00:09:00 yuanyun_ elber

At the end of the previous chapter , We see a avdtp Of l2cap channel It's set up , Next avdtp You can start walking .

Avdtp The document of is another 140 A multi page behemoth , There are still a lot of things to see .

Avdtp yes a2dp(advanced audio distribution protocol) The basic agreement of , Generally speaking ,avdtp Of l2cap channel It is necessary to establish two , Here we first establish the first , That is to say signal channel( This is the same as l2cap Of signal channel So close , Broadly , It can be said that signal channel The function of the is to control ), Then there is another one stream channel, As the name suggests, it is used to transmit code stream .

Let's take a look avdtp signal Connection process , Actually sum l2cap The connection process of is quite similar ,l2cap It is the equipment of both parties that must determine the other party cid, Then configure it , After friendly negotiation , Establishing a connection .

Avdtp There is one sep The concept of ,stream end point, Each device is virtualized with several sep( It's usually 1 individual ), Every sep To distribute independently seid, Be similar to l2cap Of cid, It's just sep、seid It's a preset , and cid It is dynamically allocated during connection .

When connecting , First, through discover The command found several peer devices sep, Every sep The type of media (audio?video?multi?), Let's say , The local sep It's a audio sink( Audio playback device , For example, speakers ), distant sep It's a audio source( Sound source equipment , For example, mobile phones ), So these two sep You can connect .

Here's the picture , Send this discover The command is actually two bytes , But two bytes are taken in bits , Contains a lot of information , for instance transaction,packet type It's a single,message type yes command wait , Let's not talk about this . Insert a sentence , there packet type Subcontracting is also supported , except single outside , also start ,continue,end package , Is it very similar to l2cap The subcontracting mechanism of ? But it's basically useless here ,signal channel Your bag is usually very small .

Then the remote end replied , The other party has 6 individual sep, Every sep The types of audio src, You can take a look at each sep There are distributive opposites seid Of .

Next get capability and set configuration The process is similar to l2cap Configuration process , First INT End ( launch avdtp The party connected is called INT) towards ACP End ( Accept avdtp One side of the connection ) send out get capability command:

Then the other party replies with support codec Information , Including the encoding format is sbc( bluetooth sink It is an option that must be supported by default ), Sampling rate 、 Compression ratio, etc , It's all about audio .

INT End receipt ACP After the end information , And local capablity Perform an operation with ,( Usually the upper floor profile To do it ), Then proceed to the final configuration

Received the following message ACP After receiving the configured message , The configuration process is complete .

Next , To get into stream establishment The stage of .

First ,INT send out stream OPEN command

When you receive a reply , Enter key operations , We can build stream channel 了 , It's called transport session,avdtp Stipulated tranport session It's not just stream channel, There may be recovery channel and report channel, Although the latter two are not commonly used , Let's just cut in .Report channel As the name suggests, it is used for reporting , The report includes some statistical information 、 Time alignment 、 Channel quality, etc , To help the upper software have a better strategy for error recovery .

Recovery channel And error correction , Bluetooth transmission is reliable , It can also be said to be unreliable .

Reliable because it has ARQ Retransmission mechanism , Unreliable because this retransmission is not unlimited , Especially for acl Link , There is one flush timeout Of , We mentioned it before l2cap Configuration process , Speaking of MTU This option , I want to mention flush timeout This option , If this option is set , Then it means that there is an upper limit to the emphasis on transmission , When the upper limit is exceeded , If retransmission has not been successful , The package will be removed . Error correction code provided by Bluetooth itself FEC Functional limitation , therefore avdtp There is one recovery channel Further provide error correction function .

Idle time , establish stream channel And establish signal channel It's the same thing ,l2cap channel A set of processes established .

When stream channel When it's set up , as long as signal channel issue start command , It means playing music , Can be in stream channel Up pass stream Code stream , Follow another set RTP The format of (real-time transport protocol), I won't repeat . Here's the picture , This is a bag stream data , Contains 7 frame , Probably 20 many ms The data of .

In the middle of the song , You can also pause 、 Reconfiguration, etc , through signal channel Issue the corresponding command suspend、reconfigure wait .

The basic process is like the following figure :

The format is too complicated , We are not going to analyze them one by one ,spec All of them have , I just picked up the outline . In the next chapter, we will further analyze the code .

原网站

版权声明
本文为[yuanyun_ elber]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020629284270.html