Android在连接BLE设备的时候,遇到连接没多久就自动断开的情况。通过HCI来分析一下。

BLE设备发送连接参数更新请求
3909    15:53:01.224737 TexasIns_f0:d3:41 (Hon-RFID3)   HandHeld_e0:e5:4f (EDA) L2CAP   21  Rcvd Connection Parameter Update Request
回复BLE发送过来的请求
3910    15:53:01.225744 HandHeld_e0:e5:4f (EDA) TexasIns_f0:d3:41 (Hon-RFID3)   L2CAP   15  Sent Connection Parameter Update Response (Accepted)
发送连接更新请求,host通过hci发给controller
3911    15:53:01.227044 host    controller  HCI_CMD 18  Sent LE Connection Update
更新参数操作执行成功。controller发给host。这条命令之后,协议栈会发送命令给出去,给对面的BLE设备。
3963    15:53:01.566723 controller  host    HCI_EVT 13  Rcvd LE Meta (LE Connection Update Complete)
这边在等待BLE设备的回复,等待超时了。后面就断开。
5410    15:53:12.491452 controller  host    HCI_EVT 7   Rcvd Disconnect Complete

最后一个帧的内容,显示连接超时。

Frame 5410: 7 bytes on wire (56 bits), 7 bytes captured (56 bits)Encapsulation type: Bluetooth H4 with linux header (99)Arrival Time: Apr 25, 2019 23:53:12.491452000 China Standard Time[Time shift for this packet: 0.000000000 seconds]Epoch Time: 1556207592.491452000 seconds[Time delta from previous captured frame: 0.001655000 seconds][Time delta from previous displayed frame: 0.001655000 seconds][Time since reference or first frame: 86.503400000 seconds]Frame Number: 5410Frame Length: 7 bytes (56 bits)Capture Length: 7 bytes (56 bits)[Frame is marked: False][Frame is ignored: False]Point-to-Point Direction: Received (1)[Protocols in frame: bluetooth:hci_h4:bthci_evt]
Bluetooth[Source: controller][Destination: host]
Bluetooth HCI H4[Direction: Rcvd (0x01)]HCI Packet Type: HCI Event (0x04)
Bluetooth HCI Event - Disconnect CompleteEvent Code: Disconnect Complete (0x05)Parameter Total Length: 4Status: Success (0x00)Connection Handle: 0x0002Reason: Connection Timeout (0x08)

而另外一个台设备, 却不会断开,第一个帧显示对面LE设备所能支持结构,其中Connection Parameters Request Procedure: False,表示不支持更新参数请求。

第一个帧:
1408    15:57:13.490071 controller  host    HCI_EVT 15  Rcvd LE Meta (LE Read Remote Used Features Complete)
第一个帧的内容:
Frame 1408: 15 bytes on wire (120 bits), 15 bytes captured (120 bits)Encapsulation type: Bluetooth H4 with linux header (99)Arrival Time: Apr 25, 2019 23:57:13.490071000 China Standard Time[Time shift for this packet: 0.000000000 seconds]Epoch Time: 1556207833.490071000 seconds[Time delta from previous captured frame: 0.002823000 seconds][Time delta from previous displayed frame: 0.002823000 seconds][Time since reference or first frame: 39.218678000 seconds]Frame Number: 1408Frame Length: 15 bytes (120 bits)Capture Length: 15 bytes (120 bits)[Frame is marked: False][Frame is ignored: False]Point-to-Point Direction: Received (1)[Protocols in frame: bluetooth:hci_h4:bthci_evt]
Bluetooth[Source: controller][Destination: host]
Bluetooth HCI H4[Direction: Rcvd (0x01)]HCI Packet Type: HCI Event (0x04)
Bluetooth HCI Event - LE MetaEvent Code: LE Meta (0x3e)Parameter Total Length: 12Sub Event: LE Read Remote Used Features Complete (0x04)Status: Success (0x00)Connection Handle: 0x0002Supported LE Features: 0x0000000000000001, LE Encryption.... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ...1 = LE Encryption: True.... .... .... .... .... .... .... .... .... .... .... .... .... .... .... ..0. = Connection Parameters Request Procedure: False.... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .0.. = Extended Reject Indication: False.... .... .... .... .... .... .... .... .... .... .... .... .... .... .... 0... = Slave-Initiated Features Exchange: False.... .... .... .... .... .... .... .... .... .... .... .... .... .... ...0 .... = Ping: False.... .... .... .... .... .... .... .... .... .... .... .... .... .... ..0. .... = Data Packet Length Extension: False.... .... .... .... .... .... .... .... .... .... .... .... .... .... .0.. .... = LL Privacy: False.... .... .... .... .... .... .... .... .... .... .... .... .... .... 0... .... = Extended Scanner Filter Policies: False.... .... .... .... .... .... .... .... .... .... .... .... .... ...0 .... .... = LE 2M PHY: False.... .... .... .... .... .... .... .... .... .... .... .... .... ..0. .... .... = Stable Modulation Index - Tx: False.... .... .... .... .... .... .... .... .... .... .... .... .... .0.. .... .... = Stable Modulation Index - Rx: False.... .... .... .... .... .... .... .... .... .... .... .... .... 0... .... .... = LE Coded PHY: False.... .... .... .... .... .... .... .... .... .... .... .... ...0 .... .... .... = LE Extended Advertising: False.... .... .... .... .... .... .... .... .... .... .... .... ..0. .... .... .... = LE Periodic Advertising: False.... .... .... .... .... .... .... .... .... .... .... .... .0.. .... .... .... = Channel Selection Algorithm #2: False.... .... .... .... .... .... .... .... .... .... .... .... 0... .... .... .... = Power Class 1: False.... .... .... .... .... .... .... .... .... .... .... ...0 .... .... .... .... = Minimum Number of Used Channels Procedure: False0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 000. .... .... .... .... = Reserved: 0x000000000000[Command in frame: 1393][Pending in frame: 1398][Pending-Response Delta: 54.527ms][Command-Response Delta: 57.991ms]

虽然不支持更新参数请求,但是却发了更新参数请求过来,这个现象比较奇怪。

参数更新请求。
2698    15:57:19.440508 TexasIns_f0:d3:41 (Hon-RFID3)   localhost ()    L2CAP   21  Rcvd Connection Parameter Update Request
请求回复。
2702    15:57:19.441762 localhost ()    TexasIns_f0:d3:41 (Hon-RFID3)   L2CAP   15  Sent Connection Parameter Update Response (Accepted)
发送更新过去。
2705    15:57:19.442326 host    controller  HCI_CMD 18  Sent LE Connection Update
这条命令没有处理,应为没有controller通过hci发给host的命令回复,所以没有处理。就不会存在后面的等待超时。

转载于:https://www.cnblogs.com/helloworldtoyou/p/10775106.html

Android Bluetooth hci 命令分析相关推荐

  1. 【转】Android bluetooth介绍(三): 蓝牙扫描(scan)设备分析

    原文网址:http://blog.csdn.net/xubin341719/article/details/38584469 关键词:蓝牙blueZ  A2DP.SINK.sink_connect.s ...

  2. android 蓝牙扫描流程,Android 9.0 Bluetooth源码分析(二)蓝牙扫描流程

    1 UI 蓝牙开始扫描位于setting的 /packages/apps/Settings/src/com/android/settings/bluetooth/BluetoothPairingDet ...

  3. 如何获取并分析Bluetooth HCI层Command Packet和Event Packet包

    首先,如何来确定什么样的包为Command/Event Packet呢? 我们知道,通过HCI Packet包括四种,即Command,Event,ACL和SCO/eSCO,对应到MS-Stack中的 ...

  4. Android源代码编译命令m/mm/mmm/make分析

    Android源代码编译命令m/mm/mmm/make分析 2014-03-10     我来说两句    来源:Android源代码编译命令m/mm/mmm/make分析   收藏    我要投稿 ...

  5. Android Bluetooth蓝牙开发\蓝牙协议\蓝牙通信例子_Android支持蓝牙4.0版本_BLE开发

    一.Android Bluetooth现状 在android官网可以了解到android4.2新增了部分新功能,但是对于BT熟悉的人或许开始头疼了,那就是Android4.2引入了一个新的蓝牙协议栈针 ...

  6. Android blueZ HCI(二):hcitool hcidump常用方法

    关键词:hciconfig  hcitool hcidump 作者:xubin341719(欢迎转载,请注明作者,请尊重版权,谢谢!) 欢迎指正错误,共同学习.共同进步!! Android blueZ ...

  7. android蓝牙源码分析

    关键词:蓝牙blueZ  A2DP.SINK.sink_connect.sink_disconnect.sink_suspend.sink_resume.sink_is_connected.sink_ ...

  8. Android bluetooth介绍(二): android 蓝牙代码架构及其uart 到rfcomm流程

    关键词:蓝牙blueZ  UART  HCI_UART H4  HCI  L2CAP RFCOMM  版本:基于android4.2之前版本 bluez内核:linux/linux3.08 系统:an ...

  9. Android bluetooth介绍(两): android 蓝牙源架构和uart 至rfcomm过程

    关键词:蓝牙blueZ  UART  HCI_UART H4  HCI  L2CAP RFCOMM  版本号:基于android4.2先前版本 bluez内核:linux/linux3.08 系统:a ...

最新文章

  1. python2好还是python3好-总结对比Python2和Python3之间的区别
  2. 网关是个啥?为什么电脑不设置网关就没法上网?笔记本为啥不用设置网关?
  3. Java进阶之网络编程
  4. Android下如何计算两经纬点之间距离?
  5. 推荐一本学javascript的书籍---经典
  6. SQA定义、质量模型、SQA与测试的关系
  7. [APK拆解]谷歌眼镜XE16设置新语言,当你盯着屏幕时可同步检测
  8. 基于单片机的数字频率计设计
  9. drop与delete的区别
  10. qq2018旧版本7.3.1下载_QQ旧版本2018下载
  11. for_each(pbegin, pend, work);#include<algorithm>
  12. Docker_notes_practice
  13. java工程license机制_使用truelicense实现用于JAVA工程license机制(包括license生成和验证)...
  14. 如何将PPT进行压缩?简单的方法介绍
  15. 面对DDoS攻击的威胁时应该怎么做呢?
  16. Word 模板渲染引擎-Poi-tl - 标签(二)
  17. 气液滑环与其他滑环的工作原理有什么区别
  18. 通过VMware Horizon Client访问虚拟机
  19. 基于在线地图的轨迹跟踪服务_JUST技术:利用轨迹拼接分析实时可达区域
  20. 会员制营销以及E-mail营销的培训

热门文章

  1. 实验三进程调度模拟程序
  2. C++ BYTE数组转字符串
  3. Yii中缓存依赖的处理
  4. 安装eclipse for c/c++环境
  5. Linux云服务器下Tomcat部署超详细
  6. python 面向对象(三大特性)
  7. 使用消息队列实现分布式事务-公认较为理想的分布式事务解决方案(转)
  8. C#去掉字符串中的汉字
  9. MySQL 在 LIMIT 条件后注入
  10. 第五十九天 how can I 坚持 --------补昨天5月31号