react-native-ble-manager icon indicating copy to clipboard operation
react-native-ble-manager copied to clipboard

UpdateValueForCharacteristic receives data very slowly on android

Open pooja-chothe opened this issue 5 years ago • 11 comments

Version

Tell us which versions you are using:

  • react-native-ble-manager v6.6.2
  • react-native v0.55.4
  • iOS/Android v.?

I am using react-native-ble-manager module for bluetooth communication(BLE). When I write some command using bleManager.Write() function then sensor returns some amount of data, but data receiving speed is very slow on android and better on iOS. So how i can improve the data receiving speed. Please let me know if anyone know the solution.

Thanks in advance.

pooja-chothe avatar Apr 15 '19 06:04 pooja-chothe

bandwidth is proportional to the MTU packet size, and inversely proportional to the event time duration. Need low packet duration, and large number of bytes for the MTU.

This a good one to read for some background on ble throughput. https://www.silabs.com/community/wireless/bluetooth/knowledge-base.entry.html/2015/08/06/throughput_with_blue-Wybp.

I'm having issues as well, I'm trying to increase the MTU size with bleManager.requestMTU(id, 244). The promise returns and says it has updated it, but I know it hasn't worked, as I can see on my embedded device the MTU is stuck at 20 bytes. @pooja-chothe I suspect you are having similar issues, and your MTU is stuck at 20 bytes as well ? You should try increasing it, and see if you have any luck. Sounds like iOS automatically negotiates as high MTU as possible. That's why your iOS is working good, and android like crap.

Anyone have any luck successfully increasing the MTU on android ? I 've tried a different app, same phone, to same device, I'm getting MTU of 244. So I think it's an issue with this library ?

Thanks

drchorney avatar Apr 20 '19 21:04 drchorney

Any update on this? Having the same issue.

@drchorney did you find a solution?

JacopoKenzo avatar Jun 13 '19 01:06 JacopoKenzo

Doesn't look like a closed issue to me :)

JacopoKenzo avatar Jun 18 '19 23:06 JacopoKenzo

@JacopoKenzo , unfortunately no, I tried playing around with various configuration/settings to try to get the MTU to actually work. But no success. In the end I switched over to react-native-ble-plx. When I set the MTU size with react-native-ble-plx, it actually works. So I'm not using this library anymore...

drchorney avatar Jun 18 '19 23:06 drchorney

@drchorney I was having problems receiving notifications with react-native-ble-plx that's why I switched to this library.. wonder if I should give it another try.

JacopoKenzo avatar Jun 18 '19 23:06 JacopoKenzo

@JacopoKenzo, yeah I started with react-native-ble-plx as well, and then I also switched over to this library as I liked the listener logic and the more functional nature of the library. I hate passing around the manager = new BleManager(). But.... I hate transferring data at an MTU of 20 bytes much much more... With react-native-ble-plx I can max out the MTU size on android.

drchorney avatar Jun 19 '19 00:06 drchorney

Hi guys, I can reopen the issue but I can't test on your device and I don't see problem in the code.

marcosinigaglia avatar Jun 19 '19 09:06 marcosinigaglia

yo tambien tengo problemas aumentando el MTU. no cambia de 20

daniel-alzate avatar Jul 17 '19 04:07 daniel-alzate

I am having issues with delays and the MTU causing a data cutoff as well. A subsequent read takes a moment as well.

I am not transferring much data and the performance is problematic.

skhameneh avatar Aug 28 '19 03:08 skhameneh

I was able to fix part of this by finishing the MTU upgrade on the device itself. Even with the MTU upgrade, UpdateValueForCharacteristic only provides 20 bytes.

I would like a GATT notification without data event as well as the full MTU window with this event.

skhameneh avatar Aug 28 '19 04:08 skhameneh

This is what ended up working for me.

const mtu = await BleManager.requestMTU(deviceID, 128); # request the MTU size in bytes
const services = await BleManager.retrieveServices(deviceID);
await BleManager.writeWithoutResponse(deviceID, serviceId, characteristicId, data, mtu); # pass the MTU size in bytes to maxByteSize optional param

The BleManger.write() documentation mentions that maxByteSize is the number of bytes before the message is split, but BleManager.writeWithoutResponse() does not.

Relevant docs: https://github.com/innoveit/react-native-ble-manager#writeperipheralid-serviceuuid-characteristicuuid-data-maxbytesize

Rowansdabomb avatar Aug 20 '21 21:08 Rowansdabomb