<?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>Switching keyboard/mouse between 3 paired devices</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/37369/switching-keyboard-mouse-between-3-paired-devices</link><description>I need to switch between 3 central devices (device slots, rather) with a peer manager and SDK 12.3.0 (nrf51822-based keyboard, see sdk12_3 branch for a peer manager https://github.com/joric/mitosis/tree/devel ). Can anyone tell me how to do that properly</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 14 Aug 2018 13:59:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/37369/switching-keyboard-mouse-between-3-paired-devices" /><item><title>RE: Switching keyboard/mouse between 3 paired devices</title><link>https://devzone.nordicsemi.com/thread/144206?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2018 13:59:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa4f76df-e94a-45c2-a083-80ec371a790c</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;That is the correct api you&amp;nbsp;can&amp;nbsp; use to bond with a new central yes.&lt;/p&gt;
&lt;p&gt;-Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Switching keyboard/mouse between 3 paired devices</title><link>https://devzone.nordicsemi.com/thread/144120?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2018 09:42:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc191abf-f605-4223-918c-53429c7f10b5</guid><dc:creator>joric</dc:creator><description>&lt;p&gt;OK I think&amp;nbsp;ble_advertising_restart_without_whitelist() worked. I&amp;#39;ll test it and maybe post full solution then.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Switching keyboard/mouse between 3 paired devices</title><link>https://devzone.nordicsemi.com/thread/144112?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2018 09:14:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c02d9144-b7aa-48bf-8653-8e646d97c92f</guid><dc:creator>joric</dc:creator><description>&lt;p&gt;I didn&amp;#39;t quite get the thing the the address. I can change the address, but how do I advertise to a second peer when I already have one bonded peer? Should I advertise with an empty whitelist or something?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Switching keyboard/mouse between 3 paired devices</title><link>https://devzone.nordicsemi.com/thread/143932?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2018 11:56:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a4dc57d-8660-4581-8a15-2a2ff267e06f</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I guess&amp;nbsp; there are difference ways of doing this, but the simplest may be to just control the GAP address for the peripheral device before starting to advertise:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    ble_gap_addr_t gap_addr;
    err_code = sd_ble_gap_addr_get(&amp;amp;gap_addr);
    APP_ERROR_CHECK(err_code);
        
    gap_addr.addr[3] = 1; // switch status 1, 2, or 3
    
    err_code = sd_ble_gap_addr_set(&amp;amp;gap_addr);
    APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;That way the peripheral device will appear as a new peripheral device depending on the&amp;nbsp;current GAP&amp;nbsp;address, and only the specific central that have bonded with the current GAP address will connect to it.&lt;/p&gt;
&lt;p&gt;The next problem you will face is to know which old bond you should delete if you pair with a new central. This may be solved by storing the state of the switch (or GAP address)&amp;nbsp;after successful bonding by calling something like:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;                uint16_t length = 8; 
                uint8_t addr[8];
                
                for(uint8_t i=0; i&amp;lt;BLE_GAP_ADDR_LEN; i++)
                    addr[i] = gap_addr.addr[i];
                
                err_code = pm_peer_data_app_data_store(m_peer_id,addr,length,NULL);
                APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;To retrieve saved states of the switch (or GAP address) later you can call&amp;nbsp;pm_peer_data_bonding_load()&amp;nbsp;followed by pm_peer_delete() to delete a specific bond. You should look at the implementation of&amp;nbsp;peer_list_get() on how to cycle through bonds (bonded peer id&amp;#39;s). E.g.:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void peer_list_find_and_delete_bonds(void)
{
    pm_peer_id_t peer_id;

    peer_id = pm_next_peer_id_get(PM_PEER_ID_INVALID);

    while (peer_id != PM_PEER_ID_INVALID)
    {
        // Call pm_peer_data_app_data_load()
        // Check stored switch (or GAP address)
        // if previously bonded you can call pm_peer_delete()
        
        peer_id = pm_next_peer_id_get(peer_id);
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>