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 Reply Children
  •  

    Good news! It turns out this had nothing to do with the flags, or the whitelist, but the encoding of the service UUIDs.

    The UUIDs were local variables inside advertising_init(). I moved them to the top of the BLE_agent.c file instead.

    static uint8_t m_ipd_value = 0;    //testing ble notification
    
        ble_uuid_t m_adv_uuids[] =
        {
            {BLE_UUID_CYCLING_POWER,         BLE_UUID_TYPE_BLE},
            {BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE}
        };

    The first time the UUID was encoded, the memory pointed to was still correct, but the second time we tried to encode the UUID into the advertising data, the memory was corrupted because ble_uuid_t m_adv_uuids[] was no longer in scope.

    Can't blame you for making this mistake! There is even a misleading documentation in advertising module that insinuates that the UUID will be copied and stored inside the advertising module. This is not true and it's actually corrected in the documentation for 15.1.0.

    Good luck, I hope your project continues smoothly Slight smile

  • Thank you Håvard for your great help. Everything is going well now.

Related