(1)IO Capability Request Event(常用)
这个event表示在简单配对过程中host需要提供自己的IO capabilities,host应该使用HCI_IO_Capability_Request_Reply或者HCI_IO_Capability_Request_Negative_Reply进行回复。
参数说明:
BR_ADDR(6 Octets):远端设备地址
举例说明:
0x04:表示HCI Event Packet
0x31:表示这个event是IO Capability Request event
0x06:表示Parameter_Total_Length即6个byte
0xeb 0x01 0xce 0x55 0x36 0x34:表示远端设备地址BD_ADDR,即远端设备地址是0x34:0x36:0x55:0xce:0x01:0xeb
(2)IO Capability Request Reply Command(常用)
收到IO Capability Request event时可以使用这个命令回复,and specifies the current I/O
参数说明:
BR_ADDR(6 Octets):对方设备地址
IO_Capability(1 Octets):取值范围
OOB_Data_Present(1 Octets):取值范围
如果在IO Capabilty Request event中已经收到来自BD_ADDR设备的OOB认证数据,则OOB_Data_Present应该设置为:
0x1:P-192 OOB authentication data from remote device present表示只收到P-192 OOB数据
0x2:P-256 OOB authentication data from remote device present表示只收到P-256 OOB数据
0x3:P-192 and P-256 OOB authentication data from remote device present表示收到了P-192和P-256 OOB数据
如果在IO Capabilty Request event中没有收到来自BD_ADDR设备的OOB认证数据,则OOB_Data_Present应该设置为:
0x0:OOB authentication data not present
Authentication_Requirements(1 Octets):取值范围
如果不需要link key,则Authentication_Requirements可以设置成:
0x0:MITM Protection Not Required – No Bonding
0x2:MITM Protection Not Required – Dedicated Bonding
0x4:MITM Protection Not Required – General Bonding
如果2个Hosts设置的Authentication_Requirements都是上面中的一个,那么host应该使用Just Works Association Model.
如果需要link key,则Authentication_Requirements可以设置成:
0x1:MITM Protection Required – No Bonding
0x3:MITM Protection Required – Dedicated Bonding
0x5:MITM Protection Required – General Bonding
返回参数说明:
Status(1 Octet):0x00表示成功,其他表示失败
BR_ADDR(6 Octets):对方设备地址
举例说明:
Command如下:
0x01:表示HCI Command Packet
0x042b:表示是HCI_IO_Capability_Request_Reply command
指令的OGF是0x01即0000 01
OCF是0x002b即00 0010 1011
所以整个opcode是0000 0100 0010 1011即0x042b
0x09:表示Parameter_Total_Length=9,即参数总长度是9个byte
0x01:表示设置Secure_Connections_Host_Support为enabled
0xeb 0x01 0xce 0x55 0x36 0x34:表示远端设备地址BD_ADDR,即远端设备地址是0x34:0x36:0x55:0xce:0x01:0xeb
0x01:表示IO_Capability为DisplayOnly
0x00:表示OOB_Data_Present为OOB authentication data not present
0x03:表示Authentication_Requirements为MITM Protection Required – Dedicated Bonding
Command Complete event:
0x04:表示HCI Event Packet
0x0e:表示这个event是command complete event
0x0a:表示Parameter_Total_Length即10个byte
0x01:表示Num_HCI_Command_Packets
0x042b:表示是HCI_IO_Capability_Request_Reply command
0x00:表示status为0
0xeb 0x01 0xce 0x55 0x36 0x34:表示远端设备地址BD_ADDR,即远端设备地址是0x34:0x36:0x55:0xce:0x01:0xeb
(3)IO Capability Request Negative Reply Command(常用)
收到IO Capability Request Event 以后,可以使用这个command拒绝
参数说明:
BR_ADDR(6 Octets):远端设备地址
Reason(1 Octets):拒绝的原因
返回参数说明:
Status(1 Octets):0x00表示成功,其他表示失败
BR_ADDR(6 Octets):远端设备地址
注意:Reason参数不能使用0x37 (Simple Pairing not Supported by Host)
举例说明:(暂时没有)
(4)IO Capability Response Event(常用)
表示本地设备接收到来自远端设备的IO Capability回复
参数说明:
BR_ADDR(6 Octets):远端设备地址
IO_Capability(1 Octets):取值范围
OOB_Data_Present(1 Octets):取值范围
Authentication_Requirements(1 Octets):取值范围
举例说明:
0x04:表示HCI Event Packet
0x32:表示这个event是IO Capability Response event
0x09:表示Parameter_Total_Length即9个byte
0xeb 0x01 0xce 0x55 0x36 0x34:表示远端设备地址BD_ADDR,即远端设备地址是0x34:0x36:0x55:0xce:0x01:0xeb
0x03:表示IO_Capability为NoInputNoOutput
0x00:表示OOB_Data_Present为OOB authentication data not present
0x02:表示Authentication_Requirements为MITM Protection Not Required – Dedicated Bonding
第二阶段:public key exchange没有 HCIcommand
第三阶段:Authentication stage 1:Numeric Comparison和Just work
(1)User Confirmation Request Event(常用)
这个event是controller发送给host,请求用户确认Numeric_Value,即用户界面会跳出配对提示框,Numeric_Value就是配对码(host也可能直接响应不在UI显示)
Host可以使用User_Confirmation_Request_Reply或者User_Confirmation_Request_Negative_Reply来响应这个event
至于是否显示根据自己的代码设计,但是我感觉:
如果host的io capability是DisplayYesNo则可以显示配对码让用户选择YES/NO,如果是DisplayOnly,则可以显示一小段时间,host自动回复controller,如果是KeyboardOnly或者NoInputNoOutput就别显示了
注意:host回复controller应该在LMP response timeout之前
参数说明:
BR_ADDR(6 Octets):远端设备地址
Numeric_Value(4 Octets):用于显示的配对码000000-999999
举例说明:
0x04:表示HCI Event Packet
0x33:表示这个event是User Confirmation Request event
0x0a:表示Parameter_Total_Length即10个byte
0xcc 0xc8 0x17 0xd5 0x13 0x0a:表示远端设备地址BD_ADDR,即远端设备地址是0x0a 0x13 0xd5 0x17 0xc8 0xcc
0x84 0x00 0x02 0x00:配对码为0x00020084(这是十六进制,一般给用户显示十进制)
(2)User Confirmation Request Reply Command(常用)
当收到User Confirmation Request Event后,可以使用这个命令表示同意配对,host也可以不询问用户直接调用这个command同意配对。
参数说明:
BR_ADDR(6 Octets):远端设备地址
返回参数说明:
Status(1 Octets):0x00表示成功,其他表示失败
BR_ADDR(6 Octets):远端设备地址
举例说明:
0x01:表示HCI Command Packet
0x042c:表示是HCI_User_Confirmation_Request_Reply command
指令的OGF是0x01即0000 01
OCF是0x002C即00 0010 1100
所以整个opcode是0000 0100 0010 1100即0x042C
0x06:表示Parameter_Total_Length=6,即参数总长度是9个byte
0xcc 0xc8 0x17 0xd5 0x13 0x0a:表示远端设备地址BD_ADDR,即远端设备地址是0x0a 0x13 0xd5 0x17 0xc8 0xcc
Command Complete event:
0x04:表示HCI Event Packet
0x0e:表示这个event是command complete event
0x0a:表示Parameter_Total_Length即10个byte
0x01:表示Num_HCI_Command_Packets
0x042C:表示是HCI_User_Confirmation_Request_Reply command
0x00:表示status为0
0xcc 0xc8 0x17 0xd5 0x13 0x0a:表示远端设备地址BD_ADDR,即远端设备地址是0x0a 0x13 0xd5 0x17 0xc8 0xcc
(3)User Confirmation Request Negative Reply Command(常用)
当收到User Confirmation Request Event后,可以使用这个命令表示拒绝配对,host也可以不询问用户直接调用这个command拒绝配对。
参数说明:
BR_ADDR(6 Octets):远端设备地址
返回参数说明:
Status(1 Octets):0x00表示成功,其他表示失败
BR_ADDR(6 Octets):远端设备地址
举例说明:(暂时没有)
第三阶段:Authentication stage 1:Passkey Entry procedure
(1)User Passkey Request Event(常用)
这个event表示Simple Pairing过程中需要host输入passkey,host应该使用User_Passkey_Request_Reply或者User_Passkey_Request_Negative_Reply回复
参数说明:
BR_ADDR(6 Octets):远端设备地址
举例说明:(暂时没有)
(2)User Passkey Notification Event(常用)
这个event表示controller提供一个passkey给host,用于显示。Passkey Entry过程中IO capability为DisplayOnly或者DisplayYesNo的设备会收到这个event
参数说明:
BR_ADDR(6 Octets):远端设备地址
Passkey(4 Octets):用于显示的passkey,000000-999999
举例说明:(暂时没有)
(3)Send Keypress Notification Command(常用)
Passkey Entry过程中IO capability为KeyboardOnly的设备用这个command来通知远端设备自己开始输入密码/清除密码/输入密码结束等动作。
参数说明:
BR_ADDR(6 Octets):远端设备地址
Notification-Type(1 Octets):取值范围:
返回参数说明:
Status(1 Octets):0x00表示成功,其他表示失败
BR_ADDR(6 Octets):远端设备地址
举例说明:(暂时没有)
(4)Keypress Notification Event(常用)
当远端设备使用Send Keypress Notification Command发送passkey输入状态时,本地host就会接收到这个event,用来确定远端设备的动作。
参数说明:
BR_ADDR(6 Octets):远端设备地址
Notification-Type(1 Octets):取值范围:
举例说明:(暂时没有)
(5)User Passkey Request Reply Command(常用)
当host收到User Passkey Request event后,host可以使用这个command将用户输入的passkey(Numeric_Value)发送给Controller
参数说明:
BR_ADDR(6 Octets):远端设备地址
Numeric_Value(4 Octets):表示用户输入的passkey,000000-999999
返回参数说明:
Status(1 Octets):0x00表示成功,其他表示失败
BR_ADDR(6 Octets):远端设备地址
举例说明:(暂时没有)
(6)User Passkey Request Negative Reply Command(常用)
当host收到User Passkey Request event或者User Passkey Notification Event后,可以中这个command拒绝配对。
参数说明:
BR_ADDR(6 Octets):远端设备地址
返回参数说明:
Status(1 Octets):0x00表示成功,其他表示失败
BR_ADDR(6 Octets):远端设备地址
举例说明:(暂时没有)
第三阶段:Authentication stage 1:OOB(没用过不会用)