Set BLE Mesh device name at runtime for advertising

I'm using an nRF7002DK, SDK v2.7.0, and I've set it up as a BLE mesh node following the Zephyr bluetooth mesh sample. It's running fine, and I'm able to provision it using the nRF Mesh app on my phone, I also see it when scanning with the nRF Connect app. Now I'd like to change its advertising name but I can't seem to get that to work. 

I have CONFIG_BT_SETTINGS and CONFIG_BT_DEVICE_NAME_DYNAMIC set in my application prj.conf, and I'm trying to change the name from the application using bt_set_name(...). I can see the name is getting saved because subsequent calls to bt_get_name return the expected name, but it's still showing on nRF Mesh as the default "Zephyr" (or whatever CONFIG_BT_DEVICE_NAME is set to).

All of the documentation and posts I've seen haven't been for mesh setups, so the advertising gets handled manually, directly in the application, and it's straightforward how to change the advertising data. However, in the mesh sample, advertising appears to take place internally as there are no occurrences of any bt_le_adv_* or bt_adv_* functions (callback included below for convenience). I've tried calling bt_set_name() at each step in bt_ready but none of those attempts were successful. I also tried using bt_le_adv_update_data(), as advised in the documentation for the bt_set_name() function.

I'd include my code but it's the same as the mesh sample.

Is there an example somewhere that shows how to change the device name for a BLE mesh device?

static void bt_ready(int err)
{
	if (err) {
		printk("Bluetooth init failed (err %d)\n", err);
		return;
	}

	printk("Bluetooth initialized\n");

	err = bt_mesh_init(&prov, &comp);
	if (err) {
		printk("Initializing mesh failed (err %d)\n", err);
		return;
	}

	if (IS_ENABLED(CONFIG_SETTINGS)) {
		settings_load();
	}

	/* This will be a no-op if settings_load() loaded provisioning info */
	bt_mesh_prov_enable(BT_MESH_PROV_ADV | BT_MESH_PROV_GATT);

	printk("Mesh initialized\n");
}

Parents Reply Children
No Data
Related