Peripheral

open class Peripheral(scope: CoroutineScope, impl: Peripheral.Executor) : Peripheral<String, AndroidExecutor>

Android-specific implementation of a peripheral.

This class extends Peripheral and adds Android-specific methods.

Parameters

scope

scope The coroutine scope.

impl

The executor that provides methods to interact with the peripheral.

Inheritors

Constructors

Link copied to clipboard
constructor(scope: CoroutineScope, impl: Peripheral.Executor)

Types

Link copied to clipboard

An interface that provides methods to interact with the peripheral.

Properties

Link copied to clipboard

MAC address of the peripheral as String, alias for Peripheral.identifier.

Link copied to clipboard
val bondState: StateFlow<BondState>

Returns the current bond state as StateFlow.

Link copied to clipboard

The current connection parameters as StateFlow.

Link copied to clipboard

Returns whether the system has bond information associated with this peripheral.

Link copied to clipboard
open override val identifier: String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val name: String?
Link copied to clipboard
val phy: StateFlow<PhyInUse?>

The current PHY in use for transmitting and receiving data.

Link copied to clipboard
val state: StateFlow<ConnectionState>
Link copied to clipboard

The Bluetooth device type of the remote device.

Functions

Link copied to clipboard
suspend fun createBond()

Initiates bonding with the peripheral.

Link copied to clipboard
suspend fun disconnect()
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
open override fun maximumWriteValueLength(type: WriteType): Int

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

Link copied to clipboard
suspend fun readPhy(): PhyInUse

Read the current transmitter PHY and receiver PHY of the connection.

Link copied to clipboard
suspend fun readRssi(): Int
Link copied to clipboard
suspend fun refreshCache()

Refreshes the cached GATT database associated with the peripheral and starts new service discovery automatically.

Link copied to clipboard
suspend fun removeBond()

Removes the bond information associated with the peripheral.

Link copied to clipboard

Requests new connection parameters.

Link copied to clipboard

Requests the highest possible MTU (ATT_MTU_MAX).

Link copied to clipboard
fun services(uuids: List<Uuid>): StateFlow<List<RemoteService>?>
Link copied to clipboard
suspend fun setPreferredPhy(txPhy: Phy, rxPhy: Phy, phyOptions: PhyOption): PhyInUse

Set the preferred connection PHY.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
suspend fun usingReliableWrite(operations: suspend ReliableWriteScope.() -> Unit)

Initiates a reliable write transaction for a given characteristic.