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.
-
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?
- If I bonded with device previously, does it change adverticement-connection algorithm in case of whitelist advertisement ?
Sincerely yours,