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

s332 advertising whitelist error

Hello Nordic:

I am trying to add advertising with whitelist function to my code which is base on

nrf52832 dk

softdevice s332 5.0.0

SDK 14.2

I use the example code HID MOUSE Application which implement whitelist as reference.

I make functions related to whitelist almost exactly the same as in HID MOUSE Application and copy the missing function like peer_list_get() to my code.

When the first device is bonded and added into whitelist, the function seems to work correctly.

However when the device  disconnected, the device did go to direct advertising but somehow return an error afterwards as below.

0> <info> ant_hrm: ANT HRM channel 0 init
0> <info> ant_hrm: ANT HRM channel 0 open
0> <info> app: Initialization finish entering main loop
0> <info> app: pm_whitelist_get returns 0 addr in whitelist and 0 irk whitelist
0> <info> app: Fast advertising.
0> <info> app: pm_whitelist_get returns 0 addr in whitelist and 0 irk whitelist
0> <info> app: Slow advertising.
0> <info> app: Connected.
0> <info> app: Link secured. Role: 1. conn_handle: 0, Procedure: 1
0> <info> app: New Bond, add the peer to the whitelist if possible
0> <info> app: m_whitelist_peer_cnt 1, MAX_PEERS_WLIST 8
0> <info> app: add 0 to whitelist
0> <info> app: Disconnected
0> <info> app: BLE_ADV_EVT_PEER_ADDR_REQUEST
0> <info> app: Directed advertising.
0> <info> app: pm_whitelist_get returns 1 addr in whitelist and 1 irk whitelist
0> <error> app: ERROR 7 [NRF_ERROR_INVALID_PARAM] at ..\..\..\..\..\..\components\ble\ble_advertising\ble_advertising.c:287

after reset, the error always come up

0> <info> ant_hrm: ANT HRM channel 0 init
0> <info> app: pm_whitelist_get returns 1 addr in whitelist and 1 irk whitelist
0> <error> app: ERROR 7 [NRF_ERROR_INVALID_PARAM] at ..\..\..\..\..\..\components\ble\ble_advertising\ble_advertising.c:287

This erorr was ERROR 12801 [Unknown error code] from ble_advertising_error_handler before i put APP_ERROR_CHECK to advertising.c.

As far as I know from other posts, 12801 stands for "BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST"

which is Use of Whitelist not permitted with discoverable.

It seems that the problem occur because the device is trying to advertise with whitelist.

I did set BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE in advertising_init() but the example code also do so which seems like it will switch automatically the flag to BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED before switching to advertising with whitelist from the code below, am i correct?

static ret_code_t set_adv_mode_fast(ble_advertising_t * const p_advertising,
                                    ble_gap_adv_params_t    * p_adv_params)
{
    ret_code_t ret;

    p_adv_params->interval = p_advertising->adv_modes_config.ble_adv_fast_interval;
    p_adv_params->timeout  = p_advertising->adv_modes_config.ble_adv_fast_timeout;

    if ((p_advertising->adv_modes_config.ble_adv_whitelist_enabled) &&
        (!p_advertising->whitelist_temporarily_disabled) &&
        (whitelist_has_entries(p_advertising)))
    {
        #if (NRF_SD_BLE_API_VERSION <= 2)
            p_adv_params->p_whitelist = &m_whitelist;
        #endif

        p_adv_params->fp = BLE_GAP_ADV_FP_FILTER_CONNREQ;
        p_advertising->advdata.flags  = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;

        ret = ble_advdata_set(&(p_advertising->advdata), NULL);
        if (ret != NRF_SUCCESS)
        {
						APP_ERROR_CHECK(ret);
            return ret;
        }

        p_advertising->adv_evt = BLE_ADV_EVT_FAST_WHITELIST;
    }
    else
    {
        p_advertising->adv_evt = BLE_ADV_EVT_FAST;
    }

    return NRF_SUCCESS;
}

I also try to switch the flag in advertising_init() directly to BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED however the advertising mode seems to go to IDLE directly which result in sleep mode enter.

Since I am new to Bluetooth and embedded system. This might be a stupid question. but Could you kindly let me know how to fix this problem?

Parents
  • Hi Håvard,

    For your last point, "you never delete the old bonds but always use them." I also notice this but since our product is not going to have any bottom in the future. I am thinking about  deleting bonds after searching with whitelist for some time, but since the program is stuck here I haven't finish that part. Thanks for pointing out anyway~

    and " it looks like you commented out the code that actually restores the whitelist from flash and loads it into the SoftDevice." is because I am still testing the ANT part of this code and by doing so, the error code won't appear. Maybe there are some better ways?

    To be honest, I don't know much about debugging. The call stack is always showing "app error fault handler" from KEIL. I also try using Segger studio but it shows only call stack 0x000008c8. Is it normal to be like this?

    Therefore I try inserting breakpoint at all the places that returns NRF_ERROR_INVALID_PARAM in adv_data.c and it seems like it came from advdata_check(). I notice that when I delete all bonds and start the program. It also returns NRF_ERROR_INVALID_PARAM, but the program keeps on running without error when i continue running it.

    below is the call stack when the program start with nothing stored in the whitelist. It returns NRF_ERROR_INVALID_PARAM but no error occur to stop the program.

    below is the call stack that returns NRF_ERROR_INVALID_PARAM after I add the first device successfully to the whitelist and then disconnect from it. So looks like on_timeout is what cause the advertising error handler() to stop the program.

    When  there is exist  a whitelist, NRF_ERROR_INVALID_PARAM returned with the below call stack will cause the app error fault handler to stop the program.

    does this mean there are something wrong with the p_advdata->flags?

    Thank you for your help and patience

Reply
  • Hi Håvard,

    For your last point, "you never delete the old bonds but always use them." I also notice this but since our product is not going to have any bottom in the future. I am thinking about  deleting bonds after searching with whitelist for some time, but since the program is stuck here I haven't finish that part. Thanks for pointing out anyway~

    and " it looks like you commented out the code that actually restores the whitelist from flash and loads it into the SoftDevice." is because I am still testing the ANT part of this code and by doing so, the error code won't appear. Maybe there are some better ways?

    To be honest, I don't know much about debugging. The call stack is always showing "app error fault handler" from KEIL. I also try using Segger studio but it shows only call stack 0x000008c8. Is it normal to be like this?

    Therefore I try inserting breakpoint at all the places that returns NRF_ERROR_INVALID_PARAM in adv_data.c and it seems like it came from advdata_check(). I notice that when I delete all bonds and start the program. It also returns NRF_ERROR_INVALID_PARAM, but the program keeps on running without error when i continue running it.

    below is the call stack when the program start with nothing stored in the whitelist. It returns NRF_ERROR_INVALID_PARAM but no error occur to stop the program.

    below is the call stack that returns NRF_ERROR_INVALID_PARAM after I add the first device successfully to the whitelist and then disconnect from it. So looks like on_timeout is what cause the advertising error handler() to stop the program.

    When  there is exist  a whitelist, NRF_ERROR_INVALID_PARAM returned with the below call stack will cause the app error fault handler to stop the program.

    does this mean there are something wrong with the p_advdata->flags?

    Thank you for your help and patience

Children
No Data
Related