This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Unable to connect peripheral with Peer Manager

Hi

I'm testing the Peer Manager as a replacement for the currently used device manger. I ported out code to use of the peer manager. I can see the peripheral advertising, but when i try to connect with the iOS LightBlue app the connection is terminated after a few seconds. I first thought it may be something wrong with my code, but after having the same issues with the example from the SDK i'm not sure if it's not something else.

Steps to reproduce:

  • Open the example "ble_app_hrs_rscs_relay" (arm5 no packs) from the SDK10
  • Run it on a nRF51 DK with only SD130 programed
  • Try to connect with the LightBlue App from an iOS device

Anyone using the peer manger with success? A bugfix known for this behavior?

Regards Adrian

Parents
  • Hey!

    It is a minor bug in the peer manager. Keep in mind that this module is experimental for now.

    You were correct about the BLE_ERROR_GATTS_SYS_ATTR_MISSING event causing this issue. The functions handling this event had a logical error.

    The fix: In "nRF51_SDK_10.0.0\components\ble\peer_manager\gatts_cache_manager.c", comment out lines 206-209.

    //if (peer_id == PM_PEER_ID_INVALID)
       // {
          //  return BLE_ERROR_INVALID_CONN_HANDLE;
        //}
    

    and add checks around

    err_code = pdb_read_buf_get(peer_id, PM_PEER_DATA_ID_GATT_LOCAL, &peer_data, NULL);
    if (err_code == NRF_SUCCESS)
    {
        pm_peer_data_local_gatt_db_flash_t const * p_local_gatt_db = peer_data.data.p_local_gatt_db;
        p_sys_attr_data                                            = p_local_gatt_db->p_data;
        sys_attr_len                                               = p_local_gatt_db->len;
        sys_attr_flags                                             = p_local_gatt_db->flags;
    }
    

    like this

    if (peer_id != PM_PEER_ID_INVALID)
    {
        err_code = pdb_read_buf_get(peer_id, PM_PEER_DATA_ID_GATT_LOCAL, &peer_data, NULL);
        if (err_code == NRF_SUCCESS)
        {
            pm_peer_data_local_gatt_db_flash_t const * p_local_gatt_db = peer_data.data.p_local_gatt_db;
            p_sys_attr_data                                            = p_local_gatt_db->p_data;
            sys_attr_len                                               = p_local_gatt_db->len;
            sys_attr_flags                                             = p_local_gatt_db->flags;
        }
    }
    

    I hope this solves your problem

Reply
  • Hey!

    It is a minor bug in the peer manager. Keep in mind that this module is experimental for now.

    You were correct about the BLE_ERROR_GATTS_SYS_ATTR_MISSING event causing this issue. The functions handling this event had a logical error.

    The fix: In "nRF51_SDK_10.0.0\components\ble\peer_manager\gatts_cache_manager.c", comment out lines 206-209.

    //if (peer_id == PM_PEER_ID_INVALID)
       // {
          //  return BLE_ERROR_INVALID_CONN_HANDLE;
        //}
    

    and add checks around

    err_code = pdb_read_buf_get(peer_id, PM_PEER_DATA_ID_GATT_LOCAL, &peer_data, NULL);
    if (err_code == NRF_SUCCESS)
    {
        pm_peer_data_local_gatt_db_flash_t const * p_local_gatt_db = peer_data.data.p_local_gatt_db;
        p_sys_attr_data                                            = p_local_gatt_db->p_data;
        sys_attr_len                                               = p_local_gatt_db->len;
        sys_attr_flags                                             = p_local_gatt_db->flags;
    }
    

    like this

    if (peer_id != PM_PEER_ID_INVALID)
    {
        err_code = pdb_read_buf_get(peer_id, PM_PEER_DATA_ID_GATT_LOCAL, &peer_data, NULL);
        if (err_code == NRF_SUCCESS)
        {
            pm_peer_data_local_gatt_db_flash_t const * p_local_gatt_db = peer_data.data.p_local_gatt_db;
            p_sys_attr_data                                            = p_local_gatt_db->p_data;
            sys_attr_len                                               = p_local_gatt_db->len;
            sys_attr_flags                                             = p_local_gatt_db->flags;
        }
    }
    

    I hope this solves your problem

Children
Related