This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nRF52 Connect after scan_evt_handler()

I am using the nRF5_SDK_17.0.2  "examples\ble_central\ble_app_blinky_c" example to start with my device.

It works using "init_scan.connect_if_match = true"

However, my project need to control when the device should be connected.

So I have change it to "init_scan.connect_if_match = false".

Which API should be called to connect to the device ?

void scan_evt_handler(scan_evt_t const * p_scan_evt)

{

switch(p_scan_evt->scan_evt_id)
{
   case NRF_BLE_SCAN_EVT_FILTER_MATCH:

//  Connect HERE when certain condition met

   break;

}

Parents
  • I think you have better to do the connect rule in nrf_ble_scan.c

    static void nrf_ble_scan_on_adv_report(nrf_ble_scan_t const * const p_scan_ctx,
    ble_gap_evt_adv_report_t const * const p_adv_report)

    .......


    if ((all_filter_mode) &&(!is_filter_matched)) 
    {

    if (........) /* your connect rule here*/

    {
    scan_evt.scan_evt_id = ........;    /* your definition event here*/
    nrf_ble_scan_connect_with_target(p_scan_ctx, p_adv_report);

    }



    else
    {
    scan_evt.scan_evt_id = NRF_BLE_SCAN_EVT_NOT_FOUND;
    scan_evt.params.p_not_found = p_adv_report;

    }

    }

Reply
  • I think you have better to do the connect rule in nrf_ble_scan.c

    static void nrf_ble_scan_on_adv_report(nrf_ble_scan_t const * const p_scan_ctx,
    ble_gap_evt_adv_report_t const * const p_adv_report)

    .......


    if ((all_filter_mode) &&(!is_filter_matched)) 
    {

    if (........) /* your connect rule here*/

    {
    scan_evt.scan_evt_id = ........;    /* your definition event here*/
    nrf_ble_scan_connect_with_target(p_scan_ctx, p_adv_report);

    }



    else
    {
    scan_evt.scan_evt_id = NRF_BLE_SCAN_EVT_NOT_FOUND;
    scan_evt.params.p_not_found = p_adv_report;

    }

    }

Children
No Data
Related