One of the most common questions that is often asked is about the BD_ADDR for Bluetooth SMART (WICED SMART) and how to go about getting one. In this post I would like to provide some insights into this topic and some suggestions on how to make the process simple and straightforward.
So first – what is the BD_ADDR?
BD_ADDR is defined in the Bluetooth specification as the “Bluetooth Device Address” – which is used to identify a Bluetooth device. In version 4.0 of the Bluetooth baseband specification (Core System Package) section 1.2 it is stated that “Each Bluetooth device shall be allocated a unique 48-bit Bluetooth device address and that this address shall be obtained from the IEEE Registration Authority. The address shall be created in accordance with “48-bit universal LAN MAC address” of the IEEE 802 specification.”
So at first glance basically the BD_ADDR is the same (or from the same source and format) as the Ethernet MAC address, or more generically the 802.x MAC address since WI-FI (802.11) follows essentially the same specification for its 48-bit MAC address.
However there are a few minor differences between the BD_ADDR and the 48-bit Ethernet MAC address, and also Bluetooth SMART allows a different way to obtain the address and this will also be explained below.
First – going back to where do you get the BD_ADDR from? The specification is quite clear in that this comes from the IEEE Registration Authority. What this exactly means is that the most significant 24 bits of the address are the same as the Organizational Unique Identifier (OUI) that can be obtained from the IEEE at http://standards.ieee.org/develop/regauth/oui/
Now let’s talk about the similarity and differences between the BD_ADDR and the WIFI MAC address. At a first level approximation – both are identical. The upper 24 bits are the OUI, and the lower 24-bits are a unique number that is assigned by the manufacturer for that device. However the WIFI MAC address does have a couple of bits in the OUI that can be different. Bit 0 of the MSB is used to indicate whether the address is a unicast address or a multicast address. And Bit 1 of the MSB is used to indicate whether the address is globally unique (OUI enforced) or locally administered. Bit for all practical purposes a globally unique unicast WIFI MAC address can be used as a BD_ADDR and vice-versa.
When it comes to pure Bluetooth SMART devices (devices that do not have a Bluetooth SMART READY radio or devices that do not need to interface to Bluetooth SMART READY devices via classic profiles) and do not have the need to be on a public visible network (say for example very short range devices inside your closet in your bathroom that just connect to your phone) it is possible to use a random device address. This is described in Volume 6 Part B of the Bluetooth 4.0 specification (Section 1.3). This random address is also 48-bits in length with different requirements based on the type of random address being specified. The details of the types of random addresses allowed are defined in section 10.8 of part C (Generic Access Profile) section of Volume 3 of the Bluetooth 4.0 specification.
Devices are allowed to have both a unique and a random address and use these for different purposes.
Some general guidelines –
- If your organization already has a valid OUI, generate a unique address just like you would for 802.x devices like Ethernet or WiFi using this OUI. You could use the WiFi MAC address for your BD_ADDR, but generally it is not a good idea to use the same address for both your WiFi and Bluetooth devices.
- If you do not care about your device being globally unique, then you can use a static random address with the constraint that the two most significant bits of the address need to be 1, and you cannot have all of the remaining 46 bits be either all 1 or all 0. This address can change between hardware resets, but is generally recommended not to change otherwise because this would be mean that any previous connections would become invalid without the peer being notified.
- If you really don’t want anyone to sniff your packets and your application supports it, you can also use private non-resolvable random addresses or private resolvable random addresses. Details are in the Bluetooth specification.