Hi everyone, I make the project whith nrf51822 BLE module and need to configure the bluetooth service characteristic as input/output for reading and writing the string-information with the variable length. For this purpose I configure the characteristic so:
ble_gatts_attr_t attr_char_value;
...
memset(&attr_char_value, 0, sizeof(attr_char_value));
attr_char_value.p_uuid = &ble_uuid;
attr_char_value.p_attr_md = &attr_md;
attr_char_value.init_len = DataLen; // DataLen ≤ 21
attr_char_value.init_offs = 0;
attr_char_value.max_len = DEV_NAME_DATA_MAXLEN; // DEV_NAME_DATA_MAXLEN = 21
attr_char_value.p_value = data;
sd_ble_gatts_characteristic_add(p_nms->service_handle,
&char_md,
&attr_char_value,
&p_nms->devname_char_handles);
When I try to read the n-lentgh-data by the client device from this characteristic the data contains the maximal length (21 characters) when the first n characters contain the required data, but in addition to them the characteristic gives 21-n unneeded junc-characters when the returned length is given as maximal (21) instead beeng given n, the actual size of the returned data.
How is it possible to fix this problem?