Prohibit a certain Bluetooth address with the same UUID from connecting

Hello Nordic Engineer,

I used SDK17.1.0

First chip is examples \ ble_central_and_peripheral \ experimental \ ble_app_multirole_lesc

static void scan_init(void)
{
    ret_code_t          err_code;
    ble_uuid_t          target_uuid = 
    {
        .uuid = BLE_UUID_HEART_RATE_SERVICE,
        .type = BLE_UUID_TYPE_BLE
    };

    err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_UUID_FILTER, &target_uuid);
}

Second chip is examples \ ble_peripheral \ ble_app_hrs

And Second chip BLE address is 11:22:33:44:55:66

static void scan_evt_handler(scan_evt_t const * p_scan_evt)
{
    ret_code_t err_code;

    switch(p_scan_evt->scan_evt_id)
    {
        case NRF_BLE_SCAN_EVT_CONNECTING_ERROR:
        {
            err_code = p_scan_evt->params.connecting_err.err_code;
            APP_ERROR_CHECK(err_code);
        } break;
		
		case NRF_BLE_SCAN_EVT_WHITELIST_ADV_REPORT:
        {
            // do something
        } break;

        default:
            break;
    }
}

If I want to ban the device with the address "11:22:33:44:55:66", should I do something in the "do something" in the code block?

Thanks

  • Hi tony55723,

    Our apologies for the wait, it has been a holiday here.

    The answer depends on what scanning mode you are using.

    As you have set a filter, I assume you are scanning with a filter, and not with a Whitelist. If so, you need to handle NRF_BLE_SCAN_EVT_FILTER_MATCH. Though in this case, to avoid a device, it is simplest to just exclude it in the list of address to filter for.

    If you are using scanning with whitelist, then the event generated will be NRF_BLE_SCAN_WHITELIST_ADV_REPORT.

    For more information, please go over the Scanning Module documentation: https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/lib_ble_scan.html.

    Hieu


    Please be informed that our team is currently having reduced availability due to the Easter holiday. There will be some delays in our response during this time, but we will respond to you at the earliest opportunity. Our apologies for the inconvenience.

Related