Created
January 5, 2024 09:31
-
-
Save tdcolvin/75fd3612008291aa9d7d6d06079b7b8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val callback = object: BluetoothGattCallback() { | |
... | |
@Deprecated("Deprecated in Java") | |
override fun onCharacteristicRead( | |
gatt: BluetoothGatt, | |
characteristic: BluetoothGattCharacteristic, | |
status: Int | |
) { | |
super.onCharacteristicRead(gatt, characteristic, status) | |
if (characteristic.uuid == myCharacteristicUUID) { | |
Log.v("bluetooth", String(characteristic.value)) | |
} | |
} | |
} | |
@RequiresPermission(PERMISSION_BLUETOOTH_CONNECT) | |
fun readCharacteristic(serviceUUID: UUID, characteristicUUID: UUID) { | |
val service = gatt?.getService(serviceUUID) | |
val characteristic = service?.getCharacteristic(characteristicUUID) | |
if (characteristic != null) { | |
val success = gatt?.readCharacteristic(characteristic) | |
Log.v("bluetooth", "Read status: $success") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment