connected

fun connected(name: String, appearance: Int = 0, preferredConnectionInterval: @Range(from = 6, to = 3200) IntRange = IntRange(25, 40), preferredSlaveLatency: @Range(from = 0, to = 499) Int = 0, preferredSupervisionTimeout: @Range(from = 10, to = 3200) Int = 400, maxAttMtu: @Range(from = 23, to = 517) Int = 23, maxL2capMtu: @Range(from = 27, to = 251) Int = 27, isPhyLe2MSupported: Boolean = false, isPhyCodedSupported: Boolean = false, activePhy: PhyInUse = PhyInUse.PHY_LE_1M, isBonded: Boolean = false, peripheralHasBond: Boolean = isBonded, eventHandler: PeripheralSpecEventHandler, actualServices: MockServerScope.() -> Unit? = null, cachedServices: MockServerScope.() -> Unit)

Makes the device connectable and already connected to the device at the moment of initialization (if it's in range).

Connected devices are also allowed for retrieval using CentralManager.getPeripheralById.

Parameters

name

The name of the peripheral, available from Device Name characteristic.

appearance

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

preferredConnectionInterval

The min and max connection interval, in 1.25 ms units. Valid range is from 6 (7.5ms) to 3200 (4000ms). Default is 25-40 (30-50 ms).

preferredSlaveLatency

Slave latency. Valid range is from 0 to 499. Default is 0.

preferredSupervisionTimeout

Supervision timeout in 10 ms units. Valid range is from 10 (0.1s) to 3200 (32s). Default is 400 (4 s).

maxAttMtu

The maximum supported ATT MTU (Maximum Transfer Unit). This value must be in range 23..517. The actual MTU for the connection will be the calculated using min(maxAttMtu, environment.maxAttMtu).

maxL2capMtu

The maximum supported L2CAP MTU (Maximum Transfer Unit used on L2CAP Layer using Data Length Extension (DLE)). This value must be in range 27..251.

isPhyLe2MSupported

Whether the device supports PHY LE 2M.

isPhyCodedSupported

Whether the device supports PHY LE Coded.

activePhy

The PHYs (TX and RX) used by the existing connection. Both must be supported, so to use LE 2M or LE Coded set isPhyLe2MSupported or isPhyCodedSupported too. Ignored if the peripheral is out of range, as it is not connected then.

isBonded

Whether the phone has the bond information of the peripheral.

peripheralHasBond

Whether the peripheral has the bond information of the phone. By default, the same as isBonded.

eventHandler

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

actualServices

The services available after service discovery. If null (default), they are set to be equal to cachedServices.

cachedServices

The services that are cached and will be returned immediately on service discovery without the discovery. They may differ from the actual services. On some platforms a client may invalidate cache and trigger full service discovery.