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

Commit 261e6dad authored by Chris Manton's avatar Chris Manton
Browse files

Encapsulate stack/acl/btm_acl::tBTM_ROLE_SWITCH_CMPL

Bug: 164357702
Tag: #refactor
Test: compile & verify basic functions working

Change-Id: I7f8316c237bdca0bfa8ac39bde915a24113c7e32
parent b39b98c0
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -24,6 +24,15 @@

#define BTM_MAX_SCN_ 31  // PORT_MAX_RFC_PORTS packages/modules/Bluetooth/system/stack/include/rfcdefs.h

/* Structure returned with Role Switch information (in tBTM_CMPL_CB callback
 * function) in response to BTM_SwitchRole call.
 */
typedef struct {
  RawAddress remote_bd_addr; /* Remote BD addr involved with the switch */
  uint8_t hci_status;        /* HCI status returned with the event */
  uint8_t role;              /* HCI_ROLE_MASTER or HCI_ROLE_SLAVE */
} tBTM_ROLE_SWITCH_CMPL;

typedef struct {
  BD_FEATURES peer_le_features;
  BD_FEATURES peer_lmp_feature_pages[HCI_EXT_FEATURES_PAGE_MAX + 1];
@@ -108,6 +117,8 @@ typedef struct {
  friend void btm_acl_encrypt_change(uint16_t handle, uint8_t status,
                                     uint8_t encr_enable);
  friend void btm_acl_init(void);
  friend void btm_acl_role_changed(uint8_t hci_status,
                                   const RawAddress* bd_addr, uint8_t new_role);
  friend void btm_acl_update_conn_addr(uint16_t conn_handle,
                                       const RawAddress& address);
  friend void btm_pm_proc_cmd_status(uint8_t status);
@@ -135,6 +146,7 @@ typedef struct {

  tACL_CONN acl_db[MAX_L2CAP_LINKS];
  tBTM_PM_MCB pm_mode_db[MAX_L2CAP_LINKS];
  tBTM_ROLE_SWITCH_CMPL switch_role_ref_data;
  uint16_t btm_acl_pkt_types_supported;
  uint16_t btm_def_link_policy;
  uint16_t btm_def_link_super_tout;
+7 −6
Original line number Diff line number Diff line
@@ -690,10 +690,11 @@ void btm_acl_encrypt_change(uint16_t handle, uint8_t status,
  else if (p->switch_role_state == BTM_ACL_SWKEY_STATE_ENCRYPTION_ON) {
    p->switch_role_state = BTM_ACL_SWKEY_STATE_IDLE;
    p->encrypt_state = BTM_ACL_ENCRYPT_STATE_IDLE;
    auto new_role = btm_cb.devcb.switch_role_ref_data.role;
    auto hci_status = btm_cb.devcb.switch_role_ref_data.hci_status;
    BTA_dm_report_role_change(btm_cb.devcb.switch_role_ref_data.remote_bd_addr,
                              new_role, hci_status);
    auto new_role = btm_cb.acl_cb_.switch_role_ref_data.role;
    auto hci_status = btm_cb.acl_cb_.switch_role_ref_data.hci_status;
    BTA_dm_report_role_change(
        btm_cb.acl_cb_.switch_role_ref_data.remote_bd_addr, new_role,
        hci_status);

    BTM_TRACE_DEBUG(
        "%s: Role Switch Event: new_role 0x%02x, HCI Status 0x%02x, rs_st:%d",
@@ -1441,9 +1442,9 @@ void btm_blacklist_role_change_device(const RawAddress& bd_addr,
void btm_acl_role_changed(uint8_t hci_status, const RawAddress* bd_addr,
                          uint8_t new_role) {
  const RawAddress* p_bda =
      (bd_addr) ? bd_addr : &btm_cb.devcb.switch_role_ref_data.remote_bd_addr;
      (bd_addr) ? bd_addr : &btm_cb.acl_cb_.switch_role_ref_data.remote_bd_addr;
  tACL_CONN* p = internal_.btm_bda_to_acl(*p_bda, BT_TRANSPORT_BR_EDR);
  tBTM_ROLE_SWITCH_CMPL* p_data = &btm_cb.devcb.switch_role_ref_data;
  tBTM_ROLE_SWITCH_CMPL* p_data = &btm_cb.acl_cb_.switch_role_ref_data;
  tBTM_SEC_DEV_REC* p_dev_rec;

  BTM_TRACE_DEBUG("%s: peer %s hci_status:0x%x new_role:%d", __func__,
+0 −2
Original line number Diff line number Diff line
@@ -92,8 +92,6 @@ typedef struct {
      p_inq_tx_power_cmpl_cb; /* Callback function to be called when  */
                              /* read inq tx power function completes  */

  tBTM_ROLE_SWITCH_CMPL switch_role_ref_data;

  alarm_t* read_tx_power_timer;     /* Read tx power timer */
  tBTM_CMPL_CB* p_tx_power_cmpl_cb; /* Callback function to be called       */

+0 −9
Original line number Diff line number Diff line
@@ -49,15 +49,6 @@
 *  ACL Types
 ***************/

/* Structure returned with Role Switch information (in tBTM_CMPL_CB callback
 * function) in response to BTM_SwitchRole call.
 */
typedef struct {
  uint8_t hci_status;        /* HCI status returned with the event */
  uint8_t role;              /* HCI_ROLE_MASTER or HCI_ROLE_SLAVE */
  RawAddress remote_bd_addr; /* Remote BD addr involved with the switch */
} tBTM_ROLE_SWITCH_CMPL;

/* Structure returned with QoS information (in tBTM_CMPL_CB callback function)
 * in response to BTM_SetQoS call.
 */