GATT: Fix data length parameter
Should also account for L2CAP header size (4)
Bug: 199009840
Tag: #feature
Test: NRF connect
Change-Id: I6b51a8ef046d81836a4ca4850d052b68e0f4dd46
diff --git a/stack/gatt/gatt_cl.cc b/stack/gatt/gatt_cl.cc
index aef2d2e..7126917 100644
--- a/stack/gatt/gatt_cl.cc
+++ b/stack/gatt/gatt_cl.cc
@@ -46,6 +46,8 @@
#define GATT_MTU_RSP_MIN_LEN 2
#define GATT_READ_BY_TYPE_RSP_MIN_LEN 1
+#define L2CAP_PKT_OVERHEAD 4
+
using base::StringPrintf;
using bluetooth::Uuid;
using bluetooth::eatt::EattExtension;
@@ -1052,7 +1054,7 @@
tcb.payload_size = mtu;
}
- BTM_SetBleDataLength(tcb.peer_bda, tcb.payload_size);
+ BTM_SetBleDataLength(tcb.peer_bda, tcb.payload_size + L2CAP_PKT_OVERHEAD);
gatt_end_operation(p_clcb, status, NULL);
}
diff --git a/stack/gatt/gatt_sr.cc b/stack/gatt/gatt_sr.cc
index c0aedfa..9fe642c 100644
--- a/stack/gatt/gatt_sr.cc
+++ b/stack/gatt/gatt_sr.cc
@@ -32,6 +32,7 @@
#include "stack/eatt/eatt.h"
#include "stack/l2cap/l2c_int.h"
#define GATT_MTU_REQ_MIN_LEN 2
+#define L2CAP_PKT_OVERHEAD 4
using base::StringPrintf;
using bluetooth::Uuid;
@@ -814,7 +815,7 @@
LOG(INFO) << "MTU request PDU with MTU size " << +tcb.payload_size;
- BTM_SetBleDataLength(tcb.peer_bda, tcb.payload_size);
+ BTM_SetBleDataLength(tcb.peer_bda, tcb.payload_size + L2CAP_PKT_OVERHEAD);
tGATT_SR_MSG gatt_sr_msg;
gatt_sr_msg.mtu = tcb.payload_size;