Skip to content

Commit dcbcbe8

Browse files
Thomas-Deppekartben
authored andcommitted
Bluetooth: Host: Add host support for Advertising Coding Selection
Extends the API for Advertising Coding Selection. The API is extended to set the Advertising Coding Selection (Host Support) bit. With this feature, the primary and secondary PHY can now explicitly report S=2 or S=8 coding in the extended advertising report. Previously, the report only indicated LE Coded regardless of whether S=2 or S=8 data coding was used. The API now sets the host support bit and ensures that the advertising PHY coding scheme is conveyed to the application via the scan callback. The support is enabled by CONFIG_BT_EXT_ADV_CODING_SELECTION, and requires a controller that selects CONFIG_BT_CTLR_ADV_EXT_CODING_SELECTION_SUPPORT. Signed-off-by: Thomas Deppe <[email protected]>
1 parent b39a830 commit dcbcbe8

File tree

5 files changed

+57
-3
lines changed

5 files changed

+57
-3
lines changed

include/zephyr/bluetooth/gap.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,8 +747,16 @@ enum {
747747
BT_GAP_LE_PHY_1M = BIT(0),
748748
/** LE 2M PHY */
749749
BT_GAP_LE_PHY_2M = BIT(1),
750-
/** LE Coded PHY */
750+
/** LE Coded PHY, coding scheme not specified */
751751
BT_GAP_LE_PHY_CODED = BIT(2),
752+
/** LE Coded S=8 PHY. Only used for advertising reports
753+
* when Kconfig BT_EXT_ADV_CODING_SELECTION is enabled.
754+
*/
755+
BT_GAP_LE_PHY_CODED_S8 = BIT(3),
756+
/** LE Coded S=2 PHY. Only used for advertising reports
757+
* when Kconfig BT_EXT_ADV_CODING_SELECTION is enabled.
758+
*/
759+
BT_GAP_LE_PHY_CODED_S2 = BIT(4),
752760
};
753761

754762
/** Advertising PDU types */

include/zephyr/bluetooth/hci_types.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3203,6 +3203,14 @@ struct bt_hci_evt_le_phy_update_complete {
32033203
#define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_INCOMPLETE 2
32043204
#define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_RX_FAILED 0xFF
32053205

3206+
/* Advertising Coding Selection extended advertising report PHY values.
3207+
* Only used when Kconfig BT_EXT_ADV_CODING_SELECTION is enabled.
3208+
*/
3209+
#define BT_HCI_LE_ADV_EVT_PHY_1M 0x01
3210+
#define BT_HCI_LE_ADV_EVT_PHY_2M 0x02
3211+
#define BT_HCI_LE_ADV_EVT_PHY_CODED_S8 0x03
3212+
#define BT_HCI_LE_ADV_EVT_PHY_CODED_S2 0x04
3213+
32063214
struct bt_hci_evt_le_ext_advertising_info {
32073215
uint16_t evt_type;
32083216
bt_addr_le_t addr;

subsys/bluetooth/controller/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,7 @@ config BT_CTLR_ADV_PERIODIC_RSP
787787
config BT_CTLR_ADV_EXT_CODING_SELECTION
788788
bool "Advertising Coding Selection support"
789789
depends on BT_CTLR_PHY_CODED && BT_CTLR_ADV_EXT_CODING_SELECTION_SUPPORT
790+
select BT_CTLR_SET_HOST_FEATURE if BT_OBSERVER
790791
default y if BT_EXT_ADV_CODING_SELECTION
791792
help
792793
Enable support for Bluetooth 6.0 Advertising Coding Selection

subsys/bluetooth/host/hci_core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3683,6 +3683,14 @@ static int le_init(void)
36833683
}
36843684
}
36853685

3686+
if (IS_ENABLED(CONFIG_BT_EXT_ADV_CODING_SELECTION) &&
3687+
BT_FEAT_LE_ADV_CODING_SEL(bt_dev.le.features)) {
3688+
err = le_set_host_feature(BT_LE_FEAT_BIT_ADV_CODING_SEL_HOST, 1);
3689+
if (err) {
3690+
return err;
3691+
}
3692+
}
3693+
36863694
return le_set_event_mask();
36873695
}
36883696

subsys/bluetooth/host/scan.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,28 @@ static uint8_t get_adv_type(uint8_t evt_type)
741741
}
742742
}
743743

744+
/* Convert Extended adv report PHY to GAP PHY */
745+
static uint8_t get_ext_adv_coding_sel_phy(uint8_t hci_phy)
746+
{
747+
/* Converts from Extended adv report PHY to BT_GAP_LE_PHY_*
748+
* When Advertising Coding Selection (Host Support) is enabled
749+
* the controller will return the advertising coding scheme which
750+
* can be S=2 or S=8 data coding.
751+
*/
752+
switch (hci_phy) {
753+
case BT_HCI_LE_ADV_EVT_PHY_1M:
754+
return BT_GAP_LE_PHY_1M;
755+
case BT_HCI_LE_ADV_EVT_PHY_2M:
756+
return BT_GAP_LE_PHY_2M;
757+
case BT_HCI_LE_ADV_EVT_PHY_CODED_S8:
758+
return BT_GAP_LE_PHY_CODED_S8;
759+
case BT_HCI_LE_ADV_EVT_PHY_CODED_S2:
760+
return BT_GAP_LE_PHY_CODED_S2;
761+
default:
762+
return 0;
763+
}
764+
}
765+
744766
/* Convert extended adv report evt_type field to adv props */
745767
static uint16_t get_adv_props_extended(uint16_t evt_type)
746768
{
@@ -755,8 +777,15 @@ static uint16_t get_adv_props_extended(uint16_t evt_type)
755777
static void create_ext_adv_info(struct bt_hci_evt_le_ext_advertising_info const *const evt,
756778
struct bt_le_scan_recv_info *const scan_info)
757779
{
758-
scan_info->primary_phy = bt_get_phy(evt->prim_phy);
759-
scan_info->secondary_phy = bt_get_phy(evt->sec_phy);
780+
if (IS_ENABLED(CONFIG_BT_EXT_ADV_CODING_SELECTION) &&
781+
BT_FEAT_LE_ADV_CODING_SEL(bt_dev.le.features)) {
782+
scan_info->primary_phy = get_ext_adv_coding_sel_phy(evt->prim_phy);
783+
scan_info->secondary_phy = get_ext_adv_coding_sel_phy(evt->sec_phy);
784+
} else {
785+
scan_info->primary_phy = bt_get_phy(evt->prim_phy);
786+
scan_info->secondary_phy = bt_get_phy(evt->sec_phy);
787+
}
788+
760789
scan_info->tx_power = evt->tx_power;
761790
scan_info->rssi = evt->rssi;
762791
scan_info->sid = evt->sid;

0 commit comments

Comments
 (0)