Peripheral

abstract class Peripheral<ID : Any, EX : Peripheral.Executor<ID>>(scope: CoroutineScope, impl: EX) : Peer<ID>

Class representing a Bluetooth LE peripheral.

Constructors

Link copied to clipboard
constructor(scope: CoroutineScope, impl: EX)

Types

Link copied to clipboard
interface Executor<ID : Any>

An interface that provides methods to interact with the peripheral.

Properties

Link copied to clipboard
open override val identifier: ID
Link copied to clipboard

Returns true if the peripheral is currently connected.

Link copied to clipboard

Returns true if the peripheral is disconnected of getting disconnected.

Link copied to clipboard
val name: String?

The friendly Bluetooth name of the remote device. The local adapter will automatically retrieve remote names when performing a device scan, and will cache them. This method just returns the name for this device from the cache

Link copied to clipboard
val state: StateFlow<ConnectionState>

The connection state of the peripheral, as StateFlow. The flow emits a new value whenever the state of the peripheral changes.

Functions

Link copied to clipboard
suspend fun disconnect()

Disconnects the client from the peripheral.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

The maximum amount of data, in bytes, you can send to a characteristic in a single write request.

Link copied to clipboard
suspend fun readRssi(): Int

Reads the received signal strength indicator (RSSI) of the peripheral.

Link copied to clipboard
fun services(uuids: List<Uuid> = emptyList()): StateFlow<List<RemoteService>?>

Returns a flow with a list of services discovered on the device.

Link copied to clipboard
open override fun toString(): String