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?

  • Oh my gosh it worked!! But I had to use the nRF Connect App in order to test the connection. If I used the HRS central example app, somehow it is not able to connect to the peripheral. I added the smartphone's MAC address to the whitelist and I was able to connect to the nrf52. After that, I removed the device's address from the whitelist and was not able to perform the connection afterwards.

Reply Children
No Data
Related