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

How to handle LED blinking when advertising and LED flash when button is pressed;

Hi,

I am a newbie to nrf, I am trying to understand the lbs example while running on nrf dev board. I want to set my application as follows:

  1. Blinking LED while advertising
  2. sending data packet when button pressed with LED indication (flash)

Please suggest the main functions to handle for this application.

Thanks.

Parents
  • Hi,

    Have a look at the tutorial on the Board Support Package. Once you have that running you can make an event handler that does something like this pseudocode:

    switch(evt)
        case button_pressed:
            send_packet;
        default:
            do_nothing;
    

    Best regards,

    Øyvind

  • Ok, I misunderstood, I thought you wanted to have the LEDs blinking each time the radio was active. To get a LED to blink while advertising you can use BSP_INDICATE_ADVERTISING like this

    err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
    APP_ERROR_CHECK(err_code);
    

    Since you want your application to stop indicating that it is advertising when you are connected you need to do something like this upon entering connected state.

    err_code = bsp_indication_set(BSP_INDICATE_IDLE);
    APP_ERROR_CHECK(err_code);
    

    Make sure that you have all the dependencies met for BSP(See the SDK), this may include adding BSP.c to your project. Also be aware that other things that change the LEDs can conflict with the BSP, so there's a lot to take into consideration

Reply
  • Ok, I misunderstood, I thought you wanted to have the LEDs blinking each time the radio was active. To get a LED to blink while advertising you can use BSP_INDICATE_ADVERTISING like this

    err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
    APP_ERROR_CHECK(err_code);
    

    Since you want your application to stop indicating that it is advertising when you are connected you need to do something like this upon entering connected state.

    err_code = bsp_indication_set(BSP_INDICATE_IDLE);
    APP_ERROR_CHECK(err_code);
    

    Make sure that you have all the dependencies met for BSP(See the SDK), this may include adding BSP.c to your project. Also be aware that other things that change the LEDs can conflict with the BSP, so there's a lot to take into consideration

Children
No Data
Related