digidotcom / xbee-android

Android library to interact with Digi International's XBee radio frequency modules from mobile devices.
Mozilla Public License 2.0
17 stars 12 forks source link

Bluetooth Serial communication slow #17

Open theJoey opened 4 years ago

theJoey commented 4 years ago

I am working on implementing your library into an android app but I am facing a performance issue. When I use your app (xbee on google play) I can send at least 10 commands per second through the serial interface However, when I use your library, I can only send 5 commands per seconds with this method :

mXBeeDevice.sendUserDataRelay( XBeeLocalInterface.SERIAL, data )

I followed your github example so I have no idea where the issue comes from.

Can you give me a clue about what happened please?

DanielLazarHTDM commented 2 years ago

Hi theJoey,

well I had same impression.

than I've put into: xbee_android_library/src/main/java/com/digi/xbee/api/android/connection/bluetooth/AndroidBluetoothInterface.java

bluetoothGatt.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_HIGH);

To boost it and after that instead of about 100 ms per write it is able to write 30 ms. Check following log every frame received in serial console.

12-28 16:33:24.642 23047 23047 I PERFORMANCE: 30 [ms] 91226 bytes 12-28 16:33:24.672 23047 23047 I PERFORMANCE: 30 [ms] 91459 bytes 12-28 16:33:24.702 23047 23047 I PERFORMANCE: 30 [ms] 91692 bytes 12-28 16:33:24.733 23047 23047 I PERFORMANCE: 31 [ms] 91925 bytes 12-28 16:33:24.763 23047 23047 I PERFORMANCE: 29 [ms] 92158 bytes 12-28 16:33:24.792 23047 23047 I PERFORMANCE: 29 [ms] 92391 bytes 12-28 16:33:24.822 23047 23047 I PERFORMANCE: 30 [ms] 92624 bytes 12-28 16:33:24.852 23047 23047 I PERFORMANCE: 30 [ms] 92857 bytes 12-28 16:33:24.882 23047 23047 I PERFORMANCE: 30 [ms] 93090 bytes 12-28 16:33:24.883 23047 23047 I PERFORMANCE: Total: 12481 [ms] 93090 bytes => 7.458536976203829 kB/s

Cheers, Dan