From 631685302e1369088ddb41bea1f940753ad14826 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 17 Aug 2017 10:54:17 +0200 Subject: [PATCH] hci: use default_classic_name if not set --- src/hci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/hci.c b/src/hci.c index 45bb72b40..d07ee8353 100644 --- a/src/hci.c +++ b/src/hci.c @@ -168,6 +168,9 @@ static hci_stack_t hci_stack_static; static hci_stack_t * hci_stack = NULL; #ifdef ENABLE_CLASSIC +// default name +static const char * default_classic_name = "BTstack 00:00:00:00:00:00"; + // test helper static uint8_t disable_l2cap_timeouts = 0; #endif @@ -1261,7 +1264,6 @@ static void hci_initializing_run(void){ break; case HCI_INIT_WRITE_LOCAL_NAME: { hci_stack->substate = HCI_INIT_W4_WRITE_LOCAL_NAME; - const char * local_name = hci_stack->local_name ? hci_stack->local_name : "BTstack 00:00:00:00:00:00"; hci_reserve_packet_buffer(); uint8_t * packet = hci_stack->hci_packet_buffer; // construct HCI Command and send @@ -1271,7 +1273,7 @@ static void hci_initializing_run(void){ packet[1] = opcode >> 8; packet[2] = DEVICE_NAME_LEN; memset(&packet[3], 0, DEVICE_NAME_LEN); - memcpy(&packet[3], local_name, strlen(local_name)); + memcpy(&packet[3], hci_stack->local_name, strlen(hci_stack->local_name)); // expand '00:00:00:00:00:00' in name with bd_addr hci_replace_bd_addr_placeholder(&packet[3], DEVICE_NAME_LEN); hci_send_cmd_packet(packet, HCI_CMD_HEADER_SIZE + DEVICE_NAME_LEN); @@ -2426,6 +2428,9 @@ void hci_init(const hci_transport_t *transport, const void *config){ // bondable by default hci_stack->bondable = 1; + // classic name + hci_stack->local_name = default_classic_name; + // Secure Simple Pairing default: enable, no I/O capabilities, general bonding, mitm not required, auto accept hci_stack->ssp_enable = 1; hci_stack->ssp_io_capability = SSP_IO_CAPABILITY_NO_INPUT_NO_OUTPUT;