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

Commit 6ae9007e authored by Henri Chataing's avatar Henri Chataing Committed by Automerger Merge Worker
Browse files

Merge changes Ice2e2e46,I83d2bbad am: db59c72d am: 819b3fd3 am: bb4469cf

parents 02a0d2e0 bb4469cf
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -123,6 +123,7 @@ cc_test_host {
        "rootcanal_defaults",
    ],
    srcs: [
        "test/controller/le/le_set_random_address_test.cc",
        "test/controller/le/le_clear_filter_accept_list_test.cc",
        "test/controller/le/le_add_device_to_filter_accept_list_test.cc",
        "test/controller/le/le_remove_device_from_filter_accept_list_test.cc",
@@ -130,6 +131,12 @@ cc_test_host {
        "test/controller/le/le_clear_resolving_list_test.cc",
        "test/controller/le/le_remove_device_from_resolving_list_test.cc",
        "test/controller/le/le_set_address_resolution_enable_test.cc",
        "test/controller/le/le_set_advertising_parameters_test.cc",
        "test/controller/le/le_set_advertising_enable_test.cc",
        "test/controller/le/le_set_scan_parameters_test.cc",
        "test/controller/le/le_set_scan_enable_test.cc",
        "test/controller/le/le_set_extended_scan_parameters_test.cc",
        "test/controller/le/le_set_extended_scan_enable_test.cc",
    ],
    header_libs: [
        "libbluetooth_headers",
+2 −0
Original line number Diff line number Diff line
@@ -308,6 +308,8 @@ ControllerProperties::ControllerProperties(const std::string& file_name)
            total_num_le_acl_data_packets);
  ParseUint(root, "total_num_iso_data_packets ", total_num_iso_data_packets);
  ParseUint(root, "num_supported_iac", num_supported_iac);
  ParseUint(root, "le_advertising_physical_channel_tx_power",
            le_advertising_physical_channel_tx_power);

  ParseUintArray(root, "lmp_features", lmp_features);
  ParseUintVector(root, "supported_standard_codecs", supported_standard_codecs);
+3 −0
Original line number Diff line number Diff line
@@ -79,6 +79,9 @@ struct ControllerProperties {
  // Number of Supported IAC (Vol 4, Part E § 7.3.43).
  uint8_t num_supported_iac{4};

  // LE Advertising Physical Channel TX Power (Vol 4, Part E § 7.8.6).
  uint8_t le_advertising_physical_channel_tx_power{static_cast<uint8_t>(-10)};

  // Supported Codecs (Vol 4, Part E § 7.4.8).
  // Implements the [v1] version only.
  std::vector<uint8_t> supported_standard_codecs{0};
+46 −112
Original line number Diff line number Diff line
@@ -2096,22 +2096,15 @@ void DualModeController::LeSetAdvertisingParameters(CommandView command) {
  auto command_view = gd_hci::LeSetAdvertisingParametersView::Create(
      gd_hci::LeAdvertisingCommandView::Create(command));
  ASSERT(command_view.IsValid());
  auto peer_address = command_view.GetPeerAddress();
  auto type = command_view.GetAdvertisingType();
  if (type != bluetooth::hci::AdvertisingType::ADV_DIRECT_IND_HIGH &&
      type != bluetooth::hci::AdvertisingType::ADV_DIRECT_IND_LOW) {
    peer_address = Address::kEmpty;
  }
  link_layer_controller_.SetLeAdvertisingParameters(
  ErrorCode status = link_layer_controller_.LeSetAdvertisingParameters(
      command_view.GetAdvertisingIntervalMin(),
      command_view.GetAdvertisingIntervalMax(), type,
      static_cast<uint8_t>(command_view.GetOwnAddressType()),
      static_cast<uint8_t>(command_view.GetPeerAddressType()), peer_address,
      command_view.GetAdvertisingIntervalMax(),
      command_view.GetAdvertisingType(), command_view.GetOwnAddressType(),
      command_view.GetPeerAddressType(), command_view.GetPeerAddress(),
      command_view.GetAdvertisingChannelMap(),
      command_view.GetAdvertisingFilterPolicy());

  send_event_(bluetooth::hci::LeSetAdvertisingParametersCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS));
      kNumCommandPackets, status));
}

void DualModeController::LeReadAdvertisingPhysicalChannelTxPower(
@@ -2123,7 +2116,7 @@ void DualModeController::LeReadAdvertisingPhysicalChannelTxPower(
  send_event_(
      bluetooth::hci::LeReadAdvertisingPhysicalChannelTxPowerCompleteBuilder::
          Create(kNumCommandPackets, ErrorCode::SUCCESS,
                 link_layer_controller_.GetLeAdvertisingTxPower()));
                 properties_.le_advertising_physical_channel_tx_power));
}

void DualModeController::LeSetAdvertisingData(CommandView command) {
@@ -2132,13 +2125,14 @@ void DualModeController::LeSetAdvertisingData(CommandView command) {
  auto payload = command.GetPayload();
  auto data_size = *payload.begin();
  auto first_data = payload.begin() + 1;
  std::vector<uint8_t> payload_bytes{first_data, first_data + data_size};
  std::vector<uint8_t> advertising_data{first_data, first_data + data_size};
  ASSERT_LOG(command_view.IsValid(), "%s command.size() = %zu",
             gd_hci::OpCodeText(command.GetOpCode()).c_str(), command.size());
  ASSERT(command_view.GetPayload().size() == 32);
  link_layer_controller_.SetLeAdvertisingData(payload_bytes);
  ErrorCode status =
      link_layer_controller_.LeSetAdvertisingData(advertising_data);
  send_event_(bluetooth::hci::LeSetAdvertisingDataCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS));
      kNumCommandPackets, status));
}

void DualModeController::LeSetScanResponseData(CommandView command) {
@@ -2146,10 +2140,11 @@ void DualModeController::LeSetScanResponseData(CommandView command) {
      gd_hci::LeAdvertisingCommandView::Create(command));
  ASSERT(command_view.IsValid());
  ASSERT(command_view.GetPayload().size() == 32);
  link_layer_controller_.SetLeScanResponseData(std::vector<uint8_t>(
      command_view.GetPayload().begin() + 1, command_view.GetPayload().end()));
  ErrorCode status = link_layer_controller_.LeSetScanResponseData(
      std::vector<uint8_t>(command_view.GetPayload().begin() + 1,
                           command_view.GetPayload().end()));
  send_event_(bluetooth::hci::LeSetScanResponseDataCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS));
      kNumCommandPackets, status));
}

void DualModeController::LeSetAdvertisingEnable(CommandView command) {
@@ -2160,7 +2155,7 @@ void DualModeController::LeSetAdvertisingEnable(CommandView command) {
  LOG_INFO("%s | LeSetAdvertisingEnable (%d)", GetAddress().ToString().c_str(),
           command_view.GetAdvertisingEnable() == gd_hci::Enable::ENABLED);

  auto status = link_layer_controller_.SetLeAdvertisingEnable(
  ErrorCode status = link_layer_controller_.LeSetAdvertisingEnable(
      command_view.GetAdvertisingEnable() == gd_hci::Enable::ENABLED);
  send_event_(bluetooth::hci::LeSetAdvertisingEnableCompleteBuilder::Create(
      kNumCommandPackets, status));
@@ -2170,15 +2165,13 @@ void DualModeController::LeSetScanParameters(CommandView command) {
  auto command_view = gd_hci::LeSetScanParametersView::Create(
      gd_hci::LeScanningCommandView::Create(command));
  ASSERT(command_view.IsValid());
  link_layer_controller_.SetLeScanType(
      static_cast<uint8_t>(command_view.GetLeScanType()));
  link_layer_controller_.SetLeScanInterval(command_view.GetLeScanInterval());
  link_layer_controller_.SetLeScanWindow(command_view.GetLeScanWindow());
  link_layer_controller_.SetLeAddressType(command_view.GetOwnAddressType());
  link_layer_controller_.SetLeScanFilterPolicy(

  ErrorCode status = link_layer_controller_.LeSetScanParameters(
      command_view.GetLeScanType(), command_view.GetLeScanInterval(),
      command_view.GetLeScanWindow(), command_view.GetOwnAddressType(),
      command_view.GetScanningFilterPolicy());
  send_event_(bluetooth::hci::LeSetScanParametersCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS));
      kNumCommandPackets, status));
}

void DualModeController::LeSetScanEnable(CommandView command) {
@@ -2189,15 +2182,11 @@ void DualModeController::LeSetScanEnable(CommandView command) {
  LOG_INFO("%s | LeSetScanEnable (%d)", GetAddress().ToString().c_str(),
           command_view.GetLeScanEnable() == gd_hci::Enable::ENABLED);

  if (command_view.GetLeScanEnable() == gd_hci::Enable::ENABLED) {
    link_layer_controller_.SetLeScanEnable(gd_hci::OpCode::LE_SET_SCAN_ENABLE);
  } else {
    link_layer_controller_.SetLeScanEnable(gd_hci::OpCode::NONE);
  }
  link_layer_controller_.SetLeFilterDuplicates(
  ErrorCode status = link_layer_controller_.LeSetScanEnable(
      command_view.GetLeScanEnable() == gd_hci::Enable::ENABLED,
      command_view.GetFilterDuplicates() == gd_hci::Enable::ENABLED);
  send_event_(bluetooth::hci::LeSetScanEnableCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS));
      kNumCommandPackets, status));
}

void DualModeController::LeCreateConnection(CommandView command) {
@@ -2214,11 +2203,8 @@ void DualModeController::LeCreateConnection(CommandView command) {
  if (initiator_filter_policy ==
      bluetooth::hci::InitiatorFilterPolicy::USE_PEER_ADDRESS) {
    // Connect list not used
    uint8_t peer_address_type =
        static_cast<uint8_t>(command_view.GetPeerAddressType());
    Address peer_address = command_view.GetPeerAddress();
    link_layer_controller_.SetLePeerAddressType(peer_address_type);
    link_layer_controller_.SetLePeerAddress(peer_address);
    link_layer_controller_.SetLePeerAddress(AddressWithType{
        command_view.GetPeerAddress(), command_view.GetPeerAddressType()});
  }
  link_layer_controller_.SetLeAddressType(command_view.GetOwnAddressType());
  link_layer_controller_.SetLeConnectionIntervalMin(
@@ -2437,18 +2423,10 @@ void DualModeController::LeAddDeviceToResolvingList(CommandView command) {
  auto command_view = gd_hci::LeAddDeviceToResolvingListView::Create(
      gd_hci::LeSecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());
  AddressType peer_identity_address_type;
  switch (command_view.GetPeerIdentityAddressType()) {
    case bluetooth::hci::PeerAddressType::PUBLIC_DEVICE_OR_IDENTITY_ADDRESS:
      peer_identity_address_type = AddressType::PUBLIC_DEVICE_ADDRESS;
      break;
    case bluetooth::hci::PeerAddressType::RANDOM_DEVICE_OR_IDENTITY_ADDRESS:
      peer_identity_address_type = AddressType::RANDOM_DEVICE_ADDRESS;
      break;
  }
  ErrorCode status = link_layer_controller_.LeAddDeviceToResolvingList(
      peer_identity_address_type, command_view.GetPeerIdentityAddress(),
      command_view.GetPeerIrk(), command_view.GetLocalIrk());
      command_view.GetPeerIdentityAddressType(),
      command_view.GetPeerIdentityAddress(), command_view.GetPeerIrk(),
      command_view.GetLocalIrk());
  send_event_(bluetooth::hci::LeAddDeviceToResolvingListCompleteBuilder::Create(
      kNumCommandPackets, status));
}
@@ -2457,18 +2435,9 @@ void DualModeController::LeRemoveDeviceFromResolvingList(CommandView command) {
  auto command_view = gd_hci::LeRemoveDeviceFromResolvingListView::Create(
      gd_hci::LeSecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());

  AddressType peer_identity_address_type;
  switch (command_view.GetPeerIdentityAddressType()) {
    case bluetooth::hci::PeerAddressType::PUBLIC_DEVICE_OR_IDENTITY_ADDRESS:
      peer_identity_address_type = AddressType::PUBLIC_DEVICE_ADDRESS;
      break;
    case bluetooth::hci::PeerAddressType::RANDOM_DEVICE_OR_IDENTITY_ADDRESS:
      peer_identity_address_type = AddressType::RANDOM_DEVICE_ADDRESS;
      break;
  }
  ErrorCode status = link_layer_controller_.LeRemoveDeviceFromResolvingList(
      peer_identity_address_type, command_view.GetPeerIdentityAddress());
      command_view.GetPeerIdentityAddressType(),
      command_view.GetPeerIdentityAddress());
  send_event_(
      bluetooth::hci::LeRemoveDeviceFromResolvingListCompleteBuilder::Create(
          kNumCommandPackets, status));
@@ -2478,23 +2447,9 @@ void DualModeController::LeSetExtendedScanParameters(CommandView command) {
  auto command_view = gd_hci::LeSetExtendedScanParametersView::Create(
      gd_hci::LeScanningCommandView::Create(command));
  ASSERT(command_view.IsValid());
  auto parameters = command_view.GetParameters();
  // Multiple phys are not supported.
  ASSERT(command_view.GetScanningPhys() == 1);
  ASSERT(parameters.size() == 1);

  auto status = ErrorCode::SUCCESS;
  if (link_layer_controller_.GetLeScanEnable() == OpCode::NONE) {
    link_layer_controller_.SetLeScanType(
        static_cast<uint8_t>(parameters[0].le_scan_type_));
    link_layer_controller_.SetLeScanInterval(parameters[0].le_scan_interval_);
    link_layer_controller_.SetLeScanWindow(parameters[0].le_scan_window_);
    link_layer_controller_.SetLeAddressType(command_view.GetOwnAddressType());
    link_layer_controller_.SetLeScanFilterPolicy(
        command_view.GetScanningFilterPolicy());
  } else {
    status = ErrorCode::COMMAND_DISALLOWED;
  }
  ErrorCode status = link_layer_controller_.LeSetExtendedScanParameters(
      command_view.GetOwnAddressType(), command_view.GetScanningFilterPolicy(),
      command_view.GetScanningPhys(), command_view.GetParameters());
  send_event_(
      bluetooth::hci::LeSetExtendedScanParametersCompleteBuilder::Create(
          kNumCommandPackets, status));
@@ -2504,16 +2459,12 @@ void DualModeController::LeSetExtendedScanEnable(CommandView command) {
  auto command_view = gd_hci::LeSetExtendedScanEnableView::Create(
      gd_hci::LeScanningCommandView::Create(command));
  ASSERT(command_view.IsValid());
  if (command_view.GetEnable() == gd_hci::Enable::ENABLED) {
    link_layer_controller_.SetLeScanEnable(
        gd_hci::OpCode::LE_SET_EXTENDED_SCAN_ENABLE);
  } else {
    link_layer_controller_.SetLeScanEnable(gd_hci::OpCode::NONE);
  }
  link_layer_controller_.SetLeFilterDuplicates(
      command_view.GetFilterDuplicates() == gd_hci::FilterDuplicates::ENABLED);
  ErrorCode status = link_layer_controller_.LeSetExtendedScanEnable(
      command_view.GetEnable() == gd_hci::Enable::ENABLED,
      command_view.GetFilterDuplicates(), command_view.GetDuration(),
      command_view.GetPeriod());
  send_event_(bluetooth::hci::LeSetExtendedScanEnableCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS));
      kNumCommandPackets, status));
}

void DualModeController::LeExtendedCreateConnection(CommandView command) {
@@ -2531,9 +2482,10 @@ void DualModeController::LeExtendedCreateConnection(CommandView command) {

  if (initiator_filter_policy ==
      gd_hci::InitiatorFilterPolicy::USE_PEER_ADDRESS) {
    link_layer_controller_.SetLePeerAddressType(
        static_cast<uint8_t>(command_view.GetPeerAddressType()));
    link_layer_controller_.SetLePeerAddress(command_view.GetPeerAddress());
    link_layer_controller_.SetLePeerAddress(AddressWithType{
        command_view.GetPeerAddress(),
        command_view.GetPeerAddressType(),
    });
  }
  link_layer_controller_.SetLeAddressType(command_view.GetOwnAddressType());
  link_layer_controller_.SetLeConnectionIntervalMin(
@@ -2556,27 +2508,11 @@ void DualModeController::LeSetPrivacyMode(CommandView command) {
  auto command_view = gd_hci::LeSetPrivacyModeView::Create(
      gd_hci::LeSecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());

  Address peer_identity_address = command_view.GetPeerIdentityAddress();
  uint8_t privacy_mode = static_cast<uint8_t>(command_view.GetPrivacyMode());

  AddressType peer_identity_address_type;
  switch (command_view.GetPeerIdentityAddressType()) {
    case bluetooth::hci::PeerAddressType::PUBLIC_DEVICE_OR_IDENTITY_ADDRESS:
      peer_identity_address_type = AddressType::PUBLIC_DEVICE_ADDRESS;
      break;
    case bluetooth::hci::PeerAddressType::RANDOM_DEVICE_OR_IDENTITY_ADDRESS:
      peer_identity_address_type = AddressType::RANDOM_DEVICE_ADDRESS;
      break;
  }
  if (link_layer_controller_.LeResolvingListContainsDevice(
          peer_identity_address_type, peer_identity_address)) {
    link_layer_controller_.LeSetPrivacyMode(
        peer_identity_address_type, peer_identity_address, privacy_mode);
  }

  ErrorCode status = link_layer_controller_.LeSetPrivacyMode(
      command_view.GetPeerIdentityAddressType(),
      command_view.GetPeerIdentityAddress(), command_view.GetPrivacyMode());
  send_event_(bluetooth::hci::LeSetPrivacyModeCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS));
      kNumCommandPackets, status));
}

void DualModeController::LeReadIsoTxSync(CommandView command) {
@@ -2910,8 +2846,6 @@ void DualModeController::LeSetExtendedScanResponseData(CommandView command) {
  auto command_view = gd_hci::LeSetExtendedScanResponseDataView::Create(
      gd_hci::LeAdvertisingCommandView::Create(command));
  ASSERT(command_view.IsValid());
  link_layer_controller_.SetLeScanResponseData(std::vector<uint8_t>(
      command_view.GetPayload().begin() + 1, command_view.GetPayload().end()));
  auto raw_command_view = gd_hci::LeSetExtendedScanResponseDataRawView::Create(
      gd_hci::LeAdvertisingCommandView::Create(command));
  ASSERT(raw_command_view.IsValid());
+346 −36

File changed.

Preview size limit exceeded, changes collapsed.

Loading