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
  • Hello,

    According to the Battery Service specification, which you can find here (click on the 1.0-link next to "Battery Service"), the battery level characteristic can not be written to:

    So while it probably is possible to implement it, you will not be able to certify the product with Bluetooth if that is possible.

    Best regards,

    Edvin

  • Ok,

    So, Is there any service I can make it as Writable in heart rate example just to quickly check for one experiment.
    or I need to create one service to make it writable. ?

  • 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 :-)

Reply Children
Related