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

Create a on/off control by using BLE in ble_app_blinky exemple

Hello, 

I would like to ask how to use the exemple 'ble_app_blinky' (a device central and a device peripheral) to realize a function like this:

I press a button in one board (device central) then the command will be sent to another board (device peripheral) by the BLE connection so that a LED on device peripheral will be illumed. I have seen the exemple 'ble_app_blinky_pca', there exists already the 'Service' and 'Characteristic' to illume a LED.

But in the function 'static void button_event_handler(uint8_t pin_no, uint8_t button_action)', I can see the log of the case 'case LEDBUTTON_BUTTON:'  but it seen that it doesn't work.

So I want to ask: it it that function who realize the function which I want? If not, how can I do to realize what I want please?

Thank you very much !

  • There are two button_event_handler(..) functions, one in the peripheral device and one in the central device, and both of the functions will react to a button press.

    For the central device:

    The “Nordic LED Button Service” has two characteristics, which is Button and LED. The button_event_handler function inside the central device will write a value to the LED characteristic. If the button is pushed, it will write a value of 1 and if the button is released it will write a value of 0. The peripheral device will handle the write event by turning the LED on and off.

    For the peripheral device:

    The button_event_handler in the code for the peripheral device will react to a button press by notifying the value of the Button characteristic. The central device will receive the notification and handle it in a similar manner as described above, and the LED will be turned on an off on the central board.

    This makes it possible to control the LED’s on the other device from both the central and the peripheral device.

    Best regards Simon Iversen

  • "But in the function 'static void button_event_handler(uint8_t pin_no, uint8_t button_action)', I can see the log of the case 'case LEDBUTTON_BUTTON:'  but it seen that it doesn't work."

    we need debug information...

Related