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

sd_ble_gap_authenticate causes HardFault

Hi

I am using nRF51822, S130, SDK12, Working on adding static key security to my application

So far I have change the GLS (glucose) example to static passkey and connected successfully using nRF Connect and NRF DK51

Since than I have tried to migrate that code into a thin version of my existing application and encountered a Hardfault after the sd_ble_gap_authenticate command,

A problem I didn't see on the the project I worked on based on the SDK example version - this is the call stack 

I have not changed anything in those functions, only, as I said, as far as I know I only changed to Static passkey with the following code after ble_stack_init() in main()

			uint8_t passkey[] = STATIC_PASSKEY;
			//m_static_pin_option.gap.passkey.p_passkey = passkey; //gap_opt
			m_static_pin_option.gap_opt.passkey.p_passkey = passkey; //gap_opt
			err_code =  sd_ble_opt_set(BLE_GAP_OPT_PASSKEY, &m_static_pin_option);
			APP_ERROR_CHECK(err_code);		

the routine from which the HardFault is invoked -

static ret_code_t link_secure_peripheral(uint16_t conn_handle, ble_gap_sec_params_t * p_sec_params)
{
    // This should never happen for a peripheral.
    NRF_PM_DEBUG_CHECK(p_sec_params != NULL);

    // VERIFY_PARAM_NOT_NULL(p_sec_params);

    ret_code_t err_code = sd_ble_gap_authenticate(conn_handle, p_sec_params);

    return err_code;
}

Would greatly appreciate any inputs and insights on this issue, since I have no idea what causes it

Thanks!

Related