Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How LED ON at same time in Central connected to 3 ble peripheral.

Hello,

I have developing one project in that i am using nRF52832 and SD 15.0. Here is the current application developing:

  1. There are 3 ble app_blinky(ble peripheral) example operated on battery and it connected to multilink central.
  2. Lets say ble peripheral name A, B, C and central device is master.
  3. Each ble peripheral- A interface simply 2 push switch and whenever it press digital signal goes to connected central and then ON particular GPIO LED.
  4. Same point two for other B and C ble peripheral. Therefore total LEDs on central side has 6 for each switch.
  5. Now i am able to connect 3 ble peripheral to central but not able to ON particular LED controlled by ble peripheral slave.

Problems:

  1. When switch press of device A , B or C then how i know in central whether it coming from A or B or C. I know connection handle link for each connection but i can do it will you please provide me program snippet for understanding.
  2. Once all switches (Total 6) press at same time then it will wake up all 3 peripherals A, B and C connect to central device. Want to ON all 6 LEDs in central at same time frame. How i can do it.

Thanks......

  • Thanks for your reply...

    I have able to handle this with connection handle..

    Now how i can send battery percentage level at the time of switch press. We want to send battery level as well because out devices is operated on battery. 

    Please suggest me best solution for that. 

    Thanks...

  • Hi,

    you need to configure the button using button library. And when the button is pressed, your registered callback will be called and in that callback you need to use ble_battery library to be able to transmit battery information.

  • Thanks for your response...!!!

    I have checked this ble_battery library but unable to understand how to add this with "Nordic_Blinky" example. Will you please provide me program example including battery service and blinky example.

    I am able to add battery service with Blinky example but how i send this battery level when i press button to Multilink central board. will you please also provide small program snippet for the same.

    Thanks..!!

  • Hi Parag,

    Unfortunately we do not have resources to make code snippets for all the possible designs on our chip. But this should not be hard.

    if you check the SDK15\examples\ble_peripheral\ble_app_bps\main.c line 397 -> timers_init()

    You can see that in timers_init function we used battery_level_meas_timeout_handler as a timeout callback function  This means that a battery level update is sent to the peer everytime the timer expires.

    In your case you need to call  battery_level_meas_timeout_handler (maybe rename this to battery_level_meas_button_push_handler) in bsp_event_handler for example like this

    static void bsp_event_handler(bsp_event_t event)
    {
        ret_code_t err_code;
    
        switch (event)
        {
            case ...
            case ...
            case BSP_EVENT_KEY_0:
                battery_level_update();
                break;
    
            default:
                break;
        }
    }

    ofcourse you need to initialize bas service as you can see in     services_init() function here.

    The examples uses simulated sensor data to get the battery_level,but you can get this from the ADC sample on your input voltage pin as described here

  • Hi Aryan,

    As per your suggestion now i am able to add battery service in my modified blinky example. i use ble_bas source and library file. But how i can read this battery level in my multilink example. How i can read battery service characteristics at multilink central side when press button. 

    For reference i refer ble_app_hrs_c example from sdk 15.0 but not able to read battery level. will you please provide me example for the same. so i can refer i modify my current multi-link central code with read battery level characterstics.

    Thanks you so much.....

Related