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

Commit 38f15eb7 authored by Jack He's avatar Jack He Committed by Automerger Merge Worker
Browse files

Merge "Fix error of LE_MULTI_ADVT" am: bce07a79 am: ddb5e0b7

parents 60ecaaac ddb5e0b7
Loading
Loading
Loading
Loading
+22 −6
Original line number Diff line number Diff line
@@ -121,6 +121,9 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
      advertising_api_type_ = AdvertisingApiType::EXTENDED;
    } else if (controller_->IsSupported(hci::OpCode::LE_MULTI_ADVT)) {
      advertising_api_type_ = AdvertisingApiType::ANDROID_HCI;
      num_instances_ = controller_->GetVendorCapabilities().max_advt_instances_;
      // number of LE_MULTI_ADVT start from 1
      num_instances_ += 1;
    } else {
      advertising_api_type_ = AdvertisingApiType::LEGACY;
      int vendor_version = os::GetAndroidVendorReleaseVersion();
@@ -211,7 +214,8 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
  }

  AdvertiserId allocate_advertiser() {
    AdvertiserId id = 0;
    // number of LE_MULTI_ADVT start from 1
    AdvertiserId id = advertising_api_type_ == AdvertisingApiType::ANDROID_HCI ? 1 : 0;
    {
      std::unique_lock lock(id_mutex_);
      while (id < num_instances_ && advertising_sets_.count(id) != 0) {
@@ -249,11 +253,13 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
  }

  void create_advertiser(
      int reg_id,
      AdvertiserId id,
      const AdvertisingConfig config,
      const common::Callback<void(Address, AddressType)>& scan_callback,
      const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback,
      os::Handler* handler) {
    id_map_[id] = reg_id;
    advertising_sets_[id].scan_callback = scan_callback;
    advertising_sets_[id].set_terminated_callback = set_terminated_callback;
    advertising_sets_[id].handler = handler;
@@ -341,7 +347,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
    id_map_[id] = reg_id;

    if (advertising_api_type_ != AdvertisingApiType::EXTENDED) {
      create_advertiser(id, config, scan_callback, set_terminated_callback, handler);
      create_advertiser(reg_id, id, config, scan_callback, set_terminated_callback, handler);
      return;
    }

@@ -531,12 +537,14 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
                this, &impl::check_status_with_id<LeSetAdvertisingParametersCompleteView>, advertiser_id));
      } break;
      case (AdvertisingApiType::ANDROID_HCI): {
        auto own_address_type =
            static_cast<OwnAddressType>(advertising_sets_[advertiser_id].current_address.GetAddressType());
        le_advertising_interface_->EnqueueCommand(
            hci::LeMultiAdvtParamBuilder::Create(
                config.interval_min,
                config.interval_max,
                config.advertising_type,
                config.own_address_type,
                own_address_type,
                advertising_sets_[advertiser_id].current_address.GetAddress(),
                config.peer_address_type,
                config.peer_address,
@@ -1252,6 +1260,7 @@ size_t LeAdvertisingManager::GetNumberOfAdvertisingInstances() const {
}

AdvertiserId LeAdvertisingManager::create_advertiser(
    int reg_id,
    const AdvertisingConfig config,
    const common::Callback<void(Address, AddressType)>& scan_callback,
    const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback,
@@ -1272,8 +1281,15 @@ AdvertiserId LeAdvertisingManager::create_advertiser(
  if (id == kInvalidId) {
    return id;
  }
  GetHandler()->Post(common::BindOnce(&impl::create_advertiser, common::Unretained(pimpl_.get()), id, config,
                                      scan_callback, set_terminated_callback, handler));
  GetHandler()->Post(common::BindOnce(
      &impl::create_advertiser,
      common::Unretained(pimpl_.get()),
      reg_id,
      id,
      config,
      scan_callback,
      set_terminated_callback,
      handler));
  return id;
}

@@ -1287,7 +1303,7 @@ AdvertiserId LeAdvertisingManager::ExtendedCreateAdvertiser(
    os::Handler* handler) {
  AdvertisingApiType advertising_api_type = pimpl_->get_advertising_api_type();
  if (advertising_api_type != AdvertisingApiType::EXTENDED) {
    return create_advertiser(config, scan_callback, set_terminated_callback, handler);
    return create_advertiser(reg_id, config, scan_callback, set_terminated_callback, handler);
  };

  if (config.directed) {
+1 −0
Original line number Diff line number Diff line
@@ -161,6 +161,7 @@ class LeAdvertisingManager : public bluetooth::Module {
 private:
  // Return -1 if the advertiser was not created, otherwise the advertiser ID.
  AdvertiserId create_advertiser(
      int reg_id,
      const AdvertisingConfig config,
      const common::Callback<void(Address, AddressType)>& scan_callback,
      const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback,