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

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

Merge "RootCanal: Implement the HCI Read Rssi command"

parents 473b3c01 ac78dcfd
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -61,6 +61,10 @@ bluetooth::hci::Role AclConnection::GetRole() const { return role_; };

void AclConnection::SetRole(bluetooth::hci::Role role) { role_ = role; }

int8_t AclConnection::GetRssi() const { return rssi_; }

void AclConnection::SetRssi(int8_t rssi) { rssi_ = rssi; }

void AclConnection::ResetLinkTimer() {
  last_packet_timestamp_ = std::chrono::steady_clock::now();
}
+8 −0
Original line number Diff line number Diff line
@@ -59,6 +59,10 @@ class AclConnection {

  void SetRole(bluetooth::hci::Role role);

  int8_t GetRssi() const;

  void SetRssi(int8_t rssi);

  void ResetLinkTimer();

  std::chrono::steady_clock::duration TimeUntilNearExpiring() const;
@@ -75,6 +79,10 @@ class AclConnection {
  AddressWithType resolved_address_;
  Phy::Type type_{Phy::Type::BR_EDR};

  // Reports the RSSI measured for the last packet received on
  // this connection.
  int8_t rssi_{0};

  // State variables
  bool encrypted_{false};
  uint16_t link_policy_settings_{0};
+10 −0
Original line number Diff line number Diff line
@@ -236,6 +236,16 @@ bool AclConnectionHandler::IsEncrypted(uint16_t handle) const {
  return acl_connections_.at(handle).IsEncrypted();
}

void AclConnectionHandler::SetRssi(uint16_t handle, int8_t rssi) {
  if (HasHandle(handle)) {
    acl_connections_.at(handle).SetRssi(rssi);
  }
}

int8_t AclConnectionHandler::GetRssi(uint16_t handle) const {
  return HasHandle(handle) ? acl_connections_.at(handle).GetRssi() : 0;
}

Phy::Type AclConnectionHandler::GetPhyType(uint16_t handle) const {
  if (!HasHandle(handle)) {
    return Phy::Type::BR_EDR;
+3 −0
Original line number Diff line number Diff line
@@ -93,6 +93,9 @@ class AclConnectionHandler {
  void Encrypt(uint16_t handle);
  bool IsEncrypted(uint16_t handle) const;

  void SetRssi(uint16_t handle, int8_t rssi);
  int8_t GetRssi(uint16_t handle) const;

  Phy::Type GetPhyType(uint16_t handle) const;

  uint16_t GetAclLinkPolicySettings(uint16_t handle) const;
+14 −1
Original line number Diff line number Diff line
@@ -300,6 +300,19 @@ void DualModeController::ReadBufferSize(CommandView command) {
      properties_.total_num_sco_data_packets));
}

void DualModeController::ReadRssi(CommandView command) {
  auto command_view =
      gd_hci::ReadRssiView::Create(gd_hci::AclCommandView::Create(command));
  ASSERT(command_view.IsValid());

  uint16_t connection_handle = command_view.GetConnectionHandle();
  int8_t rssi = 0;

  ErrorCode status = link_layer_controller_.ReadRssi(connection_handle, &rssi);
  send_event_(bluetooth::hci::ReadRssiCompleteBuilder::Create(
      kNumCommandPackets, status, connection_handle, rssi));
}

void DualModeController::ReadEncryptionKeySize(CommandView command) {
  auto command_view = gd_hci::ReadEncryptionKeySizeView::Create(
      gd_hci::SecurityCommandView::Create(command));
@@ -3711,7 +3724,7 @@ const std::unordered_map<OpCode, DualModeController::CommandHandler>
        //{OpCode::RESET_FAILED_CONTACT_COUNTER,
        //&DualModeController::ResetFailedContactCounter},
        //{OpCode::READ_LINK_QUALITY, &DualModeController::ReadLinkQuality},
        //{OpCode::READ_RSSI, &DualModeController::ReadRssi},
        {OpCode::READ_RSSI, &DualModeController::ReadRssi},
        //{OpCode::READ_AFH_CHANNEL_MAP,
        //&DualModeController::ReadAfhChannelMap},
        //{OpCode::READ_CLOCK, &DualModeController::ReadClock},
Loading