To abstract from the actual hardware that is used to run an example, some examples use the Board Support Package. This module provides definitions of BSP indication states, which are indicated in different ways on different boards. In combination with the BSP BLE Button Module, the Board Support Package provides dynamic button functionality.
BSP indication states
Some examples use Board Support Package (BSP) states instead of a fast assignment of LEDs to indicate states. In this way, examples can easily be tested on different boards, like the development board and the dongle. States are indicated in different ways depending on the hardware that is used.
The following table lists how the BSP states are indicated on PCA10028 and PCA10031:
BSP state | PCA10028 | PCA10031 |
BSP_INDICATE_IDLE | All LEDs are off | All LEDs are off |
BSP_INDICATE_SCANNING | LED 1 is blinking (period 2 sec, duty cycle: 10%) | Red LED is blinking (period 2 sec, duty cycle: 10%) |
BSP_INDICATE_ADVERTISING | LED 1 is blinking (period 2 sec, duty cycle: 10%) | Red LED is blinking (period 2 sec, duty cycle: 10%) |
BSP_INDICATE_ADVERTISING_WHITELIST | LED 1 is blinking fast (period 1 sec, duty cycle: 20%) | Red LED is blinking fast (period 1 sec, duty cycle: 20%) |
BSP_INDICATE_ADVERTISING_SLOW | LED 1 is blinking slowly (period 4.4 sec, duty cycle: 10%) | Red LED is is blinking slowly (period 4.4 sec, duty cycle: 10%) |
BSP_INDICATE_ADVERTISING_DIRECTED | LED 1 is blinking very fast (period 0.6 sec, duty cycle: 50%) | Red LED is blinking very fast (period 0.6 sec, duty cycle: 50%) |
BSP_INDICATE_BONDING | LED 1 is blinking (period 200 msec, duty cycle: 50%) | Red LED is blinking (period 200 msec, duty cycle: 50%) |
BSP_INDICATE_CONNECTED | LED 1 is on | Red LED is on |
BSP_INDICATE_SENT_OK | LED 2 is inverted for 100 msec | Green LED is inverted for 100 msec |
BSP_INDICATE_SEND_ERROR | LED 2 is inverted for 500 msec | Green LED is inverted for 500 msec |
BSP_INDICATE_RCV_OK | LED 2 is inverted for 100 msec | Green LED is inverted for 100 msec |
BSP_INDICATE_RCV_ERROR | LED 2 is inverted for 500 msec | Green LED is inverted for 500 msec |
BSP_INDICATE_FATAL_ERROR | All LEDs are on | All LEDs are on |
BSP_INDICATE_USER_STATE_OFF | All LEDs are off | All LEDs are off |
BSP_INDICATE_USER_STATE_0 | LEDs 2, 3, and 4 are off, LED 1 is on | Green and blue LEDs are off, red LED is on |
BSP_INDICATE_USER_STATE_1 | LEDs 1, 3, and 4 are off, LED 2 is on | Red and blue LED are off, green LED is on |
BSP_INDICATE_USER_STATE_2 | LEDs 3 and 4 are off, LEDs 1 and 2 are on | Blue LED is off, red and green LEDs are on |
BSP_INDICATE_USER_STATE_3 | All LEDs are on | All LEDs are on |
BSP_INDICATE_USER_STATE_ON | All LEDs are on | All LEDs are on |
The following BSP alerts can be indicated on top of the states described in the previous table:
BSP alert | PCA10028 | PCA10031 |
BSP_INDICATE_ALERT_0 | LED 3 is blinking (period 1200 msec, duty cycle: 50%) | Blue LED is blinking (period 1200 msec, duty cycle: 50%) |
BSP_INDICATE_ALERT_1 | LED 3 is blinking (period 800 msec, duty cycle: 50%) | Blue LED is blinking (period 800 msec, duty cycle: 50%) |
BSP_INDICATE_ALERT_2 | LED 3 is blinking (period 400 msec, duty cycle: 50%) | Blue LED is blinking (period 400 msec, duty cycle: 50%) |
BSP_INDICATE_ALERT_3 | LED 3 is on | Blue LED is on |
BSP_INDICATE_ALERT_OFF | LED 3 is off | Blue LED is off |
The states are defined in bsp_indication_t.
BSP BLE Button Assignments
Most BLE examples use the following standard button assignments as configured by the BSP BLE Button Module:
During advertising or scanning:
- Button 1: Sleep (if not also in a connection)
- Button 2 long push: Turn off whitelist.
During sleep:
- Button 1: Wake up.
- Button 2: Wake up and delete bond information.
During connection:
- Button 1 long push: Disconnect.
- Push and release on all buttons: Application-specific.
Testing the BSP BLE Button Functionality
This procedure will verify the BLE button functionality in an example project.
- Compile, flash, and run the BLE example.
- Press and release button 1. Observe that BSP_INDICATE_IDLE is indicated which means the chip is in system-off (asleep).
- Press button 1. Observe that the device is awake.
- Establish a BLE connection to the device.
- Press and hold button 1. Observe that the device has disconnected.
- Establish a BLE connection to the device, and establish a bond, then disconnect.
- If the device is using whitelist, press and hold button 2. Observe that the whitelist has been turned off.
- Press button 1 twice to go to sleep and wake up. Observe that the bond has been persistently stored.
- Press and release button 1 (the device is now asleep). Press button 2. Observe that the bond is gone.