Skip to content

Commit 54f3d7c

Browse files
nimble/util: Add public address provider for u-blox modules
Modules from u-blox AG are preprogrammed with a valid public device address stored in UICR registers. This package makes this address usable by NimBLE LL.
1 parent 7dd5987 commit 54f3d7c

File tree

4 files changed

+74
-22
lines changed

4 files changed

+74
-22
lines changed

nimble/drivers/nrf5x/src/ble_hw.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,29 +77,12 @@ ble_ll_addr_provide_public(uint8_t *addr)
7777
uint32_t addr_high;
7878
uint32_t addr_low;
7979

80-
#if MYNEWT_VAL(BLE_PHY_UBLOX_BMD345_PUBLIC_ADDR)
81-
/*
82-
* The BMD-345 modules are preprogrammed from the factory with a unique public
83-
* The Bluetooth device address stored in the CUSTOMER[0] and CUSTOMER[1]
84-
* registers of the User Information Configuration Registers (UICR).
85-
* The Bluetooth device address consists of the IEEE Organizationally Unique
86-
* Identifier (OUI) combined with the hexadecimal digits that are printed on
87-
* a 2D barcode and in human-readable text on the module label.The Bluetooth
88-
* device address is stored in little endian format. The most significant
89-
* bytes of the CUSTOMER[1] register are 0xFF to complete the 32-bit register.
90-
*/
91-
92-
/* Copy into device address. We can do this because we know platform */
93-
addr_low = NRF_UICR->CUSTOMER[0];
94-
addr_high = NRF_UICR->CUSTOMER[1];
95-
#else
9680
if ((NRF_FICR->DEVICEADDRTYPE & 1) != 0) {
9781
return -1;
9882
}
9983

10084
addr_low = NRF_FICR->DEVICEADDR[0];
10185
addr_high = NRF_FICR->DEVICEADDR[1];
102-
#endif
10386

10487
memcpy(&addr[0], &addr_low, 4);
10588
memcpy(&addr[4], &addr_high, 2);

nimble/drivers/nrf5x/syscfg.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,9 @@ syscfg.defs:
8383
value: 0
8484

8585
BLE_PHY_UBLOX_BMD345_PUBLIC_ADDR:
86-
description: >
87-
Ublox BMD-345 modules come with public address preprogrammed
88-
in UICR register. If enabled public address will be read from
89-
custom UICR instead of FICR register.
86+
description: use nimble/util/addr_ublox package instead
9087
value: 0
91-
restrictions: BLE_PHY_ADDR_PROVIDER_PUBLIC
88+
defunct: 1
9289

9390
BLE_PHY_ADDR_PROVIDER_PUBLIC:
9491
description: Enables public address provider API

nimble/util/addr_ublox/pkg.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
pkg.name: nimble/util/addr_ublox
21+
pkg.description: Public address provider for u-blox modules
22+
pkg.author: "Apache Mynewt <[email protected]>"
23+
pkg.homepage: "https://mynewt.apache.org/"
24+
25+
pkg.apis:
26+
- ble_addr_provider_public
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#include <stdint.h>
21+
#include <nrfx.h>
22+
23+
int
24+
ble_ll_addr_provide_public(uint8_t *addr)
25+
{
26+
uint32_t addr_high;
27+
uint32_t addr_low;
28+
29+
/* The u-blox modules are preprogrammed from the factory with a unique public
30+
* device address. The address is stored in the CUSTOMER[0] and CUSTOMER[1]
31+
* registers of the UICR in little endian format. The most significant bytes
32+
* of the CUSTOMER[1] register are 0xFF to complete the 32-bit register value.
33+
*
34+
* The Bluetooth device address consists of the registered OUI combined with
35+
* the hexadecimal digits printed on a 2D barcode and as a human-readable
36+
* text on the module label.
37+
*/
38+
39+
addr_low = NRF_UICR->CUSTOMER[0];
40+
addr_high = NRF_UICR->CUSTOMER[1];
41+
42+
memcpy(&addr[0], &addr_low, 4);
43+
memcpy(&addr[4], &addr_high, 2);
44+
45+
return 0;
46+
}

0 commit comments

Comments
 (0)