參考:在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