From 33a73cee152930dcb6c974a7c30c790048a640f6 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Fri, 19 Mar 2021 15:33:04 +0100 Subject: [PATCH] nimble/util: Use VS HCI command for reading static random address Use dedicated VS command for reading static address instead of calling controller code from host. This is required to properly support multi-core MCUs where host and controller runs on separate cores. --- nimble/host/util/src/addr.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/nimble/host/util/src/addr.c b/nimble/host/util/src/addr.c index 9b43d237c..b3112f128 100644 --- a/nimble/host/util/src/addr.c +++ b/nimble/host/util/src/addr.c @@ -19,23 +19,21 @@ #include "host/ble_hs.h" #include "host/util/util.h" - -#if MYNEWT_VAL(BLE_CONTROLLER) -#include "controller/ble_hw.h" -#endif +#include "../src/ble_hs_hci_priv.h" 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) +#if MYNEWT_VAL(BLE_HCI_VS) + struct ble_hci_vs_rd_static_addr_rp rsp; int rc; - rc = ble_hw_get_static_addr(addr); + rc = ble_hs_hci_cmd_tx(BLE_HCI_OP(BLE_HCI_OGF_VENDOR, + BLE_HCI_OCF_VS_RD_STATIC_ADDR), + NULL, 0, &rsp, sizeof(rsp)); if (rc == 0) { + addr->type = BLE_ADDR_RANDOM; + memcpy(addr->val, rsp.addr, sizeof(addr->val)); return 0; } #endif