PeripheralSpec

A specification of a peripheral that can be simulated.

Use PeripheralSpec.simulatePeripheral to create a new peripheral specification.

Parameters

identifier

The peripheral identifier.

addressType

The address type of the peripheral.

initialProximity

The initial proximity of the peripheral.

isInitiallyConnected

Whether the peripheral is initially connected.

isKnown

Whether the peripheral has been scanned before and its address type is cached. It is not possible to connect to an unknown device without scanning.

isBonded

Whether the peripheral is bonded.

advertisingSets

List of advertisement configurations.

eventHandler

The event handler that will be called for every event emulating a real peripheral.

services

The services available after service discovery.

cachedServices

The services cached on the client side.

isServiceCacheValid

Whether the cached services are valid.

Types

Link copied to clipboard
class Builder<ID : Any>

The builder for the PeripheralSpec.

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The address type of the peripheral.

Link copied to clipboard

The appearance of the peripheral, exposed with Appearance characteristic. See Bluetooth Assigned Numbers: link, 2.6 Appearance Values.

Link copied to clipboard

Current connection parameters.

Link copied to clipboard
val events: SharedFlow<GattEvent>
Link copied to clipboard

The peripheral identifier.

Link copied to clipboard

Whether the peripheral is bonded.

Link copied to clipboard

Whether the peripheral is connected.

Link copied to clipboard

Whether the peripheral has been scanned before and its address type is cached.

Link copied to clipboard

Current L2CAP MTU.

Link copied to clipboard

The maximum supported ATT MTU (ATT layer Maximum Transfer Unit).

Link copied to clipboard

The maximum L2CAP MTU (Maximum Transfer Unit used on L2CAP Layer using Data Length Extension (DLE)).

Link copied to clipboard
var mtu: Int?

Current ATT MTU.

Link copied to clipboard
val name: String?

The name of the peripheral, exposed with Device Name characteristic.

Link copied to clipboard
var phy: Phy?

The currently used PHY.

Link copied to clipboard

The preferred connection interval range.

Link copied to clipboard

The preferred slave latency.

Link copied to clipboard

The preferred supervision timeout.

Link copied to clipboard

The proximity of the peripheral.

Link copied to clipboard

The set of supported PHYs.

Link copied to clipboard

The peripheral type.

Functions

Link copied to clipboard

Simulates the situation when the device is scanned and advertisement data is received.

Link copied to clipboard
fun simulateConnection(preferredPhy: List<Phy> = listOf(Phy.PHY_LE_1M))

Simulates the situation when another application on the device tries to connects to the device.

Link copied to clipboard

Simulates a connection parameters update request from the peripheral.

Link copied to clipboard

Simulates a situation when the peripheral is gracefully disconnecting from the device.

Link copied to clipboard
fun simulateMacChange(newIdentifier: ID, addressType: AddressType)

Simulates a change of the peripheral identifier (Device Address).

Link copied to clipboard

Simulates an MTU request from the peripheral.

Link copied to clipboard

Simulates a change in the proximity of the peripheral.

Link copied to clipboard

Simulates peripheral reset.

Link copied to clipboard

Simulates a change in the services offered by the peripheral.

Link copied to clipboard
fun simulateValueUpdate(handle: Int, value: ByteArray)

Simulates a characteristic value update on the peripheral.