<?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>Setting static random address more than once</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/98410/setting-static-random-address-more-than-once</link><description>Hello, 
 I am using bt_id_create() to set static random address. 
 bt_id_create() is called before bt_enable(). 
 This works and sets the device address to a random address I specify. 
 But how can I change that address? For example - I have everything</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 04 Oct 2023 10:01:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/98410/setting-static-random-address-more-than-once" /><item><title>RE: Setting static random address more than once</title><link>https://devzone.nordicsemi.com/thread/448785?ContentTypeID=1</link><pubDate>Wed, 04 Oct 2023 10:01:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:270e013d-7886-4d0a-9907-b253620c2d5b</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;continued in this thread:&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/104359/bt_le_adv_start-returns--22-with-adv_param-id-1"&gt;bt_le_adv_start() returns -22, with adv_param.id=1&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting static random address more than once</title><link>https://devzone.nordicsemi.com/thread/448579?ContentTypeID=1</link><pubDate>Mon, 02 Oct 2023 22:16:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47b3aba3-d369-4e49-8f76-bc9875fdbc65</guid><dc:creator>lionfish</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve got the same issue as MDL. I am using the nRF52832. I took the original version of peripheral_lbs and copied in the new version of main() as above. I also added CONFIG_BT_ID_MAX=2.&lt;/p&gt;
&lt;p&gt;I noticed that it said &amp;quot;No ID address. App must call settings_load()&amp;quot; so I added a check to see if the settings_load method is working. I added a line to prj.conf CONFIG_SETTINGS=y.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the output on the terminal:&lt;/p&gt;
&lt;p&gt;Starting Bluetooth Peripheral LBS example&lt;br /&gt;I: 6 Sectors of 4096 bytes&lt;br /&gt;I: alloc wra: 0, fa8&lt;br /&gt;I: data wra: 0, d4&lt;br /&gt;I: SoftDevice Controller build revision: &lt;br /&gt;I: 6d 90 41 2a 38 e8 ad 17 |m.A*8...&lt;br /&gt;I: 29 a5 03 38 39 27 d7 85 |)..89&amp;#39;..&lt;br /&gt;I: 1f 85 d8 e1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |....&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;I: No ID address. App must call settings_load()&lt;br /&gt;Bluetooth initialized&lt;br /&gt;Loading settings...&lt;br /&gt;Advertising failed to start (err -22)&lt;/p&gt;
&lt;p&gt;adv_param has in it:&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;id:&lt;br /&gt;1 &amp;#39;\001&amp;#39;&lt;br /&gt;sid:&lt;br /&gt;0 &amp;#39;\000&amp;#39;&lt;br /&gt;secondary_max_skip:&lt;br /&gt;0 &amp;#39;\000&amp;#39;&lt;br /&gt;options:&lt;br /&gt;1&lt;br /&gt;interval_min:&lt;br /&gt;32&lt;br /&gt;interval_max:&lt;br /&gt;32&lt;br /&gt;peer:&lt;br /&gt;0x0 &amp;lt;cbvprintf_package&amp;gt;&lt;/p&gt;
&lt;div class="invisible scrollbar horizontal" style="background-color:#202020;bottom:0px;color:#cccccc;font-family:&amp;#39;Droid Sans Mono&amp;#39;, &amp;#39;monospace&amp;#39;, monospace;font-size:14px;font-style:normal;font-weight:400;height:10px;left:0px;letter-spacing:normal;position:absolute;text-align:start;text-indent:0px;text-transform:none;white-space:nowrap;width:390px;"&gt;&lt;/div&gt;
&lt;p&gt;if that&amp;#39;s useful?&lt;/p&gt;
&lt;p&gt;ad has in it an array of two entries:&lt;/p&gt;
&lt;p&gt;[0]&lt;br /&gt;type:1 &amp;#39;\001&amp;#39;&lt;br /&gt;data_len:1 &amp;#39;\001&amp;#39;data:0x2000075c &amp;lt;__compound_literal.1&amp;gt; &amp;quot;\006\002#Ѽ\352_x#\025\336\357\022\022%\025&amp;quot;&lt;br /&gt;[1]&lt;br /&gt;type:9 &amp;#39;\t&amp;#39;&lt;br /&gt;data_len:10 &amp;#39;\n&amp;#39;&lt;br /&gt;data:0x27ba7 &amp;quot;Nordic_LBS&amp;quot;&lt;/p&gt;
&lt;div class="visible scrollbar horizontal" style="background:#202020;bottom:0px;color:#cccccc;font-family:&amp;#39;Droid Sans Mono&amp;#39;, &amp;#39;monospace&amp;#39;, monospace;font-size:14px;font-style:normal;font-weight:400;height:10px;left:0px;letter-spacing:normal;position:absolute;text-align:start;text-indent:0px;text-transform:none;white-space:nowrap;width:540px;"&gt;&lt;/div&gt;
&lt;p&gt;I realise I&amp;#39;ve the same problem&lt;/p&gt;
&lt;div style="background-color:#1f1f1f;color:#cccccc;font-family:&amp;#39;Droid Sans Mono&amp;#39;, &amp;#39;monospace&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#9cdcfe;"&gt;param&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#9cdcfe;"&gt;id&lt;/span&gt;&lt;span style="color:#cccccc;"&gt; &lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;&amp;gt;=&lt;/span&gt;&lt;span style="color:#cccccc;"&gt; &lt;/span&gt;&lt;span style="color:#9cdcfe;"&gt;bt_dev&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;.&lt;/span&gt;&lt;span style="color:#9cdcfe;"&gt;id_count&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;it makes sense this should cause an error (as it&amp;#39;s zero-indexed), but it&amp;#39;s not clear how I make the &amp;#39;id_count&amp;#39; bigger?&lt;/p&gt;
&lt;p&gt;&lt;code class="notranslate"&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;Should I be calling&lt;/span&gt; bt_id_create?&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;I wonder if it has anything to do with &lt;a href="https://github.com/zephyrproject-rtos/zephyr/issues/55723"&gt;this issue&lt;/a&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting static random address more than once</title><link>https://devzone.nordicsemi.com/thread/444737?ContentTypeID=1</link><pubDate>Wed, 06 Sep 2023 13:44:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05bfc7f1-e628-40c6-bf04-17dca7ccc13a</guid><dc:creator>MDL</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I can not get this working on my nRF52840dk. I created a new application from the peripheral_lbs sample. I copied your code from above and added CONFIG_BT_ID_MAX = 2 to my .conf file.&lt;/p&gt;
&lt;p&gt;bt_le_adv_start() returns -22 and when debugging I found that valid_adv_ext_param() in adv.c is returning false where param-&amp;gt;id is equal to bt_dev.id_count:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div style="background-color:#f5f5f5;color:#333333;font-family:Consolas, &amp;#39;Courier New&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#4b69c6;"&gt;if&lt;/span&gt;&lt;span style="color:#333333;"&gt; &lt;/span&gt;&lt;span style="color:#777777;"&gt;(&lt;/span&gt;&lt;span style="color:#7a3e9d;"&gt;param&lt;/span&gt;&lt;span style="color:#777777;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#7a3e9d;"&gt;id&lt;/span&gt;&lt;span style="color:#333333;"&gt; &lt;/span&gt;&lt;span style="color:#777777;"&gt;&amp;gt;=&lt;/span&gt;&lt;span style="color:#333333;"&gt; &lt;/span&gt;&lt;span style="color:#7a3e9d;"&gt;bt_dev&lt;/span&gt;&lt;span style="color:#777777;"&gt;.&lt;/span&gt;&lt;span style="color:#7a3e9d;"&gt;id_count&lt;/span&gt;&lt;span style="color:#333333;"&gt; &lt;/span&gt;&lt;span style="color:#777777;"&gt;||&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#333333;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="color:#777777;"&gt;!&lt;/span&gt;&lt;span style="color:#aa3731;font-weight:bold;"&gt;bt_addr_le_cmp&lt;/span&gt;&lt;span style="color:#777777;"&gt;(&amp;amp;&lt;/span&gt;&lt;span style="color:#7a3e9d;"&gt;bt_dev&lt;/span&gt;&lt;span style="color:#777777;"&gt;.&lt;/span&gt;&lt;span style="color:#7a3e9d;"&gt;id_addr&lt;/span&gt;&lt;span style="color:#777777;"&gt;[&lt;/span&gt;&lt;span style="color:#7a3e9d;"&gt;param&lt;/span&gt;&lt;span style="color:#777777;"&gt;-&amp;gt;&lt;/span&gt;&lt;span style="color:#7a3e9d;"&gt;id&lt;/span&gt;&lt;span style="color:#777777;"&gt;],&lt;/span&gt;&lt;span style="color:#333333;"&gt; &lt;/span&gt;&lt;span style="color:#aa3731;font-weight:bold;"&gt;BT_ADDR_LE_ANY&lt;/span&gt;&lt;span style="color:#777777;"&gt;))&lt;/span&gt;&lt;span style="color:#333333;"&gt; &lt;/span&gt;&lt;span style="color:#777777;"&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#333333;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="color:#4b69c6;"&gt;return&lt;/span&gt;&lt;span style="color:#333333;"&gt; &lt;/span&gt;&lt;span style="color:#aa3731;font-weight:bold;"&gt;false&lt;/span&gt;&lt;span style="color:#777777;"&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#333333;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="color:#777777;"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Tested with nRF Connect SDK v2.1.0 and v2.4.2.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting static random address more than once</title><link>https://devzone.nordicsemi.com/thread/419074?ContentTypeID=1</link><pubDate>Tue, 04 Apr 2023 13:58:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8151abdf-281d-492e-9ab8-b343d14892e0</guid><dc:creator>D0023</dc:creator><description>&lt;p&gt;Thank you. This clarified my issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting static random address more than once</title><link>https://devzone.nordicsemi.com/thread/419059?ContentTypeID=1</link><pubDate>Tue, 04 Apr 2023 13:29:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f68c8189-e2d4-4de6-bdea-bf9241aedb2c</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi D0023,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In stead of calling&amp;nbsp;&lt;span&gt;bt_id_create() you can call&amp;nbsp;bt_id_reset() to change the address of the current identity. You would need to stop advertising before changing the address.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Note that identity&amp;nbsp;&lt;/span&gt;BT_ID_DEFAULT (which is 0) is not possible to reset. You can only reset identity &amp;gt;0.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please see the following code that I modified from the lbs example. The code will advertise with different&amp;nbsp;addresses every 1 second:&amp;nbsp;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;void main(void)
{
	int blink_status = 0;
	int err;
	struct bt_le_adv_param adv_param = {
		.id = BT_ID_DEFAULT,
		.sid = 0,
		.secondary_max_skip = 0,
		.options = (BT_LE_ADV_OPT_CONNECTABLE),
		.interval_min = 0x0020, /* 20 ms */
		.interval_max = 0x0020, /* 20 ms */
		.peer = NULL,
	};

	printk(&amp;quot;Starting Bluetooth Peripheral LBS example\n&amp;quot;);

	err = dk_leds_init();
	if (err) {
		printk(&amp;quot;LEDs init failed (err %d)\n&amp;quot;, err);
		return;
	}

	err = init_button();
	if (err) {
		printk(&amp;quot;Button init failed (err %d)\n&amp;quot;, err);
		return;
	}

	if (IS_ENABLED(CONFIG_BT_LBS_SECURITY_ENABLED)) {
		err = bt_conn_auth_cb_register(&amp;amp;conn_auth_callbacks);
		if (err) {
			printk(&amp;quot;Failed to register authorization callbacks.\n&amp;quot;);
			return;
		}

		err = bt_conn_auth_info_cb_register(&amp;amp;conn_auth_info_callbacks);
		if (err) {
			printk(&amp;quot;Failed to register authorization info callbacks.\n&amp;quot;);
			return;
		}
	}

	err = bt_enable(NULL);
	if (err) {
		printk(&amp;quot;Bluetooth init failed (err %d)\n&amp;quot;, err);
		return;
	}
	printk(&amp;quot;Bluetooth initialized\n&amp;quot;);

	if (IS_ENABLED(CONFIG_SETTINGS)) {
		settings_load();
	}
	err = bt_lbs_init(&amp;amp;lbs_callbacs);
	if (err) {
		printk(&amp;quot;Failed to init LBS (err:%d)\n&amp;quot;, err);
		return;
	}
	adv_param.id=1;
	err = bt_le_adv_start(&amp;amp;adv_param, 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;);

	for (;;) {
		dk_set_led(RUN_STATUS_LED, (++blink_status) % 2);
		k_sleep(K_MSEC(RUN_LED_BLINK_INTERVAL));
		bt_le_adv_stop();
		err = bt_id_reset(1,NULL, NULL);
		if (err &amp;lt; 0) {
			printk(&amp;quot;Reset ID failed (err %d)\n&amp;quot;, err);
		};
		err = bt_le_adv_start(&amp;amp;adv_param, ad, ARRAY_SIZE(ad),
			      sd, ARRAY_SIZE(sd));
		if (err) {
			printk(&amp;quot;Advertising failed to start (err %d)\n&amp;quot;, err);
		return;
		}
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Notice how I set the advertising identity to 1 by calling &lt;em&gt;adv_param.id=&lt;/em&gt;&lt;span&gt;&lt;em&gt;1; .&lt;/em&gt; In the code I set address to NULL to generate random static address, but you can input your own address.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Also you need to configure&amp;nbsp;CONFIG_BT_ID_MAX=2&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>