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

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

commit 0ceef89b723a79968868bc5769fa166a17bbaa80
Author: MichaƂ Narajowski <[email protected]>
AuthorDate: Wed Oct 2 10:57:58 2019 +0200

    apps/bttester: Use random addr from HW instead of generating new one
---
 apps/bttester/pkg.yml   |  1 +
 apps/bttester/src/gap.c | 10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/apps/bttester/pkg.yml b/apps/bttester/pkg.yml
index cd872a2..7bec9c0 100644
--- a/apps/bttester/pkg.yml
+++ b/apps/bttester/pkg.yml
@@ -33,6 +33,7 @@ pkg.deps:
     - "@apache-mynewt-core/sys/shell"
     - "@apache-mynewt-nimble/nimble/controller"
     - "@apache-mynewt-nimble/nimble/host"
+    - "@apache-mynewt-nimble/nimble/host/util"
     - "@apache-mynewt-nimble/nimble/host/services/gap"
     - "@apache-mynewt-nimble/nimble/host/services/gatt"
     - "@apache-mynewt-nimble/nimble/host/store/ram"
diff --git a/apps/bttester/src/gap.c b/apps/bttester/src/gap.c
index 0856a68..175020b 100644
--- a/apps/bttester/src/gap.c
+++ b/apps/bttester/src/gap.c
@@ -27,6 +27,7 @@
 
 #include <host/ble_gap.h>
 #include "host/ble_gap.h"
+#include "host/util/util.h"
 #include "console/console.h"
 
 #include "../../../nimble/host/src/ble_hs_pvcy_priv.h"
@@ -161,14 +162,19 @@ static void controller_info(u8_t *data, u16_t len)
 
        memset(&rp, 0, sizeof(rp));
 
-       rc = ble_hs_id_gen_rnd(MYNEWT_VAL(BTTESTER_USE_NRPA), &addr);
+       /* Make sure we have proper identity address set (public preferred) */
+       rc = ble_hs_util_ensure_addr(1);
        assert(rc == 0);
-       rc = ble_hs_id_set_rnd(addr.val);
+       rc = ble_hs_id_copy_addr(BLE_ADDR_RANDOM, addr.val, NULL);
        assert(rc == 0);
 
        if (MYNEWT_VAL(BTTESTER_PRIVACY_MODE)) {
                if (MYNEWT_VAL(BTTESTER_USE_NRPA)) {
                        own_addr_type = BLE_OWN_ADDR_RANDOM;
+                       rc = ble_hs_id_gen_rnd(1, &addr);
+                       assert(rc == 0);
+                       rc = ble_hs_id_set_rnd(addr.val);
+                       assert(rc == 0);
                } else {
                        own_addr_type = BLE_OWN_ADDR_RPA_RANDOM_DEFAULT;
                }

Reply via email to