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: 5410
Frame 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 Complete
Event Code: Disconnect Complete (0x05)
Parameter Total Length: 4
Status: Success (0x00)
Connection Handle: 0x0002
Reason: 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: 1408
Frame 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 Meta
Event Code: LE Meta (0x3e)
Parameter Total Length: 12
Sub Event: LE Read Remote Used Features Complete (0x04)
Status: Success (0x00)
Connection Handle: 0x0002
Supported 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: False
0000 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的命令回复,所以没有处理。就不会存在后面的等待超时。

Android Bluetooth hci 命令分析的更多相关文章

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

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

  2. Android bluetooth介绍(四): a2dp connect流程分析

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

  3. Android bluetooth介绍(三): 蓝牙扫描(scan)设备分析

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

  4. Appium Android Bootstrap源码分析之命令解析执行

    通过上一篇文章<Appium Android Bootstrap源码分析之控件AndroidElement>我们知道了Appium从pc端发送过来的命令如果是控件相关的话,最终目标控件在b ...

  5. ZT 4.3 android bluetooth hfp分析

    4.3 android bluetooth hfp分析 2013-08-20 20:16 592人阅读 评论(3) 收藏 举报 所有程序执行的代码都是有入口的,在这里我们暂时分析一种情景,蓝牙打开着, ...

  6. 【转】Android bluetooth介绍(二): android blueZ蓝牙代码架构及其uart 到rfcomm流程

    原文网址:http://blog.sina.com.cn/s/blog_602c72c50102uzoj.html 关键词:蓝牙blueZ  UART  HCI_UART H4  HCI  L2CAP ...

  7. Android blueZ HCI(一个):hciconfig实施和经常使用

    关键词:hciconfighcitool  hcidump笔者:xubin341719(欢迎转载,请明确说明,请尊重版权,谢谢.)欢迎指正错误,共同学习.共同进步! . Android blueZ H ...

  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 bluetooth介绍(一):基本概念及硬件接口 BlueZ为调试和与蓝牙子系统通信提供很多设置命令行工具,包含下面这些: hciconfig hcitool hcidump sdpt ...

随机推荐

  1. BZOJ3022 : [Balkan2012]The Best Teams

    将选手和询问按照年龄排序,即可去掉年龄的限制. 将所有选手按水平排序后维护线段树,显然最优解一定是从大到小贪心选择. 线段树上每个节点维护: $g[0/1]:r+1$不选/选的时候,$l$选不选. $ ...

  2. Ios项目添加Pods

    一.概要 iOS开发时,项目中会引用许多第三方库,CocoaPods(https://github.com/CocoaPods/CocoaPods)可以用来方便的统一管理这些第三方库. 二.安装 由于 ...

  3. 前端利器Emmet

    前端利器Emmet Emmet可以通过缩写生成代码片段,可以提升前端开发的效率.使用方法就是输入HTML或者CSS的缩写,然后按tab键自动生成.原文在这里 后代 > <!-- nav&g ...

  4. C_汉诺塔的故事(递归)

    汉诺塔: 汉诺塔(又称河内塔)问题是源于印度一个古老传说的益智玩具.大梵天创造世界的时候做了三根金刚石柱子,在一根柱子上从下往上按照大小顺序摞着64片黄金圆盘.大梵天命令婆罗门把圆盘从下面开始按大小顺 ...

  5. Network Monitoring in Software-Defined Networking :A Review(综述)

    来源:IEEE SYSTEMS JOURNAL 发表时间:2018 类型:综述 主要内容:概述了SDN监控的发展,并从收集信息.预处理.传送信息.分析.和描述五个阶段进行解读,并比较了传统网络和SDN ...

  6. Deepin 15.4 编译安装 LNMP(PHP 5.6.31 + Nginx 1.12.1 + MySQL 5.6.36)

    先查看先前的文章:Ubuntu 14 编译安装 PHP 5.4.45 + Nginx 1.4.7 + MySQL 5.6.26 笔记 编译 Nginx #安装依赖库 sudo apt-get -y i ...

  7. Mac 删除/卸载 自己安装的python

    官网pkg安装的python版本 第一步:删除框架 sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7 1 第二步:删除应用目录 ...

  8. Docker学习笔记1 -- 刚入手docker时的几个命令

    目录 Hello World 后台运行 停止运行 容器 载入镜像 指定端口映射 查看日志 查看应用的进程 登入镜像内部 移除容器 镜像 查看本地镜像 拉取镜像 查找镜像 更新镜像 构建镜像 设置镜像标 ...

  9. 【.NET 深呼吸】.net core 中的轻量级 Composition

    记得前面老周写过在.net core 中使用 Composition 的烂文.上回老周给大伙伴们介绍的是一个“重量级”版本—— System.ComponentModel.Composition.应该 ...

  10. Docker查看运行中容器并进入容器

    一.简述 Docker查看运行中容器并进入容器. 二.方法 $ sudo docker ps $ sudo docker exec -it 775c7c9ee1e1 /bin/bash 将黄色文字替换 ...