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

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

Merge "RootCanal: Implement Read Failed Contact Counter command"

parents 7a639a84 44c2f097
Loading
Loading
Loading
Loading
+33 −4
Original line number Diff line number Diff line
@@ -301,6 +301,35 @@ void DualModeController::ReadBufferSize(CommandView command) {
      properties_.total_num_sco_data_packets));
}

void DualModeController::ReadFailedContactCounter(CommandView command) {
  auto command_view =
      bluetooth::hci::ReadFailedContactCounterView::Create(command);
  ASSERT(command_view.IsValid());

  uint16_t connection_handle = command_view.GetConnectionHandle();
  uint16_t failed_contact_counter = 0;
  ErrorCode status = link_layer_controller_.HasAclConnection(connection_handle)
                         ? ErrorCode::SUCCESS
                         : ErrorCode::UNKNOWN_CONNECTION;

  send_event_(bluetooth::hci::ReadFailedContactCounterCompleteBuilder::Create(
      kNumCommandPackets, status, connection_handle, failed_contact_counter));
}

void DualModeController::ResetFailedContactCounter(CommandView command) {
  auto command_view =
      bluetooth::hci::ReadFailedContactCounterView::Create(command);
  ASSERT(command_view.IsValid());

  uint16_t connection_handle = command_view.GetConnectionHandle();
  ErrorCode status = link_layer_controller_.HasAclConnection(connection_handle)
                         ? ErrorCode::SUCCESS
                         : ErrorCode::UNKNOWN_CONNECTION;

  send_event_(bluetooth::hci::ResetFailedContactCounterCompleteBuilder::Create(
      kNumCommandPackets, status, connection_handle));
}

void DualModeController::ReadRssi(CommandView command) {
  auto command_view = bluetooth::hci::ReadRssiView::Create(command);
  ASSERT(command_view.IsValid());
@@ -3510,10 +3539,10 @@ const std::unordered_map<OpCode, DualModeController::CommandHandler>
        //&DualModeController::ReadLocalSupportedControllerDelay},

        // STATUS_PARAMETERS
        //{OpCode::READ_FAILED_CONTACT_COUNTER,
        //&DualModeController::ReadFailedContactCounter},
        //{OpCode::RESET_FAILED_CONTACT_COUNTER,
        //&DualModeController::ResetFailedContactCounter},
        {OpCode::READ_FAILED_CONTACT_COUNTER,
         &DualModeController::ReadFailedContactCounter},
        {OpCode::RESET_FAILED_CONTACT_COUNTER,
         &DualModeController::ResetFailedContactCounter},
        //{OpCode::READ_LINK_QUALITY, &DualModeController::ReadLinkQuality},
        {OpCode::READ_RSSI, &DualModeController::ReadRssi},
        //{OpCode::READ_AFH_CHANNEL_MAP,
+4 −0
Original line number Diff line number Diff line
@@ -349,6 +349,10 @@ class DualModeController : public Device {
  // Status Parameters Commands
  // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.5

  // 7.5.1 - 7.5.2
  void ReadFailedContactCounter(CommandView command);
  void ResetFailedContactCounter(CommandView command);

  // 7.5.4
  void ReadRssi(CommandView command);

+4 −0
Original line number Diff line number Diff line
@@ -5875,6 +5875,10 @@ bool LinkLayerController::HasAclConnection() {
  return !connections_.GetAclHandles().empty();
}

bool LinkLayerController::HasAclConnection(uint16_t connection_handle) {
  return connections_.HasHandle(connection_handle);
}

void LinkLayerController::LeReadIsoTxSync(uint16_t /* handle */) {}

void LinkLayerController::LeSetCigParameters(
+3 −0
Original line number Diff line number Diff line
@@ -345,7 +345,10 @@ class LinkLayerController {
      uint8_t retransmission_effort, uint16_t packet_types);
  ErrorCode RejectSynchronousConnection(Address bd_addr, uint16_t reason);

  // Returns true if any ACL connection exists.
  bool HasAclConnection();
  // Returns true if the specified ACL connection handle is valid.
  bool HasAclConnection(uint16_t connection_handle);

  void HandleIso(bluetooth::hci::IsoView iso);