diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index ce1f6ec3d02..8099dc3620e 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -3541,7 +3541,10 @@ int bt_enable(bt_ready_cb_t cb) return err; } } else { - bt_set_name(CONFIG_BT_DEVICE_NAME); + err = bt_set_name(CONFIG_BT_DEVICE_NAME); + if (err) { + BT_WARN("Failed to set device name (%d)", err); + } } ready_cb = cb; @@ -3584,6 +3587,13 @@ int bt_enable(bt_ready_cb_t cb) return 0; } +#define DEVICE_NAME_LEN (sizeof(CONFIG_BT_DEVICE_NAME) - 1) +#if defined(CONFIG_BT_DEVICE_NAME_DYNAMIC) +BUILD_ASSERT(DEVICE_NAME_LEN < CONFIG_BT_DEVICE_NAME_MAX); +#else +BUILD_ASSERT(DEVICE_NAME_LEN < 248); +#endif + int bt_set_name(const char *name) { #if defined(CONFIG_BT_DEVICE_NAME_DYNAMIC) diff --git a/subsys/bluetooth/shell/bt.c b/subsys/bluetooth/shell/bt.c index 767798f4d2c..64689f12887 100644 --- a/subsys/bluetooth/shell/bt.c +++ b/subsys/bluetooth/shell/bt.c @@ -36,9 +36,6 @@ #include "ll.h" #include "hci.h" -#define DEVICE_NAME CONFIG_BT_DEVICE_NAME -#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) - /* Multiply bt 1.25 to get MS */ #define BT_INTERVAL_TO_MS(interval) ((interval) * 5 / 4)