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

Commit 7ac61e02 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Make LE CoC Maximum PDU Size configurable

Hearing Aid will need to modify this value. For existing code keep the
value as is.

Test: none
Bug: 69623109
Change-Id: I8c97882b5dd08a049d3a958c51163bad41df4d6a
parent 6c56039b
Loading
Loading
Loading
Loading
+9 −7
Original line number Original line Diff line number Diff line
@@ -51,6 +51,8 @@


using bluetooth::Uuid;
using bluetooth::Uuid;


constexpr uint16_t DEFAULT_LE_MPS = 23;

tBTA_JV_CB bta_jv_cb;
tBTA_JV_CB bta_jv_cb;


/* one of these exists for each client */
/* 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) ||
    if ((type != BTA_JV_CONN_TYPE_L2CAP) ||
        (bta_jv_check_psm(remote_psm))) /* allowed */
        (bta_jv_check_psm(remote_psm))) /* allowed */
    {
    {
      handle = GAP_ConnOpen("", sec_id, 0, &peer_bd_addr, remote_psm, &cfg,
      handle = GAP_ConnOpen("", sec_id, 0, &peer_bd_addr, remote_psm,
                            ertm_info.get(), sec_mask, chan_mode_mask,
                            DEFAULT_LE_MPS, &cfg, ertm_info.get(), sec_mask,
                            bta_jv_l2cap_client_cback, type);
                            chan_mode_mask, bta_jv_l2cap_client_cback, type);
      if (handle != GAP_INVALID_HANDLE) {
      if (handle != GAP_INVALID_HANDLE) {
        evt_data.status = BTA_JV_SUCCESS;
        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 */
  /* PSM checking is not required for LE COC */
  if (0 == sec_id ||
  if (0 == sec_id ||
      ((type == BTA_JV_CONN_TYPE_L2CAP) && (!bta_jv_check_psm(local_psm))) ||
      ((type == BTA_JV_CONN_TYPE_L2CAP) && (!bta_jv_check_psm(local_psm))) ||
      (handle = GAP_ConnOpen("JV L2CAP", sec_id, 1, nullptr, local_psm, &cfg,
      (handle = GAP_ConnOpen("JV L2CAP", sec_id, 1, nullptr, local_psm,
                             ertm_info.get(), sec_mask, chan_mode_mask,
                             DEFAULT_LE_MPS, &cfg, ertm_info.get(), sec_mask,
                             bta_jv_l2cap_server_cback, type)) ==
                             chan_mode_mask, bta_jv_l2cap_server_cback,
          GAP_INVALID_HANDLE) {
                             type)) == GAP_INVALID_HANDLE) {
    bta_jv_free_sec_id(&sec_id);
    bta_jv_free_sec_id(&sec_id);
    evt_data.status = BTA_JV_FAILURE;
    evt_data.status = BTA_JV_FAILURE;
  } else {
  } else {
+13 −4
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@
#include "bt_utils.h"
#include "bt_utils.h"
#include "btm_int.h"
#include "btm_int.h"
#include "btu.h"
#include "btu.h"
#include "device/include/controller.h"
#include "gap_api.h"
#include "gap_api.h"
#include "l2c_int.h"
#include "l2c_int.h"
#include "l2cdefs.h"
#include "l2cdefs.h"
@@ -143,6 +144,7 @@ void gap_conn_init(void) {
 *                                remote BD Address, then NULL should be passed.
 *                                remote BD Address, then NULL should be passed.
 *
 *
 *                  psm         - the PSM used for the connection
 *                  psm         - the PSM used for the connection
 *                  le_mps      - Maximum PDU Size for LE CoC
 *
 *
 *                  p_config    - Optional pointer to configuration structure.
 *                  p_config    - Optional pointer to configuration structure.
 *                                If NULL, the default GAP configuration will
 *                                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,
uint16_t GAP_ConnOpen(const char* p_serv_name, uint8_t service_id,
                      bool is_server, const RawAddress* p_rem_bda, uint16_t psm,
                      bool is_server, const RawAddress* p_rem_bda, uint16_t psm,
                      tL2CAP_CFG_INFO* p_cfg, tL2CAP_ERTM_INFO* ertm_info,
                      uint16_t le_mps, tL2CAP_CFG_INFO* p_cfg,
                      uint16_t security, uint8_t chan_mode_mask,
                      tL2CAP_ERTM_INFO* ertm_info, uint16_t security,
                      tGAP_CONN_CALLBACK* p_cb, tBT_TRANSPORT transport) {
                      uint8_t chan_mode_mask, tGAP_CONN_CALLBACK* p_cb,
                      tBT_TRANSPORT transport) {
  tGAP_CCB* p_ccb;
  tGAP_CCB* p_ccb;
  uint16_t cid;
  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) {
  if (transport == BT_TRANSPORT_LE) {
    p_ccb->local_coc_cfg.credits = L2CAP_LE_DEFAULT_CREDIT;
    p_ccb->local_coc_cfg.credits = L2CAP_LE_DEFAULT_CREDIT;
    p_ccb->local_coc_cfg.mtu = p_cfg->mtu;
    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;
  p_ccb->p_callback = p_cb;
+2 −1
Original line number Original line 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,
extern uint16_t GAP_ConnOpen(const char* p_serv_name, uint8_t service_id,
                             bool is_server, const RawAddress* p_rem_bda,
                             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,
                             tL2CAP_ERTM_INFO* ertm_info, uint16_t security,
                             uint8_t chan_mode_mask, tGAP_CONN_CALLBACK* p_cb,
                             uint8_t chan_mode_mask, tGAP_CONN_CALLBACK* p_cb,
                             tBT_TRANSPORT transport);
                             tBT_TRANSPORT transport);
+0 −2
Original line number Original line Diff line number Diff line
@@ -42,8 +42,6 @@
#define L2CAP_LE_MAX_MPS 65533
#define L2CAP_LE_MAX_MPS 65533
#define L2CAP_LE_MIN_CREDIT 0
#define L2CAP_LE_MIN_CREDIT 0
#define L2CAP_LE_MAX_CREDIT 65535
#define L2CAP_LE_MAX_CREDIT 65535
#define L2CAP_LE_DEFAULT_MTU 512
#define L2CAP_LE_DEFAULT_MPS 23
#define L2CAP_LE_DEFAULT_CREDIT 1
#define L2CAP_LE_DEFAULT_CREDIT 1


/*
/*