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

BLE bonding

Hi,

As far as I understand, every connection establishment has to start with advertising.

Event if I have already connected and bonded to a peer, after disconnection I have to start advertising in order to connect to this peer again.

Am I right?

In that case - what is the meaning of bonding here? Shouldn't the peers connect automatically again without advertising/direct advertising? Do I have another option?

Thanks!

  • Yes, I used the example and I test it with my mobile, I can see when I connect or disconnect clearly, and I tested it with more mobiles to validate the whitelist. It was all good, but I need the option to start reqular advertising as well.

    I get the idle event right after starting advertising (in the same ms).

  • OK, the problem is that the current advertising mode is Idle, and I need to set it to Fast before I restart advertising without whitelist. Or should I do another thing?

    Thanks!

  • Hi,

    I see. You could start advertising normally, and then restart, or slightly adjust the advertising module.

    The resone calling ble_advertising_restart_without_whitelistadvertising() did not work is that the module only supports restarting advertising in the same mode, and when advertising is not active the mode is IDLE. If you want to start advertising without whitelist you could expand the library with a ble_advertising_start_without_whitelist() function like this:

    uint32_t ble_advertising_start_without_whitelist(ble_advertising_t * const p_advertising,
                                                     ble_adv_mode_t            advertising_mode)
    {
        ret_code_t ret;
    
        p_advertising->whitelist_temporarily_disabled = true;
        p_advertising->whitelist_in_use               = false;
        p_advertising->adv_params.filter_policy       = BLE_GAP_ADV_FP_ANY;
        // Set correct flags.
        ret = flags_set(p_advertising, BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
        VERIFY_SUCCESS(ret);
    
        ret = ble_advertising_start(p_advertising, advertising_mode);
        if ((ret != NRF_SUCCESS) && (p_advertising->error_handler != NULL))
        {
            p_advertising->error_handler(ret);
        }
    
        return NRF_SUCCESS;
    }
    

    The only difference from the restart variant is that it does not stop advertising, and it uses the specified mode instead of the current mode. Calling this function instead of ble_advertising_start() will do the trick.

  • Thanks a lot!

    One more question - 

    I'm still confused about the difference between pm_whitelist_set and pm_device_identities_list_set. Can you please explain what does each of them do?

  • Hi,

    The device identities list is a list of device IRK's (Identity resolution keys). So that is needed for whitelisting peers that use privacy (which include any modern phone). Whitelisting static MAC addresses only work with devices that do not use privacy. Therefore, you will need code for both to handle both cases, like it is done in the SDK examples.

Related