LED state module

The LED state module is used to set LED effects based on the Bluetooth® peer state and the system state.

Controlled LEDs

The module controls LEDs defined by enumerators in led_id:

For the complete description of peer management, see Bluetooth LE bond module.

Note

If a configuration does not support Bluetooth (CONFIG_CAF_BLE_COMMON_EVENTS is disabled), the Bluetooth peer state will not be notified. In that case, the Bluetooth peer state LED is set only once during the boot. The set LED effect represents LED_PEER_STATE_DISCONNECTED state for the default peer.

Module events

Source Module

Input Event

This Module

Output Event

Sink Module

Battery charger module

battery_state_event

led_state

Bluetooth LE advertising module

ble_peer_event

Bluetooth LE state module

Bluetooth LE bond module

ble_peer_operation_event

Bluetooth LE advertising module

ble_peer_search_event

Bluetooth LE scanning module

Source modules for module_state_event

module_state_event

led_event

LED stream module

LEDs module

Note

See the Application overview for more information about the event-based communication in the nRF Desktop application and about how to read this table.

Configuration

The LED state module is enabled when you set the CONFIG_CAF_LEDS option. You must also configure CAF: LEDs module, which is used as a sink module for led_state.

For every board that has this option enabled, you must define the module configuration. The configuration must be defined in the file named CONFIG_DESKTOP_LED_STATE_DEF_PATH located in the board-specific directory in the application configuration directory. By default, the file is named as led_state_def.h.

The configuration consists of the following elements:

  • led_map - Maps the led_id values to IDs used by CAF: LEDs module. If no physical LED is assigned to a led_id value, assign LED_UNAVAILABLE as the ID used by CAF: LEDs module.

  • led_system_state_effect - Defines the LED effects used to show the system states. The effect must be defined for every system state.

  • led_peer_state_effect - Defines the LED effects used to show the Bluetooth peer states. The effect must be defined for every state of every peer.

The LED effects are defined in the caf/led_effect.h file in the common configuration directory.

LED effect API

LED Effect