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

Writable values on services

Hi ,

Just one question.

I am trying to create services using hrs examples and its useful.

Currently one question I have that ,

the battery indicator is only notifiable but instead could that service can be made writable as well.

Thanks,

Parents Reply Children
  • You can try to make the battery service writable, just for testing.

    It would be adding something like:

    add_char_params.char_props.write   = 1;

    after 

    add_char_params.char_props.read   = 1;

    And then you would have to implement something to handle the write events in the on_write() function in ble_bas.c.

    However, the heart rate characteristic is only one byte by default, so you would have to change that if you want to send more data:

        add_char_params.max_len           = sizeof(uint8_t);
        add_char_params.init_len          = sizeof(uint8_t);

    To be honest, it may be easier for you to add the nus service from the ble_app_uart example. Look at how it is implemented in that example. Using that service, you are free to send more data, and you can send this custom data both ways.

  • Yes 

    You're right.
    Actually I will try to explain here,
    In project we have IOS app, which is hiding mac of device + generic attributes, and only exposing services.
    So I just wanted to check If I can make one service with writable such that data sending from IOS can be tried.

    your suggestions are most welcome here :-)

  • Then I suggest you look into the ble_app_uart example.

    You can read the test description here.

    BR,
    Edvin

Related