summaryrefslogtreecommitdiff
path: root/tools/rootcanal
diff options
context:
space:
mode:
author Henri Chataing <henrichataing@google.com> 2024-03-12 16:10:34 +0000
committer Henri Chataing <henrichataing@google.com> 2024-03-12 22:58:06 +0000
commite61bf0f15c413fb82376d6ff168c55598ee281ca (patch)
treeb3edaf78ff8974a603e3f82d88cef3b9b2325a18 /tools/rootcanal
parent7a78a729e5fd5e3ebd061bc5c4a87724eaa31900 (diff)
RootCanal: Return accurate phy types in extended advertising reports
The primary phy type used to be hardcoded to LE 1M, and the secondary phy to No packets. This change retrieves the phy types from the extended advertising pdu. Bug: 329259305 Test: m root-canal Test: atest rootcanal_ll_test Flag: EXEMPT, tool change Change-Id: I3cabc13087dbb89d059201172317930aa1e62649
Diffstat (limited to 'tools/rootcanal')
-rw-r--r--tools/rootcanal/model/controller/le_advertiser.cc4
-rw-r--r--tools/rootcanal/model/controller/link_layer_controller.cc40
-rw-r--r--tools/rootcanal/packets/link_layer_packets.pdl18
-rw-r--r--tools/rootcanal/test/LL/DDI/ADV/BV_26_C.py4
-rw-r--r--tools/rootcanal/test/LL/DDI/ADV/BV_47_C.py4
-rw-r--r--tools/rootcanal/test/LL/DDI/SCN/BV_19_C.py4
-rw-r--r--tools/rootcanal/test/LL/DDI/SCN/BV_20_C.py4
-rw-r--r--tools/rootcanal/test/LL/DDI/SCN/BV_79_C.py4
-rw-r--r--tools/rootcanal/test/controller/le/le_scanning_filter_duplicates_test.cc4
9 files changed, 59 insertions, 27 deletions
diff --git a/tools/rootcanal/model/controller/le_advertiser.cc b/tools/rootcanal/model/controller/le_advertiser.cc
index c27beef9e5..0f5cfabadf 100644
--- a/tools/rootcanal/model/controller/le_advertiser.cc
+++ b/tools/rootcanal/model/controller/le_advertiser.cc
@@ -1841,9 +1841,9 @@ void LinkLayerController::LeAdvertising() {
advertiser.advertising_event_properties.scannable_,
advertiser.advertising_event_properties.directed_,
advertiser.advertising_sid, advertiser.advertising_tx_power,
- static_cast<model::packets::PrimaryPhyType>(
+ static_cast<model::packets::PhyType>(
advertiser.primary_advertising_phy),
- static_cast<model::packets::SecondaryPhyType>(
+ static_cast<model::packets::PhyType>(
advertiser.secondary_advertising_phy),
advertiser.periodic_advertising_interval.count(),
advertiser.advertising_data),
diff --git a/tools/rootcanal/model/controller/link_layer_controller.cc b/tools/rootcanal/model/controller/link_layer_controller.cc
index d0754bd6fb..ae595b6cd7 100644
--- a/tools/rootcanal/model/controller/link_layer_controller.cc
+++ b/tools/rootcanal/model/controller/link_layer_controller.cc
@@ -3378,9 +3378,39 @@ void LinkLayerController::ScanIncomingLeExtendedAdvertisingPdu(
bool scannable_advertising = pdu.GetScannable();
bool connectable_advertising = pdu.GetConnectable();
bool directed_advertising = pdu.GetDirected();
+ auto primary_phy = pdu.GetPrimaryPhy();
+ auto secondary_phy = pdu.GetSecondaryPhy();
+
+ // Check originating primary PHY, compare against active scanning PHYs.
+ if ((primary_phy == model::packets::PhyType::LE_1M &&
+ !scanner_.le_1m_phy.enabled) ||
+ (primary_phy == model::packets::PhyType::LE_CODED_S8 &&
+ !scanner_.le_coded_phy.enabled)) {
+ DEBUG(id_,
+ "Extended adverising ignored because the scanner is not scanning on "
+ "the primary phy type {}",
+ model::packets::PhyTypeText(primary_phy));
+ return;
+ }
- // TODO: check originating PHY, compare against active scanning PHYs
- // (scanner_.le_1m_phy or scanner_.le_coded_phy).
+ // Check originating sceondary PHY, compare against local
+ // supported features. The primary PHY is validated by the command
+ // LE Set Extended Scan Parameters.
+ if ((secondary_phy == model::packets::PhyType::LE_2M &&
+ !properties_.SupportsLLFeature(
+ bluetooth::hci::LLFeaturesBits::LE_2M_PHY)) ||
+ (secondary_phy == model::packets::PhyType::LE_CODED_S8 &&
+ !properties_.SupportsLLFeature(
+ bluetooth::hci::LLFeaturesBits::LE_CODED_PHY)) ||
+ (secondary_phy == model::packets::PhyType::LE_CODED_S2 &&
+ !properties_.SupportsLLFeature(
+ bluetooth::hci::LLFeaturesBits::LE_CODED_PHY))) {
+ DEBUG(id_,
+ "Extended adverising ignored because the scanner does not support "
+ "the secondary phy type {}",
+ model::packets::PhyTypeText(secondary_phy));
+ return;
+ }
// When a scanner receives an advertising packet that contains a resolvable
// private address for the advertiser’s device address (AdvA field) and
@@ -3477,8 +3507,10 @@ void LinkLayerController::ScanIncomingLeExtendedAdvertisingPdu(
static_cast<bluetooth::hci::DirectAdvertisingAddressType>(
resolved_advertising_address.GetAddressType());
response.address_ = resolved_advertising_address.GetAddress();
- response.primary_phy_ = bluetooth::hci::PrimaryPhyType::LE_1M;
- response.secondary_phy_ = bluetooth::hci::SecondaryPhyType::NO_PACKETS;
+ response.primary_phy_ =
+ static_cast<bluetooth::hci::PrimaryPhyType>(primary_phy);
+ response.secondary_phy_ =
+ static_cast<bluetooth::hci::SecondaryPhyType>(secondary_phy);
response.advertising_sid_ = pdu.GetSid();
response.tx_power_ = pdu.GetTxPower();
response.rssi_ = rssi;
diff --git a/tools/rootcanal/packets/link_layer_packets.pdl b/tools/rootcanal/packets/link_layer_packets.pdl
index d2fcbfca4f..a4f763d85b 100644
--- a/tools/rootcanal/packets/link_layer_packets.pdl
+++ b/tools/rootcanal/packets/link_layer_packets.pdl
@@ -150,16 +150,16 @@ packet LeLegacyAdvertisingPdu : LinkLayerPacket (type = LE_LEGACY_ADVERTISING_PD
advertising_data: 8[],
}
-enum PrimaryPhyType : 8 {
- LE_1M = 0x01,
- LE_CODED = 0x03,
-}
-
-enum SecondaryPhyType : 8 {
+// PHY type. Matching the primary and secondary PHY types
+// from the following commands and events:
+// - Vol 4, Part E § 7.7.65.13 LE Extended Advertising Report event
+// - Vol 4, Part E § 7.8.53 LE Set Extended Advertising Parameters command
+enum PhyType : 8 {
NO_PACKETS = 0x00,
LE_1M = 0x01,
LE_2M = 0x02,
- LE_CODED = 0x03,
+ LE_CODED_S8 = 0x03,
+ LE_CODED_S2 = 0x04,
}
packet LeExtendedAdvertisingPdu : LinkLayerPacket (type = LE_EXTENDED_ADVERTISING_PDU) {
@@ -171,8 +171,8 @@ packet LeExtendedAdvertisingPdu : LinkLayerPacket (type = LE_EXTENDED_ADVERTISIN
_reserved_: 5,
sid: 8, // 0xff when not provided
tx_power: 8,
- primary_phy: PrimaryPhyType,
- secondary_phy: SecondaryPhyType,
+ primary_phy: PhyType, // LE_1M | LE_CODEC_S8
+ secondary_phy: PhyType,
periodic_advertising_interval: 16,
advertising_data: 8[],
}
diff --git a/tools/rootcanal/test/LL/DDI/ADV/BV_26_C.py b/tools/rootcanal/test/LL/DDI/ADV/BV_26_C.py
index 909b08a614..24bc1d16f8 100644
--- a/tools/rootcanal/test/LL/DDI/ADV/BV_26_C.py
+++ b/tools/rootcanal/test/LL/DDI/ADV/BV_26_C.py
@@ -188,8 +188,8 @@ class Test(ControllerTest):
directed=False,
sid=0,
tx_power=0,
- primary_phy=ll.PrimaryPhyType.LE_1M,
- secondary_phy=ll.SecondaryPhyType.NO_PACKETS,
+ primary_phy=ll.PhyType.LE_1M,
+ secondary_phy=ll.PhyType.NO_PACKETS,
periodic_advertising_interval=0x100,
advertising_data=[]),
ll.LePeriodicAdvertisingPdu(source_address=controller.address,
diff --git a/tools/rootcanal/test/LL/DDI/ADV/BV_47_C.py b/tools/rootcanal/test/LL/DDI/ADV/BV_47_C.py
index 5430f8ed3b..64b471805d 100644
--- a/tools/rootcanal/test/LL/DDI/ADV/BV_47_C.py
+++ b/tools/rootcanal/test/LL/DDI/ADV/BV_47_C.py
@@ -197,8 +197,8 @@ class Test(ControllerTest):
directed=int(advertising_event_properties.directed),
sid=0,
tx_power=0,
- primary_phy=ll.PrimaryPhyType.LE_1M,
- secondary_phy=ll.SecondaryPhyType.NO_PACKETS,
+ primary_phy=ll.PhyType.LE_1M,
+ secondary_phy=ll.PhyType.NO_PACKETS,
advertising_data=advertising_data))
# 10. If the Max_Extended_Advertising_Events was set to a value different than 0, repeat steps 6–9
diff --git a/tools/rootcanal/test/LL/DDI/SCN/BV_19_C.py b/tools/rootcanal/test/LL/DDI/SCN/BV_19_C.py
index 41c3db5b94..abaa0b9e12 100644
--- a/tools/rootcanal/test/LL/DDI/SCN/BV_19_C.py
+++ b/tools/rootcanal/test/LL/DDI/SCN/BV_19_C.py
@@ -144,8 +144,8 @@ class Test(ControllerTest):
directed=not target_address is None,
sid=0,
tx_power=0x7f,
- primary_phy=ll.PrimaryPhyType.LE_1M,
- secondary_phy=ll.SecondaryPhyType.NO_PACKETS,
+ primary_phy=ll.PhyType.LE_1M,
+ secondary_phy=ll.PhyType.NO_PACKETS,
advertising_data=[])
# 4. For undirected advertisements or advertisements directed at the IUT, the Upper Tester receives
diff --git a/tools/rootcanal/test/LL/DDI/SCN/BV_20_C.py b/tools/rootcanal/test/LL/DDI/SCN/BV_20_C.py
index 726e35afcf..74a3213e10 100644
--- a/tools/rootcanal/test/LL/DDI/SCN/BV_20_C.py
+++ b/tools/rootcanal/test/LL/DDI/SCN/BV_20_C.py
@@ -142,8 +142,8 @@ class Test(ControllerTest):
directed=not target_address is None,
sid=0,
tx_power=0x7f,
- primary_phy=ll.PrimaryPhyType.LE_1M,
- secondary_phy=ll.SecondaryPhyType.NO_PACKETS,
+ primary_phy=ll.PhyType.LE_1M,
+ secondary_phy=ll.PhyType.NO_PACKETS,
advertising_data=[])
# 5. For undirected advertisements or advertisements directed at the IUT, the Lower Tester receives
diff --git a/tools/rootcanal/test/LL/DDI/SCN/BV_79_C.py b/tools/rootcanal/test/LL/DDI/SCN/BV_79_C.py
index 80a6245c68..c58b7e9029 100644
--- a/tools/rootcanal/test/LL/DDI/SCN/BV_79_C.py
+++ b/tools/rootcanal/test/LL/DDI/SCN/BV_79_C.py
@@ -85,8 +85,8 @@ class Test(ControllerTest):
directed=False,
sid=advertising_sid,
tx_power=tx_power,
- primary_phy=ll.PrimaryPhyType.LE_1M,
- secondary_phy=ll.SecondaryPhyType.NO_PACKETS,
+ primary_phy=ll.PhyType.LE_1M,
+ secondary_phy=ll.PhyType.NO_PACKETS,
periodic_advertising_interval=0x100,
advertising_data=[]),
rssi=0x10)
diff --git a/tools/rootcanal/test/controller/le/le_scanning_filter_duplicates_test.cc b/tools/rootcanal/test/controller/le/le_scanning_filter_duplicates_test.cc
index feed4edcd7..6ef5a2b1bf 100644
--- a/tools/rootcanal/test/controller/le/le_scanning_filter_duplicates_test.cc
+++ b/tools/rootcanal/test/controller/le/le_scanning_filter_duplicates_test.cc
@@ -113,8 +113,8 @@ class LeScanningFilterDuplicates : public ::testing::Test {
return FromBuilder(model::packets::LeExtendedAdvertisingPduBuilder::Create(
Address::kEmpty, Address::kEmpty, model::packets::AddressType::PUBLIC,
model::packets::AddressType::PUBLIC, 0, 1, 0, 0, 0,
- model::packets::PrimaryPhyType::LE_1M,
- model::packets::SecondaryPhyType::LE_1M, 0, data));
+ model::packets::PhyType::LE_1M, model::packets::PhyType::LE_1M, 0,
+ data));
}
static model::packets::LinkLayerPacketView FromBuilder(