Advertising and Scanning with LE Coded PHY

Description

One of the new features added in Bluetooth 5 is the LE coded PHY, which enables longer range connections. This example shows how advertising on the coded PHY works, as well how to establish a connection using the coded PHY.

Traditional Bluetooth low energy advertisements use channels 37, 38, and 39 only for advertising. The advertisement is identical on each channel and contains the advertiser’s address and advertising data payload. Starting in Bluetooth 5, it is possible to offload the advertising data payload onto one of the data channels. In this new type of advertisement, the same three advertising channels are used but instead of including the data payload, they include a pointer to the data channel and the offset time until the data payload is expected. This type of advertising is known as extended advertising. The following diagram is provided to illustrate extended advertising.

img

The common extended advertising format looks like the following:

img

The ADV mode field is shown below. Note that it is not permitted to be scannable and connectable at the same time.

img

The extended header is laid out as follows. Not all fields will be present in every advertisement.

img

The aux pointer field provides information about the auxiliary advertisement, as shown below.

img

The channel index indicates which channel the auxiliary advertisement will come on. The CA field indicates the clock accuracy, the offset units indicate whether the offset (time until the auxiliary advertisement) is in units of 30 us or 300 us, the aux offset indicates the number of offset units until the auxiliary advertisement can be expected, and the aux PHY indicates which PHY be used in the auxiliary advertisement.

The sync info field is used for Periodic Advertisement synchronization, not discussed here. The TX Power field indicates the transmitted power in dBm.

Another feature of these extended advertisements is that it is possible to specify the PHY used for the primary and secondary advertisements separately. To set the PHY used for advertisements, the following API function is used:

gecko_cmd_le_gap_set_advertise_phy(0, le_gap_phy_coded , le_gap_phy_coded);

The parameters indicate the advertisement set to be used, the PHY for primary advertisements, and the PHY used for secondary advertisements.

Advertisements on the coded PHY do not support active scanning. This means that is always necessary to use the new connectability mode le_gap_connectable_non_scannable.

To start advertising, the following API function is used:

gecko_cmd_le_gap_start_advertising(0,le_gap_general_discoverable, le_gap_connectable_non_scannable);

Remaining advertising parameters can be set as they would with the traditional 1 Mbps PHY.

Setting up

To test the example, you need two radio boards.

  1. Create an SoC-Empty example for one of the radio boards in Simplicity Studio.

  2. Copy the attached app_advertiser.c in the project replacing the existing app.c.

  3. Set DEBUG_LEVEL to 1 in app.h.

  4. Build and flash the project to the radio board.

  5. Create an SoC-Empty example for the other radio board.

  6. Copy the attached app_scanner.c in the project replacing the existing app.c.

  7. Set DEBUG_LEVEL to 1 in app.h.

  8. Build and flash the project to the radio board.

Usage

Open two terminal programs and connect to the radio boards via VCOM. After you reset both boards, the advertiser will start advertising on Coded PHY, while the scanner will start scanning on Coded PHY. Because most of the Bluetooth devices around you are advertising on 1 Mbps PHY, most probably your two test devices will find each other. Observe the logs on the terminals.

Source