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 Reply Children
  • Dear Øyvind, Thanks for your prompt reply~

    well, I went throught the BSP example, you suggested, I understood some of its main functions like sending data packets..... But as I am following LBS example, I want to add led blinking while advertising. The leds_init is already defined for advertising/connected/ledbutton.
    Please suggest, Thanks

  • Ok, I might be misunderstanding your question. You can get a lit LED while advertising by using radio notification, how to do this is fully described in this tutorial.

  • Dear Øyvind, Thanks. I checked the radio_notification example, Its quiet well explained for advertising in case of beacon. I tried to use it in my lbs application but in-case when I get connected state (nRF<-----> phone), led blinking is not off. I wish to get ,,,in connected state, led blinking should be off and once disconnected, again start blinking, indicating advertisement. How can I implement this.

    Also should I use BSP_INDICATE_ADVERTISING or RADIO_NOTIFICATION. Please clear. Thanks

  • 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

Related