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

Device manager BLE_GAP_EVT_CONNECTED

Hello, i analyze the device manager routine (device_manager_peripheral.c) and in BLE_GAP_EVT_CONNECTED case you checking containing the device address in bonded table. My question is Why my iPhone loses the bond after reset chip (iPhone bonded in last time)? i check error_code at the end of BLE_GAP_EVT_CONNECTED case and it not NRF_SUCCESS. Why is occur?

Parents
  • Hello Stian, I use nRF51_SDK_9.0.0_2e23562 and softdevice110 8.0.0 and iPhone 5s. Nrf51 chip looses the bond info after disconnect (reset button), while it is stored on the iPhone. Under the debug nrf51 go to point below (where the nrf_drv_gpiote_out_set(DEBUG_INDECATOR ) ) (err_code = 0x5, as i right understand it is "Not found")

    case BLE_GAP_EVT_CONNECTED:
                //Allocate connection instance for a new connection.
                err_code = connection_instance_allocate(&index);
    
                //Connection instance is successfully allocated.
                if (err_code == NRF_SUCCESS)
                {
                    //Application notification related information.
                    notify_app           = true;
                    event.event_id       = DM_EVT_CONNECTION;
                    handle.connection_id = index;
    
                    m_connection_table[index].conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
                    m_connection_table[index].state       = STATE_CONNECTED;
                    m_connection_table[index].peer_addr   = p_ble_evt->evt.gap_evt.params.connected.peer_addr;
    
                    if (p_ble_evt->evt.gap_evt.params.connected.irk_match == 1) ///
                    {		
    					if (m_irk_index_table[p_ble_evt->evt.gap_evt.params.connected.irk_match_idx] != DM_INVALID_ID)
    					{
    						device_index = m_irk_index_table[p_ble_evt->evt.gap_evt.params.connected.irk_match_idx];
    						err_code = NRF_SUCCESS;
    					}									
                    }
                    else
                    {
                        //Use the device address to check if the device exists in the bonded device list.
                        err_code = device_instance_find(&p_ble_evt->evt.gap_evt.params.connected.peer_addr,
                                                        &device_index, EDIV_INIT_VAL);
                    }
    
                    if (err_code == NRF_SUCCESS)
                    {
                        m_connection_table[index].bonded_dev_id = device_index;
                        m_connection_table[index].state        |= STATE_BONDED;
                        handle.device_id                        = device_index;
    
                        bond_data_load(&handle);
                    }
    				else 
    				{		
    					//After bonding and reset chip, iPhone 5 and 6 go to this point ( LED turned on)
    					// with err_code == 0x00000005
    					nrf_drv_gpiote_out_set(DEBUG_INDECATOR );
    				}
                }
                break;
    
Reply
  • Hello Stian, I use nRF51_SDK_9.0.0_2e23562 and softdevice110 8.0.0 and iPhone 5s. Nrf51 chip looses the bond info after disconnect (reset button), while it is stored on the iPhone. Under the debug nrf51 go to point below (where the nrf_drv_gpiote_out_set(DEBUG_INDECATOR ) ) (err_code = 0x5, as i right understand it is "Not found")

    case BLE_GAP_EVT_CONNECTED:
                //Allocate connection instance for a new connection.
                err_code = connection_instance_allocate(&index);
    
                //Connection instance is successfully allocated.
                if (err_code == NRF_SUCCESS)
                {
                    //Application notification related information.
                    notify_app           = true;
                    event.event_id       = DM_EVT_CONNECTION;
                    handle.connection_id = index;
    
                    m_connection_table[index].conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
                    m_connection_table[index].state       = STATE_CONNECTED;
                    m_connection_table[index].peer_addr   = p_ble_evt->evt.gap_evt.params.connected.peer_addr;
    
                    if (p_ble_evt->evt.gap_evt.params.connected.irk_match == 1) ///
                    {		
    					if (m_irk_index_table[p_ble_evt->evt.gap_evt.params.connected.irk_match_idx] != DM_INVALID_ID)
    					{
    						device_index = m_irk_index_table[p_ble_evt->evt.gap_evt.params.connected.irk_match_idx];
    						err_code = NRF_SUCCESS;
    					}									
                    }
                    else
                    {
                        //Use the device address to check if the device exists in the bonded device list.
                        err_code = device_instance_find(&p_ble_evt->evt.gap_evt.params.connected.peer_addr,
                                                        &device_index, EDIV_INIT_VAL);
                    }
    
                    if (err_code == NRF_SUCCESS)
                    {
                        m_connection_table[index].bonded_dev_id = device_index;
                        m_connection_table[index].state        |= STATE_BONDED;
                        handle.device_id                        = device_index;
    
                        bond_data_load(&handle);
                    }
    				else 
    				{		
    					//After bonding and reset chip, iPhone 5 and 6 go to this point ( LED turned on)
    					// with err_code == 0x00000005
    					nrf_drv_gpiote_out_set(DEBUG_INDECATOR );
    				}
                }
                break;
    
Children
No Data
Related