Bluetooth LE latency module¶
Use the Bluetooth LE latency module to:
Lower the Bluetooth LE connection latency either when Configuration channel is in use or when a firmware update is received by the Simple Management Protocol module (low latency ensures quick data exchange).
Request setting the initial connection parameters for a new Bluetooth connection.
Keep the connection latency low for the LLPM (Low Latency Packet Mode) connections to improve performance.
Disconnect the Bluetooth Central if the connection has not been secured in the predefined amount of time after the connection occurred.
Module events¶
Source Module |
Input Event |
This Module |
Output Event |
Sink Module |
---|---|---|---|---|
|
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Note
See the Overview: Firmware architecture for more information about the event-based communication in the nRF Desktop application and about how to read this table.
Configuration¶
The module requires the basic Bluetooth configuration, as described in Bluetooth in nRF Desktop. The module is enabled for every nRF Desktop peripheral device.
You can use the option CONFIG_DESKTOP_BLE_SECURITY_FAIL_TIMEOUT_S
to define the maximum allowed time for establishing the connection security.
If the connection is not secured during this period of time, the peripheral device disconnects.
You can set the option CONFIG_DESKTOP_BLE_LOW_LATENCY_LOCK
to keep the connection latency low for the LLPM connections.
This speeds up sending the first HID report after not sending a report for some connection intervals.
Enabling this option increases the power consumption - the connection latency is kept low unless the device is in the low power mode.
Implementation details¶
The Bluetooth LE latency module uses delayed works (k_work_delayable
) to control the connection latency and trigger the security timeout.
Note
The module does not request an increase in the connection latency until the connection is secured. Increasing the slave latency can significantly increase the amount of time required to establish the Bluetooth connection security level on some hosts.
The module listens for the following events related to data transfer initiated by the connected Bluetooth central:
config_event
- This event is received when the Configuration channel is in use.ble_smp_transfer_event
- This event is received when the firmware update is received by Simple Management Protocol module.
When these events are received, the module sets the connection latency to low.
When the Configuration channel is no longer in use and firmware update is not received by Simple Management Protocol module (no mentioned events for LOW_LATENCY_CHECK_PERIOD_MS
), the module sets the connection latency to CONFIG_BT_PERIPHERAL_PREF_SLAVE_LATENCY
to reduce the power consumption.
Note
If the option
CONFIG_DESKTOP_BLE_LOW_LATENCY_LOCK
is enabled, the LLPM connection latency is not increased unless the device is in the low power mode.When the device is in the low power mode and the events related to data transfer are not received, the connection latency is set to higher value to reduce the power consumption.
The ble_latency
module receives Configuration channel events, but it is not configurable with the Configuration channel.
The module does not register itself using the GEN_CONFIG_EVENT_HANDLERS
macro.
Note
Zephyr’s Bluetooth API does not allow to use the LLPM connection intervals in the connection parameter update request. If the LLPM connection interval is in use:
The nRF Desktop peripheral uses a 7.5-ms interval in the request.
The nRF Desktop central ignores the requested connection interval, and only the connection latency is updated.
For more detailed information, see the Bluetooth LE connection parameters module documentation page.