DefaultBluetoothServer

class DefaultBluetoothServer : BluetoothServer, CoroutineScope

The default implementation of BluetoothServer. It makes the Hardware advertise AdvertiseData and exposes LocalService to connect to.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
open override val isAdvertising: StateFlow<Boolean>

A StateFlow indicating whether this server is currently advertising

Link copied to clipboard
open override val services: StateFlow<List<LocalService>>

A StateFlow of the LocalServices that are currently discoverable

Link copied to clipboard
open override val status: StateFlow<ServerStatus>

A StateFlow of the ServerStatus of this Server

Functions

Link copied to clipboard
open suspend override fun add(uuid: UUID, service: LocalService.DSL.Primary.() -> Unit): LocalService?

Attempts to add a LocalService at a given UUID and suspends until it has been added.

Link copied to clipboard
open suspend override fun advertise(data: AdvertiseData.Builder.() -> Unit): Boolean

Starts advertising with the given data

Link copied to clipboard
open override fun close()

Closes this BluetoothServer After this method has been called the Server will no longer be available. Any subsequent calls to advertise, add, remove, or removeAllServices will fail.

Link copied to clipboard
open suspend override fun remove(service: LocalService): Boolean

Attempts to remove a LocalService and suspends until it has been removed.

Link copied to clipboard
open suspend override fun removeAllServices(): Boolean

Attempts to remove all LocalService and suspends until they have been removed.

Link copied to clipboard
open override fun stopAdvertising()

Stops advertising any AdvertiseData