diff --git a/platform/daemon/daemon.c b/platform/daemon/daemon.c index 329deeeae..fbb01c123 100644 --- a/platform/daemon/daemon.c +++ b/platform/daemon/daemon.c @@ -1876,6 +1876,8 @@ static void handle_gatt_client_event(uint8_t packet_type, uint8_t * packet, uint } #endif +static char hostname[30]; + int main (int argc, char * const * argv){ static int tcp_flag = 0; @@ -1997,6 +1999,11 @@ int main (int argc, char * const * argv){ // init HCI hci_init(transport, config, control, remote_device_db); + // hostname for POSIX systems + gethostname(hostname, 30); + hostname[29] = '\0'; + gap_set_local_name(hostname); + #ifdef HAVE_PLATFORM_IPHONE_OS // iPhone doesn't use SSP yet as there's no UI for it yet and auto accept is not an option hci_ssp_set_enable(0); diff --git a/src/hci.c b/src/hci.c index 93381275e..543ebc047 100644 --- a/src/hci.c +++ b/src/hci.c @@ -1046,18 +1046,12 @@ static void hci_initializing_run(void){ if (hci_stack->local_name){ hci_send_cmd(&hci_write_local_name, hci_stack->local_name); } else { - char hostname[30]; -#ifdef EMBEDDED + char local_name[30]; // BTstack-11:22:33:44:55:66 - strcpy(hostname, "BTstack "); - strcat(hostname, bd_addr_to_str(hci_stack->local_bd_addr)); - log_info("---> Name %s", hostname); -#else - // hostname for POSIX systems - gethostname(hostname, 30); - hostname[29] = '\0'; -#endif - hci_send_cmd(&hci_write_local_name, hostname); + strcpy(local_name, "BTstack "); + strcat(local_name, bd_addr_to_str(hci_stack->local_bd_addr)); + log_info("---> Name %s", local_name); + hci_send_cmd(&hci_write_local_name, local_name); } break; case HCI_INIT_WRITE_SCAN_ENABLE: