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

ANCS add to S130

I develop ANCS success in S110,but in example ble_app_hrs_rscs_relay of S130 SDK9 .I don't know how to add the ANCS.I find S110 has ble_bondmnngr.c file,but in S130 dosn't exsit,Just find device_manager_central.c file. The phone can't bond the device .Should I add the ble_bondmnngr.c to the project like in S110? TKS

Parents

  • case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
        
                 event.event_id = DM_EVT_SECURITY_SETUP;
    
                m_connection_table[index].state |= STATE_PAIRING;
                notify_app                       = true;
    
                if (m_connection_table[index].bonded_dev_id == DM_INVALID_ID)
                {
                    //Assign a peer index as a new bond or update existing bonds.
                    err_code = device_instance_allocate((uint8_t *)&device_index,
                                                        &m_connection_table[index].peer_addr);
    
                    //Allocation successful.
                    if (err_code == NRF_SUCCESS)
                    {
                        handle.device_id                        = device_index;
                        m_connection_table[index].bonded_dev_id = device_index;
                    }
                    else
                    {
                        event_result = err_code;
                        notify_app   = true;
                    }
                }
                else
                {
                    //Bond/key refresh.
                    event.event_id = DM_EVT_SECURITY_SETUP_REFRESH;
                    memset(m_gatts_table[index].attributes, 0, DM_GATT_SERVER_ATTR_MAX_SIZE);
    
                    //Set the update flag for bond data.
                    m_connection_table[index].state |= STATE_BOND_INFO_UPDATE;
                }
    
                ble_gap_sec_keyset_t keys_exchanged;
    
    
                keys_exchanged.keys_central.p_enc_key  = NULL;
                keys_exchanged.keys_central.p_id_key   = &m_peer_table[m_connection_table[index].bonded_dev_id].peer_id; 
                keys_exchanged.keys_central.p_sign_key = NULL;
                keys_exchanged.keys_periph.p_enc_key   = &m_bond_table[index].peer_enc_key;
                keys_exchanged.keys_periph.p_id_key    = NULL;
                keys_exchanged.keys_periph.p_sign_key  = NULL;
    
                err_code = sd_ble_gap_sec_params_reply(p_ble_evt->evt.gap_evt.conn_handle,
                                                       BLE_GAP_SEC_STATUS_SUCCESS,
                                                       &m_application_table[0].sec_param, 
                                                       &keys_exchanged);
    
                if (err_code != NRF_SUCCESS)
                {
                    event_result = err_code;
                    notify_app   = false;
                }
                break;
    

    The program can run here,but then go to restart.

Reply

  • case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
        
                 event.event_id = DM_EVT_SECURITY_SETUP;
    
                m_connection_table[index].state |= STATE_PAIRING;
                notify_app                       = true;
    
                if (m_connection_table[index].bonded_dev_id == DM_INVALID_ID)
                {
                    //Assign a peer index as a new bond or update existing bonds.
                    err_code = device_instance_allocate((uint8_t *)&device_index,
                                                        &m_connection_table[index].peer_addr);
    
                    //Allocation successful.
                    if (err_code == NRF_SUCCESS)
                    {
                        handle.device_id                        = device_index;
                        m_connection_table[index].bonded_dev_id = device_index;
                    }
                    else
                    {
                        event_result = err_code;
                        notify_app   = true;
                    }
                }
                else
                {
                    //Bond/key refresh.
                    event.event_id = DM_EVT_SECURITY_SETUP_REFRESH;
                    memset(m_gatts_table[index].attributes, 0, DM_GATT_SERVER_ATTR_MAX_SIZE);
    
                    //Set the update flag for bond data.
                    m_connection_table[index].state |= STATE_BOND_INFO_UPDATE;
                }
    
                ble_gap_sec_keyset_t keys_exchanged;
    
    
                keys_exchanged.keys_central.p_enc_key  = NULL;
                keys_exchanged.keys_central.p_id_key   = &m_peer_table[m_connection_table[index].bonded_dev_id].peer_id; 
                keys_exchanged.keys_central.p_sign_key = NULL;
                keys_exchanged.keys_periph.p_enc_key   = &m_bond_table[index].peer_enc_key;
                keys_exchanged.keys_periph.p_id_key    = NULL;
                keys_exchanged.keys_periph.p_sign_key  = NULL;
    
                err_code = sd_ble_gap_sec_params_reply(p_ble_evt->evt.gap_evt.conn_handle,
                                                       BLE_GAP_SEC_STATUS_SUCCESS,
                                                       &m_application_table[0].sec_param, 
                                                       &keys_exchanged);
    
                if (err_code != NRF_SUCCESS)
                {
                    event_result = err_code;
                    notify_app   = false;
                }
                break;
    

    The program can run here,but then go to restart.

Children
No Data
Related