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

How to change the value of the Button characteristic in ble_app_blinky example?

Hello there

I'm having some fun with the ble_app_blinky example, and I was just wondering if it is possible to change the value that the central receives in the Button characteristic, and change the "Button pressed" and "Button Released" messages for a numeric value, like "1" and "0".
Thanks in advance!

Parents
  • Hi Diego

    If I understand you correctly, you just want to send a different 1 byte value than the ones used in the example?

    The button characteristic is updated by calling the ble_lbs_on_button_change(uint16_t conn_handle, ble_lbs_t * p_lbs, uint8_t button_state) function, and you can set the button_state value to any 8-bit value that you want, so this should not be a problem. 

    If you want to extend the button characteristic to accept more than 8-bits of data then you will have to make some changes to the service functions, but then I would suggest using the ble_app_uart example instead.  

    Best regards
    Torbjørn

Reply
  • Hi Diego

    If I understand you correctly, you just want to send a different 1 byte value than the ones used in the example?

    The button characteristic is updated by calling the ble_lbs_on_button_change(uint16_t conn_handle, ble_lbs_t * p_lbs, uint8_t button_state) function, and you can set the button_state value to any 8-bit value that you want, so this should not be a problem. 

    If you want to extend the button characteristic to accept more than 8-bits of data then you will have to make some changes to the service functions, but then I would suggest using the ble_app_uart example instead.  

    Best regards
    Torbjørn

Children
Related