Android bluetooth low energy (ble) writeCharacteristic delay callback
I am implementing a application on Android using BLE Api (SDK 18), and I have a issue that the transfer data process is delay very slow. This is my log.
03-12 16:20:05.121: D/BluetoothGatt(13578): writeCharacteristic() - uuid: ...
03-12 16:20:06.272: D/BluetoothGatt(13578): onCharacteristicWrite() - Device=... UUID=... Status=0
03-12 16:20:06.972: D/BluetoothGatt(13578): writeCharacteristic() - uuid: ...
03-12 16:20:08.254: D/BluetoothGatt(13578): onCharacteristicWrite() - Device=... UUID=... Status=0
03-12 16:20:10.055: D/BluetoothGatt(13578): writeCharacteristic() - uuid: ...
03-12 16:20:11.257: D/BluetoothGatt(13578): onCharacteristicWrite() - Device=... UUID=... Status=0
03-12 16:20:12.478: D/BluetoothGatt(13578): writeCharacteristic() - uuid: ...
03-12 16:20:14.250: D/BluetoothGatt(13578): onCharacteristicWrite() - Device=... UUID=... Status=0
03-12 16:20:14.960: D/BluetoothGatt(13578): writeCharacteristic() - uuid: ...
03-12 16:20:16.242: D/BluetoothGatt(13578): onCharacteristicWrite() - Device=... UUID=... Status=0
03-12 16:20:16.402: D/BluetoothGatt(13578): writeCharacteristic() - uuid: ...
03-12 16:20:20.225: D/BluetoothGatt(13578): onCharacteristicWrite() - Device=... UUID=... Status=0
03-12 16:20:20.526: D/BluetoothGatt(13578): writeCharacteristic() - uuid: ...
03-12 16:20:24.219: D/BluetoothGatt(13578): onCharacteristicWrite() - Device=... UUID=... Status=0
03-12 16:20:25.360: D/BluetoothGatt(13578): writeCharacteristic() - uuid: ...
03-12 16:20:27.222: D/BluetoothGatt(13578): onCharacteristicWrite() - Device=... UUID=... Status=0
For more information, I found that every Transfer Progress only completes when it has the onCharacteristicWrite callback, this means that all sending command before receive onCharacteristicWrite callback will be ignored.
Is this the flow of Android we have to following or there is any way to setup it skip the callback step to speed up the progress.
My code is:
privatefinalBluetoothGattCallback mGattCallback =newBluetoothGattCallback(){......@Overridepublicvoid onCharacteristicWrite(BluetoothGatt gatt,BluetoothGattCharacteristic characteristic,int status){
mSending =false;}};privatevoid writeCharacteristic(){.....
mGattCharacSetIntensity.setValue(data);
mGattCharacSetIntensity.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT);
mBluetoothGatt.writeCharacteristic(mGattCharacSetIntensity);return;}
EDIT: I have a comparison with iPhone (a BLE transfer data app from AppStore), the BLE transfer data is very quick (less than 0.5 sec), so impressive. How can we work around to SPEED UP the Android BLE Transfer progress?.
EDIT: If I set WriteType of BluetoothGattCharacteristic to WRITE_TYPE_NO_RESPONSE, and when I send many command sequentially, the Android stores them on a queue and send to remote device one by one after receive writeCharacteristic CallBack, this leads to a issue, when you stop your sending lood, the Android Sending Progress still continue with the delay (Sometime more than 3 sec).
##############
Performance of a BLE link is highly dependent on the connection interval used, and if your connection interval is high, the performance you see may not be that unreasonable. By the Core Specification, the connection interval can be between 7.5 ms and 4 s, so there's quite some flexibility.
If it's possible for you, I'd recommend you to try changing the Peripheral you're talking to to use a shorter connection interval, which should improve performance. You may have use in taking a look at this page, explaining BLE throughput, and this page, explaining connection parameters.
http://stackoverflow.com/questions/22348470/android-bluetooth-low-energy-ble-writecharacteristic-delay-callback
Android bluetooth low energy (ble) writeCharacteristic delay callback的更多相关文章
- Android Bluetooth Low Energy (BLE)简单方便的蓝牙开源库——EasyBLE
源码传送门 最新版本 功能 支持多设备同时连接 支持广播包解析 支持连接同时配对 支持搜索系统已连接设备 支持搜索器设置 支持自定义搜索过滤条件 支持自动重连.最大重连次数限制.直接重连或搜索到设备再 ...
- How to Implement Bluetooth Low Energy (BLE) in Ice Cream Sandwich
ShareThis - By Vikas Verma Bluetooth low energy (BLE) is a feature of Bluetooth 4.0 wireless radio t ...
- Bluefruit LE Sniffer - Bluetooth Low Energy (BLE 4.0) - nRF51822 驱动安装及使用
BLE Sniffer https://www.adafruit.com/product/2269 Bluefruit LE Sniffer - Bluetooth Low Energy (BLE 4 ...
- Overview and Evaluation of Bluetooth Low Energy: An Emerging Low-Power Wireless Technology
转自:http://www.mdpi.com/1424-8220/12/9/11734/htm Sensors 2012, 12(9), 11734-11753; doi:10.3390/s12091 ...
- Android使用BLE(低功耗蓝牙,Bluetooth Low Energy)
背景 在学习BLE的过程中,积累了一些心得的DEMO,放到Github,形成本文.感兴趣的同学可以下载到源代码. github: https://github.com/vir56k/bluetooth ...
- Bluetooth Low Energy 嗅探
Bluetooth Low Energy 嗅探 路人甲 · 2015/10/16 10:52 0x00 前言 如果你打开这篇文章时期望看到一些新的东西,那么很抱歉这篇文章不是你在找的那篇文章.因为严格 ...
- Bluetooth Low Energy介绍
目录 1. 介绍 2. 协议栈 3. 实现方案 3.1 硬件实现方案 3.2 软件实现方案 1. 介绍 Bluetooth low energy,也称BLE(低功耗蓝牙),在4.0规范中提出 BLE分 ...
- Bluetooth Low Energy 介绍
1.简介 BLE(Bluetooth Low Energy,低功耗蓝牙)是对传统蓝牙BR/EDR技术的补充.尽管BLE和传统蓝牙都称之为蓝牙标准,且共享射频,但是,BLE是一个完全不一样的技术.BLE ...
- Bluetooth® Low Energy Beacons
Bluetooth® Low Energy Beacons ABSTRACT (abstract ) 1.This application report presents the concept of ...
随机推荐
- 如何调试异步加载的js文件(浏览器调试动态加载js)
描述 1:jQuery->var obj= new $.js_Obj():等异步加载js文件,执行方法. obj.method(): 2:页面估计不变,通过声明不同的js文件,进行页面内容的转换 ...
- IOS 支付宝、微信回调传值给H5网页
这里用是的苹果原生和JS的交互 .有不明白JavaScriptCore框架的可以去网上搜索下这方面的资料很多废话不多说直接上代码 @protocol JSContextDelegate <JSE ...
- 自定义input file 属性
<label class="input"><input title="浏览文件" type="file" />浏览… ...
- Log4net记录日志存库并存本地
<?xml version="1.0" encoding="utf-8"?> <configuration> <configSec ...
- OC Categroy类别
Categroy类别,又称为扩展类,在类的原基础上扩展方法,且不可添加变量,如果扩展的方法与原始类中的方法相同,则会隐藏原始方法,且不可在扩展方法中通过super调用原始方法,这里与继承不同. 定义: ...
- ef codeFirst 修改表结构 增加字段等 EF code first需要重新生成库导致数据丢失的问题.
需要在库程序包管理器里依次执行以下命令: 1.启用迁移功能:Enable-Migrations -ContextTypeName MvcMovie.Models.MovieDbContext 2.建立 ...
- PHP static静态局部变量和静态全局变量总结
1.不会随着函数的调用和退出而发生变化,不过,尽管该变量还继续存在,但不能使用它.倘若再次调用定义它的函数时,它又可继续使用,而且保存了前次被调用后留下的值 2.静态局部变量只会初始化一次 3.静态属 ...
- 理解C#系列 / 核心C# / 判断&循环&跳转
判断&循环&跳转 说明 本节写的是C#语言的控制程序流的语句,“控制程序流”就是控制程序运行流程的意思. 判断 很容易理解:如果……就…… if语句:测试特定条件是否满足,如果满足就执 ...
- VS默认环境设置
VS2010的工具菜单-->导入导出设置-->重置所有设置
- webstorm 自定义代码模板
Ctrl+Shift+A查找设置live 添加代码片段Live Template 编写代码的时候 缩写+Tab 即可输出代码片段 缩写启动对应代码片段的钥匙. 描述代码片段的名字. 模板文本代码片段的 ...