当前位置:网站首页>[Bluetooth Bluetooth development] VIII. Transmission layer of ble protocol
[Bluetooth Bluetooth development] VIII. Transmission layer of ble protocol
2022-07-28 21:36:00 【Swastika twelve painting Swastika】


List of articles
8.1 Preface

Link Layer The transport layer goes up , It's the transport layer . Transport layer , be located Host and Controller Between layers , Provide the ability to transmit data without knowing the detailed data content . It is mainly transmitted through hardware media ( Such as :UART、USB、SDIO etc. ), transmission Bluetooth HCI The data of .
Here is UART Block diagram of the transport layer :

Look at the picture above , We probably have a general understanding of the transport layer , Let's analyze it in detail .
HCI Detailed introduction , having evidence or referent sources
Core5.0 P670

8.2 HCI(Host Controller Interface) Introduce

Upper figure , Shows the data transmission path between the two devices .Host adopt HCI Driver Driver and Controller On hardware HCI Firmware Exchange data and commands , The transport layer provides such capabilities .
The main role of the transport layer :
- The Bluetooth protocol stack sends the connected to the chip
command - Bluetooth chip reports to Bluetooth protocol stack
command status with create connection opcode - Bluetooth chip reports Bluetooth protocol stack
connect complete
HCI Provides a unified interface for accessing , control Controller, The transport layer is transparent , Independent of the underlying transmission technology , And no relationship Host Transferred to the Controller What is the data of .
stay HOST And Controller Between , With Command And Event Command mode for transmission .Host send out Command Information to Controller,Controller take Command Status and Params With Event Returned to Host, Finally back to Command Complete Event Indicates that the connection is complete .
More intuitive , as follows :

HCI There are four types of package formats , Namely :

- HCI Command Packet: The command sent to the chip by the Bluetooth protocol stack , namely
Host->Controller - HCI Event Packet: Events reported by Bluetooth chip to Bluetooth protocol stack , namely
Controller->Host - HCI ACL Data Packet: Common data of two-way interaction between Bluetooth protocol stack and Bluetooth chip .
- HCI Synchronous Data Packet: Common data of two-way interaction between Bluetooth protocol stack and Bluetooth chip .
Detailed see
Core5.0.pdf P670
stay Host and Controller Between ,HCI The command and event types of are as follows :
Detailed see
Core5.0.pdf P647

The interactive data format is :

8.3 HCI Packet format
HCI Provides a unified command format to access Controller, Different commands also take different time . The transport layer commands Command And events Event To communicate , Now let's mainly look at the format of communication packets .
8.3.1 Handles
Handle: Identification of the channel of the logical link , There are three categories :Connection_Handles, Logical Link Handles, and Physical Link Handles
8.3.1.1 Primary Controller Handles
Connection_Handles: By Primary Controller Handles Distribute , Identify the logical channel between the host and the master controller , When a new logical link is established ,Connection_Handles Will be assigned .
The Handle It is mainly used in :Connection Complete, Synchronous Connection Complete, LE Connection Complete, or LEEnhanced Connection Complete Of Event Incident .
8.3.1.1.1 Broadcast Connection_Handles
Host At the first power on or restart , First send HCI Data packets , Assign a Connection_Handle. thereafter , Use this Handle Go broadcast .
8.3.1.2 AMP Controller Handles
AMP Controllers There are two kinds of :Logical Link Handles, and Physical Link Handles.
about Host And AMP Controller Between Data,Command and Event operation , If Physical Link Handles To be designated , Then use the Handle, If not specified , When specified Connection_Handle Where to use Logical Link Handles
It's not right here AMP Make a detailed description .
8.3.2 HCI Command Packet
HCI Command Packet be used for Host Send a command to Controller controller .
The package format is as follows :

- OpCode Field
OpCode: Occupy two bytes , Used for command identification , Divided into two domains :OCF:OpCode Group Field and OGF OpCode Command Field.
OGF: Occupy high 6bitOCF: Occupy low 10bit, among0X3FCommissioning order for the manufacturer .

- Paramter_Total_Length Field
Paramter_Total_Length: The length of all parameters in the package .

- Paramter Field

8.3.3 HCI Event Packet
Every Command After the command is issued , They always bring one Event Return to the status after the command is executed .
The package format is as follows :

- Event_Code Field
Event_Code: Identify different event types .

- Parameter_Total_Length Field
Parameter_Total_Length: Parameter total length

- Event_Parameter Field
Event_ParameteN: Related parameters

8.3.4 HCI ACL Data Packets
HCI ACL Data Packets Specifies the format of the data packet , be used for Host And Controller Data exchange between .
There are two types of packets :
- Automatically-Flushable: Automatically refresh
Automatically refresh the package , The time of its automatic refresh depends on the set time .
- Non-Automatically-Flushable: Non automatic refresh
Non automatic refresh , The packet will not be refreshed automatically .
The package format is as follows :

- Handle Field
Handle: As mentioned above , There are several types of this field :
Connection_Handle: Used to send packets or segments on the main controllerLogical_Link_Handle: be used for AMP The controller sends packetsPhysical Link Handles: be used for AMP The controller sends packetsFlag Field
Flag Include :PB Flag and BC Flag, namely Packet_Boundary_Flag And Broadcast_Flag, The values are as follows :


8.3.5 HCI Synchronous Data Packets
The packet , Used in Host and Controller Exchange synchronous data between .
The package format is as follows :

- Packet_Status_Flag Field
This field is associated with Erroneous_Data_Reporting Parameters are related to :
- If
Erroneous_Data_ReportingParameter set todisable, bePacket_Status_FlagField set to 00 - If
Erroneous_Data_ReportingParameter set toenable, bePacket_Status_FlagFields are set according to the following table

- Data_Total_Length Field

8.4 HCI Connection package example
HCI Connect command flow :
1) The Bluetooth protocol stack sends the connection command to the chip :HCI Connect command
2) The Bluetooth chip reports the command status to the Bluetooth protocol stack :HCI Command Complete
3) After successful connection , Bluetooth chip reports the successful connection event of Bluetooth protocol stack :HCI LE Connect complete
8.4.1 HCI Connect command
Core5.0 P774
This command is used to make Link Manager Link manager to connect remote devices .
Connect command The packet format is as follows :

OCF: Here you can see OCF Value , that OGF How much is it worth ?
open
Core5.0 P774, We can seeHCI_Create_ConnectionThe order belongs toLINK CONTROL COMMANDSLink control command group , This group OGF by 0x01. SeeCore5.0 P766For the Link Control commands, the OGF is defined as 0x01.
BD_ADDR: To connect the remote Bluetooth address of the device ,6 Bytes .
Packet_Type: Supported packet types ,2 Bytes .

Page_Scan_Repetition_Mode: Whether to repeat scanning

Clock_Offset: Clock offset between master and slave devices .

Allow_Role_Switch: Whether master-slave role conversion is supported

8.4.2 Command Complete Event
When Controller Received Create_Connection command , Will send a Command Complete Event to Host.
The event format is as follows :

This event is used to return the status after most commands are sent .
Event Code: Event code
Num_HCI_Command_Packets: Set up Host It can be sent to Controller Number of command packages , If not , Is set to 0

Command_Opcode: Indicates the corresponding command code

Return_Parameters: Return the parameters specified by the command

8.4.3 Connection Complete Event
This event shows Host And Controller The connection channel between is established successfully .

Event Code: Event code
Status: Connection status

Connection_Handle: After successful connection , Generated Handle value

BD_ADDR: After successful connection MAC Address

Link_Type: Connection type

Encryption_Enabled: Is it encrypted

These parameters are not necessarily required , Here's the catch HCI package , I hope it helps .


All right. , The above is the Bluetooth Protocol HCI Detailed introduction of the interface , After a detailed understanding , We have analysis HCI The basic capability of data package !

边栏推荐
- 中国农业工程学会农业水土工程专业委员会-第十二届-笔记
- LeetCode·581.最短无序连续子数组·双指针
- Cloud security core technology
- CVPR 2022 | 网络中批处理归一化估计偏移的深入研究
- Summary of 29 typical problems in Devops planning and construction of securities enterprises based on containerized PAAS platform
- Maintenance of delta hot metal detector principle analysis of v5g-jc-r1 laser measurement sensor / detector
- JVM 内存布局详解(荣耀典藏版)
- Niuke turns on the camera and the picture disappears a few seconds later | the picture flashes when the camera is turned on
- 百度搜索为什么只抓取,却不展现页面?
- High salary in the workplace | "intermediate and advanced test" interview questions
猜你喜欢

Talk about row storage and column storage of database

(PMIC)全、半桥驱动器CSD95481RWJ PDF 规格

属性基加密仿真及代码实现(CP-ABE)论文:Ciphertext-Policy Attribute-Based Encryption

Bus, protocol, specification, interface, data acquisition and control system in industrial communication field

Kubeadm搭建kubernetes集群

到底为什么不建议使用SELECT * ?

大学荒废三年,大四自学7个月测试,找到了12K的工作

比UUID更快更安全NanoID到底是怎么实现的?(荣耀典藏版)

Leetcode linked list question - interview question 02.07. linked list intersection (learn linked list by one question and one article)

凡尔赛天花板:“毕业两年月薪才35K,真是没出息啊~~”
随机推荐
Bug of Dom4j
百度搜索为什么只抓取,却不展现页面?
Why on earth is it not recommended to use select *?
CVPR 2022 | in depth study of batch normalized estimation offset in network
两个全局变量__dirname和__filename 、fs模块常用功能进一步介绍
华为发布首款电驱动系统DriveONE:充电10分钟续航200km
Invalid prompt object name in SQL Server
MATLAB从入门到精通 第1章 MATLAB入门
Buuctf questions upload labs record pass-11~pass-20
What is the purpose of database read-write separation [easy to understand]
Cy3/Cy5/Cy5.5/Cy7荧光标记抗体/蛋白试剂盒(10~100mg标记量)
Ctfshow network lost track record (1)
蚂蚁集团境外站点 Seata 实践与探索
Modify the port number of MySQL (is there a problem modifying the port number of MySQL)
SSM use @async and create threadpooltaskexecutor thread pool
工业通讯领域的总线、协议、规范、接口、数据采集与控制系统
ABB电磁流量计维修信号变送器维修41F/E4技术参数
Query Oracle view creation statement and how to insert data into the view [easy to understand]
Leetcode linked list problem -- 142. circular linked list II (learn the linked list by one question and one article)
[英雄星球七月集训LeetCode解题日报] 第28日 动态规划