Note: This KBA has been marked as deprecated. A more updated KBA can be found here:
https://docs.silabs.com/bluetooth/latest/code-examples/stack-features/adv-and-scanning/adv-and-scanning-with-le-coded-phy
Introduction
One of the new features added in Bluetooth 5 is the LE coded PHY which enables longer range connections. This article describes how advertising on the coded PHY works, as well how to establish a connection using the coded PHY.
Discussion
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

The common extended advertising format looks like this

The ADV mode field is shown below, note that is not permitted to be scannable and connectable at the same time

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

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

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 not presently used. 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 advertisments, the following API function can be 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 can be 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.
Please refer here for an article summarizing the changes to the API in version 2.8.
Example Applications
Source code for an example advertiser and observer are attached below. To use this code please do as follows
- Create an soc-empty sample application from the project menu->new->Silicon Labs Appbuilder
- Save app.c and app.h for the advertiser to the project folder
- Comment out the while(1) in main.c
- add a call to appMain() just before the while(1) loop
- add the following line near the top of main.c
#include “app.h”
- Build the project and flash to your radio board.
- Create a second soc-empty sample as in #1 above for the client.
- Save app.c and app.h for the client to this project folder (note that the contents of app.c are different)
- Repeat steps 3 – 5 for this project.
- Open hal-config.h and change the definition of HAL_VCOM_ENABLE to 1
- Go to the hardware\kit\common\drivers folder of your SDK and copy retargetio.c, retargetserialc and retargetserial.h to the hardware\kit\common\drivers in the project
- Build and flash to a second radio board.
- Launch a console for this second board , select the Serial1 tab and hit enter in the text box at the bottom to wake it up.
- Press reset on the WSTK to see the startup messages.
- Power up the first WSTK and you’ll see that the client connects to it on the LE coded PHY.
[Deprecated] KBA_BT_0302: Advertising and Scanning with LE Coded PHY
Note: This KBA has been marked as deprecated. A more updated KBA can be found here:
https://docs.silabs.com/bluetooth/latest/code-examples/stack-features/adv-and-scanning/adv-and-scanning-with-le-coded-phy
Introduction
One of the new features added in Bluetooth 5 is the LE coded PHY which enables longer range connections. This article describes how advertising on the coded PHY works, as well how to establish a connection using the coded PHY.
Discussion
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
The common extended advertising format looks like this
The ADV mode field is shown below, note that is not permitted to be scannable and connectable at the same time
The extended header is laid out as follows, not all fields will be present in every advertisement
The aux pointer field provides information about the auxiliary advertisement as shown below
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 not presently used. 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 advertisments, the following API function can be 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 can be 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.
Please refer here for an article summarizing the changes to the API in version 2.8.
Example Applications
Source code for an example advertiser and observer are attached below. To use this code please do as follows
#include “app.h”
Hi,
Thanks, this was helpful. I made an SPP over BLE example with coded phy which works well but I did have some problems with a very slow discover services and enable notifications. It took 9 seconds to finish establishing the link before I could send data.
So, in case it helps others with the same problem:
In the example code in le-connections-client-main.c the connection parameters are set as below:
case gecko_evt_system_boot_id:
printf("System Boot\r\n");
// this caused very slow negotiation of characteristic notification.
// 700 min interval x 1.25mS = 0.87 Second connection interval x multiple intervals during negotiation!
gecko_cmd_le_gap_set_conn_parameters(700,760,1,600);
I reduced the minimum connection interval and now have a fast enough connection.
Regards,
Andy
Hi,
we're in the process of making all the sample code for these articles more portable. For now you can create an soc-empty project for your module and paste in the le-connections-client-main.c/lcoded-phy-main.c to replace the main.c that comes from the soc-empty sample.
You may also need to comment out some of the printf() statements. I'll post an updated sample here when it's ready.
Steve
I will have a try, I guess the simplest way to run this is program one kit as advertiser, as the step above, and program the other kit as NCP and use BG Tool and run with it.
EDIT: Running BG Tools as the client able to scan and read the advertisement from first part, but using the client app.c and app.h, it would just give me:
System Bootble devices in range
le_set_gap_set_discovery_timing returns 0
le_set_gap_set_discovery_type returns 0
le_set_gap_start_discovery returns 0
no connectable devices in range
EDIT2: manage to edit MAC address filter to match mine. Then also removing timers, for my purpose, I only need to plot the RSSI values no need to connect. For connection and throughput test, I would hope someone answering my question on another topic, where the throughput test can be started using Coded PHY as default.
Hi bluetoothsteve,
(1) I advice you that, using Chrome or Edge browsers, I do not see any image you posted here.
(2) I'm interested on transmit ADV Payload with Manufacturer Data (like iBeacon for example), can you suggest me the modifications needed in the actual ADVERTISER code to do that. Thanks.
Valter
@bluetoothsteve:
Hi, I have tried looking out for those images on Chrome (Version 70.0.3538.77 - Official Build, 64-bit), Microsoft Edge (Version 42.17134.1.0) and Internet Explorer (Version 11.345.17134.0). Still not visible.
Hi All,
Seems we're having trouble inlining images in knowledgebase articles. I'll attach a pdf version of the article.
Steve
Hi bluetoothsteve,
I'm interested on transmit ADV Payload with Manufacturer Data (like iBeacon for example), can you suggest me the modifications needed in the actual ADVERTISER code to do that. Thanks.
Valter