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

Commit 530520b9 authored by Chienyuan Huang's avatar Chienyuan Huang Committed by Gerrit Code Review
Browse files

Merge "gd: Rename ApiType for LE advertising/scanning"

parents 1577dfd3 4bea3590
Loading
Loading
Loading
Loading
+20 −20
Original line number Diff line number Diff line
@@ -32,9 +32,9 @@ namespace hci {
const ModuleFactory LeAdvertisingManager::Factory = ModuleFactory([]() { return new LeAdvertisingManager(); });

enum class AdvertisingApiType {
  LE_4_0 = 1,
  LEGACY = 1,
  ANDROID_HCI = 2,
  LE_5_0 = 3,
  EXTENDED = 3,
};

struct Advertiser {
@@ -103,11 +103,11 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
    }

    if (controller_->IsSupported(hci::OpCode::LE_SET_EXTENDED_ADVERTISING_PARAMETERS)) {
      advertising_api_type_ = AdvertisingApiType::LE_5_0;
      advertising_api_type_ = AdvertisingApiType::EXTENDED;
    } else if (controller_->IsSupported(hci::OpCode::LE_MULTI_ADVT)) {
      advertising_api_type_ = AdvertisingApiType::ANDROID_HCI;
    } else {
      advertising_api_type_ = AdvertisingApiType::LE_4_0;
      advertising_api_type_ = AdvertisingApiType::LEGACY;
    }
  }

@@ -184,7 +184,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
      address_manager_registered = false;
      paused = false;
    }
    if (advertising_api_type_ == AdvertisingApiType::LE_5_0) {
    if (advertising_api_type_ == AdvertisingApiType::EXTENDED) {
      le_advertising_interface_->EnqueueCommand(
          hci::LeRemoveAdvertisingSetBuilder::Create(advertiser_id),
          module_handler_->BindOnce(impl::check_status<LeRemoveAdvertisingSetCompleteView>));
@@ -206,7 +206,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
    }

    switch (advertising_api_type_) {
      case (AdvertisingApiType::LE_4_0): {
      case (AdvertisingApiType::LEGACY): {
        le_advertising_interface_->EnqueueCommand(
            hci::LeSetAdvertisingParametersBuilder::Create(
                config.interval_min,
@@ -276,7 +276,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
        curr_set.advertising_handle_ = id;
        enabled_sets_[id] = curr_set;
      } break;
      case (AdvertisingApiType::LE_5_0): {
      case (AdvertisingApiType::EXTENDED): {
        ExtendedAdvertisingConfig new_config = config;
        new_config.legacy_pdus = true;

@@ -299,7 +299,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
      os::Handler* handler) {
    id_map_[id] = reg_id;

    if (advertising_api_type_ != AdvertisingApiType::LE_5_0) {
    if (advertising_api_type_ != AdvertisingApiType::EXTENDED) {
      create_advertiser(id, config, scan_callback, set_terminated_callback, handler);
      return;
    }
@@ -429,7 +429,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
    // then the Controller will return the error code Command Disallowed (0x0C).
    // Thus, we should disable it before removing it.
    switch (advertising_api_type_) {
      case (AdvertisingApiType::LE_4_0):
      case (AdvertisingApiType::LEGACY):
        le_advertising_interface_->EnqueueCommand(
            hci::LeSetAdvertisingEnableBuilder::Create(Enable::DISABLED),
            module_handler_->BindOnce(impl::check_status<LeSetAdvertisingEnableCompleteView>));
@@ -439,7 +439,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
            hci::LeMultiAdvtSetEnableBuilder::Create(Enable::DISABLED, advertiser_id),
            module_handler_->BindOnce(impl::check_status<LeMultiAdvtCompleteView>));
        break;
      case (AdvertisingApiType::LE_5_0): {
      case (AdvertisingApiType::EXTENDED): {
        le_advertising_interface_->EnqueueCommand(
            hci::LeSetExtendedAdvertisingEnableBuilder::Create(Enable::DISABLED, enabled_vector),
            module_handler_->BindOnce(impl::check_status<LeSetExtendedAdvertisingEnableCompleteView>));
@@ -456,13 +456,13 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb

  void set_parameters(AdvertiserId advertiser_id, ExtendedAdvertisingConfig config) {
    switch (advertising_api_type_) {
      case (AdvertisingApiType::LE_4_0): {
      case (AdvertisingApiType::LEGACY): {
        // TODO
      } break;
      case (AdvertisingApiType::ANDROID_HCI): {
        // TODO
      } break;
      case (AdvertisingApiType::LE_5_0): {
      case (AdvertisingApiType::EXTENDED): {
        // sid must be in range 0x00 to 0x0F. Since no controller supports more than
        // 16 advertisers, it's safe to make sid equal to id.
        config.sid = advertiser_id % kAdvertisingSetIdMask;
@@ -539,13 +539,13 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb

  void set_data(AdvertiserId advertiser_id, bool set_scan_rsp, std::vector<GapData> data) {
    switch (advertising_api_type_) {
      case (AdvertisingApiType::LE_4_0): {
      case (AdvertisingApiType::LEGACY): {
        // TODO
      } break;
      case (AdvertisingApiType::ANDROID_HCI): {
        // TODO
      } break;
      case (AdvertisingApiType::LE_5_0): {
      case (AdvertisingApiType::EXTENDED): {
        // TODO(b/149221472): Support fragmentation
        auto operation = Operation::COMPLETE_ADVERTISEMENT;
        auto fragment_preference = FragmentPreference::CONTROLLER_SHOULD_NOT;
@@ -575,13 +575,13 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
    Enable enable_value = enable ? Enable::ENABLED : Enable::DISABLED;

    switch (advertising_api_type_) {
      case (AdvertisingApiType::LE_4_0): {
      case (AdvertisingApiType::LEGACY): {
        // TODO
      } break;
      case (AdvertisingApiType::ANDROID_HCI): {
        // TODO
      } break;
      case (AdvertisingApiType::LE_5_0): {
      case (AdvertisingApiType::EXTENDED): {
        le_advertising_interface_->EnqueueCommand(
            hci::LeSetExtendedAdvertisingEnableBuilder::Create(enable_value, enabled_sets),
            module_handler_->BindOnceOn(
@@ -648,7 +648,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
      }

      switch (advertising_api_type_) {
        case (AdvertisingApiType::LE_4_0): {
        case (AdvertisingApiType::LEGACY): {
          le_advertising_interface_->EnqueueCommand(
              hci::LeSetAdvertisingEnableBuilder::Create(Enable::DISABLED),
              module_handler_->BindOnceOn(
@@ -667,7 +667,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
            }
          }
        } break;
        case (AdvertisingApiType::LE_5_0): {
        case (AdvertisingApiType::EXTENDED): {
          if (enabled_sets.size() != 0) {
            le_advertising_interface_->EnqueueCommand(
                hci::LeSetExtendedAdvertisingEnableBuilder::Create(Enable::DISABLED, enabled_sets),
@@ -695,7 +695,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
      }

      switch (advertising_api_type_) {
        case (AdvertisingApiType::LE_4_0): {
        case (AdvertisingApiType::LEGACY): {
          le_advertising_interface_->EnqueueCommand(
              hci::LeSetAdvertisingEnableBuilder::Create(Enable::ENABLED),
              module_handler_->BindOnceOn(
@@ -714,7 +714,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
            }
          }
        } break;
        case (AdvertisingApiType::LE_5_0): {
        case (AdvertisingApiType::EXTENDED): {
          if (enabled_sets.size() != 0) {
            le_advertising_interface_->EnqueueCommand(
                hci::LeSetExtendedAdvertisingEnableBuilder::Create(Enable::ENABLED, enabled_sets),
+10 −10
Original line number Diff line number Diff line
@@ -36,9 +36,9 @@ constexpr uint16_t kDefaultLeScanInterval = 4800;
const ModuleFactory LeScanningManager::Factory = ModuleFactory([]() { return new LeScanningManager(); });

enum class ScanApiType {
  LE_4_0 = 1,
  LEGACY = 1,
  ANDROID_HCI = 2,
  LE_5_0 = 3,
  EXTENDED = 3,
};

struct LeScanningManager::impl : public bluetooth::hci::LeAddressManagerCallback {
@@ -59,11 +59,11 @@ struct LeScanningManager::impl : public bluetooth::hci::LeAddressManagerCallback
    le_scanning_interface_ = hci_layer_->GetLeScanningInterface(
        module_handler_->BindOn(this, &LeScanningManager::impl::handle_scan_results));
    if (controller_->IsSupported(OpCode::LE_SET_EXTENDED_SCAN_PARAMETERS)) {
      api_type_ = ScanApiType::LE_5_0;
      api_type_ = ScanApiType::EXTENDED;
    } else if (controller_->IsSupported(OpCode::LE_EXTENDED_SCAN_PARAMS)) {
      api_type_ = ScanApiType::ANDROID_HCI;
    } else {
      api_type_ = ScanApiType::LE_4_0;
      api_type_ = ScanApiType::LEGACY;
    }
    configure_scan();
  }
@@ -128,7 +128,7 @@ struct LeScanningManager::impl : public bluetooth::hci::LeAddressManagerCallback
    uint8_t phys_in_use = 1;

    switch (api_type_) {
      case ScanApiType::LE_5_0:
      case ScanApiType::EXTENDED:
        le_scanning_interface_->EnqueueCommand(hci::LeSetExtendedScanParametersBuilder::Create(
                                                   own_address_type_, filter_policy_, phys_in_use, parameter_vector),
                                               module_handler_->BindOnce(impl::check_status));
@@ -140,7 +140,7 @@ struct LeScanningManager::impl : public bluetooth::hci::LeAddressManagerCallback
            module_handler_->BindOnce(impl::check_status));

        break;
      case ScanApiType::LE_4_0:
      case ScanApiType::LEGACY:
        le_scanning_interface_->EnqueueCommand(
            hci::LeSetScanParametersBuilder::Create(LeScanType::ACTIVE, interval_ms_, window_ms_, own_address_type_,
                                                    filter_policy_),
@@ -164,14 +164,14 @@ struct LeScanningManager::impl : public bluetooth::hci::LeAddressManagerCallback
    }

    switch (api_type_) {
      case ScanApiType::LE_5_0:
      case ScanApiType::EXTENDED:
        le_scanning_interface_->EnqueueCommand(
            hci::LeSetExtendedScanEnableBuilder::Create(Enable::ENABLED,
                                                        FilterDuplicates::DISABLED /* filter duplicates */, 0, 0),
            module_handler_->BindOnce(impl::check_status));
        break;
      case ScanApiType::ANDROID_HCI:
      case ScanApiType::LE_4_0:
      case ScanApiType::LEGACY:
        le_scanning_interface_->EnqueueCommand(
            hci::LeSetScanEnableBuilder::Create(Enable::ENABLED, Enable::DISABLED /* filter duplicates */),
            module_handler_->BindOnce(impl::check_status));
@@ -190,7 +190,7 @@ struct LeScanningManager::impl : public bluetooth::hci::LeAddressManagerCallback
    }
    registered_callback_->Handler()->Post(std::move(on_stopped));
    switch (api_type_) {
      case ScanApiType::LE_5_0:
      case ScanApiType::EXTENDED:
        le_scanning_interface_->EnqueueCommand(
            hci::LeSetExtendedScanEnableBuilder::Create(Enable::DISABLED,
                                                        FilterDuplicates::DISABLED /* filter duplicates */, 0, 0),
@@ -198,7 +198,7 @@ struct LeScanningManager::impl : public bluetooth::hci::LeAddressManagerCallback
        registered_callback_ = nullptr;
        break;
      case ScanApiType::ANDROID_HCI:
      case ScanApiType::LE_4_0:
      case ScanApiType::LEGACY:
        le_scanning_interface_->EnqueueCommand(
            hci::LeSetScanEnableBuilder::Create(Enable::DISABLED, Enable::DISABLED /* filter duplicates */),
            module_handler_->BindOnce(impl::check_status));