A BLE device needs an address to do just about anything. For information on the various types of Bluetooth addresses, see the NimBLE Host Identity Reference.
There are several methods for assigning an address to a NimBLE device. The available options are documented below:
When Mynewt is running on a Nordic nRF platform, the NimBLE controller will attempt to read a public address out of the board's FICR or UICR registers. The controller uses the following logic while trying to read an address from hardware:
The NimBLE controller package exports a syscfg setting called BLE_PUBLIC_DEV_ADDR
. This setting can be overridden at the application or target level to configure a public Bluetooth address. For example, a target can assign the public address 11:22:33:44:55:66 as follows:
syscfg.vals: BLE_PUBLIC_DEV_ADDR: '(uint8_t[6]){0x66, 0x55, 0x44, 0x33, 0x22, 0x11}'
This setting takes the form of a C expression. Specifically, the value is a designated initializer expressing a six-byte array. Also note that the bytes are reversed, as an array is inherently little-endian, while addresses are generally expressed in big-endian.
Note: this method takes precedence over method 1. Whatever is written to the BLE_PUBLIC_DEV_ADDR
setting is the address that gets used.
Random addresses get configured through the NimBLE host. The following two functions are used in random address configuration:
For an example of how this is done, see the BLE iBeacon tutorial.
Note: A NimBLE device can be configured with multiple addresses; at most one of each address type.