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

Commit 9edf4a13 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Root-Canal: Generate LE_Channel_Selection_Algorithm event" am: 826a70d6

parents 2169b100 826a70d6
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -1828,7 +1828,7 @@ void DualModeController::LeCreateConnection(CommandView command) {
  link_layer_controller_.SetLeMaximumCeLength(
  link_layer_controller_.SetLeMaximumCeLength(
      command_view.GetMaximumCeLength());
      command_view.GetMaximumCeLength());


  auto status = link_layer_controller_.SetLeConnect(true);
  auto status = link_layer_controller_.SetLeConnect(true, false);


  send_event_(bluetooth::hci::LeCreateConnectionStatusBuilder::Create(
  send_event_(bluetooth::hci::LeCreateConnectionStatusBuilder::Create(
      status, kNumCommandPackets));
      status, kNumCommandPackets));
@@ -1906,7 +1906,7 @@ void DualModeController::LeConnectionCancel(CommandView command) {
      gd_hci::LeConnectionManagementCommandView::Create(
      gd_hci::LeConnectionManagementCommandView::Create(
          gd_hci::AclCommandView::Create(command)));
          gd_hci::AclCommandView::Create(command)));
  ASSERT(command_view.IsValid());
  ASSERT(command_view.IsValid());
  ErrorCode status = link_layer_controller_.SetLeConnect(false);
  ErrorCode status = link_layer_controller_.SetLeConnect(false, false);
  send_event_(bluetooth::hci::LeCreateConnectionCancelCompleteBuilder::Create(
  send_event_(bluetooth::hci::LeCreateConnectionCancelCompleteBuilder::Create(
      kNumCommandPackets, status));
      kNumCommandPackets, status));


@@ -2135,7 +2135,7 @@ void DualModeController::LeExtendedCreateConnection(CommandView command) {
  link_layer_controller_.SetLeMinimumCeLength(params[0].min_ce_length_);
  link_layer_controller_.SetLeMinimumCeLength(params[0].min_ce_length_);
  link_layer_controller_.SetLeMaximumCeLength(params[0].max_ce_length_);
  link_layer_controller_.SetLeMaximumCeLength(params[0].max_ce_length_);


  auto status = link_layer_controller_.SetLeConnect(true);
  auto status = link_layer_controller_.SetLeConnect(true, true);


  send_event_(bluetooth::hci::LeExtendedCreateConnectionStatusBuilder::Create(
  send_event_(bluetooth::hci::LeExtendedCreateConnectionStatusBuilder::Create(
      status, kNumCommandPackets));
      status, kNumCommandPackets));
+27 −10
Original line number Original line Diff line number Diff line
@@ -1354,7 +1354,7 @@ void LinkLayerController::IncomingLeAdvertisementPacket(
        properties_.GetLeAddress(), address));
        properties_.GetLeAddress(), address));
  }
  }


  if (!le_connect_) {
  if (!le_connect_ || le_pending_connect_) {
    return;
    return;
  }
  }
  if (!(adv_type == model::packets::AdvertisementType::ADV_IND ||
  if (!(adv_type == model::packets::AdvertisementType::ADV_IND ||
@@ -1422,7 +1422,7 @@ void LinkLayerController::IncomingLeAdvertisementPacket(
    LOG_INFO("Connecting to %s (type %hhx) own_address %s (type %hhx)",
    LOG_INFO("Connecting to %s (type %hhx) own_address %s (type %hhx)",
             incoming.GetSourceAddress().ToString().c_str(), address_type,
             incoming.GetSourceAddress().ToString().c_str(), address_type,
             own_address.ToString().c_str(), le_address_type_);
             own_address.ToString().c_str(), le_address_type_);
    le_connect_ = false;
    le_pending_connect_ = true;
    le_scan_enable_ = bluetooth::hci::OpCode::NONE;
    le_scan_enable_ = bluetooth::hci::OpCode::NONE;


    SendLeLinkLayerPacket(model::packets::LeConnectBuilder::Create(
    SendLeLinkLayerPacket(model::packets::LeConnectBuilder::Create(
@@ -1552,12 +1552,11 @@ void LinkLayerController::IncomingScoDisconnect(
  }
  }
}
}


uint16_t LinkLayerController::HandleLeConnection(AddressWithType address,
uint16_t LinkLayerController::HandleLeConnection(
                                                 AddressWithType own_address,
    AddressWithType address, AddressWithType own_address, uint8_t role,
                                                 uint8_t role,
    uint16_t connection_interval, uint16_t connection_latency,
                                                 uint16_t connection_interval,
    uint16_t supervision_timeout,
                                                 uint16_t connection_latency,
    bool send_le_channel_selection_algorithm_event) {
                                                 uint16_t supervision_timeout) {
  // Note: the HCI_LE_Connection_Complete event is not sent if the
  // Note: the HCI_LE_Connection_Complete event is not sent if the
  // HCI_LE_Enhanced_Connection_Complete event (see Section 7.7.65.10) is
  // HCI_LE_Enhanced_Connection_Complete event (see Section 7.7.65.10) is
  // unmasked.
  // unmasked.
@@ -1589,6 +1588,19 @@ uint16_t LinkLayerController::HandleLeConnection(AddressWithType address,
        static_cast<bluetooth::hci::ClockAccuracy>(0x00)));
        static_cast<bluetooth::hci::ClockAccuracy>(0x00)));
  }
  }


  // Note: the HCI_LE_Connection_Complete event is immediately followed by
  // an HCI_LE_Channel_Selection_Algorithm event if the connection is created
  // using the LE_Extended_Create_Connection command (see Section 7.7.8.66).
  if (send_le_channel_selection_algorithm_event &&
      properties_.IsUnmasked(EventCode::LE_META_EVENT) &&
      properties_.GetLeEventSupported(
          SubeventCode::CHANNEL_SELECTION_ALGORITHM)) {
    // The selection channel algorithm probably will have no impact
    // on emulation.
    send_event_(bluetooth::hci::LeChannelSelectionAlgorithmBuilder::Create(
        handle, bluetooth::hci::ChannelSelectionAlgorithm::ALGORITHM_1));
  }

  if (own_address.GetAddress() == le_connecting_rpa_) {
  if (own_address.GetAddress() == le_connecting_rpa_) {
    le_connecting_rpa_ = Address::kEmpty;
    le_connecting_rpa_ = Address::kEmpty;
  }
  }
@@ -1643,7 +1655,7 @@ void LinkLayerController::IncomingLeConnectPacket(
          static_cast<bluetooth::hci::AddressType>(connect.GetAddressType())),
          static_cast<bluetooth::hci::AddressType>(connect.GetAddressType())),
      my_address, static_cast<uint8_t>(bluetooth::hci::Role::PERIPHERAL),
      my_address, static_cast<uint8_t>(bluetooth::hci::Role::PERIPHERAL),
      connection_interval, connect.GetLeConnectionLatency(),
      connection_interval, connect.GetLeConnectionLatency(),
      connect.GetLeConnectionSupervisionTimeout());
      connect.GetLeConnectionSupervisionTimeout(), false);


  SendLeLinkLayerPacket(model::packets::LeConnectCompleteBuilder::Create(
  SendLeLinkLayerPacket(model::packets::LeConnectCompleteBuilder::Create(
      incoming.GetDestinationAddress(), incoming.GetSourceAddress(),
      incoming.GetDestinationAddress(), incoming.GetSourceAddress(),
@@ -1676,7 +1688,10 @@ void LinkLayerController::IncomingLeConnectCompletePacket(
          static_cast<bluetooth::hci::AddressType>(le_address_type_)),
          static_cast<bluetooth::hci::AddressType>(le_address_type_)),
      static_cast<uint8_t>(bluetooth::hci::Role::CENTRAL),
      static_cast<uint8_t>(bluetooth::hci::Role::CENTRAL),
      complete.GetLeConnectionInterval(), complete.GetLeConnectionLatency(),
      complete.GetLeConnectionInterval(), complete.GetLeConnectionLatency(),
      complete.GetLeConnectionSupervisionTimeout());
      complete.GetLeConnectionSupervisionTimeout(), le_extended_connect_);
  le_connect_ = false;
  le_extended_connect_ = false;
  le_pending_connect_ = false;
}
}


void LinkLayerController::IncomingLeConnectionParameterRequest(
void LinkLayerController::IncomingLeConnectionParameterRequest(
@@ -3663,6 +3678,8 @@ void LinkLayerController::Reset() {
  LeDisableAdvertisingSets();
  LeDisableAdvertisingSets();
  le_scan_enable_ = bluetooth::hci::OpCode::NONE;
  le_scan_enable_ = bluetooth::hci::OpCode::NONE;
  le_connect_ = false;
  le_connect_ = false;
  le_extended_connect_ = false;
  le_pending_connect_ = false;
  if (inquiry_timer_task_id_ != kInvalidTaskId) {
  if (inquiry_timer_task_id_ != kInvalidTaskId) {
    CancelScheduledTask(inquiry_timer_task_id_);
    CancelScheduledTask(inquiry_timer_task_id_);
    inquiry_timer_task_id_ = kInvalidTaskId;
    inquiry_timer_task_id_ = kInvalidTaskId;
+7 −2
Original line number Original line Diff line number Diff line
@@ -182,7 +182,8 @@ class LinkLayerController {
  uint16_t HandleLeConnection(AddressWithType addr, AddressWithType own_addr,
  uint16_t HandleLeConnection(AddressWithType addr, AddressWithType own_addr,
                              uint8_t role, uint16_t connection_interval,
                              uint8_t role, uint16_t connection_interval,
                              uint16_t connection_latency,
                              uint16_t connection_latency,
                              uint16_t supervision_timeout);
                              uint16_t supervision_timeout,
                              bool send_le_channel_selection_algorithm_event);


  bool ListBusy(uint16_t ignore_mask);
  bool ListBusy(uint16_t ignore_mask);


@@ -283,11 +284,13 @@ class LinkLayerController {
  void SetLeAddressType(bluetooth::hci::OwnAddressType le_address_type) {
  void SetLeAddressType(bluetooth::hci::OwnAddressType le_address_type) {
    le_address_type_ = le_address_type;
    le_address_type_ = le_address_type;
  }
  }
  ErrorCode SetLeConnect(bool le_connect) {
  ErrorCode SetLeConnect(bool le_connect, bool extended) {
    if (le_connect_ == le_connect) {
    if (le_connect_ == le_connect) {
      return ErrorCode::COMMAND_DISALLOWED;
      return ErrorCode::COMMAND_DISALLOWED;
    }
    }
    le_connect_ = le_connect;
    le_connect_ = le_connect;
    le_extended_connect_ = extended;
    le_pending_connect_ = false;
    return ErrorCode::SUCCESS;
    return ErrorCode::SUCCESS;
  }
  }
  void SetLeConnectionIntervalMin(uint16_t min) {
  void SetLeConnectionIntervalMin(uint16_t min) {
@@ -503,6 +506,8 @@ class LinkLayerController {
  bluetooth::hci::OwnAddressType le_address_type_{};
  bluetooth::hci::OwnAddressType le_address_type_{};


  bool le_connect_{false};
  bool le_connect_{false};
  bool le_extended_connect_{false};
  bool le_pending_connect_{false};
  uint16_t le_connection_interval_min_{};
  uint16_t le_connection_interval_min_{};
  uint16_t le_connection_interval_max_{};
  uint16_t le_connection_interval_max_{};
  uint16_t le_connection_latency_{};
  uint16_t le_connection_latency_{};