From a31aafb14c0bf6525f27d58bd1f65860f0f55782 Mon Sep 17 00:00:00 2001 From: Prasad Alatkar Date: Tue, 5 Jan 2021 20:33:03 +0530 Subject: [PATCH] NimBLE host: Add API to remove address from whitelist --- nimble/host/include/host/ble_gap.h | 9 +++++++++ nimble/host/src/ble_gap.c | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/nimble/host/include/host/ble_gap.h b/nimble/host/include/host/ble_gap.h index d99d424e8..ed7fbb128 100644 --- a/nimble/host/include/host/ble_gap.h +++ b/nimble/host/include/host/ble_gap.h @@ -1791,6 +1791,15 @@ int ble_gap_terminate(uint16_t conn_handle, uint8_t hci_reason); */ int ble_gap_wl_set(const ble_addr_t *addrs, uint8_t white_list_count); +/** + * Removes the address from controller's white list. + * + * @param addrs The entry to be removed from the white list. + * + * @return 0 on success; nonzero on failure. + */ +int ble_gap_wl_tx_rmv(const ble_addr_t *addrs); + /** * Initiates a connection parameter update procedure. * diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c index a5f45e613..9e275c54f 100644 --- a/nimble/host/src/ble_gap.c +++ b/nimble/host/src/ble_gap.c @@ -2110,6 +2110,23 @@ ble_gap_wl_tx_clear(void) } #endif +int +ble_gap_wl_tx_rmv(const ble_addr_t *addr) +{ + struct ble_hci_le_rmv_white_list_cp cmd; + + if (addr->type > BLE_ADDR_RANDOM) { + return BLE_HS_EINVAL; + } + + memcpy(cmd.addr, addr->val, BLE_DEV_ADDR_LEN); + cmd.addr_type = addr->type; + + return ble_hs_hci_cmd_tx(BLE_HCI_OP(BLE_HCI_OGF_LE, + BLE_HCI_OCF_LE_RMV_WHITE_LIST), + &cmd, sizeof(cmd), NULL, 0); +} + int ble_gap_wl_set(const ble_addr_t *addrs, uint8_t white_list_count) {