当前位置:网站首页>Bluetooth development (3) -- look at the air bag
Bluetooth development (3) -- look at the air bag
2022-06-11 00:08:00 【yuanyun_ elber】
stay initial At this stage, we saw a lot of hci command and hci event Interaction ,controller stay init After that, the initialization is completed , The state has also become HCI_INIT_DONE.
The next step is to go into a program called GAP Of profile,GAP This profile And others profile The obvious difference is , other profile It's all based on l2cap Of , and gap No .
Let's take a look first gap The definition of :
GAP,Generic Access Profile, The Profile Make sure it's different Bluetooth Products can discover each other and connect with each other
GAP Defines how Bluetooth devices discover and establish security with other devices / Unsafe connection
It handles some general business models ( If asked 、 Name and search ) And some security issues ( Such as guarantee )
At the same time, it also handles some services related to connection ( Such as link establishment 、 Channel and connection establishment )
GAP It stipulates some general operation tasks ; therefore , It is mandatory , And as the basis of all other Bluetooth application specifications
Gap It's called profile, Because it is also an application .
For example , Bluetooth on our mobile phones , You need to enter the Bluetooth settings menu , Open to pair , then Enter a state that can be discovered by other Bluetooth devices . This is the time , It's actually called gap The interface of .
This time, we'll grab the bag , That is from initial After completion , This order begins to enter gap Stage .

Basically, there is no room for one screen , because GAP The things involved in the layer include discovery 、 Connect 、 authentication 、 Encryption, etc , There are still a lot to talk about .
As controller Speaking of , This time and initial Compared with the first stage of , The biggest difference , Is to start interacting with the outside world .
We can take a look at the air bag .

As shown in the figure , A large number of LMP package , So-called LMP package , In fact, it is marked by the red line ACL-C package . these LMP The contents of the package are controller act , The upper level is not clear , The participation of the upper level at this stage , Mainly to controller dispatch orders , Give Way controller Enter a state , Pairable 、 Connectable 、 Read remote device information 、 encryption … wait .
And after this stage , other profile When I started working ,host The sense of participation is stronger , You can see the bags under the red box , All are l2cap Layers above the package , These bags are from host Layers pass through hci acl data The interface is distributed to controller, from controller adopt ACL –U Packets are sent to the remote end in this format .
Speaking of ACL-C\ACL-U, This stage , It is necessary for us to talk about the format of Bluetooth packets .
Take a look at the picture below , I remember an interview , An interviewer asked me about the format of Bluetooth packets , Although there are in the protocol specifications , But Bluetooth people , If you can't recite it , Is also to be despised .

First of all access code, Which includes PA,preamble, Basically, wireless communication is indispensable , Including SYNC WORD,SYNC WORD The Bluetooth address is hidden in the middle , We know that today's wireless environment is complex , There are so many bags in the air , How do we know which bags we need , According to the Bluetooth address , A lot of junk information , stay access code You can filter it out .
The picture below is access code The format of :

And then there was Packet header,packet header It mainly includes Lt_addr, This address is used to distinguish slave The equipment , Then the format of the package , Include DM1、2DH3、2EV3 And so on , Coding efficiency of different formats 、 The anti-interference performance is different , The baseband will automatically select the appropriate format to send packets according to the environment
Then flow control ,ARQ( Question and answer mechanism ), Serial number, etc , And finally a HEC Check code

stay packet header There's one in the back guard Sync , Because if it is edr Words , The modulation mode is different before and after , Need to resynchronize .
And then there was payload header, We will only discuss here acl package ,(sco Package does not discuss ) The package format mentioned above is in this LLID Contains , Actually LLID There are no more than two package formats , One is LMP-C, One is LMP-U, It's just that the LMP-U Contents related to subcontracting , We also know that l2cap Tier supports subcontracting , The main implementation is in LLID The middle mark is start Package or continous package . Pay attention to this payload header and header There is a flow control bit , It's easy to confuse , The specific contents are as follows .

And then there is payload body 了 , This is exactly what our upper level agreement issued .
controller When receiving packets , First, at the scheduled reception slot On , Turn on according to the preset FM sequence RF, If you receive access code Words , Determine the Bluetooth address , If it wasn't sent to us , Direct filtration , Then receive packet header, Among them is HEC check , If the check does not pass , And direct filtration , Then adjust RF, receive payload,payload Finally, there is crc Verified , If crc If it doesn't pass , Will be filtered out again , So finally controller to host The data package has been reached through thousands of mountains and rivers , Is reliable .
边栏推荐
- Website online customer service system Gofly source code development log - 5 Gin framework integration daemon
- [pyGame games] here it is. This Gobang game is super A. share it with your friends~
- Leetcode-209 minimum length subarray
- 【 pygame Games 】 don't find, Leisure Games Theme come 丨 Bubble Dragon applet - - Leisure Games Development recommendation
- 【Go语言学习】——并发编程
- 【Pygame小遊戲】別找了,休閑遊戲專題來了丨泡泡龍小程序——休閑遊戲研發推薦
- 快速排序
- 示波器刷新率怎么测量
- LabVIEW phase locked loop (PLL)
- Serial port missing in Ni Max in LabVIEW
猜你喜欢

Go语言Channel理解使用

Leetcode-15 sum of three numbers

C language file operation

vtk. VTP download in JS
![[auto reply or remind assistant] Mom doesn't have to worry about me missing messages any more (10 Line Code Series)](/img/b3/64429247ee1b91a05d4faa1d78a1df.png)
[auto reply or remind assistant] Mom doesn't have to worry about me missing messages any more (10 Line Code Series)

【Pygame小游戏】剧情流推荐:什么样的游戏才能获得大家的喜欢呢?(魔鬼恋人、霸总娇妻版)

Hyperleger fabric installation
![[mathematics] [continuum mechanics] symmetry tensor, strain tensor and stress tensor in fluid mechanics](/img/13/210ed249dfa3010bf69fead8e06f1b.png)
[mathematics] [continuum mechanics] symmetry tensor, strain tensor and stress tensor in fluid mechanics

【Pygame小游戏】《坦克大战》,那些童年的游戏你还记得几个呢?

示波器刷新率怎么测量
随机推荐
LabVIEW error "memory full - Application stopped on node"
B 树的简单认识
Typecho website speed optimization - Xingze V Club
Why is the website snapshot hijacked and tampered with
【AcWing】4. Multiple knapsack problem I
长投学堂开户安全吗?靠谱吗?
File转为MultipartFile的方法
Redis installation and common problem solving based on centeros7 (explanation with pictures)
归并排序
Select sort
vtk. VTP download in JS
选择排序
[opencv practice] this seal "artifact" is awesome, saving time and improving efficiency. It is powerful ~ (complete source code attached)
集合删除元素技巧 removeIf
[pyGame] stir up your brain and play the "24 o'clock" idea together ~ (awesome)
phpstudy的安装
From the perspective of Confucius Temple IP crossover, we can see how the six walnuts become "butterflies" for the second time
[pyGame games] story stream recommendation: what kind of games can you like? (devil lover, bully's wife version)
How to measure the refresh rate of oscilloscope
什么是绝对和相对路径,有哪些优缺点?