You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2021/11/09 12:02:27 UTC
[mynewt-nimble] branch master updated: nimble/ll: Add more
convenient way to set pub dev addr
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
The following commit(s) were added to refs/heads/master by this push:
new 91c5d9a nimble/ll: Add more convenient way to set pub dev addr
91c5d9a is described below
commit 91c5d9a39319b31b81d6655f4dec16e06259cd4a
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Sat Nov 6 00:45:44 2021 +0100
nimble/ll: Add more convenient way to set pub dev addr
This adds BLE_LL_PUBLIC_DEV_ADDR which allows to conveniently set
public device address as 48-bit number. It has priority over existing
BLE_PUBLIC_DEV_ADDR which allows to do the same but in a very nasty
way via code injection so is not very intuitive to use.
---
nimble/controller/src/ble_ll.c | 19 +++++++++++++++----
nimble/controller/syscfg.yml | 9 +++++++++
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/nimble/controller/src/ble_ll.c b/nimble/controller/src/ble_ll.c
index 1a8e462..5305e16 100644
--- a/nimble/controller/src/ble_ll.c
+++ b/nimble/controller/src/ble_ll.c
@@ -1573,6 +1573,10 @@ ble_ll_init(void)
{
int rc;
uint64_t features;
+#if MYNEWT_VAL(BLE_LL_PUBLIC_DEV_ADDR)
+ uint64_t pub_dev_addr;
+ int i;
+#endif
ble_addr_t addr;
struct ble_ll_obj *lldata;
@@ -1584,10 +1588,17 @@ ble_ll_init(void)
/* Set public device address if not already set */
if (ble_ll_is_addr_empty(g_dev_addr)) {
- /* Use sycfg address if configured, otherwise try to read from HW */
- if (!ble_ll_is_addr_empty(MYNEWT_VAL(BLE_PUBLIC_DEV_ADDR))) {
- memcpy(g_dev_addr, MYNEWT_VAL(BLE_PUBLIC_DEV_ADDR), BLE_DEV_ADDR_LEN);
- } else {
+#if MYNEWT_VAL(BLE_LL_PUBLIC_DEV_ADDR)
+ pub_dev_addr = MYNEWT_VAL(BLE_LL_PUBLIC_DEV_ADDR);
+
+ for (i = 0; i < BLE_DEV_ADDR_LEN; i++) {
+ g_dev_addr[i] = pub_dev_addr & 0xff;
+ pub_dev_addr >>= 8;
+ }
+#else
+ memcpy(g_dev_addr, MYNEWT_VAL(BLE_PUBLIC_DEV_ADDR), BLE_DEV_ADDR_LEN);
+#endif
+ if (ble_ll_is_addr_empty(g_dev_addr)) {
rc = ble_hw_get_public_addr(&addr);
if (!rc) {
memcpy(g_dev_addr, &addr.val[0], BLE_DEV_ADDR_LEN);
diff --git a/nimble/controller/syscfg.yml b/nimble/controller/syscfg.yml
index 13b6780..de6e688 100644
--- a/nimble/controller/syscfg.yml
+++ b/nimble/controller/syscfg.yml
@@ -308,6 +308,13 @@ syscfg.defs:
packets for receive on secondary advertising channel.
value: 0
+ BLE_LL_PUBLIC_DEV_ADDR:
+ description: >
+ Set public device address. Address is specified as 48-bit number.
+ If non-zero, this setting has priority over BLE_PUBLIC_DEV_ADDR.
+ Note: this setting should only be used for testing purposes, it is
+ not intended for production builds.
+ value: 0x000000000000
BLE_PUBLIC_DEV_ADDR:
description: >
Allows the target or app to override the public device address
@@ -316,6 +323,7 @@ syscfg.defs:
chip specific location. If non-zero, this address will
be used.
value: "(uint8_t[6]){0x00, 0x00, 0x00, 0x00, 0x00, 0x00}"
+ deprecated: 1
BLE_LL_DTM:
description: >
@@ -462,3 +470,4 @@ syscfg.vals.!BLE_HOST:
syscfg.restrictions:
- OS_CPUTIME_FREQ == 32768
+ - BLE_LL_PUBLIC_DEV_ADDR <= 0xffffffffffff