请选择 进入手机版 | 继续访问电脑版
查看: 2334|回复: 0

[技术交流] 【和你一起聊聊BLE】——蓝牙DTM测试指令 之 HCI数据包解析

[复制链接]

93

主题

99

帖子

381

积分

利尔达员工

Rank: 9Rank: 9Rank: 9

积分
381
发表于 2019-5-5 19:51:52 | 显示全部楼层 |阅读模式
使用HCI指令对BLE进行DTM测试时,对应的指令解析如下。

一、HCI数据包通常分为四种类型:
1. HCI Command Packet 0x01;
2. HCI ACL Data Packets 0x02;
3. HCI Synchronous Data Packets 0x03;
4. HCI Event Packet  0x04;
如果人机交互包是通过公共物理接口发送的,必须添加数据包指示符。人机交互包指示符应在人机交互包之前立即发送。

二、 HCI Command Packet 结构如下:

OpCode为操作码(长度为16 bits),由组字段OCF(10 bits)和命令字段OGF(6 bits)两部分组成。

OGF(高6位):
For the Link Control commands, the OGF is defined as 0x01.
For the Link Policy Commands, the OGF is defined as 0x02.
For the HCI Control and Baseband Commands, the OGF is defined as 0x03.
For Informational Parameters Commands, the OGF is defined as 0x04.
For the Status Parameters Commands, the OGF is defined as 0x05.
For the Testing Commands, the OGF is defined as 0x06.
For the LE Controller Commands, the OGF code is defined as 0x08.
0x3F reserved for vendor-specific debug commands  

OCF(低10位):
OCF与具体的命令有关,使用时需要参考蓝牙的Core文档。

Parameter Total Length:数据长度

Parameter N:数据包内容

三、DTM指令解析:
LE Transmitter Test Command 、LE Receiver Test Command、LE Test End Command指令属于HCI Command Packet  ,所以包头需要添加数据包指示符0x01。
这三条指令属于LE Controller Commands,所以对应的OGF为0x08。
这三条测试指令对应的OCF和数据包内容参考如下:



由于OCF占低10位,OGF占高6位,以LE Transmitter Test Command为例进行换算:


按照数据包格式为高位在右,得出LE Transmitter Test Command的包为:0x01 0x1E 0x20 0x03 xx yy zz;LE Receiver Test Command的包头为:0x01 0x1D 0x20 0x01 xx;LE Test End Command的包头为:0x01 0x1F 0x20 0x00。
数据包内容根据测试需求进行配置。
















本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表