diff --git a/nimble/host/include/host/ble_esp_gap.h b/nimble/host/include/host/ble_esp_gap.h index f5c076963..93211a3d9 100644 --- a/nimble/host/include/host/ble_esp_gap.h +++ b/nimble/host/include/host/ble_esp_gap.h @@ -39,6 +39,16 @@ typedef enum gap_status gap_status_t; #endif #endif + +/** + * 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); + /** * This API gives the current status of various stack operations * diff --git a/nimble/host/include/host/ble_gap.h b/nimble/host/include/host/ble_gap.h index bf554a314..d6635c063 100644 --- a/nimble/host/include/host/ble_gap.h +++ b/nimble/host/include/host/ble_gap.h @@ -3050,8 +3050,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 ebfacc797..911371043 100644 --- a/nimble/host/src/ble_gap.c +++ b/nimble/host/src/ble_gap.c @@ -2896,7 +2896,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; @@ -7587,7 +7587,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); @@ -8433,6 +8441,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) int ble_gap_clear_legacy_adv(void) diff --git a/nimble/host/src/ble_hs_id.c b/nimble/host/src/ble_hs_id.c index dffa3af24..a5bb4a100 100644 --- a/nimble/host/src/ble_hs_id.c +++ b/nimble/host/src/ble_hs_id.c @@ -222,11 +222,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; diff --git a/nimble/include/nimble/hci_common.h b/nimble/include/nimble/hci_common.h index 1b116e339..a34454f61 100644 --- a/nimble/include/nimble/hci_common.h +++ b/nimble/include/nimble/hci_common.h @@ -482,20 +482,20 @@ struct ble_hci_le_rd_resolv_list_size_rp { } __attribute__((packed)); #define BLE_HCI_OCF_LE_RD_PEER_RESOLV_ADDR (0x002B) -struct ble_hci_le_rd_peer_recolv_addr_cp { +struct ble_hci_le_rd_peer_resolv_addr_cp { uint8_t peer_addr_type; uint8_t peer_id_addr[6]; } __attribute__((packed)); -struct ble_hci_le_rd_peer_recolv_addr_rp { +struct ble_hci_le_rd_peer_resolv_addr_rp { uint8_t rpa[6]; } __attribute__((packed)); #define BLE_HCI_OCF_LE_RD_LOCAL_RESOLV_ADDR (0x002C) -struct ble_hci_le_rd_local_recolv_addr_cp { +struct ble_hci_le_rd_local_resolv_addr_cp { uint8_t peer_addr_type; uint8_t peer_id_addr[6]; } __attribute__((packed)); -struct ble_hci_le_rd_local_recolv_addr_rp { +struct ble_hci_le_rd_local_resolv_addr_rp { uint8_t rpa[6]; } __attribute__((packed));