<?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>Using FICR device address with hci_uart example from NCS on nRF52x</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/92804/using-ficr-device-address-with-hci_uart-example-from-ncs-on-nrf52x</link><description>Hi, 
 is it possible to configure the hci_uart example from NCS in a way that the FICR device address of a nRF52840 is used as public device address? I cloned and compiled the project without any changes and would like the controller to use the hardware</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 13 Oct 2022 16:36:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/92804/using-ficr-device-address-with-hci_uart-example-from-ncs-on-nrf52x" /><item><title>RE: Using FICR device address with hci_uart example from NCS on nRF52x</title><link>https://devzone.nordicsemi.com/thread/390701?ContentTypeID=1</link><pubDate>Thu, 13 Oct 2022 16:36:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f1deef6f-5bef-4b99-b816-91c0579de6d7</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;Hi Oliver,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I was working on your case. Good to know that you found a solution.&lt;/p&gt;
&lt;p&gt;Here is how I solved it:&lt;/p&gt;
&lt;p&gt;We can use NRF_FICR structure to read device ID, and we can use&amp;nbsp;bt_ctlr_set_public_addr() to set the address read.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class="ui-code" data-mode="text"&gt;DA[0] = NRF_FICR-&amp;gt;DEVICEID[0];
DA[1] = NRF_FICR-&amp;gt;DEVICEID[1];
bt_ctlr_set_public_addr(DA);&lt;/pre&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Thanks and regards,&lt;/p&gt;
&lt;p&gt;Naeem&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using FICR device address with hci_uart example from NCS on nRF52x</title><link>https://devzone.nordicsemi.com/thread/390699?ContentTypeID=1</link><pubDate>Thu, 13 Oct 2022 16:22:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b552e845-f0de-4cb5-b528-6afcf646f58b</guid><dc:creator>OliverB</dc:creator><description>&lt;p&gt;Found a solution in the meantime:&lt;/p&gt;
&lt;p&gt;Using bt_ctlr_set_public_addr from bluetooth/controller.h I can set the public address:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void get_device_address(uint8_t mac_address[6]) {
  unsigned int device_addr_0 = NRF_FICR-&amp;gt;DEVICEADDR[0];
  unsigned int device_addr_1 = NRF_FICR-&amp;gt;DEVICEADDR[1];
  const uint8_t *part_0 = (const uint8_t *)(&amp;amp;device_addr_0);
  const uint8_t *part_1 = (const uint8_t *)(&amp;amp;device_addr_1);
  mac_address[0] = part_1[1];
  mac_address[1] = part_1[0];
  mac_address[2] = part_0[3];
  mac_address[3] = part_0[2];
  mac_address[4] = part_0[1];
  mac_address[5] = part_0[0];

  LOG_HEXDUMP_DBG(mac_address, 6, &amp;quot;Address&amp;quot;);
}

void main(void) {
  ...

  uint8_t address[6];
  get_mac_address(address);
  bt_ctlr_set_public_addr(address);

  /* Enable the raw interface, this will in turn open the HCI driver */
  bt_enable_raw(&amp;amp;rx_queue);
  
  ...
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Thanks to&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/76344/retrieve-ble-mac-address-in-zephyr-environment"&gt;Retrieve BLE MAC address in Zephyr environment&lt;/a&gt;&amp;nbsp;&amp;nbsp;for implementation of get_device_address().&lt;/p&gt;
&lt;div id="gtx-trans" style="left:65px;position:absolute;top:48.2585px;"&gt;
&lt;div class="gtx-trans-icon"&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>