CommunicationsGattServer

class CommunicationsGattServer(context: Context, coroutineScope: CoroutineScope) : LifecycleObserver

Wrapper for BluetoothGattServer that uses coroutines to manage all asynchronous calls.

Note: All listener callbacks are called on the main thread.

Constructors

Link copied to clipboard
fun CommunicationsGattServer(context: Context, coroutineScope: CoroutineScope)

Functions

Link copied to clipboard
suspend fun addService(service: BluetoothGattService): Boolean

Adds the specified service. Returns true on success, false otherwise.

Link copied to clipboard
fun close()

Closes the server and releases its resources.

Link copied to clipboard
suspend fun indicateCharacteristicChanged(    deviceId: DeviceId,     serviceUuid: ServiceUuid,     characteristicId: CharacteristicId,     value: ByteArray): Boolean

Indicates to the device with the specified deviceId that the value of the characteristic with the specified characteristicId on the service with the specified serviceUuid has changed to the specified value.

Link copied to clipboard
suspend fun notifyCharacteristicChanged(    deviceId: DeviceId,     serviceUuid: ServiceUuid,     characteristicId: CharacteristicId,     value: ByteArray): Boolean

Notifies the device with the specified deviceId that the value of the characteristic with the specified characteristicId on the service with the specified serviceUuid has changed to the specified value.

Link copied to clipboard
suspend fun removeService(serviceUuid: ServiceUuid): Boolean

Removes the service with the specified serviceUuid.

Link copied to clipboard
suspend fun start(listener: CommunicationsGattServerListener)

Starts the gatt server with the specified listener.