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

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

Merge changes I223c9f56,I8837333f

* changes:
  RootCanal: Remove unecessary std::move in DualModeController
  RootCanal: Misc improvements
parents d655515e 9e780ad1
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2421,6 +2421,14 @@ packet SendKeypressNotificationComplete : CommandComplete (command_op_code = SEN
  bd_addr : Address,
}

packet SetEventMaskPage2 : Command (op_code = SET_EVENT_MASK_PAGE_2) {
  event_mask_page_2: 64,
}

packet SetEventMaskPage2Complete : CommandComplete (command_op_code = SET_EVENT_MASK_PAGE_2) {
  status: ErrorCode,
}

packet ReadLeHostSupport : Command (op_code = READ_LE_HOST_SUPPORT) {
}

+68 −108
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ using gd_hci::OpCode;
using std::vector;

namespace rootcanal {
constexpr uint16_t DualModeController::kSecurityManagerNumKeys;
constexpr uint16_t kNumCommandPackets = 0x01;
constexpr uint16_t kLeMaximumAdvertisingDataLength = 256;
constexpr uint16_t kLeMaximumDataLength = 64;
@@ -55,11 +54,11 @@ void DualModeController::Close() {
}

void DualModeController::SendCommandCompleteUnknownOpCodeEvent(
    uint16_t command_opcode) const {
    uint16_t op_code) const {
  std::unique_ptr<bluetooth::packet::RawBuilder> raw_builder_ptr =
      std::make_unique<bluetooth::packet::RawBuilder>();
  raw_builder_ptr->AddOctets1(kNumCommandPackets);
  raw_builder_ptr->AddOctets2(command_opcode);
  raw_builder_ptr->AddOctets2(op_code);
  raw_builder_ptr->AddOctets1(
      static_cast<uint8_t>(ErrorCode::UNKNOWN_HCI_COMMAND));

@@ -88,10 +87,7 @@ DualModeController::DualModeController(const std::string& properties_filename,
        DualModeController::SendLinkLayerPacket(packet, phy_type);
      });

  std::array<uint8_t, 64> supported_commands;
  for (size_t i = 0; i < 64; i++) {
    supported_commands[i] = 0;
  }
  std::array<uint8_t, 64> supported_commands{0};

#define SET_HANDLER(name, method)                                  \
  active_hci_commands_[OpCode::name] = [this](CommandView param) { \
@@ -307,7 +303,7 @@ DualModeController::DualModeController(const std::string& properties_filename,
  SET_SUPPORTED(WRITE_CONNECTION_ACCEPT_TIMEOUT, WriteConnectionAcceptTimeout);
  SET_SUPPORTED(LE_SET_ADDRESS_RESOLUTION_ENABLE, LeSetAddressResolutionEnable);
  SET_SUPPORTED(LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT,
                LeSetResovalablePrivateAddressTimeout);
                LeSetResolvablePrivateAddressTimeout);
  SET_SUPPORTED(READ_SYNCHRONOUS_FLOW_CONTROL_ENABLE,
                ReadSynchronousFlowControlEnable);
  SET_SUPPORTED(WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE,
@@ -376,9 +372,9 @@ void DualModeController::HandleSco(
  if (loopback_mode_ == LoopbackMode::ENABLE_LOCAL) {
    uint16_t handle = sco_packet.GetHandle();

    auto sco_builder = bluetooth::hci::ScoBuilder::Create(
        handle, sco_packet.GetPacketStatusFlag(), sco_packet.GetData());
    send_sco_(std::move(sco_builder));
    send_sco_(bluetooth::hci::ScoBuilder::Create(
        handle, sco_packet.GetPacketStatusFlag(), sco_packet.GetData()));

    std::vector<bluetooth::hci::CompletedPackets> completed_packets;
    bluetooth::hci::CompletedPackets cp;
    cp.connection_handle_ = handle;
@@ -566,14 +562,8 @@ void DualModeController::ReadBdAddr(CommandView command) {
void DualModeController::ReadLocalSupportedCommands(CommandView command) {
  auto command_view = gd_hci::ReadLocalSupportedCommandsView::Create(command);
  ASSERT(command_view.IsValid());

  std::array<uint8_t, 64> supported_commands{0};
  size_t len = std::min(properties_.supported_commands.size(), (size_t)64);
  std::copy_n(properties_.supported_commands.begin(), len,
              supported_commands.begin());

  send_event_(bluetooth::hci::ReadLocalSupportedCommandsCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS, supported_commands));
      kNumCommandPackets, ErrorCode::SUCCESS, properties_.supported_commands));
}

void DualModeController::ReadLocalSupportedFeatures(CommandView command) {
@@ -1270,11 +1260,11 @@ void DualModeController::EnhancedFlush(CommandView command) {
}

void DualModeController::SetEventMaskPage2(CommandView command) {
  auto payload =
      std::make_unique<bluetooth::packet::RawBuilder>(std::vector<uint8_t>(
          {static_cast<uint8_t>(bluetooth::hci::ErrorCode::SUCCESS)}));
  send_event_(bluetooth::hci::CommandCompleteBuilder::Create(
      kNumCommandPackets, command.GetOpCode(), std::move(payload)));
  auto command_view = bluetooth::hci::SetEventMaskPage2View::Create(command);
  ASSERT(command_view.IsValid());
  link_layer_controller_.SetEventMaskPage2(command_view.GetEventMaskPage2());
  send_event_(bluetooth::hci::SetEventMaskPage2CompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS));
}

void DualModeController::ReadLocalOobData(CommandView command) {
@@ -1311,7 +1301,6 @@ void DualModeController::ChangeConnectionPacketType(CommandView command) {

  auto status =
      link_layer_controller_.ChangeConnectionPacketType(handle, packet_type);

  send_event_(bluetooth::hci::ChangeConnectionPacketTypeStatusBuilder::Create(
      status, kNumCommandPackets));
}
@@ -1685,25 +1674,15 @@ void DualModeController::WriteLinkSupervisionTimeout(CommandView command) {
void DualModeController::ReadLocalName(CommandView command) {
  auto command_view = gd_hci::ReadLocalNameView::Create(command);
  ASSERT(command_view.IsValid());

  std::array<uint8_t, 248> local_name{0};
  size_t len = std::min(link_layer_controller_.GetName().size(), (size_t)247);
  std::copy_n(link_layer_controller_.GetName().begin(), len,
              local_name.begin());

  send_event_(bluetooth::hci::ReadLocalNameCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS, local_name));
      kNumCommandPackets, ErrorCode::SUCCESS,
      link_layer_controller_.GetLocalName()));
}

void DualModeController::WriteLocalName(CommandView command) {
  auto command_view = gd_hci::WriteLocalNameView::Create(command);
  ASSERT(command_view.IsValid());
  const auto local_name = command_view.GetLocalName();
  std::vector<uint8_t> name_vec(248);
  for (size_t i = 0; i < 248; i++) {
    name_vec[i] = local_name[i];
  }
  link_layer_controller_.SetName(name_vec);
  link_layer_controller_.SetLocalName(command_view.GetLocalName());
  send_event_(bluetooth::hci::WriteLocalNameCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS));
}
@@ -1711,7 +1690,7 @@ void DualModeController::WriteLocalName(CommandView command) {
void DualModeController::WriteExtendedInquiryResponse(CommandView command) {
  auto command_view = gd_hci::WriteExtendedInquiryResponseView::Create(command);
  ASSERT(command_view.IsValid());
  link_layer_controller_.SetExtendedInquiryData(std::vector<uint8_t>(
  link_layer_controller_.SetExtendedInquiryResponse(std::vector<uint8_t>(
      command_view.GetPayload().begin() + 1, command_view.GetPayload().end()));
  send_event_(
      bluetooth::hci::WriteExtendedInquiryResponseCompleteBuilder::Create(
@@ -2060,14 +2039,18 @@ void DualModeController::LeSetAddressResolutionEnable(CommandView command) {
          kNumCommandPackets, status));
}

void DualModeController::LeSetResovalablePrivateAddressTimeout(
void DualModeController::LeSetResolvablePrivateAddressTimeout(
    CommandView command) {
  // NOP
  auto payload =
      std::make_unique<bluetooth::packet::RawBuilder>(std::vector<uint8_t>(
          {static_cast<uint8_t>(bluetooth::hci::ErrorCode::SUCCESS)}));
  send_event_(bluetooth::hci::CommandCompleteBuilder::Create(
      kNumCommandPackets, command.GetOpCode(), std::move(payload)));
  auto command_view =
      bluetooth::hci::LeSetResolvablePrivateAddressTimeoutView::Create(
          bluetooth::hci::LeSecurityCommandView::Create(command));
  ASSERT(command_view.IsValid());
  ErrorCode status =
      link_layer_controller_.LeSetResolvablePrivateAddressTimeout(
          command_view.GetRpaTimeout());
  send_event_(
      bluetooth::hci::LeSetResolvablePrivateAddressTimeoutCompleteBuilder::
          Create(kNumCommandPackets, status));
}

void DualModeController::LeReadLocalSupportedFeatures(CommandView command) {
@@ -2370,7 +2353,8 @@ void DualModeController::LeReadSuggestedDefaultDataLength(CommandView command) {
  send_event_(
      bluetooth::hci::LeReadSuggestedDefaultDataLengthCompleteBuilder::Create(
          kNumCommandPackets, ErrorCode::SUCCESS,
          le_suggested_default_data_bytes_, le_suggested_default_data_time_));
          link_layer_controller_.GetLeSuggestedMaxTxOctets(),
          link_layer_controller_.GetLeSuggestedMaxTxTime()));
}

void DualModeController::LeWriteSuggestedDefaultDataLength(
@@ -2379,20 +2363,21 @@ void DualModeController::LeWriteSuggestedDefaultDataLength(
      gd_hci::LeConnectionManagementCommandView::Create(
          gd_hci::AclCommandView::Create(command)));
  ASSERT(command_view.IsValid());
  uint16_t bytes = command_view.GetTxOctets();
  uint16_t time = command_view.GetTxTime();
  if (bytes > 0xFB || bytes < 0x1B || time < 0x148 || time > 0x4290) {
    send_event_(
        bluetooth::hci::LeWriteSuggestedDefaultDataLengthCompleteBuilder::
            Create(kNumCommandPackets,
                   ErrorCode::INVALID_HCI_COMMAND_PARAMETERS));
    return;

  uint16_t max_tx_octets = command_view.GetTxOctets();
  uint16_t max_tx_time = command_view.GetTxTime();
  ErrorCode status = ErrorCode::SUCCESS;
  if (max_tx_octets > 0xFB || max_tx_octets < 0x1B || max_tx_time < 0x148 ||
      max_tx_time > 0x4290) {
    status = ErrorCode::INVALID_HCI_COMMAND_PARAMETERS;
  } else {
    link_layer_controller_.SetLeSuggestedMaxTxOctets(max_tx_octets);
    link_layer_controller_.SetLeSuggestedMaxTxTime(max_tx_time);
  }
  le_suggested_default_data_bytes_ = bytes;
  le_suggested_default_data_time_ = time;

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

void DualModeController::LeAddDeviceToResolvingList(CommandView command) {
@@ -2471,19 +2456,15 @@ void DualModeController::LeSetPrivacyMode(CommandView command) {
}

void DualModeController::LeReadIsoTxSync(CommandView command) {
  auto iso_command_view = gd_hci::LeIsoCommandView::Create(command);
  ASSERT(iso_command_view.IsValid());
  auto command_view =
      gd_hci::LeReadIsoTxSyncView::Create(std::move(iso_command_view));
  auto command_view = gd_hci::LeReadIsoTxSyncView::Create(
      gd_hci::LeIsoCommandView::Create(command));
  ASSERT(command_view.IsValid());
  link_layer_controller_.LeReadIsoTxSync(command_view.GetConnectionHandle());
}

void DualModeController::LeSetCigParameters(CommandView command) {
  auto iso_command_view = gd_hci::LeIsoCommandView::Create(command);
  ASSERT(iso_command_view.IsValid());
  auto command_view =
      gd_hci::LeSetCigParametersView::Create(std::move(iso_command_view));
  auto command_view = gd_hci::LeSetCigParametersView::Create(
      gd_hci::LeIsoCommandView::Create(command));
  ASSERT(command_view.IsValid());
  link_layer_controller_.LeSetCigParameters(
      command_view.GetCigId(), command_view.GetSduIntervalMToS(),
@@ -2494,10 +2475,8 @@ void DualModeController::LeSetCigParameters(CommandView command) {
}

void DualModeController::LeCreateCis(CommandView command) {
  auto iso_command_view = gd_hci::LeIsoCommandView::Create(command);
  ASSERT(iso_command_view.IsValid());
  auto command_view =
      gd_hci::LeCreateCisView::Create(std::move(iso_command_view));
  auto command_view = gd_hci::LeCreateCisView::Create(
      gd_hci::LeIsoCommandView::Create(command));
  ASSERT(command_view.IsValid());
  ErrorCode status =
      link_layer_controller_.LeCreateCis(command_view.GetCisConfig());
@@ -2506,10 +2485,8 @@ void DualModeController::LeCreateCis(CommandView command) {
}

void DualModeController::LeRemoveCig(CommandView command) {
  auto iso_command_view = gd_hci::LeIsoCommandView::Create(command);
  ASSERT(iso_command_view.IsValid());
  auto command_view =
      gd_hci::LeRemoveCigView::Create(std::move(iso_command_view));
  auto command_view = gd_hci::LeRemoveCigView::Create(
      gd_hci::LeIsoCommandView::Create(command));
  ASSERT(command_view.IsValid());
  uint8_t cig = command_view.GetCigId();
  ErrorCode status = link_layer_controller_.LeRemoveCig(cig);
@@ -2518,10 +2495,8 @@ void DualModeController::LeRemoveCig(CommandView command) {
}

void DualModeController::LeAcceptCisRequest(CommandView command) {
  auto iso_command_view = gd_hci::LeIsoCommandView::Create(command);
  ASSERT(iso_command_view.IsValid());
  auto command_view =
      gd_hci::LeAcceptCisRequestView::Create(std::move(iso_command_view));
  auto command_view = gd_hci::LeAcceptCisRequestView::Create(
      gd_hci::LeIsoCommandView::Create(command));
  ASSERT(command_view.IsValid());
  ErrorCode status = link_layer_controller_.LeAcceptCisRequest(
      command_view.GetConnectionHandle());
@@ -2530,20 +2505,16 @@ void DualModeController::LeAcceptCisRequest(CommandView command) {
}

void DualModeController::LeRejectCisRequest(CommandView command) {
  auto iso_command_view = gd_hci::LeIsoCommandView::Create(command);
  ASSERT(iso_command_view.IsValid());
  auto command_view =
      gd_hci::LeRejectCisRequestView::Create(std::move(iso_command_view));
  auto command_view = gd_hci::LeRejectCisRequestView::Create(
      gd_hci::LeIsoCommandView::Create(command));
  ASSERT(command_view.IsValid());
  link_layer_controller_.LeRejectCisRequest(command_view.GetConnectionHandle(),
                                            command_view.GetReason());
}

void DualModeController::LeCreateBig(CommandView command) {
  auto iso_command_view = gd_hci::LeIsoCommandView::Create(command);
  ASSERT(iso_command_view.IsValid());
  auto command_view =
      gd_hci::LeCreateBigView::Create(std::move(iso_command_view));
  auto command_view = gd_hci::LeCreateBigView::Create(
      gd_hci::LeIsoCommandView::Create(command));
  ASSERT(command_view.IsValid());
  ErrorCode status = link_layer_controller_.LeCreateBig(
      command_view.GetBigHandle(), command_view.GetAdvertisingHandle(),
@@ -2557,10 +2528,8 @@ void DualModeController::LeCreateBig(CommandView command) {
}

void DualModeController::LeTerminateBig(CommandView command) {
  auto iso_command_view = gd_hci::LeIsoCommandView::Create(command);
  ASSERT(iso_command_view.IsValid());
  auto command_view =
      gd_hci::LeTerminateBigView::Create(std::move(iso_command_view));
  auto command_view = gd_hci::LeTerminateBigView::Create(
      gd_hci::LeIsoCommandView::Create(command));
  ASSERT(command_view.IsValid());
  ErrorCode status = link_layer_controller_.LeTerminateBig(
      command_view.GetBigHandle(), command_view.GetReason());
@@ -2569,10 +2538,8 @@ void DualModeController::LeTerminateBig(CommandView command) {
}

void DualModeController::LeBigCreateSync(CommandView command) {
  auto iso_command_view = gd_hci::LeIsoCommandView::Create(command);
  ASSERT(iso_command_view.IsValid());
  auto command_view =
      gd_hci::LeBigCreateSyncView::Create(std::move(iso_command_view));
  auto command_view = gd_hci::LeBigCreateSyncView::Create(
      gd_hci::LeIsoCommandView::Create(command));
  ASSERT(command_view.IsValid());
  ErrorCode status = link_layer_controller_.LeBigCreateSync(
      command_view.GetBigHandle(), command_view.GetSyncHandle(),
@@ -2584,16 +2551,14 @@ void DualModeController::LeBigCreateSync(CommandView command) {
}

void DualModeController::LeBigTerminateSync(CommandView command) {
  auto iso_command_view = gd_hci::LeIsoCommandView::Create(command);
  ASSERT(iso_command_view.IsValid());
  auto command_view =
      gd_hci::LeBigTerminateSyncView::Create(std::move(iso_command_view));
  auto command_view = gd_hci::LeBigTerminateSyncView::Create(
      gd_hci::LeIsoCommandView::Create(command));
  ASSERT(command_view.IsValid());
  link_layer_controller_.LeBigTerminateSync(command_view.GetBigHandle());
}

void DualModeController::LeRequestPeerSca(CommandView command) {
  auto command_view = gd_hci::LeRequestPeerScaView::Create(std::move(command));
  auto command_view = gd_hci::LeRequestPeerScaView::Create(command);
  ASSERT(command_view.IsValid());
  ErrorCode status = link_layer_controller_.LeRequestPeerSca(
      command_view.GetConnectionHandle());
@@ -2602,10 +2567,8 @@ void DualModeController::LeRequestPeerSca(CommandView command) {
}

void DualModeController::LeSetupIsoDataPath(CommandView command) {
  auto iso_command_view = gd_hci::LeIsoCommandView::Create(command);
  ASSERT(iso_command_view.IsValid());
  auto command_view =
      gd_hci::LeSetupIsoDataPathView::Create(std::move(iso_command_view));
  auto command_view = gd_hci::LeSetupIsoDataPathView::Create(
      gd_hci::LeIsoCommandView::Create(command));
  ASSERT(command_view.IsValid());
  link_layer_controller_.LeSetupIsoDataPath(
      command_view.GetConnectionHandle(), command_view.GetDataPathDirection(),
@@ -2614,10 +2577,8 @@ void DualModeController::LeSetupIsoDataPath(CommandView command) {
}

void DualModeController::LeRemoveIsoDataPath(CommandView command) {
  auto iso_command_view = gd_hci::LeIsoCommandView::Create(command);
  ASSERT(iso_command_view.IsValid());
  auto command_view =
      gd_hci::LeRemoveIsoDataPathView::Create(std::move(iso_command_view));
  auto command_view = gd_hci::LeRemoveIsoDataPathView::Create(
      gd_hci::LeIsoCommandView::Create(command));
  ASSERT(command_view.IsValid());
  link_layer_controller_.LeRemoveIsoDataPath(
      command_view.GetConnectionHandle(),
@@ -2971,8 +2932,7 @@ void DualModeController::ReadLoopbackMode(CommandView command) {
  auto command_view = gd_hci::ReadLoopbackModeView::Create(command);
  ASSERT(command_view.IsValid());
  send_event_(bluetooth::hci::ReadLoopbackModeCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS,
      static_cast<LoopbackMode>(loopback_mode_)));
      kNumCommandPackets, ErrorCode::SUCCESS, loopback_mode_));
}

void DualModeController::WriteLoopbackMode(CommandView command) {
+12 −18
Original line number Diff line number Diff line
@@ -67,7 +67,6 @@ class DualModeController : public Device {
      model::packets::LinkLayerPacketView incoming) override;

  virtual void TimerTick() override;

  virtual void Close() override;

  // Route commands and data from the stack.
@@ -532,7 +531,7 @@ class DualModeController : public Device {
  void LeSetAddressResolutionEnable(CommandView args);

  // 7.8.45
  void LeSetResovalablePrivateAddressTimeout(CommandView args);
  void LeSetResolvablePrivateAddressTimeout(CommandView args);

  // 7.8.46
  void LeReadMaximumDataLength(CommandView args);
@@ -626,17 +625,9 @@ class DualModeController : public Device {
  LinkLayerController link_layer_controller_{address_, properties_};

 private:
  // Set a timer for a future action
  void AddControllerEvent(std::chrono::milliseconds,
                          const TaskCallback& callback);

  void AddConnectionAction(const TaskCallback& callback, uint16_t handle);

  void SendCommandCompleteUnknownOpCodeEvent(uint16_t command_opcode) const;

  // Unused state to maintain consistency for the Host
  uint16_t le_suggested_default_data_bytes_{0x20};
  uint16_t le_suggested_default_data_time_{0x148};
  // Send a HCI_Command_Complete event for the specified op_code with
  // the error code UNKNOWN_OPCODE.
  void SendCommandCompleteUnknownOpCodeEvent(uint16_t op_code) const;

  // Callbacks to send packets back to the HCI.
  std::function<void(std::shared_ptr<bluetooth::hci::AclBuilder>)> send_acl_;
@@ -645,21 +636,24 @@ class DualModeController : public Device {
  std::function<void(std::shared_ptr<bluetooth::hci::ScoBuilder>)> send_sco_;
  std::function<void(std::shared_ptr<bluetooth::hci::IsoBuilder>)> send_iso_;

  // Maintains the commands to be registered and used in the HciHandler object.
  // Keys are command opcodes and values are the callbacks to handle each
  // command.
  // Map supported opcodes to the function implementing the handler
  // for the associated command. The map should be a subset of the
  // supported_command field in the properties_ object.
  std::unordered_map<bluetooth::hci::OpCode,
                     std::function<void(bluetooth::hci::CommandView)>>
      active_hci_commands_;

  // Loopback mode (Vol 4, Part E § 7.6.1).
  // The local loopback mode is used to pass the android Vendor Test Suite
  // with RootCanal.
  bluetooth::hci::LoopbackMode loopback_mode_;

#ifndef ROOTCANAL_LMP
  SecurityManager security_manager_;
#endif /* ROOTCANAL_LMP */

  DualModeController(const DualModeController& cmdPckt) = delete;
  DualModeController& operator=(const DualModeController& cmdPckt) = delete;
  DualModeController(const DualModeController& other) = delete;
  DualModeController& operator=(const DualModeController& other) = delete;
};

}  // namespace rootcanal
+37 −17
Original line number Diff line number Diff line
@@ -254,6 +254,22 @@ ErrorCode LinkLayerController::LeSetRandomAddress(Address random_address) {
  return ErrorCode::SUCCESS;
}

// HCI LE Set Host Feature command (Vol 4, Part E § 7.8.45).
ErrorCode LinkLayerController::LeSetResolvablePrivateAddressTimeout(
    uint16_t rpa_timeout) {
  // Note: no documented status code for this case.
  if (rpa_timeout < 0x1 || rpa_timeout > 0x0e10) {
    LOG_INFO(
        "rpa_timeout (0x%04x) is outside the range of supported values "
        " 0x1 - 0x0e10",
        rpa_timeout);
    return ErrorCode::INVALID_HCI_COMMAND_PARAMETERS;
  }

  resolvable_private_address_timeout_ = seconds(rpa_timeout);
  return ErrorCode::SUCCESS;
}

// HCI LE Set Host Feature command (Vol 4, Part E § 7.8.115).
ErrorCode LinkLayerController::LeSetHostFeature(uint8_t bit_number,
                                                uint8_t bit_value) {
@@ -1314,11 +1330,23 @@ void LinkLayerController::SetSecureConnectionsSupport(bool enable) {
  }
}

void LinkLayerController::SetName(std::vector<uint8_t> const& name) {
  name_.fill(0);
  for (size_t i = 0; i < 248 && i < name.size(); i++) {
    name_[i] = name[i];
void LinkLayerController::SetLocalName(
    std::array<uint8_t, 248> const& local_name) {
  std::copy(local_name.begin(), local_name.end(), local_name_.begin());
}

void LinkLayerController::SetLocalName(std::vector<uint8_t> const& local_name) {
  ASSERT(local_name.size() <= local_name_.size());
  local_name_.fill(0);
  std::copy(local_name.begin(), local_name.end(), local_name_.begin());
}

void LinkLayerController::SetExtendedInquiryResponse(
    std::vector<uint8_t> const& extended_inquiry_response) {
  ASSERT(extended_inquiry_response.size() <= extended_inquiry_response_.size());
  extended_inquiry_response_.fill(0);
  std::copy(extended_inquiry_response.begin(), extended_inquiry_response.end(),
            extended_inquiry_response_.begin());
}

void LinkLayerController::SendLeLinkLayerPacketWithRssi(
@@ -1879,7 +1907,7 @@ void LinkLayerController::IncomingRemoteNameRequest(
  ASSERT(view.IsValid());

  SendLinkLayerPacket(model::packets::RemoteNameRequestResponseBuilder::Create(
      packet.GetDestinationAddress(), packet.GetSourceAddress(), name_));
      packet.GetDestinationAddress(), packet.GetSourceAddress(), local_name_));
}

void LinkLayerController::IncomingRemoteNameRequestResponse(
@@ -2138,7 +2166,7 @@ void LinkLayerController::IncomingInquiryPacket(
              GetAddress(), peer,
              static_cast<uint8_t>(GetPageScanRepetitionMode()),
              class_of_device_, GetClockOffset(), rssi,
              extended_inquiry_data_));
              extended_inquiry_response_));

    } break;
    default:
@@ -2213,7 +2241,8 @@ void LinkLayerController::IncomingInquiryResponsePacket(
              inquiry_response.GetPageScanRepetitionMode()),
          inquiry_response.GetClassOfDevice(),
          inquiry_response.GetClockOffset(), inquiry_response.GetRssi(),
          inquiry_response.GetExtendedData()));
          std::vector<uint8_t>(extended_inquiry_response_.begin(),
                               extended_inquiry_response_.end())));
    } break;
    default:
      LOG_WARN("Unhandled Incoming Inquiry Response of type %d",
@@ -3169,13 +3198,6 @@ void LinkLayerController::ScanIncomingLeExtendedAdvertisingPdu(
      break;
  }

  // When the Scanning_Filter_Policy is set to 0x02 or 0x03 (see Section 7.8.10)
  // and a directed advertisement was received where the advertiser used a
  // resolvable private address which the Controller is unable to resolve, an
  // HCI_LE_Directed_Advertising_Report event shall be generated instead of an
  // HCI_LE_Advertising_Report event.
  bool should_send_directed_advertising_report = false;

  if (directed_advertising) {
    switch (scanner_.scan_filter_policy) {
      // In both basic scanner filter policy modes, a directed advertising PDU
@@ -3213,8 +3235,6 @@ void LinkLayerController::ScanIncomingLeExtendedAdvertisingPdu(
              target_address.GetAddressType());
          return;
        }
        should_send_directed_advertising_report =
            target_address.IsRpa() && !resolved_target_address;
        break;
    }
  }
+41 −11

File changed.

Preview size limit exceeded, changes collapsed.

Loading