android ble connect slowly
Hi I'm writing an Android app to connect to a BLE peripheral device. Android 4.4.2, Galaxy Nexus.
I have an LED on the device to indicate connection state.
The issue is the duration from connectGatt() call to the point of receiving onConnectionStateChange STATE_CONNECTED
are so inconsistent. Some time it is very quick but most of the time it takes 5s or more. Turning Bluetooth off/on does not have any effect.
I tried TI BTool on PC with the TI BLE Dongle and it always establishes connection very fast.
I also tried with an iPhone 5S and it is fast too.
- Any one has experienced this issue too?
- Is there any chance we can improve this?
Passing true to connectGatt() autoconnect argument requests a background connection, while passing false requests a direct connection. BluetoothGatt#connect() always requests a background connection.
Background connection (according to Bluedroid sources from 4.4.2 AOSP) has scan interval of 1280ms and a window of 11.25ms. This corresponds to about 0.9% duty cycle which explains why connections, when not scanning, can take a long time to complete.
Direct connection has interval of 60ms and window of 30ms so connections complete much faster. Additionally there can only be one direct connection request pending at a time and it times out after 30 seconds. onConnectionStateChange() gets called with state=2, status=133 to indicate this timeout.
I have verified this behavior on Nexus5 but obviously YMMV.
I should mention that there is a race condition in BluetoothGatt.java that can cause a direct connection request even if autoconnect=true is passed into BluetoothDevice#connectGatt().
http://stackoverflow.com/questions/22214254/android-ble-connect-slowly
最新文章
- ASP.NET MVC系列:Area
- Ie8+,强制默认使用ie8模式
- MySQL MVCC(多版本并发控制)
- HDU1054 Strategic Game——匈牙利算法
- 安装好grunt,cmd 提示";grunt不是内部或外部命令"; 怎么办?
- IOS打开其他应用、以及被其他应用打开
- SQL Server 基础:拾遗
- [Hive - LanguageManual] Hive Concurrency Model (待)
- AXI_DMA IP学习
- CentOS7 VMware-Tools安装与共享文件夹设置
- [服务器]Gartner:2018年第四季度全球服务器收入增长17.8% 出货量增长8.5%
- 【转】Win10下python3和python2多版本同时安装并解决pip共存问题
- create-react-app项目添加less配置
- Hadoop生态集群MapReduce详解
- Go语言学习之10 Web开发与Mysql数据库
- router使用以及vue的动画效果
- [luogu P1438] 无聊的数列
- LAXCUS大数据操作系统节点挂掉后的处理
- POJ1789:Truck History(Prim算法)
- Java JDBC数据库链接
热门文章
- missing required architecture x86_64 in file 不支持64位
- 百度地图LBS开放平台AK一直没有用
- 前端插件Emmet
- Process Stats:了解你的APP如何使用内存(转)
- 在Windows Server 2012 中安装 .NET 3.5 Framework,PowerShell 安装.NET FRAMEWORK
- IOS中调整UI控件位置和尺寸
- MVC EF ObjectStateManager 中已存在具有同一键的对象。ObjectStateManager 无法跟踪具有相同键的多个对象。
- GIT Learning
- 对App数据库元素进行简单的设计
- 华丽的HTML5/jQuery动画和应用 前端必备