I have an issue regarding Android BLE. It is the following: This issue occurs on Samsung Galaxy S10e, Android 10, OneUI 2.5. It comes up when the Smartphone is connected to some Wifi. If the Smartphone is connected to Wifi, onCharacteristic Changed is not called. If Wifi is turned off, everything works as expected and onCharacteristicChanged is called. It was also tested on a Google Pixel 3XL. With this smartphone everything works as expected, no matter if connected to Wifi or not. This seems to occur since the new OneUI Version 2.5. It worked as expected on OneUI 2.1. SetCharacteristicNotification on BluetoothGatt and writeDescriptor work fine and writeDescriptor(descriptor) returns true. So I don't think there is something wrong about this code, since it works as intended when Wifi is turned off. Just for the case, here my code for enabling notifications on Android BLE:
val CHARACTERISTIC_UPDATE_NOTIFICATION_DESCRIPTOR_UUID = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
characteristic?.writeType = BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE
bg?.setCharacteristicNotification(characteristic, true)
val descriptor = characteristic?.getDescriptor(CHARACTERISTIC_UPDATE_NOTIFICATION_DESCRIPTOR_UUID)
descriptor?.value = if (enabled) BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE else byteArrayOf(0x00, 0x00)
descriptor?.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE)
bg?.writeDescriptor(descriptor) ?: false
I already tried it without the line descriptor?.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE)
. It doesn't change anything.
Is there something I am missing? Why could a Wifi connection block onCharacteristicChanged? If the Smartphone has turned on Wifi and is NOT connected, then it works. It only doesn't work when Wifi is turned on and IS connected.
writeCharacterstic and readCharacterstic are working fine and the callbacks trigger, no matter if Wifi is connected or not. So the BluetoothGattCallback is set just fine.
Can someone help me out here? Thanks!
Best, Markus