博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android bluetooth low energy (ble) writeCharacteristic delay callback
阅读量:4594 次
发布时间:2019-06-09

本文共 3820 字,大约阅读时间需要 12 分钟。

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 , explaining BLE throughput, and , explaining connection parameters.

 

http://stackoverflow.com/questions/22348470/android-bluetooth-low-energy-ble-writecharacteristic-delay-callback

 

posted on
2014-06-11 14:16 阅读(
...) 评论(
...)

转载于:https://www.cnblogs.com/savagemorgan/p/3781865.html

你可能感兴趣的文章
StringBuilder的使用与总结
查看>>
CSS3基础(2)—— 文字与字体相关样式、盒子类型、背景与边框相关样式、变形处理、动画功能...
查看>>
Java的文档注释之生成帮助文档
查看>>
转:web_url函数学习
查看>>
TCP客户端 服务端详细代码
查看>>
win10用filezilla server搭建ftp服务器一直无法访问
查看>>
SQL存储过程、视图
查看>>
MySQL系列(十一)--外键约束foreign key的基本使用
查看>>
字符串算法(KMP,Trie树,AC自动机)
查看>>
第一次从头至尾的项目
查看>>
ng-options用法详解
查看>>
封装别人的库的时候一些注意点
查看>>
【Jim】I am back (ง •_•)ง
查看>>
Mysql数据库相关知识
查看>>
flex布局学习总结
查看>>
函数式编程
查看>>
js中的事件添加和程序
查看>>
多校 2013 8
查看>>
Docker 容器管理
查看>>
zoj-3706 Break Standard Weight
查看>>