diff --git a/nimble/host/include/host/ble_esp_gap.h b/nimble/host/include/host/ble_esp_gap.h index 5915d1045..8742373be 100644 --- a/nimble/host/include/host/ble_esp_gap.h +++ b/nimble/host/include/host/ble_esp_gap.h @@ -96,6 +96,15 @@ int ble_hs_hci_util_write_sugg_def_data_len(uint16_t sugg_max_tx_octets, uint16_ */ int ble_gap_wl_tx_rmv(const ble_addr_t *addrs); +/** + * Adds the address in controller's white list. + * + * @param addrs The entry to be added in the white list. + * + * @return 0 on success; nonzero on failure. + */ +int ble_gap_wl_tx_add(const ble_addr_t *addrs); + /** * Clears all addresses from controller's white list. * diff --git a/nimble/host/include/host/ble_gap.h b/nimble/host/include/host/ble_gap.h index 21b73edb9..47fc4ec1a 100644 --- a/nimble/host/include/host/ble_gap.h +++ b/nimble/host/include/host/ble_gap.h @@ -3376,8 +3376,24 @@ int ble_gap_dtm_enh_rx_start(uint8_t rx_chan, uint8_t index, uint8_t phy); * @return 0 on success; nonzero on failure */ + int ble_gap_read_rem_ver_info(uint16_t conn_handle, uint8_t *version, uint16_t *manufacturer, uint16_t *subversion); +/** + * Read local resolvable address command + * + * @param peer_addr_type Peer Identity Address type + * + * @param peer_addr Peer Identity Address + * + * @param out_addr Local Resolvable Address received from controller. + * + * @return 0 on success; nonzero on failure + */ + +int ble_gap_rd_local_resolv_addr(uint8_t peer_addr_type, const ble_addr_t *peer_addr, + uint8_t *out_addr); + #ifdef __cplusplus } #endif diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c index c5962b96d..0f7afdd53 100644 --- a/nimble/host/src/ble_gap.c +++ b/nimble/host/src/ble_gap.c @@ -3112,7 +3112,7 @@ ble_gap_wl_busy(void) ble_gap_master.conn.using_wl; } -static int +int ble_gap_wl_tx_add(const ble_addr_t *addr) { struct ble_hci_le_add_whte_list_cp cmd; @@ -8295,7 +8295,15 @@ ble_gap_unpair(const ble_addr_t *peer_addr) // Checking if the device is in ble_store if (!rc) { if (value.sec.irk_present) { - // Delete the IRK as it is Distributed + /* We cannot delete entry from resolving list if there is ongoing + * discovery or advertising in progress */ + + if (ble_gap_adv_active() || + ble_gap_disc_active()) { + return BLE_HS_EBUSY; + } + + // Delete the IRK as it is Distributed rc = ble_hs_pvcy_remove_entry(key.sec.peer_addr.type,key.sec.peer_addr.val); if (rc != 0) { BLE_HS_LOG(ERROR, "Error while removing IRK , rc = %x\n",rc); @@ -9148,6 +9156,30 @@ ble_gap_set_transmit_power_reporting_enable(uint16_t conn_handle, return BLE_HS_ENOTSUP; #endif } +int +ble_gap_rd_local_resolv_addr(uint8_t peer_addr_type, const ble_addr_t *peer_addr, + uint8_t *out_addr) +{ + struct ble_hci_le_rd_local_resolv_addr_cp cmd; + struct ble_hci_le_rd_local_resolv_addr_rp rsp; + uint16_t opcode; + int rc; + + opcode = BLE_HCI_OP(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_LOCAL_RESOLV_ADDR); + + cmd.peer_addr_type = peer_addr_type; + memcpy(&cmd.peer_id_addr, peer_addr->val, sizeof(cmd.peer_id_addr)); + + rc = ble_hs_hci_cmd_tx(opcode, &cmd, sizeof(cmd), &rsp, sizeof(rsp)); + + if (rc!=0) { + return rc; + } + + memcpy(out_addr, &rsp.rpa, sizeof(rsp.rpa)); + + return 0; +} #if MYNEWT_VAL(BLE_HCI_VS) #if MYNEWT_VAL(BLE_POWER_CONTROL) diff --git a/nimble/host/src/ble_hs_id.c b/nimble/host/src/ble_hs_id.c index 3fa07187c..ae423934c 100644 --- a/nimble/host/src/ble_hs_id.c +++ b/nimble/host/src/ble_hs_id.c @@ -224,11 +224,13 @@ ble_hs_id_addr(uint8_t id_addr_type, const uint8_t **out_id_addr, switch (id_addr_type) { case BLE_ADDR_PUBLIC: + case BLE_ADDR_PUBLIC_ID: id_addr = ble_hs_id_pub; nrpa = 0; break; case BLE_ADDR_RANDOM: + case BLE_ADDR_RANDOM_ID: id_addr = ble_hs_id_rnd; nrpa = (ble_hs_id_rnd[5] & 0xc0) == 0; break;