My app do the following:
It sends a command with
onDescriptorWriteto the BT device.As soon the BT device gets this command it starts transferring data to the Android phone.
Android's
onCharacteristicChangedis catching all the data sent from the BT device.After all the data is transferred the Android app writes it to a file.
I've tested it and everything works totally perfect on a Samsung (Android 11), a OnePlus (Android 11), and a Xiaomi (Android 9), but the data coming from onCharacteristicChanged is getting corrupted on a Nokia (Android 11).
This test example shows the transferred data wrote into a file with a checksum. As you can see I get the very same bytes on a Xiaomi, but on the Nokia it sometimes gets corrupted.
Tested on Xiaomi MiA1 (Android 9)
File_MD5: The right file MD5 -> AE36F08213B25B5E0EE19425257D0D85
File_MD5: Measurement file MD5: AE36F08213B25B5E0EE19425257D0D85 (ok)
File_MD5: Measurement file MD5: AE36F08213B25B5E0EE19425257D0D85 (ok)
File_MD5: Measurement file MD5: AE36F08213B25B5E0EE19425257D0D85 (ok)
File_MD5: Measurement file MD5: AE36F08213B25B5E0EE19425257D0D85 (ok)
File_MD5: Measurement file MD5: AE36F08213B25B5E0EE19425257D0D85 (ok)
File_MD5: Measurement file MD5: AE36F08213B25B5E0EE19425257D0D85 (ok)
File_MD5: Measurement file MD5: AE36F08213B25B5E0EE19425257D0D85 (ok)
File_MD5: Measurement file MD5: AE36F08213B25B5E0EE19425257D0D85 (ok)
File_MD5: Measurement file MD5: AE36F08213B25B5E0EE19425257D0D85 (ok)
Tested on Nokia 5.4 (Android 11)
File_MD5: The right file MD5 -> BCF704DD811A760B5602C20DEDB61AF8
File_MD5: Measurement file MD5: BCF704DD811A760B5602C20DEDB61AF8 (ok)
File_MD5: Measurement file MD5: E65A5D38EB3D8BF4E1AF5240DFBE1840 (ERROR)
File_MD5: Measurement file MD5: BCF704DD811A760B5602C20DEDB61AF8 (ok)
File_MD5: Measurement file MD5: BCF704DD811A760B5602C20DEDB61AF8 (ok)
File_MD5: Measurement file MD5: BCF704DD811A760B5602C20DEDB61AF8 (ok)
File_MD5: Measurement file MD5: BCF704DD811A760B5602C20DEDB61AF8 (ok)
File_MD5: Measurement file MD5: 0D3A577631A115FBAF3324A9B09244A8 (ERROR)
File_MD5: Measurement file MD5: A6FB1334D7AA1520F105ACB1EC1324C5 (ERROR)
File_MD5: Measurement file MD5: BCF704DD811A760B5602C20DEDB61AF8 (ok)
File_MD5: Measurement file MD5: BCF704DD811A760B5602C20DEDB61AF8 (ok)
I'm absolutely standing incomprehensibly in front of this issue, yet another one of Android's fragmented and unreliable ecosystem.
I've tried the following:
Setting my
BluetoothGattinstance toCONNECTION_PRIORITY_HIGHmode withrequestConnectionPriorityUsing a
synchronizeddata container inonCharacteristicChangedin case if this is some multiple thread writing the same container type of error.
None of them helped.
Any insights?
E D I T:
My coworker made a firmware which simply sends incrementing numbers. As you can see within the red area, the data is corrupted, even with Nordic's own nRF toolbox app.
Should I be worried?
That means this Nokia is just doesn't work and that is it? Can this be a hardware issue for only this device?

Seems like there are some differences in the realisation on that smartphone. Try to do these things:
onCharacteristicChanged) to a thread safe collection. It'll be better to wrap each chunk in a structure ({data: ByteArray, device: *, something else...}).onCharacteristicChangedas soon as possible and them handle in a convenient way on our own thread.