2. Setting the Bluetooth Device Address and Device Name

Each SmartBond™ device software example uses a default Bluetooth Device (BD) Address, if the developer has not assigned a different one. This section provides a step-by-step description of how to change the BD Address and Device Name to make it suitable for your application needs.

2.1. Setting the BD Address

There are two types of Bluetooth Device Addresses, which are called Public Device Address and Random Device Address.

A Public Device Address is a globally unique 48-bit identifier, which consists of two fields:

  • The 24 most significant bits are called the Organizational Unique Identifier, and its purpose is to identify each company. It is administered by the IEEE Registration Authority.

  • The 24 least significant bits are assigned by the company, and they serve the purpose of identifying each device.

A Random Device Address is a privacy feature of the BLE protocol, and it helps to prevent tracking of a device. BLE provides a resolution mechanism so that only a device which holds the connection link key can identify the device.

The public address of the device is set in the CFG_NVDS_TAG_BD_ADDRESS macro in da1458x_config_advanced.h. The default address is : {0x02, 0x00, 0x70, 0xCA, 0xEA, 0x80}.

Code snippet:

/******************************************************************************************/
/* NVDS configuration                                                                     */
/* - CFG_NVDS_TAG_BD_ADDRESS   Default bdaddress. If bdaddress is written in OTP header   */
/*                             this value is ignored                                      */
/******************************************************************************************/
#define CFG_NVDS_TAG_BD_ADDRESS             {0x02, 0x00, 0x70, 0xCA, 0xEA, 0x80}

To change the BD Address you only have to change this define. For instance, you can set it to:

Code snippet:

#define CFG_NVDS_TAG_BD_ADDRESS             {0x01, 0x02, 0x03, 0x04, 0x05, 0x06}

A new device with {0x01, 0x02, 0x03, 0x04, 0x05, 0x06} as the BD Address will then show up in the list of discovered devices as shown in Figure 6 (screenshot from a BLE Scanner application).

_images/Figure3.jpg

Figure 6 Setting the BD Address

2.2. Setting the Advertised Device Name

Since it would be quite difficult for a user to identify a device using only its BD Address, BLE provides the Device Name property, which is a human-friendly name used to tag a device. This is assigned with the USER_DEVICE_NAME macro, which can be customized in user_config.h.

This example demonstrates how to change the advertised Device Name based on the barebone example: projects/target_apps/ble_examples/ble_app_barebone. Section “Build a DA14531 Application” of the DA14531 Getting Started Guide with the PRO-Development Kit demonstrate a BLE advertising procedure. Refer to this for more details.

The barebone example demonstrates a simple barebone project which advertises its presence with customized data. Figure 7 shows an example where a smartphone operates as a Central and a DA14585/586 or DA14531 device as a Peripheral.

Code snippet:

/*
 ****************************************************************************************
 *
 * Device name.
 *
 * - If there is space left in the advertising or scan response data, the device name
 *   is copied there. The device name can be read at anytime by a connected peer, if
 *   the application supports it.
 * - The Bluetooth device name can be up to 248 bytes.
 *
 ****************************************************************************************
 */
/// Device name
#define USER_DEVICE_NAME        "DLG-BRBN"

/// Device name length
#define USER_DEVICE_NAME_LEN    (sizeof(USER_DEVICE_NAME)-1)
BLE connection with Pro DK

Figure 7 BLE Connection with Pro DK

To customize the advertised device name, change the macro definition as required:

Code snippet:

#define USER_DEVICE_NAME        "DLG-TUTORIAL"

Then compile and download the barebone example again to see that your device name has changed.