From f7364db99277f1da03eb997c862b283fcad6ff88 Mon Sep 17 00:00:00 2001 From: Josh Wu Date: Mon, 12 Jan 2026 21:01:50 +0800 Subject: [PATCH] Correct ATT_MTU in enhanced bearers --- bumble/gatt_client.py | 2 -- bumble/gatt_server.py | 1 - bumble/l2cap.py | 4 +++- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bumble/gatt_client.py b/bumble/gatt_client.py index 87823663..94b24cd6 100644 --- a/bumble/gatt_client.py +++ b/bumble/gatt_client.py @@ -285,8 +285,6 @@ def __init__(self, bearer: att.Bearer) -> None: self._bearer_id = ( f'[0x{bearer.connection.handle:04X}|CID=0x{bearer.source_cid:04X}]' ) - # Fill the mtu. - bearer.on_att_mtu_update(att.ATT_DEFAULT_MTU) self.connection = bearer.connection else: bearer.on(bearer.EVENT_DISCONNECTION, self.on_disconnection) diff --git a/bumble/gatt_server.py b/bumble/gatt_server.py index 29e4c28b..e37fefac 100644 --- a/bumble/gatt_server.py +++ b/bumble/gatt_server.py @@ -115,7 +115,6 @@ def on_channel(channel: l2cap.LeCreditBasedChannel): channel.connection.handle, channel.source_cid, ) - channel.att_mtu = att.ATT_DEFAULT_MTU channel.sink = lambda pdu: self.on_gatt_pdu( channel, att.ATT_PDU.from_bytes(pdu) ) diff --git a/bumble/l2cap.py b/bumble/l2cap.py index 7023a870..f01276e9 100644 --- a/bumble/l2cap.py +++ b/bumble/l2cap.py @@ -1647,7 +1647,9 @@ def __init__( self.connection_result = None self.disconnection_result = None self.drained = asyncio.Event() - self.att_mtu = 0 # Filled by GATT client or server later. + # Core Specification Vol 3, Part G, 5.3.1 ATT_MTU + # ATT_MTU shall be set to the minimum of the MTU field values of the two devices. + self.att_mtu = min(mtu, peer_mtu) self.drained.set()