To advertise a *configurable* device name the previous guidance seemed to be:
prj.conf
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
Code Snippet
// Advertisement Data
static const struct bt_data ad[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_MY_SERVICE_VAL),
};
err = bt_enable(NULL);
err = bt_set_name("My New Name");
err = bt_le_adv_start(BT_LE_ADV_CONN_NAME, ad, ARRAY_SIZE(ad), NULL, 0);Please note I have intentionally removed all error handling from the code snippet for brevity.
BT_LE_ADV_CONN_NAME and similar macros are now deprecated. It seems that the recommended solution is to manually add the name to the advertising data however you cannot reference bt_get_name() from ad[] so it is not clear how best to replace the deprecated macros and still user bt_set_name() and add the dynamic name to advertising data.
What is the recommended approach for this please?