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

Commit d881ba40 authored by Chris Manton's avatar Chris Manton
Browse files

Use tHCI_STATUS throughout shim interface

Bug: 166280067
Tag: #refactor
Test: act.py -tc BleCocTest
Test: ble paired 2 phones
Test: classic paired Bose SoundLink

Change-Id: Ia6b600dbe0a8dbf99b1e97d6776a5dfe7f48248f
parent f8090e1d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ class ClassicShimAclConnection

  void OnDisconnection(hci::ErrorCode reason) override {
    btm_sec_disconnected(connection_->GetHandle(),
                         static_cast<uint8_t>(reason));
                         static_cast<tHCI_STATUS>(reason));
  }

  void OnReadRemoteVersionInformationComplete(uint8_t lmp_version,
@@ -351,7 +351,7 @@ void bluetooth::shim::legacy::Acl::OnLeConnectFail(

  uint16_t handle{0};  /* TODO Unneeded */
  bool enhanced{true}; /* TODO logging metrics only */
  uint8_t status = ToLegacyHciErrorCode(reason);
  tHCI_STATUS status = ToLegacyHciErrorCode(reason);

  acl_ble_connection_fail(legacy_address_with_type, handle, enhanced, status);
}
+7 −7
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

#include <cstdint>
#include "stack/include/bt_types.h"
#include "stack/include/hci_error_code.h"
#include "types/raw_address.h"

namespace bluetooth {
@@ -25,11 +26,11 @@ namespace shim {
namespace legacy {

typedef struct {
  void (*on_connected)(const RawAddress& bda, uint16_t handle, uint8_t status,
  void (*on_connected)(const RawAddress& bda, uint16_t handle,
                       tHCI_STATUS status, uint8_t enc_mode);
  void (*on_failed)(const RawAddress& bda, uint16_t handle, tHCI_STATUS status,
                    uint8_t enc_mode);
  void (*on_failed)(const RawAddress& bda, uint16_t handle, uint8_t status,
                    uint8_t enc_mode);
  void (*on_disconnected)(uint16_t handle, uint8_t reason);
  void (*on_disconnected)(uint16_t handle, tHCI_STATUS reason);
} acl_classic_connection_interface_t;

typedef struct {
@@ -39,8 +40,8 @@ typedef struct {
                       const RawAddress& local_rpa, const RawAddress& peer_rpa,
                       uint8_t peer_addr_type);
  void (*on_failed)(const tBLE_BD_ADDR& address_with_type, uint16_t handle,
                    bool enhanced, uint8_t status);
  void (*on_disconnected)(uint16_t handle, uint8_t reason);
                    bool enhanced, tHCI_STATUS status);
  void (*on_disconnected)(uint16_t handle, tHCI_STATUS reason);
} acl_le_connection_interface_t;

typedef struct {
@@ -77,7 +78,6 @@ typedef struct {
  void (*on_role_change)(uint8_t new_role);
  void (*on_role_discovery_complete)(uint8_t current_role);
} acl_classic_link_interface_t;
;

typedef struct {
  void (*on_connection_update)(uint16_t connection_interval,
+13 −12
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ inline std::unique_ptr<bluetooth::packet::RawBuilder> MakeUniquePacket(
  return payload;
}

inline uint8_t ToLegacyHciErrorCode(hci::ErrorCode reason) {
inline tHCI_STATUS ToLegacyHciErrorCode(hci::ErrorCode reason) {
  switch (reason) {
    case hci::ErrorCode::SUCCESS:
      return HCI_SUCCESS;
@@ -138,17 +138,17 @@ inline uint8_t ToLegacyHciErrorCode(hci::ErrorCode reason) {
    case hci::ErrorCode::CONNECTION_ACCEPT_TIMEOUT:
      return HCI_ERR_HOST_TIMEOUT;
    case hci::ErrorCode::UNSUPORTED_FEATURE_OR_PARAMETER_VALUE:
      return static_cast<uint8_t>(
      return static_cast<tHCI_STATUS>(
          hci::ErrorCode::UNSUPORTED_FEATURE_OR_PARAMETER_VALUE);
    case hci::ErrorCode::INVALID_HCI_COMMAND_PARAMETERS:
      return HCI_ERR_ILLEGAL_PARAMETER_FMT;
    case hci::ErrorCode::REMOTE_USER_TERMINATED_CONNECTION:
      return HCI_ERR_PEER_USER;
    case hci::ErrorCode::REMOTE_DEVICE_TERMINATED_CONNECTION_LOW_RESOURCES:
      return static_cast<uint8_t>(
      return static_cast<tHCI_STATUS>(
          hci::ErrorCode::REMOTE_DEVICE_TERMINATED_CONNECTION_LOW_RESOURCES);
    case hci::ErrorCode::REMOTE_DEVICE_TERMINATED_CONNECTION_POWER_OFF:
      return static_cast<uint8_t>(
      return static_cast<tHCI_STATUS>(
          hci::ErrorCode::REMOTE_DEVICE_TERMINATED_CONNECTION_POWER_OFF);
    case hci::ErrorCode::CONNECTION_TERMINATED_BY_LOCAL_HOST:
      return HCI_ERR_CONN_CAUSE_LOCAL_HOST;
@@ -157,30 +157,31 @@ inline uint8_t ToLegacyHciErrorCode(hci::ErrorCode reason) {
    case hci::ErrorCode::PAIRING_NOT_ALLOWED:
      return HCI_ERR_PAIRING_NOT_ALLOWED;
    case hci::ErrorCode::UNKNOWN_LMP_PDU:
      return static_cast<uint8_t>(hci::ErrorCode::UNKNOWN_LMP_PDU);
      return static_cast<tHCI_STATUS>(hci::ErrorCode::UNKNOWN_LMP_PDU);
    case hci::ErrorCode::UNSUPPORTED_REMOTE_OR_LMP_FEATURE:
      return HCI_ERR_UNSUPPORTED_REM_FEATURE;
    case hci::ErrorCode::SCO_OFFSET_REJECTED:
      return static_cast<uint8_t>(hci::ErrorCode::SCO_OFFSET_REJECTED);
      return static_cast<tHCI_STATUS>(hci::ErrorCode::SCO_OFFSET_REJECTED);
    case hci::ErrorCode::SCO_INTERVAL_REJECTED:
      return static_cast<uint8_t>(hci::ErrorCode::SCO_INTERVAL_REJECTED);
      return static_cast<tHCI_STATUS>(hci::ErrorCode::SCO_INTERVAL_REJECTED);
    case hci::ErrorCode::SCO_AIR_MODE_REJECTED:
      return static_cast<uint8_t>(hci::ErrorCode::SCO_AIR_MODE_REJECTED);
      return static_cast<tHCI_STATUS>(hci::ErrorCode::SCO_AIR_MODE_REJECTED);
    case hci::ErrorCode::INVALID_LMP_OR_LL_PARAMETERS:
      return static_cast<uint8_t>(hci::ErrorCode::INVALID_LMP_OR_LL_PARAMETERS);
      return static_cast<tHCI_STATUS>(
          hci::ErrorCode::INVALID_LMP_OR_LL_PARAMETERS);
    case hci::ErrorCode::UNSPECIFIED_ERROR:
      return HCI_ERR_UNSPECIFIED;
    case hci::ErrorCode::UNSUPPORTED_LMP_OR_LL_PARAMETER:
      return static_cast<uint8_t>(
      return static_cast<tHCI_STATUS>(
          hci::ErrorCode::UNSUPPORTED_LMP_OR_LL_PARAMETER);
    case hci::ErrorCode::ROLE_CHANGE_NOT_ALLOWED:
      return static_cast<uint8_t>(hci::ErrorCode::ROLE_CHANGE_NOT_ALLOWED);
      return static_cast<tHCI_STATUS>(hci::ErrorCode::ROLE_CHANGE_NOT_ALLOWED);
    case hci::ErrorCode::LINK_LAYER_COLLISION:
      return HCI_ERR_LMP_ERR_TRANS_COLLISION;
    case hci::ErrorCode::ENCRYPTION_MODE_NOT_ACCEPTABLE:
      return HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE;
    case hci::ErrorCode::CONTROLLER_BUSY:
      return static_cast<uint8_t>(hci::ErrorCode::CONTROLLER_BUSY);
      return static_cast<tHCI_STATUS>(hci::ErrorCode::CONTROLLER_BUSY);
  }
}

+2 −1
Original line number Diff line number Diff line
@@ -107,7 +107,8 @@ void acl_ble_enhanced_connection_complete(
}

void acl_ble_connection_fail(const tBLE_BD_ADDR& address_with_type,
                             uint16_t handle, bool enhanced, uint8_t status) {
                             uint16_t handle, bool enhanced,
                             tHCI_STATUS status) {
  if (status != HCI_ERR_ADVERTISING_TIMEOUT) {
    btm_cb.ble_ctr_cb.set_connection_state_idle();
    btm_ble_clear_topology_mask(BTM_BLE_STATE_INIT_BIT);
+2 −2
Original line number Diff line number Diff line
@@ -2761,8 +2761,8 @@ bool acl_set_peer_le_features_from_handle(uint16_t hci_handle,
  return true;
}

void btm_acl_connected(const RawAddress& bda, uint16_t handle, uint8_t status,
                       uint8_t enc_mode) {
void btm_acl_connected(const RawAddress& bda, uint16_t handle,
                       tHCI_STATUS status, uint8_t enc_mode) {
  btm_sec_connected(bda, handle, status, enc_mode);
  btm_acl_set_paging(false);
  l2c_link_hci_conn_comp(status, handle, bda);
Loading