GATT CONN TERMINATE LOCAL HOST occurs when bonding with Android

Hello.

I am developing using nrf52832 (S132 v7.0.1, SDK v17.0.0).

Since I want to bond with Android, I have created a central code that summarizes the functions that I think are necessary by referring to various sample sources.
On Android, a pairing request is displayed, but when I press connect, it becomes GATT CONN TERMINATE LOCAL HOST and I cannot bond.
Does anyone know how to deal with it?

I can't use nRF Sniffer because I don't have two boards.

Best regards.

Parents
  • Have you included the pm_evt_handler() function and peer manager library files in your project in order to include and add bonding to your project? Just setting the SEC_PARAM_BOND to 1 won't be sufficient in a project that hasn't implemented the peer manager at all.

    Best regards,

    Simon

  • 0
    71 pts.
    in reply to Simonr

    Hello.

    I have included the peer manager and pm_evt_handler () in my project with the code settings below. Is there anything else I need?

    #define SEC_PARAM_BOND            1                                /**< Perform bonding. */
    #define SEC_PARAM_MITM            0                                /**< Man In The Middle protection not required. */
    #define SEC_PARAM_LESC            1                                /**< LE Secure Connections not enabled. */
    #define SEC_PARAM_KEYPRESS        0                                /**< Keypress notifications not enabled. */
    #define SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_NONE             /**< No I/O capabilities. */
    #define SEC_PARAM_OOB             0                                /**< Out Of Band data not available. */
    #define SEC_PARAM_MIN_KEY_SIZE    7                                /**< Minimum encryption key size. */
    #define SEC_PARAM_MAX_KEY_SIZE    16                               /**< Maximum encryption key size. */
    
    static void peer_manager_init(void)
    {
        ble_gap_sec_params_t sec_param;
        ret_code_t err_code;
    
        err_code = pm_init();
        APP_ERROR_CHECK(err_code);
    
        memset(&sec_param, 0, sizeof(ble_gap_sec_params_t));
    
        sec_param.bond           = SEC_PARAM_BOND;
        sec_param.mitm           = SEC_PARAM_MITM;
        sec_param.lesc           = SEC_PARAM_LESC;
        sec_param.keypress       = SEC_PARAM_KEYPRESS;
        sec_param.io_caps        = SEC_PARAM_IO_CAPABILITIES;
        sec_param.oob            = SEC_PARAM_OOB;
        sec_param.min_key_size   = SEC_PARAM_MIN_KEY_SIZE;
        sec_param.max_key_size   = SEC_PARAM_MAX_KEY_SIZE;
        sec_param.kdist_own.enc  = 1;
        sec_param.kdist_own.id   = 1;
        sec_param.kdist_peer.enc = 1;
        sec_param.kdist_peer.id  = 1;
    
        err_code = pm_sec_params_set(&sec_param);
        APP_ERROR_CHECK(err_code);
    
        err_code = pm_register(pm_evt_handler);
        APP_ERROR_CHECK(err_code);
    
        return;
    }
    
    static void pm_evt_handler(pm_evt_t const * p_evt)
    {
        pm_conn_sec_config_t conn_sec_config;
    
        pm_handler_on_pm_evt(p_evt);
        pm_handler_flash_clean(p_evt);
    
        switch (p_evt->evt_id) {
            case PM_EVT_BONDED_PEER_CONNECTED:
                break;
    
            case PM_EVT_CONN_SEC_START:
                break;
    
            case PM_EVT_CONN_SEC_SUCCEEDED:
                break;
    
            case PM_EVT_CONN_SEC_FAILED:
                break;
    
            case PM_EVT_CONN_SEC_CONFIG_REQ:
                // Even true didn't make sense.
                conn_sec_config.allow_repairing = false;
                pm_conn_sec_config_reply(p_evt->conn_handle, &conn_sec_config);
                break;
    
            case PM_EVT_CONN_SEC_PARAMS_REQ:
                break;
    
            case PM_EVT_STORAGE_FULL:
                break;
    
            case PM_EVT_ERROR_UNEXPECTED:
                break;
    
            case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED:
                break;
    
            case PM_EVT_PEER_DATA_UPDATE_FAILED:
                break;
    
            case PM_EVT_PEER_DELETE_SUCCEEDED:
                break;
    
            case PM_EVT_PEER_DELETE_FAILED:
                break;
                
            case PM_EVT_PEERS_DELETE_SUCCEEDED:
                break;
    
            case PM_EVT_PEERS_DELETE_FAILED:
                break;
    
            case PM_EVT_LOCAL_DB_CACHE_APPLIED:
                break;
    
            case PM_EVT_LOCAL_DB_CACHE_APPLY_FAILED:
                break;
    
            case PM_EVT_SERVICE_CHANGED_IND_SENT:
                break;
    
            case PM_EVT_SERVICE_CHANGED_IND_CONFIRMED:
                break;
    
            case PM_EVT_SLAVE_SECURITY_REQ:
                break;
    
            case PM_EVT_FLASH_GARBAGE_COLLECTED:
                break;
    
            case PM_EVT_FLASH_GARBAGE_COLLECTION_FAILED:
                break;
    
            default:
                break;
        }
    
        return;
    }

    Best regards.

Reply
  • 0
    71 pts.
    in reply to Simonr

    Hello.

    I have included the peer manager and pm_evt_handler () in my project with the code settings below. Is there anything else I need?

    #define SEC_PARAM_BOND            1                                /**< Perform bonding. */
    #define SEC_PARAM_MITM            0                                /**< Man In The Middle protection not required. */
    #define SEC_PARAM_LESC            1                                /**< LE Secure Connections not enabled. */
    #define SEC_PARAM_KEYPRESS        0                                /**< Keypress notifications not enabled. */
    #define SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_NONE             /**< No I/O capabilities. */
    #define SEC_PARAM_OOB             0                                /**< Out Of Band data not available. */
    #define SEC_PARAM_MIN_KEY_SIZE    7                                /**< Minimum encryption key size. */
    #define SEC_PARAM_MAX_KEY_SIZE    16                               /**< Maximum encryption key size. */
    
    static void peer_manager_init(void)
    {
        ble_gap_sec_params_t sec_param;
        ret_code_t err_code;
    
        err_code = pm_init();
        APP_ERROR_CHECK(err_code);
    
        memset(&sec_param, 0, sizeof(ble_gap_sec_params_t));
    
        sec_param.bond           = SEC_PARAM_BOND;
        sec_param.mitm           = SEC_PARAM_MITM;
        sec_param.lesc           = SEC_PARAM_LESC;
        sec_param.keypress       = SEC_PARAM_KEYPRESS;
        sec_param.io_caps        = SEC_PARAM_IO_CAPABILITIES;
        sec_param.oob            = SEC_PARAM_OOB;
        sec_param.min_key_size   = SEC_PARAM_MIN_KEY_SIZE;
        sec_param.max_key_size   = SEC_PARAM_MAX_KEY_SIZE;
        sec_param.kdist_own.enc  = 1;
        sec_param.kdist_own.id   = 1;
        sec_param.kdist_peer.enc = 1;
        sec_param.kdist_peer.id  = 1;
    
        err_code = pm_sec_params_set(&sec_param);
        APP_ERROR_CHECK(err_code);
    
        err_code = pm_register(pm_evt_handler);
        APP_ERROR_CHECK(err_code);
    
        return;
    }
    
    static void pm_evt_handler(pm_evt_t const * p_evt)
    {
        pm_conn_sec_config_t conn_sec_config;
    
        pm_handler_on_pm_evt(p_evt);
        pm_handler_flash_clean(p_evt);
    
        switch (p_evt->evt_id) {
            case PM_EVT_BONDED_PEER_CONNECTED:
                break;
    
            case PM_EVT_CONN_SEC_START:
                break;
    
            case PM_EVT_CONN_SEC_SUCCEEDED:
                break;
    
            case PM_EVT_CONN_SEC_FAILED:
                break;
    
            case PM_EVT_CONN_SEC_CONFIG_REQ:
                // Even true didn't make sense.
                conn_sec_config.allow_repairing = false;
                pm_conn_sec_config_reply(p_evt->conn_handle, &conn_sec_config);
                break;
    
            case PM_EVT_CONN_SEC_PARAMS_REQ:
                break;
    
            case PM_EVT_STORAGE_FULL:
                break;
    
            case PM_EVT_ERROR_UNEXPECTED:
                break;
    
            case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED:
                break;
    
            case PM_EVT_PEER_DATA_UPDATE_FAILED:
                break;
    
            case PM_EVT_PEER_DELETE_SUCCEEDED:
                break;
    
            case PM_EVT_PEER_DELETE_FAILED:
                break;
                
            case PM_EVT_PEERS_DELETE_SUCCEEDED:
                break;
    
            case PM_EVT_PEERS_DELETE_FAILED:
                break;
    
            case PM_EVT_LOCAL_DB_CACHE_APPLIED:
                break;
    
            case PM_EVT_LOCAL_DB_CACHE_APPLY_FAILED:
                break;
    
            case PM_EVT_SERVICE_CHANGED_IND_SENT:
                break;
    
            case PM_EVT_SERVICE_CHANGED_IND_CONFIRMED:
                break;
    
            case PM_EVT_SLAVE_SECURITY_REQ:
                break;
    
            case PM_EVT_FLASH_GARBAGE_COLLECTED:
                break;
    
            case PM_EVT_FLASH_GARBAGE_COLLECTION_FAILED:
                break;
    
            default:
                break;
        }
    
        return;
    }

    Best regards.

Children
No Data
Related