nRF51 SDK - S110 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
BSP BLE Button Module

The BLE Button Module provides a dynamic configuration of button actions. It is used in most BLE examples in the SDK.

The application must propagate BLE events to the BLE Button Module. Based on these events, the BLE Button Module configures the Board Support Package to generate BSP events for certain button actions. These BSP events should then be handled by the application's BSP event handler.

For example, when the application is connected, long pressing Button 1 generates the event BSP_EVENT_DISCONNECT. The application's BSP event handler should react to this event by performing a disconnect.

The Board Support Package, configured by the BLE Button Module, generates the following events for button actions:

Current state Button Action Event
Sleep 1 Push BSP_EVENT_WAKEUP
Sleep 2 Push BSP_EVENT_CLEAR_BONDING_DATA
Awake 2 Long Push BSP_EVENT_WHITELIST_OFF
Connected 1 Long push BSP_EVENT_DISCONNECT
Not Connected 1 Release BSP_EVENT_SLEEP

The application is responsible for interpreting and implementing the event actions. The first two events will wake the device from sleep mode. These actions can therefore not be handled by the application's event handler. Instead, they are indicated to the application through the bsp_btn_ble_init function.

Note
The bsp_btn_ble_init function should be called as early as possible during device initialization to catch wakeup button presses.

When the device is not in a connection, the BLE Button Module assumes full control of all button actions from button 1, in addition to the long push action on all buttons. When the device is connected, the BLE Button Module controls all long push actions, and assigns the default events to the push and release actions of all button 1 so they can be utilized by the application.