connectable

fun connectable(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, eventHandler: PeripheralSpecEventHandler, services: MockServerScope.() -> Unit): PeripheralSpec.Builder<ID>

Makes the device connectable, but not connected at the moment of initialization.

This method should be used to mock a peripheral seen for the first time, that is one which wasn't scanned, bonded or connected before.

No services will be cached on the client side.

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.

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.

eventHandler

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

services

The services available after service discovery.


fun connectable(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, isBonded: Boolean = false, eventHandler: PeripheralSpecEventHandler, actualServices: MockServerScope.() -> Unit? = null, cachedServices: MockServerScope.() -> Unit): PeripheralSpec.Builder<ID>

Makes the device connectable, but not connected at the moment of initialization.

This method should be used to mock a peripheral that was connected before, so some services may be cached on the client side. It is also possible to mock a situation in which the cached services are invalid and will return an error when accessed, in which case they need to be invalidated (i.e. using Service Changed characteristic) and discovered again.

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.

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.

isBonded

Whether the peripheral is bonded.

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.