Multiple Advertising Sets
Bluetooth 5 introduces a number of useful new features, such as multiple advertising sets. This feature supports having more than one advertising sets concurrently without having to stop and restart advertising.
All parameters including the advertising interval, advertising data, discoverability, connectability and number of advertisements to send before stopping can be configured independently for each advertising set. The most relevant APIs for configuring advertising sets are discussed below.
Maximum Advertising Sets
To enable multiple advertising, the
MAX_ADVERTISERS value should be set greater than one. The default value is 1.
To set the advertising data, use the API
gecko_cmd_le_gap_bt5_set_adv_data(handle, scan_rsp, adv_data_len, adv_data_data), where:
handle: advertising set handle
scan_rsp: tells whether the data is
- 0: Advertising packets
- 1: Scan response packets
- 2: OTA advertising packets
- 4: OTA scan response packets
- 8: Periodic advertising packets
adv_data_len: array length
adv_data_data: data to be set
Maximum Advertising Power
Users can also set the maximum advertising TX power on a given advertising set by calling the API
power is the TX power in units of 0.1 dBm on a given advertising set specified by
handle. For instance, value of 80 sets the TX power to 8dBm.
Note that if the TX power value goes over the global value that was set using
gecko_cmd_system_set_tx_power command, the global value will be the maximum limit.
To control advertising parameters , use
gecko_cmd_le_gap_set_advertise_timing(handle, interval_min, interval_max, duration, maxevents), where:
handle: advertising set handle
interval_min: minimum advertising interval in units of 0.625 ms
interval_max: maximum advertising interval in units of 0.625 ms
duration: advertising duration in units of 10 ms for the advertising set specified by
maxevents: the maximum number of advertising events to send before advertiser is stopped.
Finally, advertising on a given advertising set can be started using
gecko_cmd_le_gap_start_advertising(handle, discover, connect), where
discover: the discoverable mode of the advertising set
connect: the connectable mode of the advertising set
Note that the number of concurrent advertising is limited by the
MAX_ADVERTISERS configuration discussed above. Similarly, the number of connectable advertising is also limited by
MAX_CONNECTIONS configuration. For example, only one connectable advertising can be enabled if the device has (
MAX_CONNECTIONS - 1) connections when this command is called. The limitation does not apply to non-connectable advertising, though.
The example code below demonstrates multiple advertising features in Bluetooth 5. Two advertising sets, one connnectable, and another non-connectable (iBeacon), are configured separately using their respective handles. The advertising interval and TX power values used for each advertising set is different so that they can easily be distinguished from the Energy Profile perspective in Simplicity Studio.
In addition to debug print out messages, LED0 is used to indicate the connection status. Follow the instructions below and verify the result using the Energy Profile perspective in Simplicity Studio, and the LED0 status on the controller board.
Create a new
SOC - Emptyproject in Simplicity Studio.
app.hfile and replace the content in each file with the respective contents provided under source.
Build the project and download to your target device.
Open Energy Profile perspective in Simplicity Studio and Start Energy Capture on your device (Quick Access menu). You should be able to see the following linear plot for the current consumption of your device.
Open Blue Gecko mobile app and try to connect with your target device. LED0 will be ON when connection is established. Meanwhile, beacons are still broadcast.
Disconnect the connection and the advertising should start again. The following figure shows the debug print out messages.