软件协议文档
终端设备协议文档
功能&协议池(所有功能协议)
MQTT协议文档
HTTP协议文档
微光TLV协议文档
微光卡&码协议
功能模块&UI文档
人脸机
VF105
门禁标品MQTT协议文档(DejaOS版本)
Access control standard MQTT protocol document
VF系列HTTP协议接口文档V1.0.28(Vbar版本)
VF系列MQTT协议文档V1.37.0(Vbar版本)
VF系列-协议模式下通讯协议文档V1.0.4(Vbar版本)
VF203
门禁标品MQTT协议文档(DejaOS版本)
Access control standard MQTT protocol document
VF系列HTTP协议接口文档V1.0.28(Vbar版本)
VF系列-协议模式下通讯协议文档V1.0.4(Vbar版本)
VF系列-MQTT协议文档V1.37.2(Vbar版本)
VF 系列 HTTP 协议接口文档-V1.37.1(Vbar版本)
VF106
门禁标品MQTT协议文档(Android版本)
Access control standard MQTT protocol document
VF114
门禁标品MQTT协议文档(DejaOS版本)
Access control standard MQTT protocol document
VF系列HTTP协议接口文档V1.0.28(Vbar版本)
VF系列-协议模式下通讯协议文档V1.0.4(Vbar版本)
VF205
门禁标品MQTT协议文档(DejaOS版本)
VF系列HTTP协议接口文档V1.0.28(Vbar版本)
VF系列-协议模式下通讯协议文档V1.0.4(Vbar版本)
读头
EE200
读头标品TLV通讯协议
Read header standard TLV communication protocol
读头标品TLV通讯协议V3.10(Vbar版本)
TX200
读头标品TLV通讯协议
Read header standard TLV communication protocol
QT960
读头标品TLV通讯协议
Read header standard TLV communication protocol
QT660
读头标品TLV通讯协议
Read header standard TLV communication protocol
Q340
读头标品TLV通讯协议
Read header standard TLV communication protocol
M300
读头标品TLV通讯协议
Read header standard TLV communication protocol
读头标品TLV通讯协议V3.10(Vbar版本)
JL7000
读头标品TLV通讯协议
Read header standard TLV communication protocol
Q350
读头标品TLV通讯协议
Read header standard TLV communication protocol
MU86
读头标品TLV通讯协议
Read header standard TLV communication protocol
读头标品TLV通讯协议V3.10(Vbar版本)
MET
读头标品TLV通讯协议
Read header standard TLV communication protocol
扫码器TCP/HTT通讯协议V1.0(Vbar版本)
读头标品TLV通讯协议V3.10(Vbar版本)
M350
读头标品TLV通讯协议
Read header standard TLV communication protocol
读头标品TLV通讯协议V3.10(Vbar版本)
扫码器TCP/HTT通讯协议V1.0(Vbar版本)
DW200
读头标品TLV通讯协议(DejaOS版本)
Read header standard TLV communication protocol
读头标品HTTP&TCP协议文档(DejaOS版本)
读头标品HTTP&TCP协议文档(Vbar版本)
读头标品TLV通讯协议V3.10(Vbar版)
读头标品RS485一拖多协议V0.7(Vbar版本)
M340
读头标品TLV通讯协议
Read header standard TLV communication protocol
CR90
刷卡模块通信协议v3.0
CR90指令文档
微光指令:0x60 蓝牙设备控制
1.7/2.x扫码器配置字段说明文档
门禁
DW200
门禁标品MQTT协议文档(DejaOS版本)
Access control standard MQTT protocol document
门禁扫码器MQTT协议文档(Vbar版本)
MU86
门禁标品MQTT协议文档
Access control standard MQTT protocol document
门禁20180820 MQTT协议文档V1.0.2(Vbar版)
Q350
门禁标品MQTT协议文档
Access control standard MQTT protocol document
门禁20180820 MQTT协议文档V1.0.2(Vbar版)
MET
门禁标品MQTT协议文档
Access control standard MQTT protocol document
门禁20180820 MQTT协议文档V1.0.2(Vbar版)
M350
门禁标品MQTT协议文档
Access control standard MQTT protocol document
门禁20180820 MQTT协议V1.0.1(Vbar版本)
门禁20180820 MQTT协议文档V1.0.2(Vbar版本)
MP86
门禁20180820 MQTT协议文档V1.0.2(Vbar版本)
控制板
CC104
控制板标品MQTT协议文档
Control board standard MQTT protocol documentation
CC101
控制板标品MQTT协议文档
Control board standard MQTT protocol documentation
CC101标品20211101MQTT协议V3.6(Vbar版本)
平台服务协议文档
网关服务接口定义
门禁应用接口定义
工具文档
多弦产品API签名安全规则
海外锁
app和后台的mqtt协议
文档
-
+
首页
微光指令:0x60 蓝牙设备控制
# 0x60 :蓝牙设备控制指令 <br> <table> <thead> <tr> <td bgcolor=#1E90FF colspan="5">指令: 0x60</td> <td colspan="5">修改/获取蓝牙的一些参数 </td> </tr> </thead> <body> <tr> <td colspan="10"> 说明:<br>P1: 指示V的数据格式和功能<br>P2:根据P1和设备类型不同,而不同 </td> </tr> <tr> <td bgcolor=#FFFF00> 项目</td><td> 字节</td> <td colspan="3">说明</td> <td> 项目</td><td> 字节</td> <td colspan="3">说明</td> </tr> <tr> <td>包头 </td><td>2Byte </td><td colspan="3"> 0x55 0xAA </td><td>包头 </td><td>1Byte </td><td colspan="3">0x55 0xAA</td><td> </tr> <tr> <td>命令字</td><td> 1Byte</td><td colspan="3"> 0x60</td><td> 命令字</td><td> 1Byte</td><td colspan="3"> 0x60</td> </tr> <tr> <td>数据域长度</td><td> 2 Byte</td><td colspan="3"> N </td><td>标识字</td><td> 1Byte</td><td colspan="3"> 0x00 : 成功 非0 : 参见附录1</td> </tr> <tr> <td rowspan="4">数据域</td> <td rowspan="4">N Byte</td> <td>P1</td><td> 1 Byte</td><td>指示V的数据格式和功能</td><td> 数据域长度 </td><td>2 Byte <td colspan="3">N</td> </tr> <tr> <td>P2</td><td> 1 Byte</td><td> X </td><td rowspan="3">数据域</td><td rowspan="3"> N Byte</td><td rowspan="3" colspan="3"></td> </tr> <tr> <td>V<sub>d</sub> </td><td>L Byte</td><td> 根据P1值确定</td> </tr> <tr> <td>SHA256 _ENC </td><td> </td><td>不一定存在</td><td></td> </tr> <tr> <td>校验字</td><td> 1 Byte</td><td colspan="3"> </td><td> 校验字</td><td> 1 Byte </td><td colspan="3"></td> </tr> </body> </table> ## 1.1 P1 = 0x01 配置蓝牙相关参数 支持的蓝牙相关参数如下表格。每项TLV指示蓝牙的一个配置项, 当存在多个配置项时,采用平铺的格式:<font color=#FF000 > V<sub>p</sub></font> = TLV + TLV ....。 对于CR90设备,此时P2=1 <table> <tr> <td bgcolor=#1e90ff> T (1 Byte) </td> <td>L(1 Byte)<td bgcolor=#00BFFF> V</td> </tr> <tr> <td > 蓝牙名称(0x10) </td> <td >N Byte</td> <td> N=0: 获取<br>N !=0 :设置 </td> </tr> <tr> <td>蓝牙地址 (0x11) </td><td>N Byte</td><td colspan="3">N=0: 获取<br>N !=0 :设置</td> </tr> <tr> <td>蓝牙固件版本号(0x12)</td><td> 0 Byte </td><td olspan="3"></td> </tr> <tr> <td>广播中的SN(0x14)</td><td> 0/6 Byte</td> <td olspan="3"> <a href="http://wiki.dxiot.com:90/zh/embed/%E9%80%9A%E4%BF%A1%E5%8D%8F%E8%AE%AE/%E8%93%9D%E7%89%99%E7%9B%B8%E5%85%B3/%E5%BE%AE%E5%85%89%E8%93%9D%E7%89%99%E8%AE%BE%E5%A4%87%E5%B9%BF%E6%92%AD%E6%95%B0%E6%8D%AE%E8%A7%84%E8%8C%83"><div> 设置:参见广播规范</div></a><br>L=0:表示获取</td> </tr> <tr> <td>广播中的设备状态标识(0x15)</td><td> 0/1 Byte </td> <td olspan="3"> <a href="http://wiki.dxiot.com:90/zh/embed/%E9%80%9A%E4%BF%A1%E5%8D%8F%E8%AE%AE/%E8%93%9D%E7%89%99%E7%9B%B8%E5%85%B3/%E5%BE%AE%E5%85%89%E8%93%9D%E7%89%99%E8%AE%BE%E5%A4%87%E5%B9%BF%E6%92%AD%E6%95%B0%E6%8D%AE%E8%A7%84%E8%8C%83"><div> 设置:参见广播规范</div></a> <br>L=0:表示获取</td> </tr> </table> P2的值: <table> <tr> <td bgcolor=#1e90ff> 设备类型</td> <td> 值 </td> </tr> <tr> <td>CR90</td> <td> 1 </td> </tr> <tr> <td>DW200</td> <td> 0 </td> </tr> </table> ### 1.1.1 使用流程 情况一:<font color=#FF000 >V<sub>p</sub></font>中存在修改参数的Tag 1. 向设备请求随机数(16/32 Byte),然后使用会话根密钥加密,加密出的密文就是此次会话密钥<font color=#FF000 >K<sub>sec</sub></font> 2. 计算<font color=#FF000 >V<sub>T</sub></font>, TLV格式,其T = 0xff, V=SHA256 _ENC, SHA256 _ENC的计算方式如下   **V<sub>sha256</sub>**=SHA256(P1 + P2 + <font color=#FF00>V<sub>p</sub></font>)   SHA256_ENC = F<sub>enc</sub>(**V<sub>sha256</sub>**) 3. V<sub>d</sub> = V<sub>p</sub> + V<sub>T</sub> <font color=##FEEE00>注意:1. 加密函数F<sub>enc</sub> 为AES 2. 会话根密钥: 根据具体设备而定 </font> 情况二:<font color=#FF000 >V<sub>p</sub></font>中不存在修改参数的Tag     V<sub>d</sub> = V<sub>p</sub><br> ## 1.2 P1=0x7A: 用户主控转发P1=0x01的请求 <br> <table> <thead> <tr> <td colspan="5">指令: 0x60</td> <td colspan="5">用于主控转发P1=0x01的请求。 </td> </tr> </thead> <body> <tr> <td colspan="10"> 说明: 当主控识别0x60: P1=0x01的请求不是来自于蓝牙上位机,而是来自于其他方式,如上位机通过USB发送0x60: P1=0x01指令。或者上位机(用户)不通过微光通信协议,如: 扫码请求,MQTT请求等方式请求P=0x01支持的功能时,主机解析其合法性后,若是合法,则通过此指令与蓝牙交互,实现P1=0x01支持的功能。<br><br>P2: 其含义由主机赋值并解释,蓝牙MCU不做解析,原封返回。 </td> </tr> <tr> <td> 项目</td><td> 字节</td> <td colspan="3"><font color=#008000>BLE -> HOST </font></td> <td> 项目</td><td> 字节</td> <td colspan="3"><font color=PaleVioletRed>HOST -> BLE </font></td> </tr> <tr> <td>包头 </td><td>2Byte </td><td colspan="3"> 0x55 0xAA </td><td>包头 </td><td>1Byte </td><td colspan="3">0x55 0xAA</td><td> </tr> <tr> <td>命令字</td><td> 1Byte</td><td colspan="3"> 0x60</td><td> 命令字</td><td> 1Byte</td><td colspan="3"> 0x60</td> </tr> <tr> <td>数据域长度</td><td> 2 Byte</td><td colspan="3"> N </td><td>标识字</td><td> 1Byte</td><td colspan="3"> 0x00 </td> </tr> <tr> <td rowspan="4">数据域</td> <td rowspan="4">N Byte</td> <td>P1</td><td> 1 Byte</td><td>0x7A</td><td> 数据域长度 </td><td>2 Byte <td colspan="3">N</td> </tr> <tr> <td>P2</td><td> 1 Byte</td><td> </td><td rowspan="3">数据域</td><td rowspan="3"> N Byte</td><td>P1</td><td>1 Byte</td><td>0x7A</td> </tr> <tr> <td rowspan="2">V </td><td rowspan="2">X Byte</td><td rowspan="2"></td> <td>P2</td><td> 1 Byte </td><td></td> </tr> <tr> <td>V</td><td> X Byte </td><td>参见P=0x01中的V<sub>p</sub></td> </tr> <tr> <td>校验字</td><td> 1 Byte</td><td colspan="3"> </td><td> 校验字</td><td> 1 Byte </td><td colspan="3"></td> </tr> </body> </table> ## 1.3 P1=0x7E <br> <table> <thead> <tr> <td colspan="5">指令: 0x60</td> <td colspan="5">P1= 0x7E: 用于主控和蓝牙之间的内部交互使用 </td> </tr> </thead> <body> <tr> <td colspan="10"> 说明<br>1. 支持半双工,双方的通信角色不在通过协议包的格式区分,而是通过P2的值区分:<br>  P2=0x80: 表示应答包<br>  P2=0x01: 表示请求包,并指示对方需要应答<br>  P2=0x00: 表示请求包,指示对方不需要应答<br>P3: 其值含义由TLV数据决定<br>V: 基础格式为TLV, 若有多项TLV,可平铺模式依次排列(需要相同的P3含义),也可单独发送(同时需要主控支持),支持的TLV如下:<br><table> <tr> <td>T (1 Byte)</td><td>L(1 Byte)</td><td>V</td> </tr> <tr> <td>状态交互: <font color=#FF1493>0x01</font></td> <td></td><td><br>参见1.2.1</td> </tr> <tr> <td>主控获取蓝牙参数: <font color=#FF1493>0x02</font></td> <td>0</td><td>参见1.2.2</td> </tr> <tr> <td>开关蓝牙广播: <font color=#FF1493>0x03</font></td> <td>0</td><td>参见1.2.3</td> </tr> <tr> <td>蓝牙发送Log: <font color=#FF1493>0x11</font></td> <td>0</td><td>暂不支持</td> </tr> </table> </td> </tr> <tr> <td> 项目</td><td> 字节</td> <td colspan="3"><font color=#008000>BLE -> HOST </font></td> <td> 项目</td><td> 字节</td> <td colspan="3"><font color=PaleVioletRed>HOST -> BLE</font></td> </tr> <tr> <td>包头 </td><td>2Byte </td><td colspan="3"> 0x55 0xAA </td><td>包头 </td><td>1Byte </td><td colspan="3">0x55 0xAA</td><td> </tr> <tr> <td>命令字</td><td> 1Byte</td><td colspan="3"> 0x60</td><td> 命令字</td><td> 1Byte</td><td colspan="3"> 0x60</td> </tr> <tr> <td>数据域长度</td><td> 2 Byte</td><td colspan="3"> N </td><td>标识字</td><td> 1Byte</td><td colspan="3"> 0x00 </td> </tr> <tr> <td rowspan="5">数据域</td> <td rowspan="5">N Byte</td> <td>P1</td><td> 1 Byte</td><td>0x7E</td><td> 数据域长度 </td><td>2 Byte <td colspan="3">N</td> </tr> <tr> <td>P2</td><td> 1 Byte</td><td> </td><td rowspan="4">数据域</td><td rowspan="4"> N Byte</td> <td> P1</td><td> 1 Byte</td><td> 0x7E </td> </tr> <tr> <td>P3</td><td> 1 Byte</td><td> </td><td>P2</td><td> 1 Byte</td><td> </td> </tr> <tr> <td rowspan="2">V </td><td rowspan="2">X Byte</td><td rowspan="2">TLV数据</td> <td>P3</td><td>1 Byte</td><td></td> </tr> <tr> <td>V</td><td> X Byte</td><td> TLV数据 </td> </tr> <tr> <td>校验字</td><td> 1 Byte</td><td colspan="3"> </td><td> 校验字</td><td> 1 Byte </td><td colspan="3"></td> </tr> </body> </table> <br> ### 1.3.1 Tag: 0x01 状态交互 >用自己(请求方)的状态去交换对端(应答方)的状态 <table> <tr> <td bgcolor=LightSeaGreen colspan="3">HOST -> BLE </td> </tr> <tr> <td>T (1 Byte)</td><td>L (1 Byte)</td><td>V</td> </tr> <tr> <td>0x01</td><td>N</td><td>V<sub>host</sub></td> </tr> </table> V<sub>host</sub>的格式: <table> <tr> <td>Host State(1Byte)</td> </tr> <tr> <td>00: 正常; <br>01:主控休眠;<br> 02:主控关机</td> </tr> </table> <table> <tr> <td bgcolor=LightSeaGreen colspan="3">BLE -> HOST</td> </tr> <tr> <td>T (1 Byte)</td><td>L (1 Byte)</td><td>V</td> </tr> <tr> <td>0x01</td><td>N</td><td>V<sub>ble</sub></td> </tr> </table> V<sub>ble</sub>的格式: <table> <tr> <td>BLE State(1Byte)</td> <td>BLE restart Flg(1Byte)</td> </tr> <tr> <td>0x40: 等待升级状态</td> <td>进入此状态的原因:<br> 0x80: 命令进入的, 0x02: 原固件无法启动</td> </tr> </table> ### 1.3.2 Tag: 0x02 主控获取蓝牙参数 <table> <tr> <td bgcolor=LightSeaGreen colspan="3">HOST -> BLE </td> <td bgcolor=LightSalmon colspan="3">BLE -> HOST </td> </tr> <tr> <td>T</td><td>L</td><td>V</td> <td>T</td><td>L</td><td>V</td> </tr> <tr> <td>0x02</td><td>0</td><td></td> <td>0x02</td><td>N</td><td> 多项TLV 数据,平铺结构<br>T: 0x01: 蓝牙名称<br>T: 0x02 蓝牙MAC Addr<br>T:0x03 SN<br>T:0x04 广播中的设备状态</td> </tr> </table> ### 1.3.3 Tag: 0x03 主控开关蓝牙广播 <table> <tr> <th style="background-color: lightyellow;" rowspan="2">HOST->BLE </th> <th style="background-color: lightblue;">HEAD</th> <th style="background-color: lightgreen;">CMD</th> <th style="background-color: lightgreen;">标识字</th> <th >DLen</th> <th style="background-color: lightpink;">P1</th> <th style="background-color: lightcyan;">P2</th> <th style="background-color: lightcyan;">P3</th> <th style="background-color: lightcyan;">T</th> <th style="background-color: lightpink;">L</th> <th style="background-color: lightpink;">req</th> <th style="background-color: lightcyan;">CONN_ID</th> <th style="background-color: lightcyan;">校验字</th> </tr> <tr> <td style="background-color: lightblue;">55 AA</td> <td style="background-color: lightgreen;">60</td> <td style="background-color: lightgreen;">0</td> <td >07 00</td> <td style="background-color: lightpink;">7E</td> <td >BIT0=1: 需要BLE应答</td> <td >0</td> <td >03</td> <td >1</td> <td >0: 关闭广播,1: 打开广播</td> <td style="background-color: lightcyan;">0xFE</td> <td style="background-color: lightcyan;">BCC</td> </tr> </table> <table> <tr> <th style="background-color: lightyellow;" rowspan="2">BLE -> HOST</th> <th style="background-color: lightblue;">HEAD</th> <th style="background-color: lightgreen;">CMD</th> <th >DLen</th> <th style="background-color: lightpink;">P1</th> <th style="background-color: lightcyan;">P2</th> <th style="background-color: lightcyan;">P3</th> <th style="background-color: lightcyan;">T</th> <th style="background-color: lightpink;">L</th> <th style="background-color: lightpink;">result</th> <th style="background-color: lightcyan;">CONN_ID</th> <th style="background-color: lightcyan;">校验字</th> </tr> <tr> <td style="background-color: lightblue;">55 AA</td> <td style="background-color: lightgreen;">60</td> <td >23 00</td> <td style="background-color: lightpink;">7E</td> <td >BIT7=1</td> <td >0</td> <td >03</td> <td >1</td> <td >0: 成功; oth: 失败</td> <td style="background-color: lightcyan;">0xFE</td> <td style="background-color: lightcyan;">BCC</td> </tr> </table> ### 1.3.4 外设连接事件上报 <table> <tr> <th style="background-color: lightyellow;" rowspan="2">BLE -> HOST</th> <th style="background-color: lightblue;">HEAD</th> <th style="background-color: lightgreen;">CMD</th> <th >DLen</th> <th style="background-color: lightpink;">P1</th> <th style="background-color: lightcyan;">P2</th> <th style="background-color: lightcyan;">P3</th> <th style="background-color: lightcyan;">T</th> <th style="background-color: lightpink;">L</th> <th style="background-color: lightpink;">FLAG</th> <th style="background-color: lightpink;">Reason</th> <th style="background-color: lightpink;">central_MAC_ADDR(OPTION)</th> <th style="background-color: lightcyan;">CONN_ID</th> <th style="background-color: lightcyan;">校验字</th> </tr> <tr> <td style="background-color: lightblue;">55 AA</td> <td style="background-color: lightgreen;">60</td> <td >23 00</td> <td style="background-color: lightpink;">7E</td> <td >0</td> <td >0</td> <td >01</td> <td >8/2</td> <td >BIT0: 设备状态; BIT1: 某个central连接</td> <td >0</td> <td style="background-color: lightpink;">d0000c1068f7</td> <td style="background-color: lightcyan;">0x02(分配的连接号)</td> <td style="background-color: lightcyan;">BCC</td> </tr> </table> <table> <tr> <th style="background-color: lightyellow;" rowspan="2">BLE -> HOST</th> <th style="background-color: lightblue;">HEAD</th> <th style="background-color: lightgreen;">CMD</th> <th >DLen</th> <th style="background-color: lightpink;">P1</th> <th style="background-color: lightcyan;">P2</th> <th style="background-color: lightcyan;">P3</th> <th style="background-color: lightcyan;">T</th> <th style="background-color: lightpink;">L</th> <th style="background-color: lightpink;">FLAG</th> <th style="background-color: lightpink;">Reason</th> <th style="background-color: lightpink;">central_MAC_ADDR(OPTION)</th> <th style="background-color: lightcyan;">CONN_ID</th> <th style="background-color: lightcyan;">校验字</th> </tr> <tr> <td style="background-color: lightblue;">55 AA</td> <td style="background-color: lightgreen;">60</td> <td >23 00</td> <td style="background-color: lightpink;">7E</td> <td >0</td> <td >0</td> <td >01</td> <td >8/2</td> <td >BIT0: 设备状态; BIT2: 被动断开; BIT3: 外设主动断开</td> <td >reason</td> <td style="background-color: lightpink;">d0000c1068f7</td> <td style="background-color: lightcyan;">0x02(分配的连接号)</td> <td style="background-color: lightcyan;">BCC</td> </tr> </table> ## 1.4 P1=0x0A 设备作为Central模式时的操作指令 ### 1.4.1 基础通信格式(协议格式中未说明的都是一字节)</br> <table> <tr> <th style="background-color: lightyellow;" rowspan="2">BLE -> HOST</th> <th style="background-color: lightblue;">HEAD(2Byte)</th> <th style="background-color: lightgreen;">CMD</th> <th >DLen(2Byte)</th> <th style="background-color: lightpink;">Data(N Byte)</th> <th style="background-color: lightcyan;">校验字</th> </tr> <tr> <td style="background-color: lightblue;">55 AA</td> <td style="background-color: lightgreen;">60</td> <td >L</td> <td style="background-color: lightpink;">P1, P2, P3 + V + CONN_ID</td> <td style="background-color: lightcyan;">BCC</td> </tr> </table> <table> <tr> <th style="background-color: lightyellow;" rowspan="2">HOST -> BLE</th> <th style="background-color: lightblue;">HEAD(2Byte)</th> <th style="background-color: lightgreen;">CMD</th> <th style="background-color: lightgreen;">标识字</th> <th >DLen(2Byte)</th> <th style="background-color: lightpink;">Data(N Byte)</th> <th style="background-color: lightcyan;">校验字</th> </tr> <tr> <td style="background-color: lightblue;">55 AA</td> <td style="background-color: lightgreen;">60</td> <td style="background-color: lightgreen;"></td> <td >L</td> <td style="background-color: lightpink;">P1, P2, P3 + V + CONN_ID</td> <td style="background-color: lightcyan;">BCC</td> </tr> </table></br> <span style="color: red;">关于P2各BIT位的说明</span></br> <table> <tr> <th style="background-color: lightgray;">位</th> <th style="background-color: lightblue;">7(MSB)</th> <th style="background-color: lightgreen;">6</th> <th style="background-color: lightyellow;">5</th> <th style="background-color: lightpink;">4</th> <th style="background-color: lightcyan;">3</th> <th colspan="3" style="background-color: lightcoral;">2 - 0(LSB)</th> </tr> <tr> <td style="background-color: lightgray;">说明</td> <td style="background-color: lightblue;">P2_FLAG</td> <td style="background-color: lightgreen;">x</td> <td style="background-color: lightyellow;">x</td> <td style="background-color: lightpink;">x</td> <td style="background-color: lightcyan;">x</td> <td colspan="3" style="background-color: lightcoral;">P2_Source</td> </tr> </table> P2_FLAG: HOST->BLE时,只能是0, BLE->HOST: 1: 异步事件, 0:应答HOST的请求<br> P2_Source: 指示BLE设备将数据发给哪端,是HOST还是远端BLE设备。1表示发给远端BLE设备,其他值:表示HOST,至于HOST传给谁,HOST定义。当前不支持1<br> x: 当前无定义, 默认是0<br> <span style="color: red;">关于P3的说明</span></br> 当P2指示的是请求与应答,那么P3 =0, 当P2指示的是异步事件,那么P3表示具体事件<br> <span style="color: red;">CONN_ID</span> 连接号: 0xFE: 指本机蓝牙 oth_val: 有效连接号 ### 1.4.2 支持的命令请求</br> 命令的请求与应答是数据域中的<span style="color: red;">V</span>, 其格式是TLV。每次请求只能发一个TLV。 <table> <tr> <th style="background-color: lightgray;">Type</th> <th style="background-color: lightblue;">Length</th> <th style="background-color: lightgreen;">Value</th> <th style="background-color: lightgreen;">说明</th> </tr> <tr> <td style="background-color: lightblue;">0x01</td> <td style="background-color: lightgreen;"></td> <td style="background-color: lightyellow;">扫描参数</td> <td style="background-color: lightyellow;">扫描设备</td> </tr> <tr> <td style="background-color: lightblue;">0x02</td> <td style="background-color: lightgreen;">0</td> <td style="background-color: lightyellow;">无</td> <td style="background-color: lightyellow;">停止扫描设备</td> </tr> <tr> <td style="background-color: lightblue;">0x03</td> <td style="background-color: lightgreen;"></td> <td style="background-color: lightyellow;">连接参数</td> <td style="background-color: lightyellow;">连接设备</td> </tr> <tr> <td style="background-color: lightblue;">0x04</td> <td style="background-color: lightgreen;">0</td> <td style="background-color: lightyellow;">无</td> <td style="background-color: lightyellow;">断开设备</td> </tr> <tr> <td style="background-color: lightblue;">0x05</td> <td style="background-color: lightgreen;"></td> <td style="background-color: lightyellow;">0 + 服务的UUID</td> <td style="background-color: lightyellow;">发现服务</td> </tr> <tr> <td style="background-color: lightblue;">0x08</td> <td style="background-color: lightgreen;">3 + L</td> <td style="background-color: lightyellow;">特征handle(2Byte) + FLag(1Byte) + usrData<br></td> <td style="background-color: lightyellow;">特征写</td> </tr> <tr> <td style="background-color: lightblue;">0x09</td> <td style="background-color: lightgreen;">5</td> <td style="background-color: lightyellow;">参数</td> <td style="background-color: lightyellow;">订阅特征notify/Indication</td> </tr> <tr> <td style="background-color: lightblue;">0x0a</td> <td style="background-color: lightgreen;">4</td> <td style="background-color: lightyellow;">chr handle(2byte) + offset(2Byte)</td> <td style="background-color: lightyellow;">特征读</td> </tr> </table> 应答TLV: <table> <tr> <th style="background-color: lightgray;">Type</th> <th style="background-color: lightblue;">Length</th> <th style="background-color: lightgreen;">Value</th> </tr> <tr> <td style="background-color: lightblue;">T</td> <td style="background-color: lightgreen;">1</td> <td style="background-color: lightyellow;">结果: <br>ERR_CODE_SUCCESS = 0<br> ERR_CODE_NO_MEM = 0x01<br> ERR_CODE_INCOMPLETE_PARAM = 0x02<br> ERR_CODE_NOT_SUPPORT_UUID_TYPE = 0x03<br> ERR_CODE_INVALID_CONNID = 0x04<br> ERR_CODE_SYSERR = 0x05<br> ERR_CODE_INVALID_PARAM = 0x06<br> ERR_CODE_DATALEN_OVERFLOW = 0x07<br> ERR_CODE_FUNC_NOT_START = 0x08<br> ERR_CODE_FUNC_OPS_FAILED = 0x09<br></td> </tr> </table> <span style="color: red;">对于特征读的应答TLV</span> <table> <tr> <th style="background-color: lightgray;">Type</th> <th style="background-color: lightblue;">Length</th> <th style="background-color: lightgreen;">result</th> <th style="background-color: lightgreen;">chr handle</th> <th style="background-color: lightgreen;">chrData(OPTION)</th> </tr> <tr> <td style="background-color: lightblue;">T</td> <td style="background-color: lightgreen;">L</td> <td style="background-color: lightyellow;">结果: <br>ERR_CODE_SUCCESS = 0<br> ERR_CODE_NO_MEM = 0x01<br> ERR_CODE_INCOMPLETE_PARAM = 0x02<br> ERR_CODE_NOT_SUPPORT_UUID_TYPE = 0x03<br> ERR_CODE_INVALID_CONNID = 0x04<br> ERR_CODE_SYSERR = 0x05<br> ERR_CODE_INVALID_PARAM = 0x06<br> ERR_CODE_DATALEN_OVERFLOW = 0x07<br> ERR_CODE_FUNC_NOT_START = 0x08<br> ERR_CODE_FUNC_OPS_FAILED = 0x09<br></td> <td style="background-color: lightgray;"></td> <td style="background-color: lightgray;">L>1时存在</td> </tr> </table> <span style="color: red;">对于特征写的应答TLV</span> <table> <tr> <th style="background-color: lightgray;">Type</th> <th style="background-color: lightblue;">Length</th> <th style="background-color: lightgreen;">result</th> <th style="background-color: lightgreen;">chr handle</th> </tr> <tr> <td style="background-color: lightblue;">T</td> <td style="background-color: lightgreen;">L</td> <td style="background-color: lightyellow;">结果: <br>ERR_CODE_SUCCESS = 0<br> ERR_CODE_NO_MEM = 0x01<br> ERR_CODE_INCOMPLETE_PARAM = 0x02<br> ERR_CODE_NOT_SUPPORT_UUID_TYPE = 0x03<br> ERR_CODE_INVALID_CONNID = 0x04<br> ERR_CODE_SYSERR = 0x05<br> ERR_CODE_INVALID_PARAM = 0x06<br> ERR_CODE_DATALEN_OVERFLOW = 0x07<br> ERR_CODE_FUNC_NOT_START = 0x08<br> ERR_CODE_FUNC_OPS_FAILED = 0x09<br> ERR_CODE_CONN_IS_FULL = 0x0a</td> <td style="background-color: lightgray;"></td> </tr> </table> #### 1.4.2.1 扫描设备请求 <span style="color: red;">扫描参数格式</span>: <table> <tr> <th style="background-color: lightyellow;" rowspan="2">扫描参数格式</th> <th style="background-color: lightblue;">扫描持续时间(4Byte)</th> <th style="background-color: lightgreen;">扫描广播类型(1Byte)</th> <th style="background-color: lightgreen;">扫描类型(1Byte)</th> <th style="background-color: lightgreen;">扫描间隔(2Byte)</th> <th style="background-color: lightgreen;">扫描窗口(2Byte)</th> </tr> <tr> <td style="background-color: lightblue;">(小端) 毫秒</td> <td style="background-color: lightgreen;">BIT0: 可扫描 & 可连接的<br>BIT1: 直连广播(仅允许特定设备连接)<br>BIT2: 仅可扫描广播<br>BIT3: 既不可连接也不可扫描的广播<br>BIT4: 扫描响应数据<br>BIT5:扩展广播(支持更长的数据包)</td> <td style="background-color: lightblue;">0:被动扫描 <br>1:主动扫描</td> <td style="background-color: lightblue;">(小端)(单位 0.625 ms)</td> <td style="background-color: lightblue;">(小端)(单位 0.625 ms)</td> </tr> </table> 例:扫描8500ms, 广播类型:BIT1_BIT0, 被动扫描, 扫描间隔0x60, window: 0x60<br> HOST->BLE: 55 aa 60 00 10 00<span style="background-color: lightgreen;"> 0a 00 00 <span style="color: red;">01 0a 34 21 00 00 03 00 60 00 60 00</span> </span>fe 66<br> BLE->HOST: 55 aa 60 07 00 <span style="background-color: lightgreen;"> 0a 00 00 01 01 00</span> fe 6d(请求成功应答,之后HOST等待异步事件)<br> #### 1.4.2.2 停止扫描设备 HOST->BLE: 55 aa 60 00 06 00 0a 00 00 02 00 fe 6f BLE->HOST: 55 aa 60 07 00 0a 00 00 02 01 00 fe 6e #### 1.4.2.3 请求连接设备 <table> <tr> <th style="background-color: lightyellow;" rowspan="2">连接参数</th> <th style="background-color: lightblue;">remote MAC addr(7Byte)</th> <th style="background-color: lightgreen;">bt_le_conn_param(小端)</th> <th style="background-color: lightgreen;">create_conn_timeout(2Byte)(小端)</th> </tr> <tr> <td style="background-color: lightblue;">MAC type + MAC ADDR</td> <td > interval_min(2Byte) + interval_max(2Byte) + latency(2Byte) + timeout(2Byte)</td> <td style="background-color: lightblue;">N > 10,单位10ms</td> </tr> </table> 例如: 连接外设: f7:68:10:0c:00:d0, bt_le_conn_param: 24( x 1.25 = 30ms), 26(x 1.25), 0, 40(x 10 = 400 ms) create_conn_timeout采用设备默认值,可不传<br> HOST->BLE:55 aa 60 00 15 00 <span style="background-color: lightgreen;">0a 00 00 03 0f <span style="color: red;">01 d0 00 0c 10 68 f7</span> 18 00 1a 00 00 00 28 00 </span>fe 0a<br> BLE->HOST: 55 aa 60 07 00 0a 00 00 03 01 00 fe 6f<span style="color: red;">(请求成功应答)</span><br><br> <span style="color: red;">注意: 连接请求提交后,连接成功还是失败,是以异步事件的方式上报的</span> #### 1.4.2.4 断开某个连接的设备 如: 断开连接号为2的设备 HOST->BLE: 55 aa 60 00 06 00 0a 00 00 04 00 02 95 BLE->HOST: 55 aa 60 07 00 0a 00 00 04 01 00 02 94 #### 1.4.2.4 扫描特定的服务 扫描服务,UUID: 00010000-e985-b7e8-b186-e5a49ae5bca6 <table> <tr> <th style="background-color: lightyellow;" rowspan="2">HOST -> BLE</th> <th style="background-color: lightblue;">HEAD</th> <th style="background-color: lightgreen;">CMD</th> <th style="background-color: lightgreen;">标识字</th> <th >DLen</th> <th style="background-color: lightpink;">P1</th> <th style="background-color: lightpink;">P2</th> <th style="background-color: lightpink;">P3</th> <th style="background-color: lightcyan;">T</th> <th style="background-color: lightcyan;">L</th> <th style="background-color: lightcyan;">FLAG</th> <th style="background-color: lightcyan;">UUID_LEN</th> <th style="background-color: lightpink;">UUID</th> <th style="background-color: lightpink;">CONN_ID</th> <th style="background-color: lightcyan;">校验字</th> </tr> <tr> <td style="background-color: lightblue;">55AA</td> <td style="background-color: lightgreen;">60</td> <td style="background-color: lightgreen;">00</td> <td >18 00</td> <td style="background-color: lightgreen;">0a</td> <td style="background-color: lightgreen;">00</td> <td style="background-color: lightgreen;">00</td> <td >05</td> <td >12</td> <td >00</td> <td >10</td> <td style="background-color: lightpink;">a6 bc e5 9a a4 e5 86 b1 e8 b7 85 e9 00 00 01 00</td> <td style="background-color: lightgreen;">02(当前和这个remote设备的连接号)</td> <td style="background-color: lightcyan;">BCC</td> </tr> </table> 应答成功: <table> <tr> <th style="background-color: lightyellow;" rowspan="2">BLE -> HOST</th> <th style="background-color: lightblue;">HEAD</th> <th style="background-color: lightgreen;">CMD</th> <th >DLen</th> <th style="background-color: lightpink;">P1</th> <th style="background-color: lightpink;">P2</th> <th style="background-color: lightpink;">P3</th> <th style="background-color: lightpink;">T</th> <th style="background-color: lightpink;">L</th> <th style="background-color: lightpink;">V</th> <th style="background-color: lightgreen;">CONN_ID</th> <th style="background-color: lightcyan;">校验字</th> </tr> <tr> <td style="background-color: lightblue;">55AA</td> <td style="background-color: lightgreen;">60</td> <td >07 00</td> <td style="background-color: lightpink;">0a</td> <td style="background-color: lightpink;">00</td> <td style="background-color: lightpink;">00</td> <td style="background-color: lightpink;">05</td> <td style="background-color: lightpink;">01</td> <td style="background-color: lightpink;">00</td> <td style="background-color: lightgreen;">02(当前和这个remote设备的连接号)</td> <td style="background-color: lightcyan;">BCC</td> </tr> </table> 注意:128BIT UUID定义方式: <br> #define BT_UUID_128_ENCODE(w32, w1, w2, w3, w48) \ (((w48) >> 0) & 0xFF), \ (((w48) >> 8) & 0xFF), \ (((w48) >> 16) & 0xFF), \ (((w48) >> 24) & 0xFF), \ (((w48) >> 32) & 0xFF), \ (((w48) >> 40) & 0xFF), \ (((w3) >> 0) & 0xFF), \ (((w3) >> 8) & 0xFF), \ (((w2) >> 0) & 0xFF), \ (((w2) >> 8) & 0xFF), \ (((w1) >> 0) & 0xFF), \ (((w1) >> 8) & 0xFF), \ (((w32) >> 0) & 0xFF), \ (((w32) >> 8) & 0xFF), \ (((w32) >> 16) & 0xFF), \ (((w32) >> 24) & 0xFF) 如: BT_UUID_128_ENCODE(0x00010000, 0xe985, 0xb7e8, 0xb186, 0xe5a49ae5bca6)<br> #### 1.4.2.5 订阅特征notify/Indication <table> <tr> <th style="background-color: lightyellow;" rowspan="2">参数</th> <th style="background-color: lightblue;">特征handle(2Byte)</th> <th style="background-color: lightgreen;">CCC handle(2Byte)</th> <th style="background-color: lightgreen;">FLAG(1Byte)</th> </tr> <tr> <td style="background-color: lightblue;"></td> <td ></td> <td style="background-color: lightblue;">0: notify <br>1: INDICATE</td> </tr> </table> #### 1.4.2.6 特征写 ### 1.4.3 支持的异步事件<br> #### 1.4.3.1 P3 = 1: 扫描到的广播<br> <table> <tr> <th style="background-color: lightyellow;" rowspan="2">BLE -> HOST</th> <th style="background-color: lightblue;">HEAD</th> <th style="background-color: lightgreen;">CMD</th> <th >DLen</th> <th style="background-color: lightpink;">P1</th> <th style="background-color: lightcyan;">P2</th> <th style="background-color: lightcyan;">P3</th> <th style="background-color: lightcyan;">事件状态</th> <th style="background-color: lightpink;">外设广播数据</th> <th style="background-color: lightcyan;">CONN_ID</th> <th style="background-color: lightcyan;">校验字</th> </tr> <tr> <td style="background-color: lightblue;">55 AA</td> <td style="background-color: lightgreen;">60</td> <td >23 00</td> <td style="background-color: lightpink;">0a</td> <td >BIT7=1</td> <td >01</td> <td >00: 扫描中; <br>01: 扫描结束</td> <td style="background-color: lightpink;">不一定存在</td> <td style="background-color: lightcyan;">0xFE</td> <td style="background-color: lightcyan;">BCC</td> </tr> </table> <table> <tr> <th style="background-color: lightyellow;" rowspan="2">外设广播数据(例)</th> <th style="background-color: lightblue;">广播类型</th> <th style="background-color: lightgreen;">RSSI</th> <th style="background-color: lightpink;">MAC type</th> <th style="background-color: lightcyan;">MAC ADDR</th> <th style="background-color: lightpink;">ADV Struct</th> </tr> <tr> <td >00</td> <td >c5</td> <td >01</td> <td >d0000c1068f7</td> <td >020106030356470dff01af0a0063 723930373700ebfee3</td> </tr> </table> 如: 55 aa 60 23 00 0a 80 01 00 00 c8 01 d0 00 0c 10 68 f7 02 01 06 03 03 56 47 0d ff 01 af 0a 00 63 72 39 30 37 37 00 eb fe e3 #### 1.4.3.2 P3 = 2: central模式下连接事件<br> <table> <tr> <th style="background-color: lightyellow;" rowspan="2">BLE -> HOST</th> <th style="background-color: lightblue;">HEAD</th> <th style="background-color: lightgreen;">CMD</th> <th >DLen</th> <th style="background-color: lightpink;">P1</th> <th style="background-color: lightcyan;">P2</th> <th style="background-color: lightcyan;">P3</th> <th style="background-color: lightcyan;">事件状态</th> <th style="background-color: lightpink;">Remote_MAC_ADDR</th> <th style="background-color: lightcyan;">CONN_ID</th> <th style="background-color: lightcyan;">校验字</th> </tr> <tr> <td style="background-color: lightblue;">55 AA</td> <td style="background-color: lightgreen;">60</td> <td >23 00</td> <td style="background-color: lightpink;">0a</td> <td >BIT7=1</td> <td >02</td> <td >02: 连接成功</td> <td style="background-color: lightpink;">d0000c1068f7</td> <td style="background-color: lightcyan;">0x02(分配的连接号)</td> <td style="background-color: lightcyan;">BCC</td> </tr> </table> <table> <tr> <th style="background-color: lightyellow;" rowspan="2">BLE -> HOST</th> <th style="background-color: lightblue;">HEAD</th> <th style="background-color: lightgreen;">CMD</th> <th >DLen</th> <th style="background-color: lightpink;">P1</th> <th style="background-color: lightcyan;">P2</th> <th style="background-color: lightcyan;">P3</th> <th style="background-color: lightcyan;">事件状态</th> <th style="background-color: lightpink;">reason</th> <th style="background-color: lightpink;">Remote_MAC_ADDR</th> <th style="background-color: lightcyan;">CONN_ID</th> <th style="background-color: lightcyan;">校验字</th> </tr> <tr> <td style="background-color: lightblue;">55 AA</td> <td style="background-color: lightgreen;">60</td> <td >23 00</td> <td style="background-color: lightpink;">0a</td> <td >BIT7=1</td> <td >02</td> <td >01: 连接失败;</td> <td >0x01: 连接号用完;<br> 0x02: sys API occur err; 0x03: bug;<br></td> <td style="background-color: lightpink;">d0000c1068f7</td> <td style="background-color: lightcyan;">0x02(分配的连接号)</td> <td style="background-color: lightcyan;">BCC</td> </tr> </table><table> <tr> <th style="background-color: lightyellow;" rowspan="2">BLE -> HOST</th> <th style="background-color: lightblue;">HEAD</th> <th style="background-color: lightgreen;">CMD</th> <th >DLen</th> <th style="background-color: lightpink;">P1</th> <th style="background-color: lightcyan;">P2</th> <th style="background-color: lightcyan;">P3</th> <th style="background-color: lightcyan;">事件状态</th> <th style="background-color: lightpink;">reason</th> <th style="background-color: lightpink;">CODE</th> <th style="background-color: lightpink;">Remote_MAC_ADDR</th> <th style="background-color: lightcyan;">CONN_ID</th> <th style="background-color: lightcyan;">校验字</th> </tr> <tr> <td style="background-color: lightblue;">55 AA</td> <td style="background-color: lightgreen;">60</td> <td >23 00</td> <td style="background-color: lightpink;">0a</td> <td >BIT7=1</td> <td >02</td> <td >01: 连接失败;</td> <td >0x05:连接失败<br>0x04: 交互MTU时失败;</td> <td >标准错误码</td> <td style="background-color: lightpink;">d0000c1068f7</td> <td style="background-color: lightcyan;">0x02(分配的连接号)</td> <td style="background-color: lightcyan;">BCC</td> </tr> </table> <table> <tr> <th style="background-color: lightyellow;" rowspan="2">BLE -> HOST</th> <th style="background-color: lightblue;">HEAD</th> <th style="background-color: lightgreen;">CMD</th> <th >DLen</th> <th style="background-color: lightpink;">P1</th> <th style="background-color: lightcyan;">P2</th> <th style="background-color: lightcyan;">P3</th> <th style="background-color: lightcyan;">事件状态</th> <th style="background-color: lightpink;">reason</th> <th style="background-color: lightpink;">Remote_MAC_ADDR</th> <th style="background-color: lightcyan;">CONN_ID</th> <th style="background-color: lightcyan;">校验字</th> </tr> <tr> <td style="background-color: lightblue;">55 AA</td> <td style="background-color: lightgreen;">60</td> <td >23 00</td> <td style="background-color: lightpink;">0a</td> <td >BIT7=1</td> <td >02</td> <td >03: central主动断开; <br>04: 其他断开</td> <td >断开码</td> <td style="background-color: lightpink;">d0000c1068f7</td> <td style="background-color: lightcyan;">0x02(分配的连接号)</td> <td style="background-color: lightcyan;">BCC</td> </tr> </table> #### 1.3.3.3 P3 = 3: 扫描到的服务<br> <table> <tr> <th style="background-color: lightyellow;" rowspan="2">BLE -> HOST</th> <th style="background-color: lightblue;">HEAD</th> <th style="background-color: lightgreen;">CMD</th> <th >DLen</th> <th style="background-color: lightpink;">P1</th> <th style="background-color: lightcyan;">P2</th> <th style="background-color: lightcyan;">P3</th> <th style="background-color: lightcyan;">事件状态</th> <th style="background-color: lightpink;">service Handle</th> <th style="background-color: lightpink;">service End Handle</th> <th style="background-color: lightpink;">service UUID</th> <th style="background-color: lightcyan;">CONN_ID</th> <th style="background-color: lightcyan;">校验字</th> </tr> <tr> <td style="background-color: lightblue;">55 AA</td> <td style="background-color: lightgreen;">60</td> <td >19 00</td> <td style="background-color: lightpink;">0a</td> <td >BIT7=1</td> <td >03</td> <td >00</td> <td style="background-color: lightpink;">1000(例)</td> <td style="background-color: lightpink;">1500(例)</td> <td style="background-color: lightpink;">a6bce59aa4e586b1e8b785e900000100(例)</td> <td style="background-color: lightcyan;">0x01(分配的连接号)</td> <td style="background-color: lightcyan;">BCC</td> </tr> </table> #### 1.4.3.4 P3 = 4: 服务下的特征<br> <table> <tr> <th style="background-color: lightyellow;" rowspan="2">BLE -> HOST</th> <th style="background-color: lightblue;">HEAD</th> <th style="background-color: lightgreen;">CMD</th> <th >DLen</th> <th style="background-color: lightpink;">P1</th> <th style="background-color: lightcyan;">P2</th> <th style="background-color: lightcyan;">P3</th> <th style="background-color: lightcyan;">事件状态</th> <th style="background-color: lightpink;">service Handle</th> <th style="background-color: lightpink;">characteristic Handle</th> <th style="background-color: lightpink;">characteristic properties</th> <th style="background-color: lightpink;">characteristic UUID</th> <th style="background-color: lightcyan;">CONN_ID</th> <th style="background-color: lightcyan;">校验字</th> </tr> <tr> <td style="background-color: lightblue;">55 AA</td> <td style="background-color: lightgreen;">60</td> <td >1a 00</td> <td style="background-color: lightpink;">0a</td> <td >BIT7=1</td> <td >04</td> <td >00</td> <td style="background-color: lightpink;">1000(例)</td> <td style="background-color: lightpink;">1200(例)</td> <td style="background-color: lightpink;">14(例)</td> <td style="background-color: lightpink;">a6bce59aa4e586b1e8b785e90200010001(例)</td> <td style="background-color: lightcyan;">0x01(分配的连接号)</td> <td style="background-color: lightcyan;">BCC</td> </tr> </table> <table> <tr> <th style="background-color: lightyellow;" rowspan="2">BLE -> HOST</th> <th style="background-color: lightblue;">HEAD</th> <th style="background-color: lightgreen;">CMD</th> <th >DLen</th> <th style="background-color: lightpink;">P1</th> <th style="background-color: lightcyan;">P2</th> <th style="background-color: lightcyan;">P3</th> <th style="background-color: lightcyan;">事件状态</th> <th style="background-color: lightpink;">service Handle</th> <th style="background-color: lightcyan;">CONN_ID</th> <th style="background-color: lightcyan;">校验字</th> </tr> <tr> <td style="background-color: lightblue;">55 AA</td> <td style="background-color: lightgreen;">60</td> <td >1a 00</td> <td style="background-color: lightpink;">0a</td> <td >BIT7=1</td> <td >04</td> <td >01:服务下的特征扫描完毕</td> <td style="background-color: lightpink;">1000(例)</td> <td style="background-color: lightcyan;">0x01(分配的连接号)</td> <td style="background-color: lightcyan;">BCC</td> </tr> </table><br> #### 1.4.3.5 P3 = 6: 特征下的CCC<br> <table> <tr> <th style="background-color: lightyellow;" rowspan="2">BLE -> HOST</th> <th style="background-color: lightblue;">HEAD</th> <th style="background-color: lightgreen;">CMD</th> <th >DLen</th> <th style="background-color: lightpink;">P1</th> <th style="background-color: lightcyan;">P2</th> <th style="background-color: lightcyan;">P3</th> <th style="background-color: lightcyan;">事件状态</th> <th style="background-color: lightpink;">service Handle</th> <th style="background-color: lightpink;">characteristic Handle</th> <th style="background-color: lightpink;">characteristic CCC Handle</th> <th style="background-color: lightcyan;">CONN_ID</th> <th style="background-color: lightcyan;">校验字</th> </tr> <tr> <td style="background-color: lightblue;">55 AA</td> <td style="background-color: lightgreen;">60</td> <td >1a 00</td> <td style="background-color: lightpink;">0a</td> <td >BIT7=1</td> <td >06</td> <td >00</td> <td style="background-color: lightpink;">1000(例)</td> <td style="background-color: lightpink;">1200(例)</td> <td style="background-color: lightpink;">1300(例)</td> <td style="background-color: lightcyan;">0x01(分配的连接号)</td> <td style="background-color: lightcyan;">BCC</td> </tr> </table> #### 1.4.3.6 P3 = 8: 对端的数据通知<br> 收到连接号为0x01的外设发的数据: <table> <tr> <th style="background-color: lightyellow;" rowspan="2">BLE -> HOST</th> <th style="background-color: lightblue;">HEAD</th> <th style="background-color: lightgreen;">CMD</th> <th >DLen</th> <th style="background-color: lightpink;">P1</th> <th style="background-color: lightcyan;">P2</th> <th style="background-color: lightcyan;">P3</th> <th style="background-color: lightcyan;">事件状态</th> <th style="background-color: lightpink;">CCC Handle</th> <th style="background-color: lightpink;">UsrData</th> <th style="background-color: lightcyan;">CONN_ID</th> <th style="background-color: lightcyan;">校验字</th> </tr> <tr> <td style="background-color: lightblue;">55 AA</td> <td style="background-color: lightgreen;">60</td> <td >1e 00</td> <td style="background-color: lightpink;">0a</td> <td >BIT7=1</td> <td >08</td> <td >00</td> <td style="background-color: lightpink;">1300(例)</td> <td style="background-color: lightpink;">xxxxxxxxxxx(例)</td> <td style="background-color: lightcyan;">0x01(分配的连接号)</td> <td style="background-color: lightcyan;">BCC</td> </tr> </table> ## 1.5 P1=0x03 蓝牙固件升级指令(非蓝牙通道) <br> <table> <thead> <tr> <td colspan="5">指令: 0x60</td> <td colspan="5">P1= 0x03: 用于通过非蓝牙通道升级蓝牙固件 </td> </tr> </thead> <body> <tr> <td colspan="10"> 说明<br>  P3: bit7=0 表示主控发给蓝牙,bit7=1 表示蓝牙发给主控, bit0~bit6:RFU(暂未使用)<br>  <br><br>V: 基础格式为TLV, 支持的TLV如下:<br><table> <tr> <td>T (1 Byte)</td><td>L(1 Byte)</td><td>V</td> </tr> <tr> <td>通知蓝牙进入升级流程: <font color=#FF1493>0x01</font></td> <td></td><td><br>参见1.3.1</td> </tr> <tr> <td>发送新固件包的描述信息: <font color=#FF1493>0x02</font></td> <td>0</td><td>参见1.3.2</td> </tr> <tr> <td>分块发送新固件包的数据块: <font color=#FF1493>0x3</font></td> <td>0</td><td>参见1.3.3</td> </tr> <tr> <td>固件包分块完毕指令: <font color=#FF1493>0x4</font></td> <td>0</td><td>参见1.3.3</td> </tr> <tr> <td>固件包安装指令: <font color=#FF1493>0x5</font></td> <td>0</td><td>参见1.3.3</td> </tr> </table> </td> </tr> <tr> <td> 项目</td><td> 字节</td> <td colspan="3"><font color=#008000>BLE -> HOST </font></td> <td> 项目</td><td> 字节</td> <td colspan="3"><font color=PaleVioletRed>HOST -> BLE </font></td> </tr> <tr> <td>包头 </td><td>2Byte </td><td colspan="3"> 0x55 0xAA </td><td>包头 </td><td>1Byte </td><td colspan="3">0x55 0xAA</td><td> </tr> <tr> <td>命令字</td><td> 1Byte</td><td colspan="3"> 0x60</td><td> 命令字</td><td> 1Byte</td><td colspan="3"> 0x60</td> </tr> <tr> <td>数据域长度</td><td> 2 Byte</td><td colspan="3"> N </td><td>标识字</td><td> 1Byte</td><td colspan="3"> 0x00 </td> </tr> <tr> <td rowspan="5">数据域</td> <td rowspan="5">N Byte</td> <td>P1</td><td> 1 Byte</td><td>0x03</td><td> 数据域长度 </td><td>2 Byte <td colspan="3">N</td> </tr> <tr> <td>P2</td><td> 1 Byte</td><td> </td><td rowspan="4">数据域</td><td rowspan="4"> N Byte</td> <td> P1</td><td> 1 Byte</td><td> 0x03 </td> </tr> <tr> <td>P3</td><td> 1 Byte</td><td> </td><td>P2</td><td> 1 Byte</td><td> </td> </tr> <tr> <td rowspan="2">V </td><td rowspan="2">X Byte</td><td rowspan="2">TLV数据</td> <td>P3</td><td>1 Byte</td><td></td> </tr> <tr> <td>V</td><td> X Byte</td><td> TLV数据 </td> </tr> <tr> <td>校验字</td><td> 1 Byte</td><td colspan="3"> </td><td> 校验字</td><td> 1 Byte </td><td colspan="3"></td> </tr> </body> </table> <br> ### 1.5.1 Tag: 0x01 通知蓝牙进入升级模式 <table> <tr> <td bgcolor=LightSeaGreen colspan="3">HOST -> BLE </td> <td bgcolor=LightSalmon colspan="3">BLE -> HOST </td> </tr> <tr> <td>T</td><td>L</td><td>V</td> <td>T</td><td>L</td><td>V</td> </tr> <tr> <td>0x01</td><td>0</td><td>无</td> <td>0x01</td><td>N</td><td> V[0]: 操作结果:<br>0: 成功<br>3: 当前已经运行在升级模式中 <br></td> </tr> </table> 使用逻辑:发送此指令,直到蓝牙应答结果是3时,开始下一步骤 <br> <br> ### 1.5.2 Tag: 0x02 发送升级包的描述信息 <table> <tr> <td bgcolor=LightSeaGreen colspan="3">HOST -> BLE </td> <td bgcolor=LightSalmon colspan="3">BLE -> HOST </td> </tr> <tr> <td>T</td><td>L</td><td>V</td> <td>T</td><td>L</td><td>V</td> </tr> <tr> <td>0x02</td><td>36</td><td>固件包长度(4) + 固件包签名(32)</td> <td>0x02</td><td>N</td><td> V[0]: 操作结果:<br>0: 成功<br>other:见应答码 <br></td> </tr> </table> <br> ### 1.5.3 Tag: 0x03 发送升级包 <table> <tr> <td bgcolor=LightSeaGreen colspan="3">HOST -> BLE </td> <td bgcolor=LightSalmon colspan="3">BLE -> HOST </td> </tr> <tr> <td>T</td><td>L</td><td>V</td> <td>T</td><td>L</td><td>V</td> </tr> <tr> <td>0x03</td><td>N块 = (N+1) * 512 Bytes<br></td><td>升级包N块的数据</td> <td>0x03</td><td>N</td><td> V[0]: 操作结果:<br>0: 成功<br>other:见应答码 <br></td> </tr> </table> 注意:1. 整个指令包数据域的数据长度:5 + (tag->L + 1) * 512 <br>2. 关于N的最大值: 不同的设备支持的最大值不同,对于DW200, 蓝牙端支持最大值14(也就是15块)<br>CR90设备,只支持N=0 <br> <br> ### 1.5.4 Tag: 0x04 升级包数据发送结束指令 <table> <tr> <td bgcolor=LightSeaGreen colspan="3">HOST -> BLE </td> <td bgcolor=LightSalmon colspan="3">BLE -> HOST </td> </tr> <tr> <td>T</td><td>L</td><td>V</td> <td>T</td><td>L</td><td>V</td> </tr> <tr> <td>0x04</td><td>0<br></td><td>无</td> <td>0x04</td><td>N</td><td> V[0]: 操作结果:<br>0: 成功<br>other:见应答码 <br></td> </tr> </table> <br> ### 1.5.5 Tag: 0x05 安装升级包 <table> <tr> <td bgcolor=LightSeaGreen colspan="3">HOST -> BLE </td> <td bgcolor=LightSalmon colspan="3">BLE -> HOST </td> </tr> <tr> <td>T</td><td>L</td><td>V</td> <td>T</td><td>L</td><td>V</td> </tr> <tr> <td>0x05</td><td>0<br></td><td>无</td> <td>0x05</td><td>N</td><td> V[0]: 操作结果:<br>0: 成功<br>other:见应答码 <br></td> </tr> </table> <br> ### 1.5.5 升级逻辑 1. 先发命令使蓝牙进入升级模式. 2. 蓝牙进升级模式后,会通知主控自己的状态(参见状态交互指令), 主控需要应答此指令,不然会一直上报 3. 上位机再次发送命令使蓝牙进入升级模式,当知晓蓝牙成功进入升级模式后,开始升级流程. 4. 依序发送Tag: 0x02, 0x03, 0x04, 0x05指令,完成新固件的升级 5. 注意点: Tag:0x03指令,发送升级包的数据块时,由于不同的主控设备接收数据包的缓存区大小不同,处理速度也不同。所以需要调试合适的单包容纳的数据块数,而且命令包的发送也可能需要分多次发送,每次需要延时几十毫秒。 如CR90设备的主控只支持单块传输,发送时不需要分多次。<br> 升级包的大小很大可能不是512的倍数,所以最后一包需要补齐,补齐数据任意(最好是0xff)
石磊
2025年6月18日 14:07
4
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
Word文件
PDF文档
PDF文档(打印)
分享
链接
类型
密码
更新密码
有效期