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

whitelists creation not working in my nrf51822 and softdevice S110 and SDK10.

i want to connect my nfr51822 device to only one phone( that means which phone was connected first). For this purpose i enable whitelists but i create whitelists nothing has been changed i can able to connect any devices and after i hard coded the mac address in  "static ble_gap_addr_t       whitelist_sensor_1     = {BLE_GAP_ADDR_TYPE_RANDOM_STATIC,{0xD4,0x63,0xC6,0x60,0x38,0x89}}; " it has advertising but not able to connect any device even added device also. i think whitelist is not working pls help me if anybody knows the issue.

also i include my code here

uint32_t advertising_init(void) {


    uint32_t err_code;
    ble_advdata_t advdata;

    // Build advertising data struct to pass into @ref ble_advertising_init.
    memset(&advdata, 0, sizeof(advdata));

    advdata.name_type = BLE_ADVDATA_FULL_NAME;
    advdata.include_appearance = true;
    advdata.flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
    advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids)
            / sizeof(m_adv_uuids[0]);
    advdata.uuids_complete.p_uuids = m_adv_uuids;

    ble_adv_modes_config_t options = { 0 };
    options.ble_adv_whitelist_enabled = BLE_ADV_WHITELIST_ENABLED;
    options.ble_adv_fast_enabled = BLE_ADV_FAST_ENABLED;
    options.ble_adv_fast_interval = APP_ADV_INTERVAL;
    options.ble_adv_fast_timeout = APP_ADV_TIMEOUT_IN_SECONDS;


    err_code = ble_advertising_init(&advdata, NULL, &options, on_adv_evt, NULL);
    return err_code;

}

//*************************************************

static void on_adv_evt(ble_adv_evt_t ble_adv_evt) {

    SEGGER_RTT_printf(0,"on_adv_evt\r\n");
    if (ble_adv_evt == BLE_ADV_EVT_IDLE) {
        //Restart advertisement
        SEGGER_RTT_printf(0,"BLE_ADV_EVT_IDLE\r\n");
        uint32_t err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
        APP_ERROR_CHECK(err_code);
    }
    else if (ble_adv_evt == BLE_ADV_EVT_FAST){
        SEGGER_RTT_printf(0,"BLE_ADV_EVT_FAST\r\n");
//        uint32_t err_code = ble_advertising_start(BLE_ADV_MODE_DIRECTED);
//        APP_ERROR_CHECK(err_code);
    }
    else if (ble_adv_evt == BLE_ADV_EVT_DIRECTED){
        SEGGER_RTT_printf(0,"BLE_ADV_EVT_DIRECTED\r\n");
    }
    else if (ble_adv_evt == BLE_ADV_MODE_DIRECTED_SLOW){
        SEGGER_RTT_printf(0,"BLE_ADV_MODE_DIRECTED_SLOW\r\n");
    }
    else if (ble_adv_evt == BLE_ADV_MODE_SLOW){
        SEGGER_RTT_printf(0,"BLE_ADV_MODE_SLOW\r\n");
    }
    else if (ble_adv_evt == BLE_ADV_EVT_WHITELIST_REQUEST){
        SEGGER_RTT_printf(0,"BLE_ADV_EVT_WHITELIST_REQUEST\r\n");

        ble_gap_adv_params_t adv_params;
        ble_gap_whitelist_t whitelist;
        ble_gap_addr_t    * p_whitelist_addr[1];
        ble_gap_irk_t     * p_whitelist_irk[1];

        whitelist.addr_count = 1;
        whitelist.irk_count  = 1;
        whitelist.pp_addrs   = p_whitelist_addr;
        whitelist.pp_irks    = p_whitelist_irk;

        uint32_t err_code = dm_whitelist_create(&m_app_handle, &whitelist);

        err_code = ble_advertising_whitelist_reply(&whitelist);
        APP_ERROR_CHECK(err_code);

}

i also tried hard coded mac address ( this address is my phone bluetooth mac address)

       ble_gap_whitelist_t  whitelist;
            ble_gap_addr_t*      p_whitelist_addr[1];
            static ble_gap_addr_t       whitelist_sensor_1     = {BLE_GAP_ADDR_TYPE_PUBLIC,{0xD4,0x63,0xC6,0x60,0x38,0x89}};// my phone mac
//            static ble_gap_addr_t       whitelist_sensor_2     = {BLE_GAP_ADDR_TYPE_RANDOM_STATIC,{0x89,0x38,0x60,0xC6,0x63,0xD4}};

            p_whitelist_addr[0]     = &whitelist_sensor_1;
//            p_whitelist_addr[1]     = &whitelist_sensor_2;
            whitelist.addr_count    = 1;
            whitelist.pp_addrs      =  p_whitelist_addr;
            whitelist.pp_irks       = NULL;
            whitelist.irk_count     = 0;

           ble_advertising_whitelist_reply(&whitelist);

//*******************************************************************************

any way BLE_ADV_EVT_WHITELIST_REQUEST event is working.

Parents Reply Children
  • Thanku.

    i have one more problem when i restart my firmware the stored whitlist data become cleared so  i need to  bond each time after firmware restart its not good in my application so i need to store irk details in my external flash memory (i'm using an external flash ) and once restart i want to store that irk/bond information to whitelist in initialization process . is it possible or not?

  • Have you set the .sec_param.bond  flag to '1'? This option will enable the DM to store the device information to flash (persistent across resets). I would not recommend to store bonding information to ext. flash, unless you have to because of memory constraints. It would require significant changes to the flash handling already built into the DM module. 

Related