<?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>Private Bluetooth Address</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/88961/private-bluetooth-address</link><description>Hello All, 
 i have a problem when I try to change the Bluetooth Address. 
 This is the code that works correctly: err = bt_addr_le_from_str ( &amp;quot;DE:8B:49:00:00:01&amp;quot; , &amp;quot;random&amp;quot; , &amp;amp; addr ); 
 This is the code that NOT works correctly: err = bt_addr_le_from_str</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 16 Jun 2022 08:07:32 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/88961/private-bluetooth-address" /><item><title>RE: Private Bluetooth Address</title><link>https://devzone.nordicsemi.com/thread/372731?ContentTypeID=1</link><pubDate>Thu, 16 Jun 2022 08:07:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dab0970c-12e7-40d5-a3b4-8c10c74ed54b</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;To set a public address you need to use&amp;nbsp;&lt;code&gt;bt_ctlr_set_public_addr()&lt;/code&gt;. Then you also need &amp;quot;&lt;code&gt;#include &amp;lt;bluetooth/controller.h&amp;gt;&amp;quot;.&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;A generic set address wrapper function could look like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void set_bt_addr(const char *addr_str, const char *type_str)
{
	int err;
	bt_addr_le_t addr;

	err = bt_addr_le_from_str(addr_str, type_str, &amp;amp;addr);
	if (err) {
		printk(&amp;quot;Invalid BT address (err %d)\n&amp;quot;, err);
	}

	if (addr.type == BT_ADDR_LE_PUBLIC) {
		bt_ctlr_set_public_addr(addr.a.val);
		return;
	} else {
		err = bt_id_create(&amp;amp;addr, NULL);
		if (err &amp;lt; 0) {
			printk(&amp;quot;Creating new ID failed (err %d)\n&amp;quot;, err);
		}
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And be called&amp;nbsp;like this:&amp;nbsp;&lt;code&gt;set_bt_addr(&amp;quot;DE:AD:BE:AF:BA:11&amp;quot;, &amp;quot;public&amp;quot;);&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Private Bluetooth Address</title><link>https://devzone.nordicsemi.com/thread/372589?ContentTypeID=1</link><pubDate>Wed, 15 Jun 2022 13:20:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3522f8f7-575d-42e0-bce5-8afa9475e1f0</guid><dc:creator>Epasta</dc:creator><description>&lt;p&gt;Hello Einar,&lt;/p&gt;
&lt;p&gt;before of all thanks for your reply.&lt;/p&gt;
&lt;p&gt;I have already tried to put &amp;quot;public&amp;quot; and also &amp;quot;public-id&amp;quot; in &lt;span&gt;the call bt_addr_le_from_str() but the result is the same.&lt;br /&gt;I still having the following error:&lt;br /&gt;Only static random identity address supported&lt;br /&gt;Creating new ID failed (err -22)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Do you have other suggestions?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;For point number 2 i&amp;#39;ts ok.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you again for your time.&lt;br /&gt;Best regards&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Private Bluetooth Address</title><link>https://devzone.nordicsemi.com/thread/372565?ContentTypeID=1</link><pubDate>Wed, 15 Jun 2022 12:17:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:241f2090-7122-42ec-9951-5692763a5c10</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]What could be? How can i fix this?[/quote]
&lt;p&gt;The&amp;nbsp;two most significant bits of a Bluetooth address&amp;nbsp;specifies the type of address (unless it is public, that is). This follows the Bluetooth specification. You specify a &amp;quot;random&amp;quot; address,&amp;nbsp;and by specification the two most significant bits then must be &amp;quot;11&amp;quot;. So either the address is wrong, or you have specified the wrong type. If the address is public(?), then you should use &amp;quot;public&amp;quot; in the call to&amp;nbsp;bt_addr_le_from_str().&lt;/p&gt;
[quote user=""]We&amp;nbsp;buyed a range of&amp;nbsp;Bluetooth Address but for Classic Bluetooth, can we use this range or we have to buy a specific address for BLE?[/quote]
&lt;p&gt;Bluetooth device addresses are the same for LE and classic, so it should be fine to use your existing range. (As a side note, few end products benefit from a public address. Random static addresses are effectively 46 bit, and the likelihood of collisions between devices in Bluetooth range is negligible.)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>