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

Commit b6f3d328 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

L2cap: Add API to handle HCI mode change

Add l2c_OnHciModeChangeSendPendingPackets, invoked when HCI mode is
changed to HCI_MODE_ACTIVE or HCI_MODE_SNIFF

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I1d4ed34101ab3e7c4c4e7bc03b3eade9fa4b4071
parent 914348d7
Loading
Loading
Loading
Loading
+3 −16
Original line number Diff line number Diff line
@@ -31,23 +31,18 @@
#define LOG_TAG "bt_btm_pm"

#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "bt_common.h"
#include "bt_types.h"
#include "bt_utils.h"
#include "btm_api.h"
#include "btm_int.h"
#include "btm_int_types.h"
#include "btu.h"
#include "device/include/controller.h"
#include "hcidefs.h"
#include "hcimsgs.h"
#include "l2c_int.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"
#include "stack/include/l2cap_hci_link_interface.h"

/*****************************************************************************/
/*      to handle different modes                                            */
@@ -747,7 +742,6 @@ void btm_pm_proc_mode_change(uint8_t hci_status, uint16_t hci_handle,
  tBTM_PM_MCB* p_cb = NULL;
  int xx, yy, zz;
  tBTM_PM_STATE old_state;
  tL2C_LCB* p_lcb;

  /* get the index to acl_db */
  xx = btm_handle_to_acl_index(hci_handle);
@@ -764,15 +758,8 @@ void btm_pm_proc_mode_change(uint8_t hci_status, uint16_t hci_handle,
  BTM_TRACE_DEBUG("%s switched from %s to %s.", __func__,
                  mode_to_string(old_state), mode_to_string(p_cb->state));

  p_lcb = l2cu_find_lcb_by_bd_addr(p->remote_addr, BT_TRANSPORT_BR_EDR);
  if (p_lcb != NULL) {
  if ((p_cb->state == BTM_PM_ST_ACTIVE) || (p_cb->state == BTM_PM_ST_SNIFF)) {
      /* There might be any pending packets due to SNIFF or PENDING state */
      /* Trigger L2C to start transmission of the pending packets. */
      BTM_TRACE_DEBUG(
          "btm mode change to active; check l2c_link for outgoing packets");
      l2c_link_check_send_pkts(p_lcb, NULL, NULL);
    }
    l2c_OnHciModeChangeSendPendingPackets(p->remote_addr);
  }

  /* notify registered parties */
+3 −0
Original line number Diff line number Diff line
@@ -48,3 +48,6 @@ extern void l2cble_process_rc_param_request_evt(uint16_t handle,
                                                uint16_t latency,
                                                uint16_t timeout);
#endif

// Invoked when HCI mode is changed to HCI_MODE_ACTIVE or HCI_MODE_SNIFF
extern void l2c_OnHciModeChangeSendPendingPackets(RawAddress remote);
+11 −0
Original line number Diff line number Diff line
@@ -1057,6 +1057,17 @@ void l2c_link_check_send_pkts(tL2C_LCB* p_lcb, tL2C_CCB* p_ccb, BT_HDR* p_buf) {
  }
}

void l2c_OnHciModeChangeSendPendingPackets(RawAddress remote) {
  tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(remote, BT_TRANSPORT_BR_EDR);
  if (p_lcb != NULL) {
    /* There might be any pending packets due to SNIFF or PENDING state */
    /* Trigger L2C to start transmission of the pending packets. */
    BTM_TRACE_DEBUG(
        "btm mode change to active; check l2c_link for outgoing packets");
    l2c_link_check_send_pkts(p_lcb, NULL, NULL);
  }
}

/*******************************************************************************
 *
 * Function         l2c_link_send_to_lower