<?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>sdk 12.2 Migration Peer Manager Bonding/Pairing</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/21235/sdk-12-2-migration-peer-manager-bonding-pairing</link><description>Hello, 
 I have just migrated my project from sdk 9 to sdk 12.2....and of course from Device Manager to Peer manager. My initial project which was built off of the sdk 9 hrs peripheral example, successfully pairs with IOS and Android, uses whitelists</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 18 Apr 2017 11:35:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/21235/sdk-12-2-migration-peer-manager-bonding-pairing" /><item><title>RE: sdk 12.2 Migration Peer Manager Bonding/Pairing</title><link>https://devzone.nordicsemi.com/thread/83079?ContentTypeID=1</link><pubDate>Tue, 18 Apr 2017 11:35:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0bb7f94e-52b5-40a8-a7d2-707499b042c4</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Sorry for the late reply, we have had Easter vacation here in Norway. I got the files, and sent you a reply.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sdk 12.2 Migration Peer Manager Bonding/Pairing</title><link>https://devzone.nordicsemi.com/thread/83086?ContentTypeID=1</link><pubDate>Mon, 17 Apr 2017 18:16:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29f13693-3420-4ccc-81f8-20bbeb7c4379</guid><dc:creator>eq</dc:creator><description>&lt;p&gt;BTW we are using S130 Soft Device&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sdk 12.2 Migration Peer Manager Bonding/Pairing</title><link>https://devzone.nordicsemi.com/thread/83085?ContentTypeID=1</link><pubDate>Mon, 17 Apr 2017 15:20:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4cd9bdd-0465-4b17-9b17-d393e7b274d8</guid><dc:creator>eq</dc:creator><description>&lt;p&gt;Hi Peter, any update on this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sdk 12.2 Migration Peer Manager Bonding/Pairing</title><link>https://devzone.nordicsemi.com/thread/83083?ContentTypeID=1</link><pubDate>Sat, 15 Apr 2017 16:16:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25f89222-ce50-44ee-a6e3-e6f1953cc671</guid><dc:creator>eq</dc:creator><description>&lt;p&gt;Hi Peter, checking to see if you got the files I uploaded onto MyPage.  Thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sdk 12.2 Migration Peer Manager Bonding/Pairing</title><link>https://devzone.nordicsemi.com/thread/83080?ContentTypeID=1</link><pubDate>Tue, 11 Apr 2017 19:59:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60ec42cb-73b8-4d24-87ac-72296b985789</guid><dc:creator>eq</dc:creator><description>&lt;p&gt;Thank you Peter.  I have uploaded the Project on MyPage.  The Case #: Case ID	35736&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sdk 12.2 Migration Peer Manager Bonding/Pairing</title><link>https://devzone.nordicsemi.com/thread/83082?ContentTypeID=1</link><pubDate>Tue, 11 Apr 2017 14:43:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc55a9bf-74bf-41ad-a980-34eb275c2c03</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Ok. That&amp;#39;s unexpected. Would it be possible to share your complete project so I can try to reproduce here? You can share it privately through your MyPage at nordicsemi.com as well. Please include what SoftDevice version you are using as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sdk 12.2 Migration Peer Manager Bonding/Pairing</title><link>https://devzone.nordicsemi.com/thread/83081?ContentTypeID=1</link><pubDate>Tue, 11 Apr 2017 00:21:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5be352e-5d1b-4600-9eed-f50344b79748</guid><dc:creator>eq</dc:creator><description>&lt;p&gt;Hello, yes I used the example that you referenced to do the port over to 12.2.  I have it all working EXCEPT i cannot connect when I Encrypt the Write Characteristic.  This was all working when I was on SDK 9.&lt;/p&gt;
&lt;p&gt;This is the code where I encrypt the characteristics:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/**@brief Function for adding the get_from_app characteristic.
 *
 */
static uint32_t get_from_app_char_add(ble_qiqi_t * p_qiqi, const ble_qiqi_init_t * p_qiqi_init)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_md_t cccd_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;

    memset(&amp;amp;cccd_md, 0, sizeof(cccd_md));

#ifdef CHAR_ENCRYPT
    //BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(&amp;amp;cccd_md.read_perm);
    //BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(&amp;amp;cccd_md.write_perm);

    BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&amp;amp;cccd_md.write_perm); // This works with iPhone 5/5/2016

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;cccd_md.read_perm);
    //BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;cccd_md.write_perm);
#else
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;cccd_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;cccd_md.write_perm);
#endif

    cccd_md.vloc = BLE_GATTS_VLOC_STACK;
    
    memset(&amp;amp;char_md, 0, sizeof(char_md));
    
    char_md.char_props.read   = 1;
    char_md.char_props.notify = 1;
    char_md.p_char_user_desc  = NULL;
    char_md.p_char_pf         = NULL;
    char_md.p_user_desc_md    = NULL;
    char_md.p_cccd_md         = &amp;amp;cccd_md;
    char_md.p_sccd_md         = NULL;
    
    ble_uuid.type = p_qiqi-&amp;gt;uuid_type;
    ble_uuid.uuid = QIQI_UUID_GET_CHAR;
    
    memset(&amp;amp;attr_md, 0, sizeof(attr_md));

#ifdef CHAR_ENCRYPT
    //BLE_GAP_CONN_SEC_MODE_SET_SIGNED_WITH_MITM(&amp;amp;attr_md.read_perm);
    //BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(&amp;amp;attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(&amp;amp;attr_md.write_perm);  // This works with the iPhone 5/5/2016
    //BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&amp;amp;attr_md.read_perm);

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;attr_md.read_perm);
    //BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&amp;amp;attr_md.write_perm);
#else
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&amp;amp;attr_md.write_perm);
#endif

    attr_md.vloc       = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth    = 0;
    attr_md.wr_auth    = 0;
    attr_md.vlen       = 1;
    
    memset(&amp;amp;attr_char_value, 0, sizeof(attr_char_value));

    attr_char_value.p_uuid       = &amp;amp;ble_uuid;
    attr_char_value.p_attr_md    = &amp;amp;attr_md;
    attr_char_value.init_len     = 20;//sizeof(uint8_t);
    attr_char_value.init_offs    = 0;
    attr_char_value.max_len      = 100;
    attr_char_value.p_value      = NULL;
    
    return sd_ble_gatts_characteristic_add(p_qiqi-&amp;gt;service_handle, &amp;amp;char_md,
                                               &amp;amp;attr_char_value,
                                               &amp;amp;p_qiqi-&amp;gt;get_from_app_char_handles);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;When CHAR_ENCRYPT is defined the Central (iPhone and Android) breiefly connect, and then the application crashes and restarts.  I feel like there is more to do in pm_evt_handler, but not sure what.  Here is my pm_evt_handler:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void pm_evt_handler(pm_evt_t const * p_evt)
{
    ret_code_t err_code;

    switch (p_evt-&amp;gt;evt_id)
    {
        case PM_EVT_BONDED_PEER_CONNECTED:
        {
            //NRF_LOG_INFO(&amp;quot;Connected to a previously bonded device.\r\n&amp;quot;);
        } break;

        case PM_EVT_CONN_SEC_SUCCEEDED:
        {/*
            NRF_LOG_INFO(&amp;quot;Connection secured. Role: %d. conn_handle: %d, Procedure: %d\r\n&amp;quot;,
                         ble_conn_state_role(p_evt-&amp;gt;conn_handle),
                         p_evt-&amp;gt;conn_handle,
                         p_evt-&amp;gt;params.conn_sec_succeeded.procedure);
                         */
        } break;

        case PM_EVT_CONN_SEC_FAILED:
        {
            /* Often, when securing fails, it shouldn&amp;#39;t be restarted, for security reasons.
             * Other times, it can be restarted directly.
             * Sometimes it can be restarted, but only after changing some Security Parameters.
             * Sometimes, it cannot be restarted until the link is disconnected and reconnected.
             * Sometimes it is impossible, to secure the link, or the peer device does not support it.
             * How to handle this error is highly application dependent. */
        } break;

        case PM_EVT_CONN_SEC_CONFIG_REQ:
        {
            // Reject pairing request from an already bonded peer.
            pm_conn_sec_config_t conn_sec_config = {.allow_repairing = false};
            pm_conn_sec_config_reply(p_evt-&amp;gt;conn_handle, &amp;amp;conn_sec_config);
        } break;

        case PM_EVT_STORAGE_FULL:
        {
            // Run garbage collection on the flash.
            err_code = fds_gc();
            if (err_code == FDS_ERR_BUSY || err_code == FDS_ERR_NO_SPACE_IN_QUEUES)
            {
                // Retry.
            }
            else
            {
                APP_ERROR_CHECK(err_code);
            }
        } break;

        case PM_EVT_PEERS_DELETE_SUCCEEDED:
        {
            advertising_start();
        } break;

        case PM_EVT_LOCAL_DB_CACHE_APPLY_FAILED:
        {
            // The local database has likely changed, send service changed indications.
            pm_local_database_has_changed();
        } break;

        case PM_EVT_PEER_DATA_UPDATE_FAILED:
        {
            // Assert.
            APP_ERROR_CHECK(p_evt-&amp;gt;params.peer_data_update_failed.error);
        } break;

        case PM_EVT_PEER_DELETE_FAILED:
        {
            // Assert.
            APP_ERROR_CHECK(p_evt-&amp;gt;params.peer_delete_failed.error);
        } break;

        case PM_EVT_PEERS_DELETE_FAILED:
        {
            // Assert.
            APP_ERROR_CHECK(p_evt-&amp;gt;params.peers_delete_failed_evt.error);
        } break;

        case PM_EVT_ERROR_UNEXPECTED:
        {
            // Assert.
            APP_ERROR_CHECK(p_evt-&amp;gt;params.error_unexpected.error);
        } break;

        case PM_EVT_CONN_SEC_START:
        case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED:
        case PM_EVT_PEER_DELETE_SUCCEEDED:
        case PM_EVT_LOCAL_DB_CACHE_APPLIED:
        case PM_EVT_SERVICE_CHANGED_IND_SENT:
        case PM_EVT_SERVICE_CHANGED_IND_CONFIRMED:
        default:
            break;
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sdk 12.2 Migration Peer Manager Bonding/Pairing</title><link>https://devzone.nordicsemi.com/thread/83084?ContentTypeID=1</link><pubDate>Mon, 10 Apr 2017 11:58:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ed57c8e-ca04-4788-85b6-0210b2fcdaab</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Have you followed &lt;a href="https://devzone.nordicsemi.com/tutorials/24/"&gt;this&lt;/a&gt; to migrate to Peer Manager? Most examples in the SDK uses Peer Manager. You can have a look at ble_app_hrs for example. For whitelisting you can have a look at ble_app_hids_keyboard.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>