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

Whitelist advertising/connection cases

Hello all, Before making deal with advertising in my project I read the tutorial and it helped alot. I need to develop application with 2 cases.

  1. In some way I prepare whitelist on device and want to connect devises from it. I configure the advertisement in the next way:

     uint8_t  adv_data[]  = {2,0x01,BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE,17,BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE, SERVICE_UUID128,(APPLICATION_NAME_SIZE + 1),0x09, APPLICATION_NAME};  //31 byte 
    

    if ((error_code = sd_ble_gap_adv_data_set(adv_data, sizeof(adv_data), NULL, 0)) != NRF_SUCCESS) { DBG("sd_ble_gap_adv_data_set %d\n",error_code); } (In this mode we can connect to device from Android or Windows)

Now setup whitelist (code grabbed from example):

static ble_gap_whitelist_t             m_whitelist;                                         /**< Struct that points to whitelisted addresses. */
static ble_gap_addr_t                * mp_whitelist_addr[ADV_WHITELIST_ADDR_MAX_ENTRIES]; /**< Pointer to a list of addresses. Pointed to by the whitelist */
static ble_gap_irk_t                 * mp_whitelist_irk[ADV_WHITELIST_IRK_MAX_ENTRIES];   /**< Pointer to a list of Identity Resolving Keys (IRK). Pointed to by the whitelist */

.....

static ble_gap_addr_t  ble_gap_addr;
memset(&ble_gap_addr, 0x00, sizeof(ble_gap_addr_t));
ble_gap_addr.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC;
ble_gap_addr.addr[5] =  0x85; //Nexus
ble_gap_addr.addr[4] =  0xA9;
ble_gap_addr.addr[3] =  0xE1;
ble_gap_addr.addr[2] =  0x0C;
ble_gap_addr.addr[1] =  0xD8;
ble_gap_addr.addr[0] =  0x00;

mp_whitelist_addr[0]=&ble_gap_addr;
m_whitelist.pp_addrs = mp_whitelist_addr;
m_whitelist.addr_count=1;
m_whitelist.pp_irks  = NULL; 
m_whitelist.irk_count= 0;

   adv_params.type        = BLE_GAP_ADV_TYPE_ADV_IND;
   adv_params.fp          = BLE_GAP_ADV_FP_FILTER_CONNREQ;  
   adv_params.p_peer_addr = NULL;
   adv_params.interval    = APP_ADV_INTERVAL;
   adv_params.timeout     = APP_ADV_TIMEOUT_IN_SECONDS;
   adv_params.p_whitelist = &m_whitelist; 
    
	error_code = sd_ble_gap_adv_start(&adv_params);
	DBG("sd_ble_gap_adv_start %d\n",error_code);

And here we got error "BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST" that means "Use of Whitelist not permitted with discoverable advertising." .... Ok, it explain why in the ble_app_template example the only BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED flag used. I modified my code with it but now I can't connect to device from Android (Master control panel shows greyed "Connect" button and if pressed write Connecting-Discovering services-Disconnected). Windows doesn't see device atall. What mode suggested to be correct in my case?

  1. If I bonded with device previously, does it change adverticement-connection algorithm in case of whitelist advertisement ?

Sincerely yours,

Parents
    1. So if I understand correctly, if you set your advertising flags as BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED only, then you cannot connect with an Android device. Is the Android device by any chance using resolvable addresses itself? Because then maybe what's happening is that the address that you're setting on the whitelist is a temporary resolvable address that has changed in the meantime and therefore the stack is filtering out the Android device when advertising. In that case you should use an IRK instead of an address in your whitelist.

    2. If you bond with a device and the remote device supports privacy, you will get its IRK during bonding, which you can later use to whitelist the device using its IRK instead of its address.

  • I don't know about code examples, but I really don't see why your whitelist shouldn't work with Android or Windows since for them it makes no difference at all, the whitelist is a local parameter. If you can connect without whitelist then you should be able to connect after with whitelist (regardless of the flags in the advertising data). Have you checked how you place the address from the Nexus in the ble_gap_addr variable? perhaps you're setting it reversed. Are you sure it's a public address? maybe it's using a static random address. Sorry this is all I can come up with

Reply
  • I don't know about code examples, but I really don't see why your whitelist shouldn't work with Android or Windows since for them it makes no difference at all, the whitelist is a local parameter. If you can connect without whitelist then you should be able to connect after with whitelist (regardless of the flags in the advertising data). Have you checked how you place the address from the Nexus in the ble_gap_addr variable? perhaps you're setting it reversed. Are you sure it's a public address? maybe it's using a static random address. Sorry this is all I can come up with

Children
No Data
Related