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

Whitelisting in S132 v3 for advertising filter policy

Hi,

I am using nRF5 SDK 12.1.0.

I have read the s132_nrf52_3.0.0_migration-document.pdf and I am trying to implement the whitelist without the private addresses i.e. just whitelisting public addresses

I would like to set a whitelist for advertising filter policy at the peripheral device. Please find my code as follows:

    case BLE_ADV_EVT_WHITELIST_REQUEST:
	{
    	//Public Address
    	ble_gap_addr_t public_device = {
    			.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC,
				.addr = {0x38, 0x32, 0x52, 0xCB, 0x9F, 0x77}
    	};

    	ble_gap_addr_t const * whitelist = &public_device;

    	err_code = sd_ble_gap_whitelist_set(&whitelist, 1);

    	//Check error codes after setting whitelist
    	if (err_code == NRF_SUCCESS)
        	SEGGER_RTT_WriteString(0, "Successfully set whitelist! Yeah baby\n");
        if (err_code == NRF_ERROR_INVALID_ADDR)
        	SEGGER_RTT_WriteString(0, "NRF_ERROR_INVALID_ADDR\n");
        if (err_code == BLE_ERROR_GAP_WHITELIST_IN_USE)
        	SEGGER_RTT_WriteString(0, "BLE_ERROR_GAP_WHITELIST_IN_USE\n");
        if (err_code == BLE_ERROR_GAP_INVALID_BLE_ADDR)
        	SEGGER_RTT_WriteString(0, "BLE_ERROR_GAP_INVALID_BLE_ADDR\n");
        if (err_code == NRF_ERROR_DATA_SIZE)
        	SEGGER_RTT_WriteString(0, "NRF_ERROR_DATA_SIZE\n");

    	ble_gap_adv_params_t adv_params = {0};
    	adv_params.fp = BLE_GAP_ADV_FP_FILTER_BOTH;	//Filter scan and connection requests

    	err_code = sd_ble_gap_adv_start(&adv_params);

    	//Check error codes after starting advertising
        if (err_code == NRF_SUCCESS)
        	SEGGER_RTT_WriteString(0, "Start advertising this baby!\n");

        if (err_code == NRF_ERROR_INVALID_ADDR)
        	SEGGER_RTT_WriteString(0, "NRF_ERROR_INVALID_ADDR\n");

        if (err_code == NRF_ERROR_INVALID_STATE)
        	SEGGER_RTT_WriteString(0, "NRF_ERROR_INVALID_STATE\n");

        if (err_code == NRF_ERROR_INVALID_PARAM)
        	SEGGER_RTT_WriteString(0, "NRF_ERROR_INVALID_PARAM\n");

        if (err_code == BLE_ERROR_GAP_INVALID_BLE_ADDR)
        	SEGGER_RTT_WriteString(0, "BLE_ERROR_GAP_INVALID_BLE_ADDR\n");

        if (err_code == BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST)
        	SEGGER_RTT_WriteString(0, "BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST\n");

        APP_ERROR_CHECK(err_code);
	}
	break;

I am getting an error message that says NRF_ERROR_INVALID_PARAM (in RTT Viewer) when trying to start the advertisement using the function sd_ble_gap_adv_start(). I have configured adv_params.fp to filter connection requests and scan requests.

May I know how can I overcome this issue? Am I missing some adv_params that should be configured as well?

Thank you.

Parents
  • I didn't notice that you were using the advertising module. If you want to use it, you should do like explained here. You can also look at the ble_app_hids_keyboard example on how it is implemented there.

    It gets a bit messy if you start calling sd_ble_gap_adv_start() directly in addition to using the advertising module. I would recommend either only use the advertising module, or implement all advertising functionality yourself. What do you want to do?

  • I referred to the documentation and the heart rate application uses the ble_advertising_start() function which comes from the advertising module. Yes I believe I am using the advertising module (sorry this is something new to me). I would actually like to now only use the advertising module since this function makes it a lot easier to set up advertising. By the way, if we don't use sd_ble_gap_adv_start(), how can we set the filter policy? I used sd_ble_gap_adv_start() because it allowed me to set the filter policy in the fp field.

    Thank you for confirming the advertising flag! I will try it out and let you know to see if it can solve my error. I will need to further read up on the ble_adv_whitelist_reply() function that you mentioned. Thank you for pointing that out too!

Reply
  • I referred to the documentation and the heart rate application uses the ble_advertising_start() function which comes from the advertising module. Yes I believe I am using the advertising module (sorry this is something new to me). I would actually like to now only use the advertising module since this function makes it a lot easier to set up advertising. By the way, if we don't use sd_ble_gap_adv_start(), how can we set the filter policy? I used sd_ble_gap_adv_start() because it allowed me to set the filter policy in the fp field.

    Thank you for confirming the advertising flag! I will try it out and let you know to see if it can solve my error. I will need to further read up on the ble_adv_whitelist_reply() function that you mentioned. Thank you for pointing that out too!

Children
No Data
Related