Skip to content

Instantly share code, notes, and snippets.

@tdcolvin
Created January 8, 2024 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdcolvin/42d1cf9b40fdb8d908c9cd41e906d63e to your computer and use it in GitHub Desktop.
Save tdcolvin/42d1cf9b40fdb8d908c9cd41e906d63e to your computer and use it in GitHub Desktop.
@RequiresPermission(PERMISSION_BLUETOOTH_CONNECT)
fun stopReceivingPasswordUpdates() {
val service = gatt?.getService(CTF_SERVICE_UUID)
val characteristic = service?.getCharacteristic(PASSWORD_CHARACTERISTIC_UUID)
if (characteristic != null) {
val CLIENT_CONFIG_DESCRIPTOR = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb")
val desc = characteristic.getDescriptor(CLIENT_CONFIG_DESCRIPTOR)
desc?.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE)
gatt?.writeDescriptor(desc)
gatt?.setCharacteristicNotification(characteristic, false)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment