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

What does this error mean: Connection Request Failed, reason 7

I am developing an app that uses both a central and a peripheral device using Nordic SDK 8.1. I was working off the hrm example code and wanted to move all the scanning methods to their own file to clean up the project. After doing that I get the following error on the central device when I try to connect to the peripheral: Connection Request Failed, reason 7

What does this error mean and how can I fix it?

I think the specific line of code that is breaking it is this:

                            err_code = sd_ble_gap_scan_stop();
                            if (err_code != NRF_SUCCESS)
                            {
                                printf("[APPL]: Scan stop failed, reason %d\r\n", err_code);
                            }
                            err_code = bsp_indication_set(BSP_INDICATE_IDLE);
                            APP_ERROR_CHECK(err_code);
                            m_scan_param.selective = 0;
                            // Initiate connection.
                            err_code = sd_ble_gap_connect(&p_gap_evt->params.adv_report.peer_addr,
                                                          &m_scan_param,
                                                          &m_connection_param);
                            m_whitelist_temporarily_disabled = false;
                            if (err_code != NRF_SUCCESS)
                            {
                                printf("[APPL]: Connection Request Failed, reason %d\r\n", err_code);
                            }
  • The "reason" is ismply uint32_t return code from sd_ble_gap_connect so if you see function's signature in SDK you will immediately identify it as NRF_ERROR_INVALID_PARAM (all error code values are in SDK header files, start with components\softdevice\sXXX\headers\nrf_error.h when looking for some specific - they are also now listed on Infocenter). So without running and debugging you code the most probable explanation is that you don't initialize m_scan_param or m_connection_param structures correctly after your refactoring. Print each member of these structures before calling the function and make sure all is set properly.

Related