enableNotifications

fun enableNotifications(serviceUuid: UUID, characteristicUuid: UUID, callback: (ByteArray) -> Unit)

Enables notifications for a characteristic and registers a callback for received values.

This method configures the BLE device to send notifications when the specified characteristic's value changes. The provided callback will be invoked each time a notification is received from the device.

Internally, this writes to the Client Characteristic Configuration Descriptor (CCCD) with CLIENT_CHARACTERISTIC_CONFIG_UUID to enable notifications on the remote device.

Parameters

serviceUuid

The UUID of the GATT service containing the characteristic.

characteristicUuid

The UUID of the characteristic to enable notifications for. The characteristic must support notifications (PROPERTY_NOTIFY).

callback

The callback function invoked with the ByteArray value each time a notification is received from the characteristic.

See also