I'm working with ble nordic thingy52 devices, from which I want to read data (for now only rawdata, EF680406-9B35-4933-9B10-52FFA9740042) from my Android device.
The Nordic device, on the rawdata characteristics, allows a maximum sampling rate of 200Hz. Trying to connect through the raspberry I verified that in fact enabling the rawdata notification I receive data at 200Hz. My need is to do the same on my android device (Oneplus6).
I've tried different libraries (RxJavaBLE, Nordic-Android-BLE, KABLE) and I've tried to use directly the Android BLE API, but the problem is that even if I set all the parameters that I was able to find I don't reach a frequency of 200Hz, but at most 160Hz-180Hz, and also after a few seconds the frequency of data reception drops dramatically to 30-40Hz.
My connection to device:
device.connectGatt(context, false, callback, BluetoothDevice.TRANSPORT_LE)
(I have tried both with and without using BluetoothDevice.TRANSPORT_LE)
after that, once connected I call the classic discoveryService() and once completed inside onServicesDiscovered() I try to set:
requestMtu(device, 23)
requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_HIGH)
I tried the MAX_MTU and MIN_MTU (23), I also tried to use connection priority and not, but I still have no differences in sampling frequency.
Once rawdata notifications are enabled, I read them inside the onCharacteristicChanged() method.
I also tried to set the minimum values of the connection parameters and vary them during the tests, e.g:
advertising interval 20ms
advertising timeout 0ms
min connection interval 7,5ms
max connection interval 20ms
slave latency 0
supervision timeout 1000ms
But still, I can't get nor 200Hz as the frequency of the data received inside onCharacteristicRead, and especially after several seconds the frequency decreases dramatically. What could be the cause of the problem? How can I get as close to 200Hz as possible in a more constant way?
Compared to the test performed with the Nordic-Raspberry connection, is it my Android device that is losing packets? Can it be a problem with the android Bluetooth buffer?
The tests I have run on both my phone and others (samsung and realme) are affected by the same problem. I tried searching the internet for similar issues but couldn't find an answer to my problem.
I appreciate any answers and help, Thanks