<?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>How to set BLE device name periodically</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/104967/how-to-set-ble-device-name-periodically</link><description>I&amp;#39;m using SDK 15.3 on a 52840 and this (How to set BLE device name based on device parameters) works on startup, no problem. I can set a name easily. 
 Now suppose I want to change the name every couple of minutes? I can set the name with this code but</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 25 Oct 2023 09:58:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/104967/how-to-set-ble-device-name-periodically" /><item><title>RE: How to set BLE device name periodically</title><link>https://devzone.nordicsemi.com/thread/452214?ContentTypeID=1</link><pubDate>Wed, 25 Oct 2023 09:58:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69324705-2974-4363-81a6-8d096b4bca08</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The advertising name is actually set with sd_ble_gap_device_name_set() which is often in gap_params_init() function in most of our examples.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To change the advertising name:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Change advertising name by calling&amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;sd_ble_gap_device_name_set&lt;/span&gt;&lt;span&gt;()&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Update advertising data by calling&amp;nbsp;ble_advertising_advdata_update() with new buffers but that contains the same arguments that you set in advertising_init.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span&gt;That will update your advertising data with the new GAP device name.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;See this answer,&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set BLE device name periodically</title><link>https://devzone.nordicsemi.com/thread/452028?ContentTypeID=1</link><pubDate>Tue, 24 Oct 2023 14:12:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53256c2b-c674-4cc1-9ddb-5a767c515abf</guid><dc:creator>Randy Lee</dc:creator><description>&lt;p&gt;OK, not all that familiar with the actual structure of this code, but I&amp;#39;m having trouble understanding the buffer thing here.&amp;nbsp; I don&amp;#39;t actually set a buffer that would have this name.&amp;nbsp; When I init the advertising (with MFG data) I use this code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static const ble_advertising_init_t advertising_params = {
		.advdata = {
				.name_type          = BLE_ADVDATA_FULL_NAME,					// this is like 12 bytes long
				.include_appearance = false,
				.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE,
				.p_manuf_specific_data = &amp;amp;manuf_data,
		},

		.config = {
				.ble_adv_whitelist_enabled = true,                              // This flag causes generation of BLE_ADV_EVT_WHITELIST_REQUEST&amp;#39;s
				.ble_adv_fast_enabled      = true,                              // Fast is completely the same as slow so choose any
				.ble_adv_fast_interval     = MSEC_TO_UNITS(500, UNIT_0_625_MS), // The advertising interval.
				.ble_adv_fast_timeout      = MSEC_TO_UNITS(0, UNIT_10_MS)       // The advertising duration. 0 - forever
		},

		.evt_handler = on_adv_evt
};
...
static void advertising_init(void) {
	APP_ERROR_CHECK(ble_advertising_init(&amp;amp;m_advertising, &amp;amp;advertising_params));
	ble_advertising_conn_cfg_tag_set(&amp;amp;m_advertising, APP_BLE_CONN_CFG_TAG);
}

When it sets the name first this code is using:
	BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;sec_mode);

	ErrCode = sd_ble_gap_device_name_set(&amp;amp;sec_mode, BabyID, BABY_NAME_LEN);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So I,m not setting a buffer up that has this name at all, but using particular calls to set it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This function wants an advertising buffer (a different one that&amp;#39;s being used), but I don&amp;#39;t exactly have the first one.&lt;/p&gt;
&lt;p&gt;Is there some code I can look at that has this call and how to deal with it and the rest of the stuff?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to set BLE device name periodically</title><link>https://devzone.nordicsemi.com/thread/451994?ContentTypeID=1</link><pubDate>Tue, 24 Oct 2023 13:25:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34197e4e-f4b6-4936-898e-07c6e3c17f7f</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi there,&lt;/p&gt;
&lt;p&gt;You can use&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__ble__advertising.html#gaed156c3a650acabf79890fa9da01dec2"&gt;&lt;span&gt;ble_advertising_advdata_update&lt;/span&gt;&lt;/a&gt;() to change the advertising data, remember that error will be returned if:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;It is invalid to provide non-NULL advertising set parameters while advertising.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;It is invalid to provide the same data buffers while advertising. To update advertising data, provide new advertising buffers.&lt;/em&gt;&lt;em&gt;&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can use an &lt;a href="https://devzone.nordicsemi.com/guides/short-range-guides/b/software-development-kit/posts/application-timer-tutorial"&gt;app timer&lt;/a&gt; to schedule the change of advertising set every minute.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Hopefully that answered your question &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>