diff --git a/src/hci_event_builder.c b/src/hci_event_builder.c index 0a1ee1310..20ba8be4b 100644 --- a/src/hci_event_builder.c +++ b/src/hci_event_builder.c @@ -122,8 +122,11 @@ void hci_event_builder_add_con_handle(hci_event_builder_context_t * context, hci void hci_event_builder_add_string(hci_event_builder_context_t * context, const char * text){ uint16_t length = (uint16_t) strlen(text); uint16_t pos = context->pos; - hci_event_builder_increment_pos(context, length); + hci_event_builder_increment_pos(context, length + 2); + context->buffer[pos++] = length; memcpy(&context->buffer[pos], text, length); + pos += length; + context->buffer[pos] = 0; } void hci_event_builder_add_bytes(hci_event_builder_context_t * context, const uint8_t * data, uint16_t length){ diff --git a/src/hci_event_builder.h b/src/hci_event_builder.h index f0872d81f..248d72c9b 100644 --- a/src/hci_event_builder.h +++ b/src/hci_event_builder.h @@ -141,7 +141,7 @@ void hci_event_builder_add_bd_addr(hci_event_builder_context_t * context, bd_add void hci_event_builder_add_con_handle(hci_event_builder_context_t * context, hci_con_handle_t con_handle); /** - * @bbrief Add string to event + * @bbrief Add string to event using JV format: len, string, trailing zero * @param context * @param value */