I have tried different implementations of BLE connection on Android. One with RxAndroidBle and another one with simple Android API. I used RxAndroidBle example app for testing. I connect to the same peripheral with the same service and characteristic. Though when I read or get notifications from it in the case of RxAndroidBle I receive 512 bytes and in the case of Android API - just 20. I try to request MTU 512 but onMtuChanged is never called and I still receive 20. Do I miss something?
Asked
Active
Viewed 577 times
2

Phantômaxx
- 37,901
- 21
- 84
- 115

Nataliya Le Loup
- 125
- 8
-
When you call [`requestMtu`](https://developer.android.com/reference/android/bluetooth/BluetoothGatt#requestMtu(int)) is the result `true` or `false`? – stkent May 27 '18 at 20:47
-
the result is `true` – Nataliya Le Loup May 27 '18 at 20:50
-
Are you handling exceptions in `onMtuChanged`? If I recall correctly those are swallowed by default. Might be something hiding in there... – stkent May 27 '18 at 20:55
-
the method is never called, the only thing I see in logs is: `D/BluetoothGatt: configureMTU() - device: B8:**** mtu: 512 D/BtGatt.GattService: configureMTU() - address=B8:*** mtu=512 E/bt_btif: No pending command` – Nataliya Le Loup May 27 '18 at 21:13
-
In fact when I'm also trying to call `requestConnectionPriority` i get this: `W/bt_l2cap: L2CA_UpdateBleConnParams - unknown BD_ADDR ********** E/bt_btif: Update connection parameters failed!` Any idea about that? – Nataliya Le Loup May 28 '18 at 00:28
-
No idea, sorry :/ – stkent May 28 '18 at 02:18
-
Are you trying to execute all requests at once perhaps? – Dariusz Seweryn May 28 '18 at 07:24
-
No, I also I tried only to call `requestConnectionPriority` after connection is done: ` if (newState == BluetoothProfile.STATE_CONNECTED) { boolean req = mBluetoothGatt.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_BALANCED); Log.i(TAG, "Connected to GATT server and requestConnectionPriority: "+req); } else if ` still get the same results – Nataliya Le Loup May 28 '18 at 09:46
-
Try calling the `bluetoothGatt` always from the same thread — on some implementations this may be an issue – Dariusz Seweryn May 29 '18 at 07:21
-
Any news about your case? – Dariusz Seweryn Jun 05 '18 at 17:13
-
I'm not 100% sure yet but I think it has something to do with the bonding and setting BluetoothDevice.TRANSPORT_LE option when connecting to the peripheral device. – Nataliya Le Loup Jun 05 '18 at 21:54
-
This may be related. Different versions/implementations od Android BLE stack handle dual mode devices in different ways. Usually a better handling (in LE scenarios) is achieved when `TRANSPORT_LE` is required but [this may not always be the case](https://github.com/Polidea/RxAndroidBle/issues/439) probably due to wrong peripheral implementation. Feel free to add more information when available. – Dariusz Seweryn Jun 08 '18 at 21:00
-
yes, it seems that since I set this parameter TRANSPORT_LE, max MTU is used, even if I don't set it explicitly. My device indeed is working in dual mode. Thank you! – Nataliya Le Loup Jun 14 '18 at 12:03