Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setCharacteristicNotification example is wrong #269

Open
KaneZMY opened this issue Aug 4, 2022 · 0 comments
Open

setCharacteristicNotification example is wrong #269

KaneZMY opened this issue Aug 4, 2022 · 0 comments

Comments

@KaneZMY
Copy link

KaneZMY commented Aug 4, 2022

You must writeDescriptor after gatt.setCharacteristicNotification to inform peripheral, it's NOT specific to Heart Rate Measurement.

fun setCharacteristicNotification() {
    gatt?.let { gatt ->
        gatt.setCharacteristicNotification(characteristic, true)
        val CCC_DESCRIPTOR_UUID: UUID = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb")
        val descriptor = characteristic?.getDescriptor(CCC_DESCRIPTOR_UUID)?.apply {
            value = BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE
        }
        gatt.writeDescriptor(descriptor)

https://developer.android.com/guide/topics/connectivity/bluetooth/transfer-ble-data is a bad document.
https://developer.android.com/guide/topics/connectivity/bluetooth-le#notification is good document.
Please update document and examples, save some time for others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant