Dear Nordic Team,
I'd like to inquiry how I am supposed to send a UTF8 string as the value of a characteristic.
I am trying to implement the FTMS service and the part I am talking about reads as
I am encoding it like this:
static uint8_t ftms_training_status_encode(ble_ftms_t * p_ftms, ble_ftms_training_status_t * training_status, uint8_t * p_encoded_buffer) { uint8_t len = 0; uint8_t out_len = 0; ble_srv_utf8_str_t training_status_string; uint8_t out_buf[32]; *(&p_encoded_buffer[len++]) = 1 << 0; // Flags: Training Status string present: Yes, Extended String present: No *(&p_encoded_buffer[len++]) = *training_status; // Training Status hex value switch (*training_status) { case BLE_FTMS_TRAINING_STATUS_OTHER: ble_srv_ascii_to_utf8(&training_status_string, (char *) "Other"); break; case BLE_FTMS_TRAINING_STATUS_IDLE: ble_srv_ascii_to_utf8(&training_status_string, (char *) "Idle"); break; .... default: break; } out_len = bds_ble_srv_utf8_str_encode(&training_status_string, out_buf); memcpy(&p_encoded_buffer[len], out_buf, out_len); len += out_len; return len; }
After encoding the buffer looks like this
So first byte indicates 0x1, then the type 0x0D and then the string bytes.
The question is: Am I supposed to reverse the string according to the spec? (LSB/MSB)?
Am I supposed to prefix the UTF8 string with a byte specifying the length? Whe I used "ble_srv_ascii_to_utf8(&training_status_string, (char *) "Manual");" to fill the ble_srv_utf8_str_t structure that structure consists of the length and the pointer to the string. So I wonder if, when sending a UTF8 string over BLE I am asked to prefix it with a length byte too maybe?
Thank you!