This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BSP indication state setup

Hello Nordic Team,

i use SDK 12.3 and SoftDevice S130.

In the template project (\examples\ble_peripheral\ble_app_template ), the BSP module is used to indicate advertising and connection as described in the table of BSP indication states.

In the ble blinky example (\examples\ble_peripheral\experimental_ble_app_blinky), advertising and Connection is indicated using two different leds. I want the indication of advertising  and connection to be in the same way as in the template project, but struggle with it. Based on the template project i made the following changes on the blinky example:
in on_ble_Event():

static void on_ble_evt(ble_evt_t * p_ble_evt)
{
    uint32_t err_code;

    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
            NRF_LOG_INFO("Connected\r\n");
            //bsp_board_led_on(CONNECTED_LED_PIN);  //changed here
            //bsp_board_led_off(ADVERTISING_LED_PIN);
            err_code = bsp_indiation_set(BSP_INDICATE_CONNECTED); //changed here
            m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;

            err_code = app_button_enable();
            APP_ERROR_CHECK(err_code);
            break; // BLE_GAP_EVT_CONNECTED

        case BLE_GAP_EVT_DISCONNECTED:
            NRF_LOG_INFO("Disconnected\r\n");
            //bsp_board_led_off(CONNECTED_LED_PIN); //changed here
            err_code = bsp_indiation_set(BSP_INDICATE_IDLE); // changed here
            m_conn_handle = BLE_CONN_HANDLE_INVALID;

            err_code = app_button_disable();
            APP_ERROR_CHECK(err_code);

            advertising_start();
            break; // BLE_GAP_EVT_DISCONNECTED
            ...

and in advertising_start():

static void advertising_start(void)
{
    ...
    err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING); //changed here
    APP_ERROR_CHECK(err_code);
    err_code = sd_ble_gap_adv_start(&adv_params);
    APP_ERROR_CHECK(err_code);
    //bsp_board_led_on(ADVERTISING_LED_PIN);
}

With this, advertising and connection still works but the states are not indicated via the leds. All leds are off. I think i need to initialise the bsp module somehow and  tried different Settings with bsp_init but it didn't work.

So in short, my objective is:

  • indicate advertising with a blinking led
  • indicate Connection with the same lit led
  • behaviour of the Buttons should stay the same. I do not want to use the BSP BLE Button Assignments (as far as i understand them)
  • I am not fixed to the BSP module. A simple timer to blink the led would be sufficient, but somehow i couldn't realize it so far.

Kind regards and thanks in advance

  • I've made a stupid mistake setting up the timer. The blinking works fine now.

    But if you know how to use the bsp indication states, it is a help for further tasks.

  • Hello,

    So you do not want to have the setup for the buttons in BSP?

    Have you looked at one of the examples using the BSP pack in the SDK? Such as in the experimental_ble_app_blinky example that you mention?

    I see that this example has a "simpler" LED indication, as it turns on different LEDs for the different states, while the other examples typically blink the led for "advertising", turns the LED on for "in a connection" and off for "not advertising and not in a connection"

     

    If you want to do the simple version, like in the experimental_ble_app_blinky, you only need to call bsp_boards_leds_init();

    Then you can use bsp_board_led_on() and bsp_board_led_off(), which both takes LED number as arguments.

    The leds are defined: 

    BSP_BOARD_LED_0 = 0

    BSP_BOARD_LED_1 = 1

    BSP_BOARD_LED_2 = 2

    BSP_BOARD_LED_3 = 3

    and the bsp_board_led_***() maps this to the correct pin (pin 21-24 for the nRF51 DK).

     

    If you want to use the blinking LED states, such as e.g. in the ble_app_uart example, you will have to use the buttons_leds_init(); function to initialize the buttons and LEDs, and the function 

    err_code = bsp_indication_set(BSP_INDICATE_CONNECTED); to set the different states. The list of the different states is found in bsp.h on line 118.

     

    Best regards,

    Edvin

Related