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

Commit b727885f authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by android-build-merger
Browse files

Merge "Make LE CoC Maximum PDU Size configurable" am: 6a70d01a

am: ca4b0a0f

Change-Id: I89d86e5b1c2b2a4a8670050ce16d7c9649896cb2
parents e34bee58 ca4b0a0f
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@

using bluetooth::Uuid;

constexpr uint16_t DEFAULT_LE_MPS = 23;

tBTA_JV_CB bta_jv_cb;

/* one of these exists for each client */
@@ -933,9 +935,9 @@ void bta_jv_l2cap_connect(int32_t type, tBTA_SEC sec_mask, tBTA_JV_ROLE role,
    if ((type != BTA_JV_CONN_TYPE_L2CAP) ||
        (bta_jv_check_psm(remote_psm))) /* allowed */
    {
      handle = GAP_ConnOpen("", sec_id, 0, &peer_bd_addr, remote_psm, &cfg,
                            ertm_info.get(), sec_mask, chan_mode_mask,
                            bta_jv_l2cap_client_cback, type);
      handle = GAP_ConnOpen("", sec_id, 0, &peer_bd_addr, remote_psm,
                            DEFAULT_LE_MPS, &cfg, ertm_info.get(), sec_mask,
                            chan_mode_mask, bta_jv_l2cap_client_cback, type);
      if (handle != GAP_INVALID_HANDLE) {
        evt_data.status = BTA_JV_SUCCESS;
      }
@@ -1082,10 +1084,10 @@ void bta_jv_l2cap_start_server(int32_t type, tBTA_SEC sec_mask,
  /* PSM checking is not required for LE COC */
  if (0 == sec_id ||
      ((type == BTA_JV_CONN_TYPE_L2CAP) && (!bta_jv_check_psm(local_psm))) ||
      (handle = GAP_ConnOpen("JV L2CAP", sec_id, 1, nullptr, local_psm, &cfg,
                             ertm_info.get(), sec_mask, chan_mode_mask,
                             bta_jv_l2cap_server_cback, type)) ==
          GAP_INVALID_HANDLE) {
      (handle = GAP_ConnOpen("JV L2CAP", sec_id, 1, nullptr, local_psm,
                             DEFAULT_LE_MPS, &cfg, ertm_info.get(), sec_mask,
                             chan_mode_mask, bta_jv_l2cap_server_cback,
                             type)) == GAP_INVALID_HANDLE) {
    bta_jv_free_sec_id(&sec_id);
    evt_data.status = BTA_JV_FAILURE;
  } else {
+13 −4
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "bt_utils.h"
#include "btm_int.h"
#include "btu.h"
#include "device/include/controller.h"
#include "gap_api.h"
#include "l2c_int.h"
#include "l2cdefs.h"
@@ -143,6 +144,7 @@ void gap_conn_init(void) {
 *                                remote BD Address, then NULL should be passed.
 *
 *                  psm         - the PSM used for the connection
 *                  le_mps      - Maximum PDU Size for LE CoC
 *
 *                  p_config    - Optional pointer to configuration structure.
 *                                If NULL, the default GAP configuration will
@@ -161,9 +163,10 @@ void gap_conn_init(void) {
 ******************************************************************************/
uint16_t GAP_ConnOpen(const char* p_serv_name, uint8_t service_id,
                      bool is_server, const RawAddress* p_rem_bda, uint16_t psm,
                      tL2CAP_CFG_INFO* p_cfg, tL2CAP_ERTM_INFO* ertm_info,
                      uint16_t security, uint8_t chan_mode_mask,
                      tGAP_CONN_CALLBACK* p_cb, tBT_TRANSPORT transport) {
                      uint16_t le_mps, tL2CAP_CFG_INFO* p_cfg,
                      tL2CAP_ERTM_INFO* ertm_info, uint16_t security,
                      uint8_t chan_mode_mask, tGAP_CONN_CALLBACK* p_cb,
                      tBT_TRANSPORT transport) {
  tGAP_CCB* p_ccb;
  uint16_t cid;

@@ -205,7 +208,13 @@ uint16_t GAP_ConnOpen(const char* p_serv_name, uint8_t service_id,
  if (transport == BT_TRANSPORT_LE) {
    p_ccb->local_coc_cfg.credits = L2CAP_LE_DEFAULT_CREDIT;
    p_ccb->local_coc_cfg.mtu = p_cfg->mtu;
    p_ccb->local_coc_cfg.mps = L2CAP_LE_DEFAULT_MPS;

    uint16_t max_mps = controller_get_interface()->get_acl_data_size_ble();
    if (le_mps > max_mps) {
      LOG(INFO) << "Limiting MPS to one buffer size - " << max_mps;
      le_mps = max_mps;
    }
    p_ccb->local_coc_cfg.mps = le_mps;
  }

  p_ccb->p_callback = p_cb;
+2 −1
Original line number Diff line number Diff line
@@ -163,7 +163,8 @@ typedef void(tGAP_BLE_CMPL_CBACK)(bool status, const RawAddress& addr,
 ******************************************************************************/
extern uint16_t GAP_ConnOpen(const char* p_serv_name, uint8_t service_id,
                             bool is_server, const RawAddress* p_rem_bda,
                             uint16_t psm, tL2CAP_CFG_INFO* p_cfg,
                             uint16_t psm, uint16_t le_mps,
                             tL2CAP_CFG_INFO* p_cfg,
                             tL2CAP_ERTM_INFO* ertm_info, uint16_t security,
                             uint8_t chan_mode_mask, tGAP_CONN_CALLBACK* p_cb,
                             tBT_TRANSPORT transport);
+0 −2
Original line number Diff line number Diff line
@@ -42,8 +42,6 @@
#define L2CAP_LE_MAX_MPS 65533
#define L2CAP_LE_MIN_CREDIT 0
#define L2CAP_LE_MAX_CREDIT 65535
#define L2CAP_LE_DEFAULT_MTU 512
#define L2CAP_LE_DEFAULT_MPS 23
#define L2CAP_LE_DEFAULT_CREDIT 1

/*