<?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>First BLE connection fails after reboot phone/bluetooth (works only after scanning with another app) — nRF52840 + Zephyr vs ArduinoBLE</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/122094/first-ble-connection-fails-after-reboot-phone-bluetooth-works-only-after-scanning-with-another-app-nrf52840-zephyr-vs-arduinoble</link><description>Hello everyone, 
 I’m currently developing firmware on our custom board based on the nRF52840, using nRF Connect SDK v3.0.0 and Visual Studio Code. 
 The board is designed to communicate over BLE/GATT with our proprietary Android app (tested on Android</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 13 Jun 2025 09:51:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/122094/first-ble-connection-fails-after-reboot-phone-bluetooth-works-only-after-scanning-with-another-app-nrf52840-zephyr-vs-arduinoble" /><item><title>RE: First BLE connection fails after reboot phone/bluetooth (works only after scanning with another app) — nRF52840 + Zephyr vs ArduinoBLE</title><link>https://devzone.nordicsemi.com/thread/539168?ContentTypeID=1</link><pubDate>Fri, 13 Jun 2025 09:51:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8538d9e-c1ae-42f1-81b5-9d4969756832</guid><dc:creator>Paolo S.</dc:creator><description>&lt;p data-start="165" data-end="348"&gt;Hi Edvin,&lt;br data-start="174" data-end="177" /&gt; one of our Android apps was unable to connect on the first attempt (after a BLE stack reset) to our custom nRF52840 board running firmware based on nRF Connect / Zephyr.&lt;/p&gt;
&lt;p data-start="350" data-end="438"&gt;When we flashed the Arduino-based firmware on the same board, the issue did not occur.&lt;/p&gt;
&lt;p data-start="440" data-end="663"&gt;The only difference between the two &lt;code data-start="476" data-end="485"&gt;ADV_IND&lt;/code&gt; packets was the MAC address type: &lt;strong data-start="520" data-end="530"&gt;PUBLIC&lt;/strong&gt; (Arduino) vs. &lt;strong data-start="545" data-end="562"&gt;STATIC RANDOM&lt;/strong&gt; (Zephyr).&lt;br data-start="572" data-end="575" /&gt; By forcing the Zephyr version to use a PUBLIC address, the connection now works as well.&lt;/p&gt;
&lt;p data-start="665" data-end="726"&gt;The app attempts to connect directly using the MAC address.&lt;/p&gt;
&lt;p data-start="665" data-end="726"&gt;&lt;/p&gt;
&lt;p data-start="728" data-end="806"&gt;&lt;span&gt;&amp;quot;Was the peripheral at all advertising before you set the address to a public address?&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p data-start="728" data-end="806"&gt;No, the peripheral always starts advertising only after calling &lt;code data-start="792" data-end="805"&gt;bt_enable()&lt;/code&gt;.&lt;/p&gt;
&lt;p data-start="728" data-end="806"&gt;&lt;/p&gt;
&lt;p data-start="808" data-end="975"&gt;Unfortunately, the exact cause is still unclear &amp;mdash; it might be something on the Android app side, but I plan to investigate further later on.&lt;br data-start="948" data-end="951" /&gt; For now, it&amp;rsquo;s working.&lt;/p&gt;
&lt;p data-start="977" data-end="1009"&gt;Thanks, Edvin.&lt;br data-start="991" data-end="994" /&gt; Best regards,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: First BLE connection fails after reboot phone/bluetooth (works only after scanning with another app) — nRF52840 + Zephyr vs ArduinoBLE</title><link>https://devzone.nordicsemi.com/thread/538905?ContentTypeID=1</link><pubDate>Wed, 11 Jun 2025 21:01:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62a100ce-6b12-4c68-bbbf-c19e5e15ddea</guid><dc:creator>Edvin</dc:creator><description>[quote user="Paolo Seganfreddo"]&lt;p&gt;While I&amp;#39;m at it, I’d like to ask: are there any implications or potential issues in forcing the MAC address from STATIC RANDOM to PUBLIC?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;One difference is that a public MAC address should never change during the lifetime of the device. This is according to the Bluetooth specification.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Another thing is that in order to use a public MAC address, you need to purchase a public address pool from IEEE. If you don&amp;#39;t, you are not allowed to use public MAC addresses (That applies for Arduino as well).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It still isn&amp;#39;t clear to me why you were not able to connect to the device without using a public address. But I don&amp;#39;t know what sort of devices your app was looking for. An advertising name? A particular advertising address? An UUID?&lt;/p&gt;
&lt;p&gt;Was the peripheral at all advertising before you set the address to a public address?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: First BLE connection fails after reboot phone/bluetooth (works only after scanning with another app) — nRF52840 + Zephyr vs ArduinoBLE</title><link>https://devzone.nordicsemi.com/thread/538511?ContentTypeID=1</link><pubDate>Sat, 07 Jun 2025 13:15:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50254b4d-bb2b-4d1f-ad28-a1031632fc64</guid><dc:creator>Paolo S.</dc:creator><description>&lt;p data-start="51" data-end="60"&gt;Hi Edvin,&lt;/p&gt;
&lt;p data-start="62" data-end="152"&gt;I believe I&amp;rsquo;ve found a solution.&lt;br data-start="94" data-end="97" /&gt; I was about to update the ticket when I saw your reply.&lt;/p&gt;
&lt;p data-start="154" data-end="253"&gt;The app is our own application, running on an Android device (developed using Android Studio/Java).&lt;/p&gt;
&lt;p data-start="255" data-end="503"&gt;After each Bluetooth restart on the Android device (either by rebooting the phone or restarting Bluetooth), the app wouldn&amp;rsquo;t connect to the nRF52840.&lt;/p&gt;
&lt;p data-start="255" data-end="503"&gt;Unless we launched the nRF Connect app first or any other app that performs BLE device discovery.&lt;/p&gt;
&lt;p data-start="505" data-end="669"&gt;The solution I found was to add, in our nRF52840 firmware&lt;br data-start="563" data-end="566" /&gt; a call to the function &lt;code data-start="589" data-end="624"&gt;bt_ctlr_set_public_addr(mac_addr)&lt;/code&gt; just before calling &lt;code data-start="645" data-end="666"&gt;bt_enable(bt_ready)&lt;/code&gt;,&lt;/p&gt;
&lt;p data-start="671" data-end="759"&gt;with &lt;code data-start="676" data-end="688"&gt;mac_addr[]&lt;/code&gt; set to the MAC address read from the &lt;code data-start="726" data-end="748"&gt;NRF_FICR-&amp;gt;DEVICEADDR&lt;/code&gt; registers.&lt;/p&gt;
&lt;p&gt;....&lt;br /&gt;...&lt;br /&gt;mac_addr[0] = (NRF_FICR-&amp;gt;DEVICEADDR[0] &amp;gt;&amp;gt; 0) &amp;amp; 0xFF;&lt;br /&gt;mac_addr[1] = (NRF_FICR-&amp;gt;DEVICEADDR[0] &amp;gt;&amp;gt; 8) &amp;amp; 0xFF;&lt;br /&gt;mac_addr[2] = (NRF_FICR-&amp;gt;DEVICEADDR[0] &amp;gt;&amp;gt; 16) &amp;amp; 0xFF;&lt;br /&gt;mac_addr[3] = (NRF_FICR-&amp;gt;DEVICEADDR[0] &amp;gt;&amp;gt; 24) &amp;amp; 0xFF;&lt;br /&gt;mac_addr[4] = (NRF_FICR-&amp;gt;DEVICEADDR[1] &amp;gt;&amp;gt; 0) &amp;amp; 0xFF;&lt;br /&gt;mac_addr[5] = (NRF_FICR-&amp;gt;DEVICEADDR[1] &amp;gt;&amp;gt; 8) &amp;amp; 0xFF;&lt;br /&gt;...&lt;br /&gt;..&lt;br /&gt;bt_ctlr_set_public_addr(mac_addr);&lt;/p&gt;
&lt;p&gt;err = bt_enable(bt_ready);&lt;br /&gt;if (err)&lt;br /&gt;{&lt;br /&gt;...&lt;/p&gt;
&lt;p data-start="761" data-end="883"&gt;With that call in place, Wireshark now shows the ADV_IND message with a PUBLIC MAC address instead of a STATIC RANDOM one.&lt;/p&gt;
&lt;p data-start="885" data-end="974"&gt;Our Android app now connects successfully both the first time and on subsequent attempts.&lt;/p&gt;
&lt;p data-start="976" data-end="1113"&gt;While I&amp;#39;m at it, I&amp;rsquo;d like to ask: are there any implications or potential issues in forcing the MAC address from STATIC RANDOM to PUBLIC?&lt;/p&gt;
&lt;p data-start="1115" data-end="1150"&gt;Thank you for your support,&lt;/p&gt;
&lt;p data-start="1115" data-end="1150"&gt;best regards&lt;br data-start="1142" data-end="1145" /&gt; Paolo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: First BLE connection fails after reboot phone/bluetooth (works only after scanning with another app) — nRF52840 + Zephyr vs ArduinoBLE</title><link>https://devzone.nordicsemi.com/thread/538490?ContentTypeID=1</link><pubDate>Fri, 06 Jun 2025 20:53:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34463c49-9fcf-4c25-905c-3215443c811d</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user=""]&lt;p&gt;the connection does not succeed (the app just stays in a waiting state).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;What app? The application running on the nRF52840, or the one running on your phone?&lt;/p&gt;
&lt;p&gt;This sounds like an issue where a wireshark trace from the &lt;a href="https://www.nordicsemi.com/Products/Development-tools/nRF-Sniffer-for-Bluetooth-LE"&gt;nRF Sniffer for Bluetooth LE&lt;/a&gt; might be useful. Can you please upload a .pcapng file from when the connection doesn&amp;#39;t work (the app just stays in a waiting state), and one where the connection succeeds?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, if you try the nRF Connect for Android/iOS, are you then able to reconnect after a phone reboot/toggling off-&amp;gt;on the Bluetooth?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>