Feedback
Feedback

If you are having issues with the exercises, please create a ticket on DevZone: devzone.nordicsemi.com
Click or drag files to this area to upload. You can upload up to 2 files.

Advertisement packet

Let’s examine how an advertisement packet is structured.

The BLE packet is pictured below, with the main portion going to what’s called the Protocol Data Unit (PDU). The PDU consists of either an advertising PDU (sometimes called an advertising channel PDU) or a data PDU (sometimes called a data channel PDU), depending on whether the BLE packet is used for advertisement or data transmission.

Bluetooth LE packet structure

As we can see in the image, the advertising PDU consists of a header and a payload.

The header part of the advertising PDU consists of:

Advertisement PDU header
  • PDU Type: Determines the advertisement type that we discussed in Advertising types, such as ADV_IND.
  • RFU: Reserved for future use.
  • ChSel: Set to 1 if LE Channel Selection Algorithm #2 is supported.
  • TxAdd (Tx Address): 0 or 1, depending on the transmitter address is public or random.
  • RxAdd (Rx Address): 0 or 1, depending on the receiver address is public or random.
  • Length: The length of the payload

The payload of the advertising PDU is divided into two sections, where the first 6 bytes represent the advertiser’s address (AdvA) and the rest goes to the actual advertisement data (AdvData).

Advertisement PDU payload
  • AdvA: Bluetooth address of the advertising device
  • AdvData: Advertisement data packet

Note

The payload structure depends on the kind of advertising. When doing directed advertisement (ADV_DIRECT_IND) some space is needed to also specify the receiver’s address. Therefore, the AdvData field is replaced by a receiver address field with a size of 6 bytes. Advertisement packtes of this type (ADV_DIRECT_IND) do not include a payload.

The advertisement data section is represented as shown in the figure below.

Advertising packet payload

The advertisement data packet is composed of multiple structures called advertisement data structures (AD structures). Each AD structure has a length field, a field to specify the type (AD Type), and a field for the actual data itself (AD Data). Note that the most common AD type is 1 byte long.

The advertising data types are defined by the Bluetooth specification and are documented in the nRF Connect SDK here.

Below are a few commonly used ones, that we will be using in following exercises.

  • Complete local name (BT_DATA_NAME_COMPLETE): This is simply the device name, that the human user sees when scanning for nearby devices (via a smartphone, for instance).
  • Shortened local name (BT_DATA_NAME_SHORTENED): A shorter version of the complete local name.
  • Uniform Resource Identifier (BT_DATA_URI): Used to advertise a URI like website addresses (URLs).
  • Service UUID: The Service Universally Unique Identifier is a number universally unique to a specific service. It can help scanners identify devices that are interesting to connect to. Different options are available here.
  • Manufacturer Specific Data (BT_DATA_MANUFACTURER_DATA). This is a popular type that enables companies to define their own custom advertising data, as in the case of iBeacon.
  • Flags: 1-bit variables that can flag a certain property or operational mode of that device.

Here is an example of an advertising data structure that is setting the flag BT_LE_AD_NO_BREDR.

Example of an advertising data structure

Flags

The advertisement flags are one-bit flags encapsulated in one byte, meaning that there are up to 8 flags that can be set. We will take a look at some of the most commonly used flags

  • BT_LE_AD_LIMITED: Sets LE Limited Discoverable Mode, used with connectable advertising to indicate to a central that the device is only available for a certain amount of time before the advertising times out
  • BT_LE_AD_GENERAL: Sets LE General Discoverable Mode, used in connectable advertising to indicate that advertising is available for a long period of time (timeout = 0).
  • BT_LE_AD_NO_BREDR: Indicates that classic Bluetooth (BR/EDR) is not supported

Both BT_LE_AD_LIMITED & BT_LE_AD_GENERAL are meant for a device in a peripheral role.

Register an account
Already have an account? Log in
(All fields are required unless specified optional)

  • 8 or more characters
  • Upper and lower case letters
  • At least one number or special character

Forgot your password?
Enter the email associated with your account, and we will send you a link to reset your password.