Skip to content

Instantly share code, notes, and snippets.

@charlesmuchene
Last active April 17, 2020 03:38
Show Gist options
  • Save charlesmuchene/58c63827ba330f52c3272d48d032ca39 to your computer and use it in GitHub Desktop.
Save charlesmuchene/58c63827ba330f52c3272d48d032ca39 to your computer and use it in GitHub Desktop.
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