GattServerSessionScope


interface GattServerSessionScope


A scope for operations as a GATT server role.

A scope is created for each remote device.

Collect requests to respond with requests from the client.

See also
GattServerConnectRequest

#accept()

Summary

Public functions

suspend Unit
notify(characteristic: GattCharacteristic, value: ByteArray)

Notifies a client of a characteristic value change.

Public properties

BluetoothDevice

A client device connected to the server.

Flow<GattServerRequest>

A hot Flow of incoming requests from the client.

StateFlow<Set<GattCharacteristic>>

A StateFlow of the set of characteristics that the client has requested to be notified of.

Public functions

notify

Added in 1.0.0-alpha02
suspend fun notify(characteristic: GattCharacteristic, value: ByteArray): Unit

Notifies a client of a characteristic value change.

Parameters
characteristic: GattCharacteristic

the updated characteristic

value: ByteArray

the new value of the characteristic

Throws
kotlinx.coroutines.CancellationException

if it failed to notify

kotlin.IllegalArgumentException

if the length of the value is greater than the maximum attribute length (512)

Public properties

device

Added in 1.0.0-alpha02
val deviceBluetoothDevice

A client device connected to the server.

requests

Added in 1.0.0-alpha02
val requestsFlow<GattServerRequest>

A hot Flow of incoming requests from the client.

A request is either GattServerRequest.ReadCharacteristic or GattServerRequest.WriteCharacteristics

subscribedCharacteristics

Added in 1.0.0-alpha02
val subscribedCharacteristicsStateFlow<Set<GattCharacteristic>>

A StateFlow of the set of characteristics that the client has requested to be notified of.

The set will be updated whenever the client subscribes to or unsubscribes a characteristic.

See also
notify