Skip to content

Instantly share code, notes, and snippets.

@tdcolvin
Last active January 5, 2024 09:09
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/265ad7f5215afa410bc84528476ff473 to your computer and use it in GitHub Desktop.
Save tdcolvin/265ad7f5215afa410bc84528476ff473 to your computer and use it in GitHub Desktop.
// The saved list of services. The BluetoothGattService objects here can be used
// to list the characteristics in each service.
private var services: List<BluetoothGattService> = emptyList()
@RequiresPermission(PERMISSION_BLUETOOTH_CONNECT)
fun discoverServices() {
gatt?.discoverServices()
}
private val callback = object: BluetoothGattCallback() {
//Continuing our override of methods in this object from previous steps...
...
override fun onServicesDiscovered(gatt: BluetoothGatt, status: Int) {
super.onServicesDiscovered(gatt, status)
services = gatt.services
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment