参考:在HCI层看蓝牙的连接过程_hci 获取蓝牙pin码-CSDN博客
我这边查看的是core 5.2
一、数据交互流程
1、ACL连接建立后的可选流程
参考蓝牙core5.2: vol2 --> PartF --> 4
1.1 AUTHENTICATION REQUESTED
Authentication can be explicitly executed at any time after a
connection has been established. If no Link Key is available then the Link Key
is required from the Host.身份验证可以在连接建立后的任何时间显式执行。如果没有可用的链接密钥,则需要主机提供链接密钥
1.2 简单配对信息交互
2、SYNCHRONOUS CONNECTION SETUP (SCO和ESCO连接流程)
Using the HCI_Setup_Synchronous_Connection command, a Host can add a
synchronous logical channel to the link. A synchronous logical link can be
provided by creating a SCO or an eSCO logical transport.
Note: An ACL connection must be established before a synchronous
connection can be created.HCI Setup Synchronous Connection命令用来在链路上添加同步逻辑通道。同步逻辑链路可以通过创建SCO或eSCO逻辑传输来提供。
注意:创建同步连接前,必须先建立ACL连接
分三个场景,这儿只列出来一个场景
二、hci命令和事件
Link Key Request Reply command
core5.2: vol4 --> PartE --> 7.1.10
Description:
The HCI_Link_Key_Request_Reply command is used to reply to an
HCI_Link_Key_Request event from the Controller, and specifies the Link Key
stored on the Host to be used as the link key for the connection with the other
BR/EDR Controller specified by BD_ADDR. The HCI_Link_Key_Request
event will be generated when the BR/EDR Controller needs a Link Key for a
connection.
When the BR/EDR Controller generates an HCI_Link_Key_Request event in
order for the local Link Manager to respond to the request from the remote Link
Manager (as a result of an HCI_Create_Connection or
HCI_Authentication_Requested command from the remote Host), the local
Host shall respond with either an HCI_Link_Key_Request_Reply or
HCI_Link_Key_Request_Negative_Reply command before the remote Link
Manager detects LMP response timeout.翻译:HCI Link Key Request Reply命令用于回复控制器发出的HCI Link Key Request事件,并指定存储在主机上的Link Key作为与BD ADDR指定的另一个BR/EDR控制器连接的Link Key。当BR/EDR控制器需要用于连接的Link Key时,将生成HCI Link Key Request事件。当BR/EDR控制器生成HCI链路密钥请求事件,以便本地链路管理器响应来自远程链路管理器的请求时(作为HCI创建连接或HCI认证请求的结果)
困惑1:Link Key Request一开始以为是一个hci命令,由host发起,但是却在命令里找不到这个,只能找到Link Key Request Reply?
答:Link Key Request event 是一个事件,是从controller里向host发起的,不是由蓝牙协议栈发起, 在蓝牙core的 在vol4 --> PartE --> 7.7.23