From 0d2c053f4204af9a7c37b6bc16f81001fed683e5 Mon Sep 17 00:00:00 2001 From: darshan Date: Wed, 1 Nov 2023 12:50:19 +0530 Subject: [PATCH] feat(nimble): Added API to retrieve the size of the controller's white list --- nimble/host/include/host/ble_esp_gap.h | 9 +++++++++ nimble/host/src/ble_gap.c | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/nimble/host/include/host/ble_esp_gap.h b/nimble/host/include/host/ble_esp_gap.h index 53fe0fcfd..da05316ef 100644 --- a/nimble/host/include/host/ble_esp_gap.h +++ b/nimble/host/include/host/ble_esp_gap.h @@ -77,6 +77,15 @@ int ble_gap_wl_tx_rmv(const ble_addr_t *addrs); */ int ble_gap_wl_tx_clear(void); +/** + * Retrieves the size of the controller's white list. + * + * @param size On success, total size of whitelist will be stored here. + * + * @return 0 on success; nonzero on failure. + */ +int ble_gap_wl_read_size(uint8_t *size); + #if MYNEWT_VAL(BLE_POWER_CONTROL) #if MYNEWT_VAL(BLE_HCI_VS) diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c index 309eca097..6e41e1d74 100644 --- a/nimble/host/src/ble_gap.c +++ b/nimble/host/src/ble_gap.c @@ -2501,6 +2501,21 @@ ble_gap_wl_tx_clear(void) BLE_HCI_OCF_LE_CLEAR_WHITE_LIST), NULL, 0, NULL, 0 ); } + +int ble_gap_wl_read_size(uint8_t *size) { + struct ble_hci_le_rd_white_list_rp rsp; + int rc; + + rc = ble_hs_hci_cmd_tx(BLE_HCI_OP(BLE_HCI_OGF_LE, + BLE_HCI_OCF_LE_RD_WHITE_LIST_SIZE), + NULL, 0, &rsp, sizeof(rsp)); + + if (rc == 0) { + *size = rsp.size; + } + + return rc; +} #endif int