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

whitelists data clearing when restart application in S110 and SDK10v

i have created whitelists for filtering connection its working fine now, but  when i restart my firmware the stored whitlists data become cleared so  i need to  bond each time after firmware restart its not good in my application so my question is,

i can store whitelist details( irk_count, addr_count, pp_addr , pp_irks) in my external flash memory (i'm using an external flash ) and once restart firmware i can read the data from flash memory and stored  whitelist/bond information to whitelist in initialization process . is it possible or not?

  • is it possible to set manually whitelist details or irk details to ble?

  • This is really up to you, but there is no problem to store the IRK and ADDR in internal or external flash as you see fit. Typically though these parameters are already stored in the peer manager, which typically handle bond information, both in central and peripheral role. So if you have to bond each time you restart, it may seem you have not included peer manager. If you want to provide the IRK and ADDR without peer manager, then make sure to set the adv_params with the specific values before calling sd_ble_gap_adv_start().

    Kenneth

  • Thanks for ur response.

    I have migrate device manager to peer manager but after compiling the hex file size is become large so cant able to flash to chip. So i decided to go without peer mangr . Can you please suggest where exactly i want to add set IRK and ADDR for specific device in my code.

    this is irk and addr details of my specific device

    uint8_t pp_irk[16]={0x87,0x8B,0x1B,0xFD,0xEC,0xED,0x14,0x2C,0xFE,0xC0,0x8B,0x7F,0x01,0x4A,0xEF,0x79};

    //            whitelist.addr_count = 0;
    //            whitelist.irk_count  = 1;

    p_whitelist_addr[0]->addr_type=0xC0;
    //            p_whitelist_addr[0]->addr[0]=0X07;
    //            p_whitelist_addr[0]->addr[1]=0X00;
    //            p_whitelist_addr[0]->addr[2]=0X00;
    //            p_whitelist_addr[0]->addr[3]=0XD1;
    //            p_whitelist_addr[0]->addr[4]=0X06;
    //            p_whitelist_addr[0]->addr[5]=0X00;

    This is my current working code

    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");
        uint32_t err_code;

        switch (ble_adv_evt)
        {
            case 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);
                break;

            case BLE_ADV_EVT_FAST:
                SEGGER_RTT_printf(0,"BLE_ADV_EVT_FAST\r\n");
                break;

            case 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[2];
                ble_gap_irk_t     * p_whitelist_irk[2];

                whitelist.addr_count = 2;
                whitelist.irk_count  = 2;
                whitelist.pp_addrs   = p_whitelist_addr;
                whitelist.pp_irks    = p_whitelist_irk;
                SEGGER_RTT_printf(0,"addr_count=%d , irk_count=%d\r\n",whitelist.addr_count,whitelist.irk_count);


                err_code = dm_whitelist_create(&m_app_handle, &whitelist);

                SEGGER_RTT_printf(0,"addr_count=%d , irk_count=%d\r\n",whitelist.addr_count,whitelist.irk_count);


    //            for (int i=0;i<16;i++){
    //                p_whitelist_irk[0]->irk[i]=irk_buf[i];
    //                SEGGER_RTT_printf(0,"pp_irks[%d]=%02x\r\n",i,p_whitelist_irk[0]->irk[i]);
    //            }


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

            default:
                break;
        }

    }

  • i can able to store bond information using device manager instead of peer manager. because im using DM.

    how to store bond information to internal flash of nrf51822

  • Hello, this depend whether you are using SDKv11 (or earlier), or SDKv12 (or later). Typically you will be using the persistent storage (pstorage) module or the flash data storage (fds) module. I believe there should be some examples here in devzone in either cases, you may also get some help from the documentation in the SDK you are working on.

Related