Skip to content

Commit 33a73ce

Browse files
committed
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.
1 parent ddd0046 commit 33a73ce

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

nimble/host/util/src/addr.c

+8-10
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,21 @@
1919

2020
#include "host/ble_hs.h"
2121
#include "host/util/util.h"
22-
23-
#if MYNEWT_VAL(BLE_CONTROLLER)
24-
#include "controller/ble_hw.h"
25-
#endif
22+
#include "../src/ble_hs_hci_priv.h"
2623

2724
static int
2825
ble_hs_util_load_rand_addr(ble_addr_t *addr)
2926
{
30-
/* XXX: It is unfortunate that the function to retrieve the random address
31-
* is in the controller package. A host-only device ought to be able to
32-
* automically restore a random address.
33-
*/
34-
#if MYNEWT_VAL(BLE_CONTROLLER)
27+
#if MYNEWT_VAL(BLE_HCI_VS)
28+
struct ble_hci_vs_rd_static_addr_rp rsp;
3529
int rc;
3630

37-
rc = ble_hw_get_static_addr(addr);
31+
rc = ble_hs_hci_cmd_tx(BLE_HCI_OP(BLE_HCI_OGF_VENDOR,
32+
BLE_HCI_OCF_VS_RD_STATIC_ADDR),
33+
NULL, 0, &rsp, sizeof(rsp));
3834
if (rc == 0) {
35+
addr->type = BLE_ADDR_RANDOM;
36+
memcpy(addr->val, rsp.addr, sizeof(addr->val));
3937
return 0;
4038
}
4139
#endif

0 commit comments

Comments
 (0)