Connected

data class Connected(val connectionInterval: Int, val slaveLatency: Int, val supervisionTimeout: Int) : ConnectionParameters

Bluetooth LE connection parameters.

Connection Interval

A Bluetooth LE device spends most of its time “sleeping” (hence the “Low Energy” in the name). In a connection, this is accomplished by agreeing on a connection interval saying how often the devices will communicate with each other. When they are done communicating, they will turn off the radio, set a timer and go into idle mode, and when the timer times out, they will both wake up and communicate again. The implementation of this is handled by the Bluetooth LE stack, but it is up to your application to decide how often you want the devices to communicate by setting the connection interval.

Supervision timeout

When two devices are connected, they agree on a parameter that determines how long it should take since the last packet was successfully received until the devices consider the connection lost. This is called the supervision timeout. So if one of the devices is unexpectedly switched off, runs out of battery, or if the devices are out of radio range, then this is the amount of time it takes between successfully receiving the last packet before the connection is considered lost.

Slave latency

Peripheral latency allows the peripheral to skip waking up for a certain number of connection events if it doesn't have any data to send. Usually, the connection interval is a strict tradeoff between power consumption and low latency or delay in communication. If you want to reduce the latency, but still keep a low power consumption, you can use peripheral latency. This is particularly useful in HID (Human Interface Devices) applications, such as computer mouse and keyboard applications, which usually don’t have any data to send, but when it has data to send, we want to have very low latency. Using the peripheral latency option, we can maintain low latency but reduce power consumption by remaining idle for several connection intervals.

Parameters

connectionInterval

Connection interval in 1.25ms unit. Valid range is from 6 (7.5ms) to 3200 (4000ms).

slaveLatency

Slave latency. Valid range is from 0 to 499.

supervisionTimeout

Supervision timeout in 10ms unit. Valid range is from 10 (0.1s) to 3200 (32s)

Constructors

Link copied to clipboard
constructor(connectionInterval: Int, slaveLatency: Int, supervisionTimeout: Int)

Properties

Link copied to clipboard
Link copied to clipboard

Returns the connection interval in milliseconds.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Returns the supervision timeout in milliseconds.

Functions

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