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

[nRF51822] Connectable Indirected advertising after pairing was done.

Hi sir In Desktop 2, before BTLE pairing, nRF51 uses Connectable Indirected advertising. After BTLE pairing with BTLE host, nRF51 will select Directed advertsing for saving connection time. Could nRF51use Connection Indirected advertising type to the BTLE host which was already paired with it? Then, like mouse or keyboard device, can they still work well?

Regards, Jeffery

  • Yes, this is most definitely possible, it's just a matter of editing the code used when starting advertising. If you already have a bond, and does not want to initiate a new one, I'd recommend you to use advertising with whitelisting.

    When using the bond manager, you can get hold of a whitelist by calling the ble_bondmngr_whitelist_get() function. The following two code snippets should show what's needed:

    
    static void advertising_init(void)
    {
        uint32_t      err_code;
        ble_advdata_t advdata;
        uint8_t       flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
        static ble_gap_whitelist_t whitelist;
        
        ble_uuid_t adv_uuids[] = 
        {
            {BLE_UUID_GLUCOSE_SERVICE,            BLE_UUID_TYPE_BLE},
            {BLE_UUID_BATTERY_SERVICE,            BLE_UUID_TYPE_BLE}, 
            {BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE}
        };
    
        // Build and set advertising data
        memset(&advdata, 0, sizeof(advdata));
        
        advdata.name_type               = BLE_ADVDATA_FULL_NAME;
        advdata.include_appearance      = false;
        advdata.flags.size              = sizeof(flags);
        advdata.flags.p_data            = &flags;
        advdata.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
        advdata.uuids_complete.p_uuids  = adv_uuids;
        
        err_code = ble_advdata_set(&advdata, NULL);
        APP_ERROR_CHECK(err_code);
    
        // Initialise advertising parameters (used when starting advertising)
        err_code = ble_bondmngr_whitelist_get(&whitelist);
        APP_ERROR_CHECK(err_code);
        
        memset(&m_adv_params, 0, sizeof(m_adv_params));
        
        m_adv_params.type        = BLE_GAP_ADV_TYPE_ADV_IND;
        m_adv_params.p_peer_addr = NULL;                           // Undirected advertisement
        
        if ((whitelist.addr_count > 0) || (whitelist.irk_count > 0))
        {
            m_adv_params.fp          = BLE_GAP_ADV_FP_FILTER_BOTH;
            m_adv_params.p_whitelist = &whitelist;
        }
        else
        {
            m_adv_params.fp = BLE_GAP_ADV_FP_ANY;
        }
        m_adv_params.interval    = APP_ADV_INTERVAL;
        m_adv_params.timeout     = APP_ADV_TIMEOUT_IN_SECONDS;
    }
    
    ...
    
    static void advertising_start(void)
    {
        uint32_t err_code;
        
        err_code = sd_ble_gap_adv_start(&m_adv_params);
        APP_ERROR_CHECK(err_code);
        
        nrf_gpio_pin_set(ADVERTISING_LED_PIN_NO);
    }
    
    
  • Hi dears

    Actually, this application is a testing kit used in MP. I don't want to do pairing for everey sample in a single PC since operators will got mad to repeat it. Besides, the performace of PC will become worse after a lot of bonding records were accumulated.

    So, my idea is only to pair for the first sample. Then, the bonding record will exist in the PC. Then, for other samples that they didn't have whitelist anyhow, just advertise by Connectable Indirected advertising. However, it seems not work.

  • Continue...

    As to the device address, I know each sample has unique device address. So, there is a trick to overwrite their device address same as the first sample has. This constant device address only be implemented in product line. So, adverstising packet got same device address.

  • If you're looking at developing a test for mass production, I'd recommend you to have a look at nAN-34: https://www.nordicsemi.com/eng/nordic/download_resource/20648/5/85114866

    An alternative to the setup that is proposed there is to make a Master Emulator application to do the test, instead of relying on the built-in Windows features to do the bonding. This will make it easy to create and remove bonds from the code, removing the need for operators to manually do any deletion except for on the device.

  • Dears I am thinking the vendors will not accept Master Emulator to do function test. For instance, mouse was only gotten X-Y prameters , button value, and scroll value at Master Emulator. These values are no use in product line. Operators tested visible testing items at real Windows 8, such as drawing cricles, report rates and so on. So, the best way is to bond with BTLE real host. Or, after bonding with dongle with Master Emulator, mouse or keyboard can really work as they suppose to act at Windows 8? Besides, my initial question is used Connectable Indirected ADV to a already bonded BTLE host. The all mouse or keyboard set the same device address in product line. Could it be possible?

Related