You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2021/02/04 16:58:00 UTC

[mynewt-nimble] 01/02: nuttx example: generate random address

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 f25b1de0d385537a83cd347b56c7ea168d5f9ec2
Author: Matias N <ma...@protobits.dev>
AuthorDate: Wed Jan 27 09:54:46 2021 -0300

    nuttx example: generate random address
---
 porting/examples/nuttx/ble.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/porting/examples/nuttx/ble.c b/porting/examples/nuttx/ble.c
index da7bdec..60c0f6b 100644
--- a/porting/examples/nuttx/ble.c
+++ b/porting/examples/nuttx/ble.c
@@ -97,6 +97,17 @@ static void
 app_ble_sync_cb(void)
 {
     int rc;
+    ble_addr_t addr;
+
+    /* generate new non-resolvable private address */
+
+    rc = ble_hs_id_gen_rnd(1, &addr);
+    assert(rc == 0);
+
+    /* set generated address */
+
+    rc = ble_hs_id_set_rnd(addr.val);
+    assert(rc == 0);
 
     rc = ble_hs_util_ensure_addr(0);
     assert(rc == 0);