Hello everyone,
It seems like a very basic issue but somehow I am unable to resolve it.
I have a characteristic of length 20 bytes. This characteristic is supposed to receive a string of max 20 bytes. When I receive the string in this characteristic and my string is of less than 20 characters (which will be in most of the cases); the received string is appended by the remaining bytes which were already part of the characteristic previously.
Here is the code I am using to receive string:
uint8_t msg_value; uint16_t msg_handle1=m_our_service.msg_handle.value_handle; GATT_MSG.p_value = &msg_value; GATT_MSG.len=MSG_LEN; GATT_MSG.offset=0; err_code = sd_ble_gatts_value_get(0xFFFF, msg_handle1, &GATT_MSG);
Now,
GATT_MSG.p_value is where I have the string (appended by the previously written characters)
What I wish GATT_MSG.len should have is the LENGTH of the received string BUT GATT_MSG.len is ALWAYS=20 which is the total length of this particular characteristic.
Can anyone help me figuring out how can I determine the length of characteristic received?
Thanks