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

Changing characteristic's length after initial declaration

Hi everyone,

I wanted to know if it's possible to change the length of a characteristic's value after it has been put in the attribute table. Reading some other answers in this zone, I found it was possible to change a characteristic's value after its creation (I already did it using sd_ble_gatts_value_set(...)).

To give you more context, I have a characteristic with these values (in a server device):

attr_char_value.max_len     = 8;
attr_char_value.init_len    = 8;
uint8_t value[8]            = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
attr_char_value.p_value     = value;

Then, with a client device, I perform a Write Command, which generates a write event that allows me to use sd_ble_gatts_value_set(...), which changes the value of my characteristic. So, instead of changing the value, I would like to change the length from 8 to 1 byte, so that, after that first Write Command I can only write or read 1 smooth byte of information, is that possible?

Best regards!

Parents Reply Children
  • Hi RK, at first I noticed the same but I didn't know how to do that. I was searching for a specific function to do that for me because I could not access to this attribute but I didn't find one in any of the library files. Then I realized the way to do that was setting vlen = 1, which allowed me to have a variable length value for my characteristic so I could write as most the number of bytes defined in max_len and read just the bytes desired in my application. Thanks!!

Related