Android Bluetooth Low energy (BLE) writecharacteristic delay callback

Source: Internet
Author: User



I am implementing a application on Android using BLE Api (SDK), and I had a issue that the transfer data process is de Lay 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:27.222:d/bluetoothgatt (13578): Oncharacteristicwrite ()-device= ... Uuid= ... Status=0



For more information, I found that every Transfer Progress only completes when it had the Oncharacteristicwrite callback, This means, all sending command before receive Oncharacteristicwrite callback would be ignored.



is, the flow of Android we have to following or there are any-to-be-to-setup it skip the callback step to speed up the PR Ogress.



My code is:


PrivateFinalBluetoothgattcallbackMgattcallback=NewBluetoothgattcallback(){......@Override PublicvoidOncharacteristicwrite(BluetoothgattGATT,bluetoothgattcharacteristiccharacteristic,intStatus){msending=false;}};Privatevoidwritecharacteristic(){.....mgattcharacsetintensity.SetValue(Data);mgattcharacsetintensity.Setwritetype(bluetoothgattcharacteristic.Write_type_default);Mbluetoothgatt.writecharacteristic(mgattcharacsetintensity);return;}


Edit:i has a comparison with iPhone (a ble transfer data app from AppStore), the BLE transfer data are very quick (less t Han 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 sequential Ly, the Android stores them on a queue and send to remote device one by one after receive writecharacteristic CallBack, th Is 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 are high, th E performance You see May is not is that unreasonable. By the Core specification, the connection interval can is between 7.5 ms and 4 S, so there ' s quite some flexibility.



If It's possible for you, I ' d recommend-to-try changing the peripheral you ' re talking-to-use a shorter connection I Nterval, which should improve performance. 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





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.