<?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>Get the list of Bonded devices in the peer manager</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/124812/get-the-list-of-bonded-devices-in-the-peer-manager</link><description>Hello, I am using nrf52832 along with S132 soft device and SDK 17.1.0. 
 
 Can you please provide me the peer manager api that can list the paired/bonded devices? Also, is there a way I can get the mac address and LTK key associated with each paired device</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 08 Oct 2025 12:41:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/124812/get-the-list-of-bonded-devices-in-the-peer-manager" /><item><title>RE: Get the list of Bonded devices in the peer manager</title><link>https://devzone.nordicsemi.com/thread/550899?ContentTypeID=1</link><pubDate>Wed, 08 Oct 2025 12:41:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9557c31c-4e0c-4d76-b52b-7ffa39fbc719</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The peer manager was written a good while ago and I am not sure why&amp;nbsp;the choises was made to organize the data as it is. But it is likely related to that the type of information sent from central to peripheral and peripheral to central differs from LESC and legacy pairing (you can see the details in&amp;nbsp;BLUETOOTH CORE SPECIFICATION Version 6.1 | Vol 3, Part H). Also, from page 312 you can get an overview (the right most for BR/EDR is not relevant for BLE):&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1759927250805v1.png" alt=" " /&gt;&lt;/p&gt;
[quote user="johnmjustin"]Does it mean that during pairing this key gets transferred over the air to the central device?[/quote]
&lt;p&gt;No, when using LESC no keys are transmitted in clear and there is no way for an evesdropper to calculate the key as a&amp;nbsp;Diffie–Hellman key exchange. However, for legacy pairing it is possible to eavesdrop on the pairing process, which makes legacy pairing insecure.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get the list of Bonded devices in the peer manager</title><link>https://devzone.nordicsemi.com/thread/550851?ContentTypeID=1</link><pubDate>Tue, 07 Oct 2025 22:37:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc8d6378-bf4b-487b-bfb6-1a50364f18d9</guid><dc:creator>Justin</dc:creator><description>&lt;p&gt;Hi Einar, thank you very much for pointing me out to the API.&lt;/p&gt;
&lt;p&gt;I am able to read the mac address and the key.&lt;/p&gt;
&lt;p&gt;I have a question related to the key.&lt;/p&gt;
&lt;p&gt;What is the difference between peer_ltk and own_ltk in this structure?&lt;/p&gt;
&lt;p&gt;typedef struct&lt;br /&gt; {&lt;br /&gt; uint8_t own_role; /**&amp;lt; @brief The BLE role of the local device during bonding. See @ref BLE_GAP_ROLES. */&lt;br /&gt; ble_gap_id_key_t peer_ble_id; /**&amp;lt; @brief The peer&amp;#39;s Bluetooth address and identity resolution key (IRK). */&lt;br /&gt; ble_gap_enc_key_t peer_ltk; /**&amp;lt; @brief The peer&amp;#39;s long-term encryption key (LTK) and master ID. */&lt;br /&gt; ble_gap_enc_key_t own_ltk; /**&amp;lt; @brief Locally generated long-term encryption key (LTK) and master ID, distributed to the peer. */&lt;br /&gt; } pm_peer_data_bonding_t;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I am able to see the&amp;nbsp; the key in own_ltk but peer_ltk is empty.&lt;/p&gt;
&lt;p&gt;My device is a peripheral device and I am using JustWorks for pairing with LESC turned on.&lt;br /&gt;&lt;br /&gt;The description in the own_ltk says that t&lt;span&gt;Locally generated long-term encryption key (LTK) and master ID, distributed to the peer.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Does it mean that during pairing this key gets transferred over the air to the central device?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get the list of Bonded devices in the peer manager</title><link>https://devzone.nordicsemi.com/thread/550776?ContentTypeID=1</link><pubDate>Tue, 07 Oct 2025 08:29:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04bb0950-b2d0-4552-af11-f04bc46e8ad0</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The Peer manager has API functions for iterating over the list of bonded peers. You use something like this (which is used in different variations in several SDK examples, like here from examples/ble_central/ble_app_rscs_c/main.c):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void peer_list_get(pm_peer_id_t * p_peers, uint32_t * p_size)
{
    pm_peer_id_t peer_id;
    uint32_t     peers_to_copy;

    peers_to_copy = (*p_size &amp;lt; BLE_GAP_WHITELIST_ADDR_MAX_COUNT) ?
                     *p_size : BLE_GAP_WHITELIST_ADDR_MAX_COUNT;

    peer_id = pm_next_peer_id_get(PM_PEER_ID_INVALID);
    *p_size = 0;

    while ((peer_id != PM_PEER_ID_INVALID) &amp;amp;&amp;amp; (peers_to_copy--))
    {
        p_peers[(*p_size)++] = peer_id;
        peer_id = pm_next_peer_id_get(peer_id);
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Note that as this specific example is used for whitelisting where there is a limit of 8 that is checked, but you can remove that limitation if you want o iterate over all bonded devices.&lt;/p&gt;
&lt;p&gt;There is no public API designed to give applications access to the LTK, but you can go into the internal data for the peer manager for each peer and read it. This will requier some tinkering, but you can look at&amp;nbsp;pds_peer_data_read() for how to read the peer data, which is an&amp;nbsp;pm_peer_data_t instance, and then digg furhter down into the linked&amp;nbsp;pm_peer_data_bonding_t which has the LTK and peer address.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>