From 0d482c4ed029c8c0b73cd4950b96d1115ac22213 Mon Sep 17 00:00:00 2001 From: Rahul Tank Date: Mon, 12 Jun 2023 16:43:24 +0530 Subject: [PATCH] Fix compilation issue in enabling BLE_HCI_VS flag --- nimble/host/src/ble_hs_hci_evt.c | 4 ++-- nimble/host/util/src/addr.c | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/nimble/host/src/ble_hs_hci_evt.c b/nimble/host/src/ble_hs_hci_evt.c index 3a266a692..cc26f25f3 100644 --- a/nimble/host/src/ble_hs_hci_evt.c +++ b/nimble/host/src/ble_hs_hci_evt.c @@ -103,7 +103,7 @@ static const struct ble_hs_hci_evt_dispatch_entry ble_hs_hci_evt_dispatch[] = { { BLE_HCI_EVCODE_ENC_KEY_REFRESH, ble_hs_hci_evt_enc_key_refresh }, { BLE_HCI_EVCODE_HW_ERROR, ble_hs_hci_evt_hw_error }, #if MYNEWT_VAL(BLE_HCI_VS) - { BLE_HCI_EVCODE_VS, ble_hs_hci_evt_vs }, + { BLE_HCI_EVCODE_VS_DEBUG, ble_hs_hci_evt_vs }, #endif }; @@ -322,7 +322,7 @@ ble_hs_hci_evt_num_completed_pkts(uint8_t event_code, const void *data, static int ble_hs_hci_evt_vs(uint8_t event_code, const void *data, unsigned int len) { - const struct ble_hci_ev_vs *ev = data; + const struct ble_hci_ev_vs_debug *ev = data; if (len < sizeof(*ev)) { return BLE_HS_ECONTROLLER; diff --git a/nimble/host/util/src/addr.c b/nimble/host/util/src/addr.c index 9b43d237c..da360aa77 100644 --- a/nimble/host/util/src/addr.c +++ b/nimble/host/util/src/addr.c @@ -27,12 +27,10 @@ static int ble_hs_util_load_rand_addr(ble_addr_t *addr) { - /* XXX: It is unfortunate that the function to retrieve the random address - * is in the controller package. A host-only device ought to be able to - * automically restore a random address. - */ -#if MYNEWT_VAL(BLE_CONTROLLER) - int rc; + int rc = BLE_HS_ENOADDR; + +#if MYNEWT_VAL(BLE_HCI_VS) + struct ble_hci_vs_rd_static_addr_rp rsp; rc = ble_hw_get_static_addr(addr); if (rc == 0) { @@ -40,7 +38,13 @@ ble_hs_util_load_rand_addr(ble_addr_t *addr) } #endif - return BLE_HS_ENOADDR; +#if SOC_ESP_NIMBLE_CONTROLLER + rc = esp_ble_hw_get_static_addr((esp_ble_addr_t *)addr); + if (rc == 0) { + return 0; + } +#endif + return rc; } static int