<?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>Directed advertising to Android phone without bonding</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/108920/directed-advertising-to-android-phone-without-bonding</link><description>Hello, 
 Here is my setup: 
 
 Hardware
 
 nRF52840 development kit - Qty: 2 
 
 One in Central Role 
 One in Peripheral Role 
 
 
 Android Phone (Google Pixel 4a) 
 
 
 Software
 
 SDK 15.2 (Using old SDK because I am making changes to an old project</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 19 Mar 2024 19:09:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/108920/directed-advertising-to-android-phone-without-bonding" /><item><title>RE: Directed advertising to Android phone without bonding</title><link>https://devzone.nordicsemi.com/thread/474730?ContentTypeID=1</link><pubDate>Tue, 19 Mar 2024 19:09:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:67a177a7-cecc-4d6b-bdbb-25dbc1c09fa7</guid><dc:creator>droberson</dc:creator><description>&lt;p&gt;Thanks for having an internal discussion and following up. Bonding it is.&lt;/p&gt;
&lt;p&gt;Derek&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Directed advertising to Android phone without bonding</title><link>https://devzone.nordicsemi.com/thread/474518?ContentTypeID=1</link><pubDate>Tue, 19 Mar 2024 08:47:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e2c6e2a-387c-4afd-a1ed-6219771ec187</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;After discussing with Torbjørn this morning, it seems like a case where it would be possible to do in theory, as the Bluetooth Core spec. doesn&amp;#39;t specifically not allow it, but in practice I don&amp;#39;t see how it will be possible on Android, since you would need the scanner to use a public or random static address for this to work, but since the Android device will rotate the MAC address every 15 minutes, I don&amp;#39;t see how this can be achieved. We have ended up on the stance that this is not something that&amp;#39;s supported in&amp;nbsp;our SDKs without doing bonding.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Directed advertising to Android phone without bonding</title><link>https://devzone.nordicsemi.com/thread/474354?ContentTypeID=1</link><pubDate>Mon, 18 Mar 2024 13:50:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25a57a68-474c-4a39-bc30-dd2559935562</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Derek&lt;/p&gt;
&lt;p&gt;On a second look it seems like this might not be possible. I&amp;#39;ll keep looking into it and come back to you when I know for sure, but I need some more time to dive into it and discuss it internally. I&amp;#39;ll get back to you later this week with more info.&lt;/p&gt;
&lt;p&gt;Thank you for your patience.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Directed advertising to Android phone without bonding</title><link>https://devzone.nordicsemi.com/thread/473981?ContentTypeID=1</link><pubDate>Thu, 14 Mar 2024 21:52:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c59db91-9a30-4f73-8aff-f0123a367a09</guid><dc:creator>droberson</dc:creator><description>&lt;p&gt;Hey Simon,&lt;/p&gt;
&lt;p&gt;No worries, thanks for the reply.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="75734" url="~/f/nordic-q-a/108920/directed-advertising-to-android-phone-without-bonding/473866"]but you need to get the IRK shared somehow to the Android[/quote]
&lt;p&gt;Why does the Android phone need the IRK of the Peripheral device if the Peripheral uses a BLE address type of&amp;nbsp;&lt;span&gt;BLE_GAP_ADDR_TYPE_RANDOM_STATIC? I thought only the Peripheral needed the IRK of the Android phone?&lt;/span&gt;&lt;/p&gt;
[quote userid="75734" url="~/f/nordic-q-a/108920/directed-advertising-to-android-phone-without-bonding/473866"]&lt;p&gt;We have a couple of discussions on this in the DevZone already:&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/44471/advertising-to-pre-shared-irk"&gt;Advertising to pre-shared IRK&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/43054/direct-advertising-with-unbonded-android-phone-s-irk/168963"&gt;Direct advertising with unbonded Android phone&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;[/quote]
&lt;p&gt;I reviewed both of the posts you linked. The post&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/44471/advertising-to-pre-shared-irk"&gt;Advertising to pre-shared IRK&lt;/a&gt;&amp;nbsp;never resulted in a conclusion, and the original poster was new to C, thus making his effort much more difficult, which he never achieved the desired outcome.&lt;/p&gt;
&lt;p&gt;The post&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/43054/direct-advertising-with-unbonded-android-phone-s-irk/168963"&gt;Direct advertising with unbonded Android phone&lt;/a&gt;&amp;nbsp;resulted in the following comment from FAE &lt;span&gt;Torbj&amp;oslash;rn&lt;/span&gt;:&lt;/p&gt;
&lt;p&gt;--------------------------------&lt;/p&gt;
&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The problem in this case is that the directed advertising packet will not be reported to the application as a normal advertising packet, so the phone would have to know about the device in some other way.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This is outside our control since it is handled by the Bluetooth stack in the phone.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbj&amp;oslash;rn&lt;/p&gt;
&lt;p&gt;&lt;span&gt;--------------------------------&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Based on&amp;nbsp;Torbj&amp;oslash;rn&amp;#39;s response, it doesn&amp;#39;t seem advertising to an Android phone with a pre-shared IRK is possible. Yet, Susheel and you say it is possible? Which is the case?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have directed advertising working fine without an IRK. Without IRK, my code is as follows:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;// Start advertising
ble_advertising_start(&amp;amp;m_advertising, BLE_ADV_MODE_DIRECTED);

...
This results in event BLE_ADV_EVT_PEER_ADDR_REQUEST
...

case BLE_ADV_EVT_PEER_ADDR_REQUEST:
{
   // This event occurs when directed advertising is used
   Log(BLE, &amp;quot;BLE_ADV_EVT_PEER_ADDR_REQUEST&amp;quot;);
   
   ret_code_t retCode;
   uint8_t mac[BLE_GAP_ADDR_LEN] = {0xEE, 0xA5, 0x86, 0x7E, 0xE2, 0x3A};
   ble_gap_addr_t peerAddr;

   // Set GAP structure
   peerAddr.addr_id_peer = 0;
   peerAddr.addr_type = BLE_GAP_ADDR_TYPE_RANDOM_STATIC;
   
   // Copy in MAC but reverse byte order to match GAP address type
   rev_memcpy(peerAddr.addr, mac, sizeof(peerAddr.addr));
   
   retCode = ble_advertising_peer_addr_reply(&amp;amp;m_advertising, &amp;amp;peerAddr);
   APP_ERROR_CHECK(retCode);
   
   break;
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&amp;nbsp;Here is a Wireshark capture of my working directed advertising with a random static address (No IRK).&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1710453853588v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Using the above working code as a template and&amp;nbsp;&amp;quot;Variant #1&amp;quot; in this bounce diagram:&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v3.0.0%2Fgroup___b_l_e___g_a_p___p_r_i_v_a_c_y___a_d_v___d_i_r___p_r_i_v___m_s_c.html&amp;amp;cp=2_3_0_1_1_2_1_3_9_1"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v3.0.0%2Fgroup___b_l_e___g_a_p___p_r_i_v_a_c_y___a_d_v___d_i_r___p_r_i_v___m_s_c.html&amp;amp;cp=2_3_0_1_1_2_1_3_9_1&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;My IRK define and BLE_ADV_EVT_PEER_ADDR_REQUEST handler now looks like this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;// Global constants for testing
const ble_gap_id_key_t m_peer1 = 
{
    .id_info =
    {
        // Android phone IRK
        .irk = {0x57, 0x5E, 0xA8, 0xBB, 0x22, 0x20, 0xB4, 0x47, 0xF4, 0xFF, 0xF1, 0x55, 0xE6, 0xCE, 0x02, 0xF1},
    }
};

const ble_gap_id_key_t * m_identities[] = {&amp;amp;m_peer1};

case BLE_ADV_EVT_PEER_ADDR_REQUEST:
{
   uint8_t mac[BLE_GAP_ADDR_LEN] = {0xEE, 0xA5, 0x86, 0x7E, 0xE2, 0x3A}; // Android Phone MAC
   ble_gap_addr_t peerAddr;
   
   // Set IRK so we can use directed advertising with an Android phone that uses a
   // private random resolvable address.
   retCode = sd_ble_gap_device_identities_set(m_identities, NULL, 1);
   APP_ERROR_CHECK(retCode);

   // Set GAP structure
   peerAddr.addr_id_peer = 0;
   peerAddr.addr_type = BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE;
   
   // Copy in MAC but reverse byte order to match GAP address type
   rev_memcpy(peerAddr.addr, mac, sizeof(peerAddr.addr));
   
   retCode = ble_advertising_peer_addr_reply(&amp;amp;m_advertising, &amp;amp;peerAddr);
   APP_ERROR_CHECK(retCode);
   
   break;
}&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When I attempt to advertise with&amp;nbsp;ble_advertising_start(&amp;amp;m_advertising, BLE_ADV_MODE_DIRECTED), this function returns error code 0x3202 which I understand to be&amp;nbsp;BLE_ERROR_GAP_INVALID_BLE_ADDR and the device does not advertise at all.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What am I doing wrong?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Derek&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Directed advertising to Android phone without bonding</title><link>https://devzone.nordicsemi.com/thread/473866?ContentTypeID=1</link><pubDate>Thu, 14 Mar 2024 13:00:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f7a3cbef-46e5-4f9f-98fe-9fb51245c95c</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Derek&lt;/p&gt;
&lt;p&gt;Susheel is out of office, so I have been assigned to this case while he&amp;#39;s away. it took a while to get through his cases, so sorry about the delay.&lt;/p&gt;
&lt;p&gt;Yes, directed advertising should be possible to do like this, but you need to get the IRK shared somehow to the Android, and the &amp;quot;normal/sensible&amp;quot; way to do so would be by bonding, which is what I would suggest. How you get the IRK on the Android without bonding will need to be handled by you though. We have a couple of discussions on this in the DevZone already:&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/44471/advertising-to-pre-shared-irk"&gt;Advertising to pre-shared IRK&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/43054/direct-advertising-with-unbonded-android-phone-s-irk/168963"&gt;Direct advertising with unbonded Android phone&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Directed advertising to Android phone without bonding</title><link>https://devzone.nordicsemi.com/thread/473285?ContentTypeID=1</link><pubDate>Mon, 11 Mar 2024 17:17:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:abdb9ed4-b075-4860-9aee-d4141f0a4ef2</guid><dc:creator>droberson</dc:creator><description>&lt;p&gt;Susheel,&lt;/p&gt;
&lt;p&gt;No worries, thanks for the reply. I already have the IRK from the phone I am trying to directly advertise to.&lt;/p&gt;
[quote userid="6207" url="~/f/nordic-q-a/108920/directed-advertising-to-android-phone-without-bonding/473263"]Once you get it and save it, you can use it to&lt;a href="https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/lessons/lesson-2-bluetooth-le-advertising/topic/bluetooth-address/"&gt; check that the new device address&lt;/a&gt; used by Android phone is generated by the same IRK or not. You only send directed advertising to devices that pass this translation.[/quote]
&lt;p&gt;I am not sure what you mean by this. &amp;quot;You can use it to check that the new device address&amp;quot; sounds like the Peripheral needs to listen to scan requests from all Centrals. In order to do this, the Peripheral would need to advertise to all Centrals, which&amp;nbsp;defeats the purpose of what I want to achieve (direct advertising).&lt;/p&gt;
&lt;p&gt;To summarize and clarify my original post, I want to directly advertise to an Android phone 100% of the time unless connected to the phone. Is this possible so long as the Peripheral device knows the Android phone&amp;#39;s IRK?&lt;/p&gt;
&lt;p&gt;To me, this doesn&amp;#39;t seem possible because the Android phone rotates it&amp;#39;s MAC every 15 minutes or so, hence why I am looking for a definitive answer.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Derek&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Directed advertising to Android phone without bonding</title><link>https://devzone.nordicsemi.com/thread/473263?ContentTypeID=1</link><pubDate>Mon, 11 Mar 2024 15:32:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c9b4219-028a-424c-9257-2c99faafe53d</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Derek,&lt;/p&gt;
&lt;p&gt;Sorry for delays, I was stuck in something else and did not manage to unplug from it. Thanks for being nice and patient. Really appreciate it.&amp;nbsp;&lt;/p&gt;
[quote user="droberson"]You cannot perform whitelisting and directed advertising at the same time, so how&amp;nbsp;does whitelisting apply to question #2?[/quote]
&lt;p&gt;Yes, sorry, Whitelisting cannot be used with directed advertising as it is assumed that you already know which device you want to communicate with.&lt;/p&gt;
&lt;p&gt;If you know that you want to connect to some Android phone, then you need to first connect and pair with it atleast once so that the Android phone can share its IRK with your device. Once you get it and save it, you can use it to&lt;a href="https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/lessons/lesson-2-bluetooth-le-advertising/topic/bluetooth-address/"&gt; check that the new device address&lt;/a&gt; used by Android phone is generated by the same IRK or not. You only send directed advertising to devices that pass this translation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Directed advertising to Android phone without bonding</title><link>https://devzone.nordicsemi.com/thread/472842?ContentTypeID=1</link><pubDate>Fri, 08 Mar 2024 01:55:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb140ca2-2c95-40af-8555-6b7200df4f6e</guid><dc:creator>droberson</dc:creator><description>&lt;p&gt;Any update &lt;a href="https://devzone.nordicsemi.com/members/aryan"&gt;Susheel Nuguru&lt;/a&gt;&amp;nbsp;&amp;nbsp;?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Derek&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Directed advertising to Android phone without bonding</title><link>https://devzone.nordicsemi.com/thread/472568?ContentTypeID=1</link><pubDate>Wed, 06 Mar 2024 18:35:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1af57b98-845b-46de-abac-6aa17d87caa0</guid><dc:creator>droberson</dc:creator><description>&lt;p&gt;Hey Susheel,&lt;/p&gt;
&lt;p&gt;Thanks for the reply.&lt;/p&gt;
[quote userid="6207" url="~/f/nordic-q-a/108920/directed-advertising-to-android-phone-without-bonding/472467"]Yes, This is how many customers/products have done it aswell. but that was on the older SDK, I need to dig a bit to find how to do this in nRF connect SDK.[/quote]
&lt;p&gt;I am not using nRF Connect SDK. Per the &lt;em&gt;Software&lt;/em&gt; section at the beginning of my post, I am using SDK15.2.&lt;/p&gt;
[quote userid="6207" url="~/f/nordic-q-a/108920/directed-advertising-to-android-phone-without-bonding/472467"]Again using whitelisting on IRK seems to be the solution here, as IRK wont change over time.[/quote]
&lt;p&gt;You cannot perform whitelisting and directed advertising at the same time, so how&amp;nbsp;does whitelisting apply to question #2?&lt;/p&gt;
&lt;p&gt;Source:&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/99937/whitelisting-and-directed-advertising-simultaneously"&gt;Whitelisting and Directed Advertising Simultaneously&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Derek&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Directed advertising to Android phone without bonding</title><link>https://devzone.nordicsemi.com/thread/472467?ContentTypeID=1</link><pubDate>Wed, 06 Mar 2024 13:04:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f124372-ec84-4b05-9e93-20da9edfbe0c</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user=""]Is it possible for a nRF52840 to directly advertise (and connect) to an Android phone with a pre-shared IRK without bonding to it as proposed above?[/quote]
&lt;p&gt;Yes, This is how many customers/products have done it aswell. but that was on the older SDK, I need to dig a bit to find how to do this in nRF connect SDK.&lt;/p&gt;
[quote user=""]How does the Peripheral know what BLE MAC to insert into the direct advertising packet if the Android phone changes its MAC every 15 minutes?[/quote]
&lt;p&gt;Again using whitelisting on IRK seems to be the solution here, as IRK wont change over time.&lt;/p&gt;
[quote user=""]As far as I know, the IRK stays the same for the life of the phone. Please correct me if I am wrong.[/quote]
&lt;p&gt;You are right.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>