<?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>(Zephyr / NCS) Defining BLE scan data and advertising data during runtime</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/78532/zephyr-ncs-defining-ble-scan-data-and-advertising-data-during-runtime</link><description>I have seen this question answered for the old Nordic SDK but have not been able to find a solution in Zephyr &amp;amp; NCS. I&amp;#39;m following this post on how to develop a custom BLE service in NCS. I see on step 5 they start the BLE advertising using the sd[] and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 20 Aug 2021 14:36:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/78532/zephyr-ncs-defining-ble-scan-data-and-advertising-data-during-runtime" /><item><title>RE: (Zephyr / NCS) Defining BLE scan data and advertising data during runtime</title><link>https://devzone.nordicsemi.com/thread/326003?ContentTypeID=1</link><pubDate>Fri, 20 Aug 2021 14:36:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6027bee6-1cb1-4208-917a-82f293b0c040</guid><dc:creator>zciwor</dc:creator><description>&lt;p&gt;I solved this with the help of &lt;a href="https://devzone.nordicsemi.com/members/matt.heins"&gt;matt.heins&lt;/a&gt;. You can dynamically update the sd and ad arrays at any time before advertising has started. My implementation&amp;nbsp;is below:&amp;nbsp;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;	struct bt_data ad[] = {
		BT_DATA_BYTES(BT_DATA_UUID128_ALL, HISTORY_SERVICE_UUID),
		BT_DATA(BT_DATA_NAME_COMPLETE, name_holder, sizeof(name_holder)),
	};

	struct bt_data sd[] = {
		BT_DATA(BT_DATA_NAME_COMPLETE, name_holder, sizeof(name_holder)),
	};

	//Start advertising
	err = bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad),
			      sd, ARRAY_SIZE(sd));
	if (err) 
	{
		printk(&amp;quot;Advertising failed to start (err %d)\n&amp;quot;, err);
		return;
	}

	printk(&amp;quot;Advertising successfully started\n&amp;quot;);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>