This is an automated email from the ASF dual-hosted git repository.

janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 33a73cee152930dcb6c974a7c30c790048a640f6
Author: Szymon Janc <szymon.j...@codecoup.pl>
AuthorDate: Fri Mar 19 15:33:04 2021 +0100

    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 9b43d23..b3112f1 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

Reply via email to