Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d391a6da authored by Henri Chataing's avatar Henri Chataing Committed by Gerrit Code Review
Browse files

Merge "RootCanal: Return accurate phy types in extended advertising reports" into main

parents 176b9bd0 e61bf0f1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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),
+36 −4
Original line number Diff line number Diff line
@@ -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;
+9 −9
Original line number Diff line number Diff line
@@ -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[],
}
+2 −2
Original line number Diff line number Diff line
@@ -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,
+2 −2
Original line number Diff line number Diff line
@@ -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
Loading