<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Modifying the Bluetooth name in the program did not take effect.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/125456/modifying-the-bluetooth-name-in-the-program-did-not-take-effect</link><description>I set CONFIG_BT_DEVICE_NAME_DYNAMIC=y in prj.conf, and then called it after the system started. 
 
 These functions modify the Bluetooth name, but the new Bluetooth name has not taken effect.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 06 Nov 2025 10:14:21 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/125456/modifying-the-bluetooth-name-in-the-program-did-not-take-effect" /><item><title>RE: Modifying the Bluetooth name in the program did not take effect.</title><link>https://devzone.nordicsemi.com/thread/553535?ContentTypeID=1</link><pubDate>Thu, 06 Nov 2025 10:14:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d6be8c6-e4eb-4078-bba3-a249706c85df</guid><dc:creator>Neo Yang</dc:creator><description>&lt;p&gt;After modifying the program as you suggested, the new name was successfully changed. Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Modifying the Bluetooth name in the program did not take effect.</title><link>https://devzone.nordicsemi.com/thread/553510?ContentTypeID=1</link><pubDate>Thu, 06 Nov 2025 06:58:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8fbee5a9-def7-4277-aca4-1b3253f08233</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;The problem is that the ad array (or sd if the name is placed in the scan response) still points to the original device name. I&amp;#39;ve created an example for how you can update the advertisement name based on the peripheral_lbs sample which I have included below.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/peripheral_5F00_lbs_5F00_udate_5F00_adv_5F00_name_5F00_3.1.1.zip"&gt;devzone.nordicsemi.com/.../peripheral_5F00_lbs_5F00_udate_5F00_adv_5F00_name_5F00_3.1.1.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void device_name_update(void)
{
	int err;
	static int count;
	static char new_name[BT_GAP_ADV_MAX_ADV_DATA_LEN];
	uint16_t total_payload = 0;

	memset(new_name, 0, sizeof(new_name));

	err = snprintk(new_name, sizeof(new_name), &amp;quot;%s_%d&amp;quot;, DEVICE_NAME, ++count);
	if (err &amp;lt; 0) {
		printk(&amp;quot;snprintk() failed. (err: %d)\n&amp;quot;, err);
		return;
	}

	printk(&amp;quot;New device name: %s\n&amp;quot;, new_name);

	/* Update device name. Can be read from attribue table */
	err = bt_set_name(new_name);
	if (err) {
		printk(&amp;quot;bt_set_name() failed. (err: %d)\n&amp;quot;, err);
		return;
	}

	/* Update the advertisment name field in advertisment payload */
	for (int i = 0; i &amp;lt; ARRAY_SIZE(ad); i++) {
		if (ad[i].type == BT_DATA_NAME_COMPLETE) {
			ad[i].data = new_name;
			ad[i].data_len = strlen(new_name);
		}

		total_payload += (ad[i].data_len + 2);
	}

	err = bt_le_adv_update_data(ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
	if (err &amp;amp;&amp;amp; err != -EAGAIN) {
		printk(&amp;quot;bt_le_adv_update_data() failed. (err: %d)\n&amp;quot;, err);
	}

	if (total_payload &amp;gt; BT_GAP_ADV_MAX_ADV_DATA_LEN) {
		printk(&amp;quot;Name is too long and will be truncated\n&amp;quot;);
	}

	printk(&amp;quot;Primary advertisment payload size: %d\n&amp;quot;, total_payload);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>