<?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 MAC address fails with multirole BLE (Central+Peripheral)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96672/setting-mac-address-fails-with-multirole-ble-central-peripheral</link><description>I&amp;#39;m trying to use the nRF52840 with the nRF Connect SDK 2.2.0 to create a BLE device that supports both Central and Peripheral. This basically works, but there is a problem when trying to set a public MAC address. The function `bt_ctlr_set_public_addr</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 21 Feb 2023 16:43:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96672/setting-mac-address-fails-with-multirole-ble-central-peripheral" /><item><title>RE: Setting MAC address fails with multirole BLE (Central+Peripheral)</title><link>https://devzone.nordicsemi.com/thread/411182?ContentTypeID=1</link><pubDate>Tue, 21 Feb 2023 16:43:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d413491a-818b-4301-be50-63921e4cb97c</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Good to hear that.&amp;nbsp;&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;-Amanda H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting MAC address fails with multirole BLE (Central+Peripheral)</title><link>https://devzone.nordicsemi.com/thread/411123?ContentTypeID=1</link><pubDate>Tue, 21 Feb 2023 13:41:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9cb2583-e086-4c0d-bef7-39571bff50b1</guid><dc:creator>wichmann</dc:creator><description>&lt;div&gt;
&lt;div&gt;&lt;span&gt;I tested the changes and it seems to resolve the problem. Thanks.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting MAC address fails with multirole BLE (Central+Peripheral)</title><link>https://devzone.nordicsemi.com/thread/410957?ContentTypeID=1</link><pubDate>Mon, 20 Feb 2023 15:58:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:558081c9-c98f-413e-bd33-618a887e4a0e</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The engineer found the issue. There is now a bugfix coming in &lt;a title="https://github.com/nrfconnect/sdk-nrfxlib/pull/919/files" href="https://github.com/nrfconnect/sdk-nrfxlib/pull/919/files" rel="noopener noreferrer" target="_blank"&gt;https://github.com/nrfconnect/sdk-nrfxlib/pull/919/files&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you check that this works for you?&lt;/p&gt;
&lt;p&gt;-Amanda H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting MAC address fails with multirole BLE (Central+Peripheral)</title><link>https://devzone.nordicsemi.com/thread/410632?ContentTypeID=1</link><pubDate>Fri, 17 Feb 2023 12:22:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:daebaa72-9686-4582-bae1-1e93fc2031e3</guid><dc:creator>wichmann</dc:creator><description>&lt;div&gt;
&lt;div&gt;&lt;span&gt;The workaround does not seem to work. I use the following code to test this (CONFIG_BT_CENTRAL and CONFIG_BT_PERIPHERAL enabled; I&amp;#39;m currently not using `settings_load`):&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void main(void) {
   int err;

   err = bt_enable(NULL);
   if (err) {
      LOG_ERR(&amp;quot;Bluetooth init failed (err %d)&amp;quot;, err);
   }

   k_sleep(K_MSEC(3000));     // ensure that bt_enable is done; alternatively via bt_ready_cb

   static const uint8_t _dbg_mac[6] = {0x01, 0x00, 0x00, 0x25, 0x80, 0x00};
   bt_ctlr_set_public_addr(_dbg_mac);

   bt_addr_le_t addr[CONFIG_BT_ID_MAX];
   size_t count = CONFIG_BT_ID_MAX;
   char str_buffer[30];
   bt_id_get(addr, &amp;amp;count);
   for (size_t i = 0; i &amp;lt; count; i++) {
      bt_addr_le_to_str(&amp;amp;addr[i], str_buffer, sizeof(str_buffer));
      LOG_INF(&amp;quot;ID %d: %s&amp;quot;, (int) i, str_buffer);
   }

   static const struct bt_data ble_ad_default[] = {};
   static const struct bt_data ble_sd_default[] = {};
   err = bt_le_adv_start(BT_LE_ADV_CONN_NAME, ble_ad_default, ARRAY_SIZE(ble_ad_default), ble_sd_default, ARRAY_SIZE(ble_sd_default));
   if (err) {
      LOG_ERR(&amp;quot;Advertising failed to start (err %d)&amp;quot;, err);
   }
}&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;
&lt;div&gt;&lt;span&gt;The id returned from `bt_id_get()` as well as the MAC used in advertising are still the static random address.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting MAC address fails with multirole BLE (Central+Peripheral)</title><link>https://devzone.nordicsemi.com/thread/410466?ContentTypeID=1</link><pubDate>Thu, 16 Feb 2023 19:38:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c275f3d-9c77-438c-a53a-9098d7a0c11e</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The team&amp;nbsp;found that there is a bug in the stack if &lt;code&gt;bt_ctlr_set_public_addr()&lt;/code&gt; is called before &lt;code&gt;bt_enable()&amp;nbsp;&lt;/code&gt;and will have a bug fixed later. &amp;nbsp;The workaround for this right now is &lt;span&gt;setting the address after the bt_enable(), but before settigs_load (if you have it). Please let me know whether it can work or not. Thanks.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;-Amanda H.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting MAC address fails with multirole BLE (Central+Peripheral)</title><link>https://devzone.nordicsemi.com/thread/410213?ContentTypeID=1</link><pubDate>Thu, 16 Feb 2023 05:12:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6797e60-296a-4f1f-970c-e8d32b0de238</guid><dc:creator>wichmann</dc:creator><description>&lt;p&gt;Exactly. &amp;quot;No error&amp;quot; means the public address is set correctly and &amp;quot;error&amp;quot; means the static random address is used instead. I didn&amp;#39;t try a complete communication with all these cases, only checked the output of `bt_enable()`.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting MAC address fails with multirole BLE (Central+Peripheral)</title><link>https://devzone.nordicsemi.com/thread/410170?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2023 18:13:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02fcaba3-f25e-46a9-b7d2-88e59fa83ac4</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Are you able to set&amp;nbsp;&lt;span&gt;the public address as expected for those&amp;nbsp;get &amp;quot;No error&amp;quot; in your tests?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;br /&gt;Amanda H.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting MAC address fails with multirole BLE (Central+Peripheral)</title><link>https://devzone.nordicsemi.com/thread/410051?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2023 11:43:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2fe363c-aad8-4d19-bdd0-6960507aee95</guid><dc:creator>wichmann</dc:creator><description>&lt;div&gt;
&lt;div&gt;&lt;span&gt;I did some more testing and it seems that the error is triggered when using CONFIG_BT_PERIPHERAL with the multirole SoftDevice library. To test this I edited `nrfxlib/softdevice_controller/CMakeLists.txt` to manually select the SoftDevice library (changed `zephyr_link_libraries(...)` at the end). When using CONFIG_BT_PERIPHERAL and the peripheral library (`nrfxlib\softdevice_controller\lib\cortex-m4\soft-float\libsoftdevice_controller_peripheral.a`) the address gets set as expected. If I force the use of the multirole library instead (`nrfxlib\softdevice_controller\lib\cortex-m4\soft-float\libsoftdevice_controller_multirole.a`) the error occurs and the random address is used instead. I could not reproduce the error in other constellations (e.g. CONFIG_BT_CENTRAL and multirole lib). I also tried to both use CONFIG_BT_CENTRAL and CONFIG_BT_PERIPHERAL, while using both central and peripheral libraries at the same time, instead of the multirole lib. This seems to work as well (although I did not test full communication).&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt;To sum up my tests:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;* CONFIG_BT_CENTRAL + libsoftdevice_controller_central ==&amp;gt; No error&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;* CONFIG_BT_PERIPHERAL + libsoftdevice_controller_peripheral ==&amp;gt; No error&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;* CONFIG_BT_CENTRAL + libsoftdevice_controller_multirole ==&amp;gt; No error&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;* CONFIG_BT_PERIPHERAL + libsoftdevice_controller_multirole ==&amp;gt; Error!&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;* CONFIG_BT_CENTRAL + CONFIG_BT_PERIPHERAL + libsoftdevice_controller_multirole ==&amp;gt; Error!&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;* CONFIG_BT_CENTRAL + CONFIG_BT_PERIPHERAL + libsoftdevice_controller_central + libsoftdevice_controller_peripheral ==&amp;gt;&amp;nbsp;No error&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>