目录
2. 协议浅述 (2)
2.1. HCI简介 (2)
2.2. HCI协议数据格式 (3)
2.3. HCI命令和事件介绍 (6)
3. HCI协议数据分析 (8)
HCI协议数据分析
分析的log使用手机进行抓取,log会在此文档的附件中。
其中蓝色的部分是数据包的类型,红色为具体的hci的数据,在这里我们将解析到l2cap开始建立为止,至于l2cap部分我们将在l2cap分析中说明。
1.Host:
00000010 00000010 00100000 00000110 0000000000000010 00000000 01000001 0000000100000000 00000001
00000001 00000011 00001100 00000000
Command:00000001(0x01)
Opcode:00000011 00001100(ogf:000011(0x03),ocf:0000000011(0x03))根据ogf和ocf查表可知为复位指令
Paramter total length:00000000(参数长度为零,即没有参数)
2.Controller:
00000100 00001110 00000100 00000001 00000011 00001100 00000000
Event:00000100(0x04)
Event code:00001110(0x0e,命令完成指令)
Paramter total length:00000100 (参数长度为4)
Num hci command packet:00000001(表明controller还可以接收1个host的指令)
Opcode:00000011 00001100(ogf:000011(0x03),ocf:0000000011(0x03))指明是对reset指令的回复
Status:00000000(零为成功,其他为失败,具体参考失败码)
3.Host:
00000001 00000101 00010000 00000000
Command:00000001(0x01)
Opcode:00000101 00010000(ogf:000100(0x04),ocf:0000000101(0x05))根据ogf和ocf查表可知为读取buffer大小的指令
Paramter total length:00000000(参数长度为零,即没有参数)
4.Controller:
00000100 00001110 00001011 00000001 00000101 00010000 00000000 00000000 00000100 00111100 00000111 00000000 00001000 00000000
Event:00000100(0x04)
Event code:00001110(0x0e,命令完成指令)
Paramter total length:00001011 (参数长度为11)
Num hci command packet:00000001(表明controller还可以接收1个host的指令)
Opcode:00000101 00010000(ogf:000100(0x04),ocf:0000000101(0x05))指明是对read buffer指令的回复
后面为具体的参数内容,其在指令的返回值中有描述,下同:
Status:00000000(零为成功,其他为失败,具体参考失败码)
HC_ACL_Data_Packet_Length:00000000 00000100(0x0400=1024)
HC_Synchronous_Data_Packet_Length: 00111100(0x3c=60)
HC_Total_Num_ACL_Data_Packets: 00000111 00000000(0x7=7)
HC_Total_Num_Synchronous_Data_Packets: 00001000 00000000(0x8=8)
5.Host:
00000001 00110011 00001100 00000111 10011011 00000110 11111111 00010100 00000000 00001010 00000000
Command:00000001(0x01)
Opcode:00110011 00001100(ogf:000011(0x03),ocf:0000110011 (0x33))根据ogf和ocf查表可知为设置buffer大小的指令
Paramter total length:00000111 (参数长度为7)
HC_ACL_Data_Packet_Length:10011011 00000110(0x069b=1691)
HC_Synchronous_Data_Packet_Length: 11111111 (0xff=255)
HC_Total_Num_ACL_Data_Packets: 00010100 00000000(0x14=20)
HC_Total_Num_Synchronous_Data_Packets: 00001010 00000000(0xa=10)
6.Controller:
00000100 00001110 00000100 00000001 00110011 00001100 00000000
Event:00000100(0x04)
Event code:00001110(0x0e,命令完成指令)
Paramter total length:00000100 (参数长度为4)
Num hci command packet:00000001(表明controller还可以接收1个host的指令)
Opcode:00110011 00001100(ogf:000011(0x03),ocf:0000110011 (0x33))指明是对set buffer指令的回复
Status:00000000(零为成功,其他为失败,具体参考失败码)
7.Host:
00000001 00000001 00010000 00000000
Command:00000001(0x01)
Opcode:00000001 00010000(ogf:000100(0x04),ocf:0000000001 (0x01))根据ogf和ocf查表可知为获取版本信息
Paramter total length:00000000 (参数长度为0)
8.Controller:
00000100 00001110 00001100 00000001 00000001 00010000 00000000 00001000 00000000 00000000 00001000 00011101 00000000 01011010 00000010
Event:00000100(0x04)
Event code:00001110(0x0e,命令完成指令)
Paramter total length:00001100 (参数长度为12)
Num hci command packet:00000001(表明controller还可以接收1个host的指