Skip to content

Instantly share code, notes, and snippets.

@charlesmuchene
Last active April 17, 2020 03:38
Embed
What would you like to do?
Android Gatt server - Peripheral
// Starts GattServer to serve remote Central requests
private val gattServer: BluetoothGattServer by lazyNone {
bluetoothManager.openGattServer(this.applicationContext, GattServerCallback())
}
private class GattServerCallback : BluetoothGattServerCallback() {
override fun onConnectionStateChange(device: BluetoothDevice, status: Int, newState: Int) { ... }
override fun onCharacteristicReadRequest(device: BluetoothDevice, requestId: Int, offset: Int, characteristic: BluetoothGattCharacteristic) {
// Respond with TraceCharacteristic value from given offset
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment