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

Direct advertising with unbonded Android phone's IRK

I was using NRF52832 and s132 v6.0.

I have Android phone's IRK and I have added the Android phone into the identites list manually.

After doing the direct advertising to Android phone.Why can't nrf52832 be connected ?

I have noticed that some comments in the devzone said "You can't be connected with direct advertising without bonding".But why?I think if I get the IRK ,and add to the identites list,it should be connected .It can accord to the BT core Vol 6 Part D 5.4 .

Maybe should I add the Android phone into the peer_list manually too?

  • Below is my code snippets

    //Global var
    ble_gap_id_key_t oneplus3_key = {
        .id_addr_info={
            0,
            BLE_GAP_ADDR_TYPE_RANDOM_STATIC,
            {0x76,0x53,0xd6,0xfb,0xee,0xc0},          //one_plus3  android phone
        }
    };
    
    //........................
    //........................
    //........................
    //........................
    //........................
    //........................
    
    void init_advertising(void){
    ..................................................................
    ..................................................................
        uint8_t *oneplus3_irk_string = "076b01ad29fcbb56bda76d3c9adb0ec0";  // adb shell ,/data/misc/bluedroid/bt_config.config grep "LOCAL_IRK"
    
        uint8_t temp[2];
        uint8_t *ptr = NULL;
        unsigned long ret = 0;
    
        for (int i = 0,j=0; i < BLE_GAP_SEC_KEY_LEN;i++,j+=2)
        {
            memmove(temp,&oneplus3_irk_string[j],sizeof(uint8_t)*2);
            ret = strtoul(temp, &ptr, 16);
    
            oneplus3_key.id_info.irk[i] = (uint8_t)ret;
        }
        // The irk is right ,I have test it in fast advertising with pm_address_resolve();
    ..............................................................
    ..................................................................
    
    
    
    static void on_adv_evt(ble_adv_evt_t ble_adv_evt){
    ................................................
            case BLE_ADV_EVT_WHITELIST_REQUEST:
            {
                ble_gap_id_key_t* key_list[BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT];
                memset(key_list,0,BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT*sizeof(int));
                key_list[0] =    &oneplus3_key;
                sd_ble_gap_device_identities_set(key_list,NULL,1);
    
                ble_gap_addr_t const* whitelist_addrs_gap[BLE_GAP_WHITELIST_ADDR_MAX_COUNT];
    
                ble_gap_addr_t whitelist_addrs[BLE_GAP_WHITELIST_ADDR_MAX_COUNT];
                ble_gap_irk_t  whitelist_irks[BLE_GAP_WHITELIST_ADDR_MAX_COUNT];
                uint32_t       addr_cnt = BLE_GAP_WHITELIST_ADDR_MAX_COUNT;
                uint32_t       irk_cnt  = BLE_GAP_WHITELIST_ADDR_MAX_COUNT;
    
                whitelist_addrs_gap[0] = &oneplus3_key.id_addr_info;
                memmove(&whitelist_addrs[0],&oneplus3_key.id_addr_info,sizeof(ble_gap_addr_t));
                memmove(&whitelist_irks[0],&oneplus3_key.id_info,sizeof(ble_gap_irk_t));
                addr_cnt = 1;
                irk_cnt = 1;
    
                err_code = sd_ble_gap_whitelist_set(whitelist_addrs_gap, 1);
                APP_ERROR_CHECK(err_code);
    
                // Apply the whitelist.
                err_code = ble_advertising_whitelist_reply(&m_advertising,
                                                           whitelist_addrs,
                                                           addr_cnt,
                                                           whitelist_irks,
                                                           irk_cnt);
                APP_ERROR_CHECK(err_code);
            }
            break;
    ......................................................

  • Hi

    Why can't you bond to the phone that you want to connect to?

    If you don't bond with the phone first you don't have any guarantee that the phone will accept the connection. 

    Best regards
    Torbjørn

  • Hi,

    My goal is to establish a connection without human involved. And if there has many peripherals,it will take a lot time to find specific peripheral. So I think direct advertising is a good way.

  • Hi 

    Who decides then which phone should be connected to which peripheral, if there is no human to control the procedure?

    Is this controlled from the cloud?

    Best regards
    Torbjørn

  • ovrebekk, this is a bit like nfc pairing,I call it sound wave pairing but data is one-way transmission, people take up the phone and close to the peripheral, peripheral will get the IRK.

    By the way , whitelist works fine ,direct advertising dosen't work.

Related