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

Commit 278cfa9b authored by Hansong Zhang's avatar Hansong Zhang
Browse files

DeviceCert: Fix LeAdvertisingManagerTest, LeScanningManagerTest

Initialize extended advertising config correctly
Use extended scan commands

Test: cert/run_device_cert.sh
Change-Id: Icac6e753cf0ec47b0ec8d4504769a060fd031c48
parent 6c904eb1
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -72,6 +72,8 @@ class LeAdvertisingManagerTest(GdFacadeOnlyBaseTestClass):

    def test_le_ad_scan_dut_advertises(self):
        self.register_for_le_event(hci_packets.SubeventCode.ADVERTISING_REPORT)
        self.register_for_le_event(
            hci_packets.SubeventCode.EXTENDED_ADVERTISING_REPORT)
        with EventCallbackStream(
                self.cert_device.hci.FetchLeSubevents(
                    empty_proto.Empty())) as hci_le_event_stream:
@@ -82,16 +84,19 @@ class LeAdvertisingManagerTest(GdFacadeOnlyBaseTestClass):
            self.enqueue_hci_command(
                hci_packets.LeSetRandomAddressBuilder('0C:05:04:03:02:01'),
                True)
            scan_parameters = hci_packets.PhyScanParameters()
            scan_parameters.le_scan_type = hci_packets.LeScanType.ACTIVE
            scan_parameters.le_scan_interval = 40
            scan_parameters.le_scan_window = 20
            self.enqueue_hci_command(
                hci_packets.LeSetScanParametersBuilder(
                    hci_packets.LeScanType.ACTIVE, 40, 20,
                hci_packets.LeSetExtendedScanParametersBuilder(
                    hci_packets.AddressType.RANDOM_DEVICE_ADDRESS,
                    hci_packets.LeSetScanningFilterPolicy.ACCEPT_ALL), True)
                    hci_packets.LeSetScanningFilterPolicy.ACCEPT_ALL, 1,
                    [scan_parameters]), True)
            self.enqueue_hci_command(
                hci_packets.LeSetScanEnableBuilder(
                hci_packets.LeSetExtendedScanEnableBuilder(
                    hci_packets.Enable.ENABLED,
                    hci_packets.Enable.DISABLED),  # duplicate filtering
                True)
                    hci_packets.FilterDuplicates.DISABLED, 0, 0), True)

            # DUT Advertises
            gap_name = hci_packets.GapData()
+34 −3
Original line number Diff line number Diff line
@@ -42,6 +42,39 @@ struct Advertiser {
  common::Callback<void(ErrorCode, uint8_t, uint8_t)> set_terminated_callback;
};

ExtendedAdvertisingConfig::ExtendedAdvertisingConfig(const AdvertisingConfig& config) : AdvertisingConfig(config) {
  switch (config.event_type) {
    case AdvertisingEventType::ADV_IND:
      connectable = true;
      scannable = true;
      break;
    case AdvertisingEventType::ADV_DIRECT_IND:
      connectable = true;
      directed = true;
      high_duty_directed_connectable = true;
      break;
    case AdvertisingEventType::ADV_SCAN_IND:
      scannable = true;
      break;
    case AdvertisingEventType::ADV_NONCONN_IND:
      break;
    case AdvertisingEventType::ADV_DIRECT_IND_LOW:
      connectable = true;
      directed = true;
      break;
    default:
      LOG_WARN("Unknown event type");
      break;
  }
  if (config.address_type == AddressType::PUBLIC_DEVICE_ADDRESS) {
    own_address_type = OwnAddressType::PUBLIC_DEVICE_ADDRESS;
  } else if (config.address_type == AddressType::RANDOM_DEVICE_ADDRESS) {
    own_address_type = OwnAddressType::RANDOM_DEVICE_ADDRESS;
  }
  // TODO(b/149221472): Support fragmentation
  operation = Operation::COMPLETE_ADVERTISMENT;
}

struct LeAdvertisingManager::impl {
  impl(Module* module) : module_(module), le_advertising_interface_(nullptr), num_instances_(0) {}

@@ -172,9 +205,7 @@ struct LeAdvertisingManager::impl {
                                                  module_handler_);
        break;
      case (AdvertisingApiType::LE_5_0): {
        ExtendedAdvertisingConfig new_config;
        AdvertisingConfig* base_config_ptr = &new_config;
        *(base_config_ptr) = config;
        ExtendedAdvertisingConfig new_config = config;
        new_config.legacy_pdus = true;
        create_extended_advertiser(id, new_config, scan_callback, set_terminated_callback, handler);
      } break;
+13 −11
Original line number Diff line number Diff line
@@ -41,21 +41,23 @@ class AdvertisingConfig {

class ExtendedAdvertisingConfig : public AdvertisingConfig {
 public:
  bool connectable;
  bool scannable;
  bool directed;
  bool high_duty_directed_connectable;
  bool legacy_pdus;
  bool anonymous;
  bool include_tx_power;
  bool connectable = false;
  bool scannable = false;
  bool directed = false;
  bool high_duty_directed_connectable = false;
  bool legacy_pdus = false;
  bool anonymous = false;
  bool include_tx_power = false;
  bool use_le_coded_phy;       // Primary advertisement PHY is LE Coded
  uint8_t secondary_max_skip;  // maximum advertising events to be skipped, 0x0 send AUX_ADV_IND prior ot the next event
  SecondaryPhyType secondary_advertising_phy;
  uint8_t sid;
  Enable enable_scan_request_notifications;
  uint8_t sid = 0x00;
  Enable enable_scan_request_notifications = Enable::DISABLED;
  OwnAddressType own_address_type;
  Operation operation;
  FragmentPreference fragment_preference;
  Operation operation;  // TODO(b/149221472): Support fragmentation
  FragmentPreference fragment_preference = FragmentPreference::CONTROLLER_SHOULD_NOT;
  ExtendedAdvertisingConfig() = default;
  ExtendedAdvertisingConfig(const AdvertisingConfig& config);
};

using AdvertiserId = int32_t;