* RE: Fix GATT over BR/EDR
2026-11-24 14:46 [PATCH BlueZ 1/8] tools/btgatt-client: Add BR/EDR support Simon Mikuda
@ 2026-11-24 20:44 ` bluez.test.bot
2026-11-25 15:07 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 15+ messages in thread
From: bluez.test.bot @ 2026-11-24 20:44 UTC (permalink / raw)
To: linux-bluetooth, simon.mikuda
[-- Attachment #1: Type: text/plain, Size: 1019 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1220975/
---Test result---
Test Summary:
CheckPatch PASS 2.82 seconds
GitLint PASS 1.97 seconds
BuildEll PASS 14.31 seconds
BluezMake PASS 183.27 seconds
MakeCheck PASS 3.22 seconds
MakeDistcheck PASS 105.60 seconds
CheckValgrind PASS 103.84 seconds
CheckSmatch PASS 191.69 seconds
bluezmakeextell PASS 67.26 seconds
TestFunctional PASS 938.33 seconds
IncrementalBuild PASS 223.50 seconds
ScanBuild PASS 659.07 seconds
https://github.com/bluez/bluez/pull/2907
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Fix GATT over BR/EDR
2026-11-24 20:44 ` Fix GATT over BR/EDR bluez.test.bot
@ 2026-11-25 15:07 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 15+ messages in thread
From: Luiz Augusto von Dentz @ 2026-11-25 15:07 UTC (permalink / raw)
To: linux-bluetooth; +Cc: simon.mikuda
Hi Simon,
On Tue, Nov 24, 2026 at 3:44 PM <bluez.test.bot@gmail.com> wrote:
>
> This is automated email and please do not reply to this email!
>
> Dear submitter,
>
> Thank you for submitting the patches to the linux bluetooth mailing list.
> This is a CI test results with your patch series:
> PW Link:https://patchwork.kernel.org/series/1220975/
>
> ---Test result---
>
> Test Summary:
> CheckPatch PASS 2.82 seconds
> GitLint PASS 1.97 seconds
> BuildEll PASS 14.31 seconds
> BluezMake PASS 183.27 seconds
> MakeCheck PASS 3.22 seconds
> MakeDistcheck PASS 105.60 seconds
> CheckValgrind PASS 103.84 seconds
> CheckSmatch PASS 191.69 seconds
> bluezmakeextell PASS 67.26 seconds
> TestFunctional PASS 938.33 seconds
> IncrementalBuild PASS 223.50 seconds
> ScanBuild PASS 659.07 seconds
>
>
>
> https://github.com/bluez/bluez/pull/2907
Copilot flagged 1 issue:
https://github.com/bluez/bluez/pull/2907#pullrequestreview-6046550224
> ---
> Regards,
> Linux Bluetooth
>
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: Fix GATT over BR/EDR
2026-11-25 16:58 [PATCH BlueZ v2 1/8] tools/btgatt-client: Add BR/EDR support Simon Mikuda
@ 2026-11-25 23:31 ` bluez.test.bot
2026-12-01 16:00 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 15+ messages in thread
From: bluez.test.bot @ 2026-11-25 23:31 UTC (permalink / raw)
To: linux-bluetooth, simon.mikuda
[-- Attachment #1: Type: text/plain, Size: 1019 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1222363/
---Test result---
Test Summary:
CheckPatch PASS 2.95 seconds
GitLint PASS 2.10 seconds
BuildEll PASS 16.01 seconds
BluezMake PASS 189.96 seconds
MakeCheck PASS 3.10 seconds
MakeDistcheck PASS 113.32 seconds
CheckValgrind PASS 109.76 seconds
CheckSmatch PASS 197.97 seconds
bluezmakeextell PASS 69.38 seconds
TestFunctional PASS 940.80 seconds
IncrementalBuild PASS 239.77 seconds
ScanBuild PASS 691.63 seconds
https://github.com/bluez/bluez/pull/2923
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Fix GATT over BR/EDR
2026-11-25 23:31 ` Fix GATT over BR/EDR bluez.test.bot
@ 2026-12-01 16:00 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 15+ messages in thread
From: Luiz Augusto von Dentz @ 2026-12-01 16:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: simon.mikuda
Hi Simon,
On Wed, Nov 25, 2026 at 6:32 PM <bluez.test.bot@gmail.com> wrote:
>
> This is automated email and please do not reply to this email!
>
> Dear submitter,
>
> Thank you for submitting the patches to the linux bluetooth mailing list.
> This is a CI test results with your patch series:
> PW Link:https://patchwork.kernel.org/series/1222363/
>
> ---Test result---
>
> Test Summary:
> CheckPatch PASS 2.95 seconds
> GitLint PASS 2.10 seconds
> BuildEll PASS 16.01 seconds
> BluezMake PASS 189.96 seconds
> MakeCheck PASS 3.10 seconds
> MakeDistcheck PASS 113.32 seconds
> CheckValgrind PASS 109.76 seconds
> CheckSmatch PASS 197.97 seconds
> bluezmakeextell PASS 69.38 seconds
> TestFunctional PASS 940.80 seconds
> IncrementalBuild PASS 239.77 seconds
> ScanBuild PASS 691.63 seconds
>
>
>
> https://github.com/bluez/bluez/pull/2923
Copilot flagged a couple of problems:
https://github.com/bluez/bluez/pull/2923#pullrequestreview-6120968981
> ---
> Regards,
> Linux Bluetooth
>
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH BlueZ v3 0/9] Fix GATT over BR/EDR
@ 2026-12-01 19:53 Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 1/9] tools/btgatt-client: Add BR/EDR support Simon Mikuda
` (8 more replies)
0 siblings, 9 replies; 15+ messages in thread
From: Simon Mikuda @ 2026-12-01 19:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
We need GATT over BR/EDR to pass PTS qualification of a dual-mode
device, and bluetoothd only handled it when the remote opened ATT and
both L2CAP MTUs matched:
- the ATT_MTU was our incoming MTU instead of the smaller of the two,
so a remote with a smaller MTU never finished discovery (2-3)
- GATT discovery marked the BR/EDR services resolved before SDP had
finished (4)
- EATT was connected to the LE address next to a BR/EDR bearer (5)
- LE only profiles (BAP, VCP, MCP, BASS, RAP, ...) attached over
BR/EDR (6-7)
- bluetoothd couldn't open ATT over BR/EDR itself (8): it now does on
ConnectProfile with the GATT UUID, Connect() is unchanged
btgatt-client gets BR/EDR support (1) to reproduce the MTU case. Tested
between two BlueZ boards (Intel BE200 and Broadcom BCM4359) over BR/EDR,
next to A2DP.
Changes in v3:
- shared/att: new bt_att_shutdown(); DisconnectProfile closes ATT over
BR/EDR with it, so the disconnect handlers run from the I/O event
instead of a direct att_disconnected_cb() call
- DisconnectProfile during ConnectProfile answers the ConnectProfile
request
- ConnectProfile returns -EBUSY while ATT is up or connecting on LE,
instead of a false success
- the SDP record is checked on connect instead of probe: a GATT UUID
first seen in EIR left the service unprobed after SDP
Simon Mikuda (9):
tools/btgatt-client: Add BR/EDR support
shared/att: Use the smaller L2CAP MTU as ATT MTU
device: Don't override the ATT MTU over BR/EDR
device: Don't resolve services on GATT over BR/EDR
gatt-client: Don't connect EATT on an ATT bearer over BR/EDR
profiles: Set the LE bearer for TMAP, GMAP and RAP
device: Don't accept LE profiles over ATT on BR/EDR
shared/att: Add bt_att_shutdown
device: Connect GATT over BR/EDR with ConnectProfile
profiles/audio/gmap.c | 1 +
profiles/audio/tmap.c | 1 +
profiles/ranging/rap.c | 1 +
src/device.c | 175 +++++++++++++++++++++++++++++++++++++----
src/gatt-client.c | 4 +
src/shared/att.c | 63 +++++++++++++--
src/shared/att.h | 1 +
tools/btgatt-client.c | 53 ++++++++++---
8 files changed, 265 insertions(+), 34 deletions(-)
base-commit: eecfd959cf5ae9a24ee007975439747779804be1
--
2.43.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH BlueZ v3 1/9] tools/btgatt-client: Add BR/EDR support
2026-12-01 19:53 [PATCH BlueZ v3 0/9] Fix GATT over BR/EDR Simon Mikuda
@ 2026-12-01 19:53 ` Simon Mikuda
2026-12-02 10:06 ` Fix GATT over BR/EDR bluez.test.bot
2026-12-01 19:53 ` [PATCH BlueZ v3 2/9] shared/att: Use the smaller L2CAP MTU as ATT MTU Simon Mikuda
` (7 subsequent siblings)
8 siblings, 1 reply; 15+ messages in thread
From: Simon Mikuda @ 2026-12-01 19:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
Add the bredr address type: btgatt-client then connects ATT over the
BR/EDR ATT PSM, and -m sets the L2CAP MTU, which is the ATT MTU there.
btgatt-client -t bredr -d 00:11:22:33:44:55 -m 48
Assisted-by: Claude:claude-opus-5-5
---
tools/btgatt-client.c | 53 ++++++++++++++++++++++++++++++++++---------
1 file changed, 42 insertions(+), 11 deletions(-)
diff --git a/tools/btgatt-client.c b/tools/btgatt-client.c
index 667b3d651..5a2f5fc09 100644
--- a/tools/btgatt-client.c
+++ b/tools/btgatt-client.c
@@ -1631,8 +1631,8 @@ static void signal_cb(int signum, void *user_data)
}
}
-static int l2cap_le_att_connect(bdaddr_t *src, bdaddr_t *dst, uint8_t dst_type,
- int sec)
+static int l2cap_att_connect(bdaddr_t *src, bdaddr_t *dst, uint8_t dst_type,
+ int sec, uint16_t mtu)
{
int sock;
struct sockaddr_l2 srcaddr, dstaddr;
@@ -1644,9 +1644,10 @@ static int l2cap_le_att_connect(bdaddr_t *src, bdaddr_t *dst, uint8_t dst_type,
ba2str(src, srcaddr_str);
ba2str(dst, dstaddr_str);
- printf("btgatt-client: Opening L2CAP LE connection on ATT "
- "channel:\n\t src: %s\n\tdest: %s\n",
- srcaddr_str, dstaddr_str);
+ printf("btgatt-client: Opening L2CAP %s connection on ATT "
+ "channel:\n\t src: %s\n\tdest: %s\n",
+ dst_type == BDADDR_BREDR ? "BR/EDR" : "LE",
+ srcaddr_str, dstaddr_str);
}
sock = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
@@ -1658,7 +1659,8 @@ static int l2cap_le_att_connect(bdaddr_t *src, bdaddr_t *dst, uint8_t dst_type,
/* Set up source address */
memset(&srcaddr, 0, sizeof(srcaddr));
srcaddr.l2_family = AF_BLUETOOTH;
- srcaddr.l2_cid = htobs(BT_ATT_CID);
+ if (dst_type != BDADDR_BREDR)
+ srcaddr.l2_cid = htobs(BT_ATT_CID);
srcaddr.l2_bdaddr_type = 0;
bacpy(&srcaddr.l2_bdaddr, src);
@@ -1678,10 +1680,35 @@ static int l2cap_le_att_connect(bdaddr_t *src, bdaddr_t *dst, uint8_t dst_type,
return -1;
}
+ /* On BR/EDR the ATT MTU is the L2CAP MTU */
+ if (dst_type == BDADDR_BREDR && mtu) {
+ struct l2cap_options l2o;
+ socklen_t len = sizeof(l2o);
+
+ memset(&l2o, 0, sizeof(l2o));
+ if (getsockopt(sock, SOL_L2CAP, L2CAP_OPTIONS, &l2o,
+ &len) < 0) {
+ perror("Failed to get L2CAP options");
+ close(sock);
+ return -1;
+ }
+
+ l2o.imtu = mtu;
+ if (setsockopt(sock, SOL_L2CAP, L2CAP_OPTIONS, &l2o,
+ len) < 0) {
+ perror("Failed to set L2CAP MTU");
+ close(sock);
+ return -1;
+ }
+ }
+
/* Set up destination address */
memset(&dstaddr, 0, sizeof(dstaddr));
dstaddr.l2_family = AF_BLUETOOTH;
- dstaddr.l2_cid = htobs(BT_ATT_CID);
+ if (dst_type == BDADDR_BREDR)
+ dstaddr.l2_psm = htobs(BT_ATT_PSM);
+ else
+ dstaddr.l2_cid = htobs(BT_ATT_CID);
dstaddr.l2_bdaddr_type = dst_type;
bacpy(&dstaddr.l2_bdaddr, dst);
@@ -1707,8 +1734,10 @@ static void usage(void)
printf("Options:\n"
"\t-i, --index <id>\t\tSpecify adapter index, e.g. hci0\n"
"\t-d, --dest <addr>\t\tSpecify the destination address\n"
- "\t-t, --type [random|public] \tSpecify the LE address type\n"
- "\t-m, --mtu <mtu> \t\tThe ATT MTU to use\n"
+ "\t-t, --type [random|public|bredr] \tSpecify the address "
+ "type\n"
+ "\t-m, --mtu <mtu> \t\tThe ATT MTU to use (BR/EDR: the "
+ "L2CAP MTU)\n"
"\t-s, --security-level <sec> \tSet security level (low|medium|"
"high|fips)\n"
"\t-v, --verbose\t\t\tEnable extra logging\n"
@@ -1783,9 +1812,11 @@ int main(int argc, char *argv[])
dst_type = BDADDR_LE_RANDOM;
else if (strcmp(optarg, "public") == 0)
dst_type = BDADDR_LE_PUBLIC;
+ else if (strcmp(optarg, "bredr") == 0)
+ dst_type = BDADDR_BREDR;
else {
fprintf(stderr,
- "Allowed types: random, public\n");
+ "Allowed types: random, public, bredr\n");
return EXIT_FAILURE;
}
break;
@@ -1841,7 +1872,7 @@ int main(int argc, char *argv[])
mainloop_init();
- fd = l2cap_le_att_connect(&src_addr, &dst_addr, dst_type, sec);
+ fd = l2cap_att_connect(&src_addr, &dst_addr, dst_type, sec, mtu);
if (fd < 0)
return EXIT_FAILURE;
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH BlueZ v3 2/9] shared/att: Use the smaller L2CAP MTU as ATT MTU
2026-12-01 19:53 [PATCH BlueZ v3 0/9] Fix GATT over BR/EDR Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 1/9] tools/btgatt-client: Add BR/EDR support Simon Mikuda
@ 2026-12-01 19:53 ` Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 3/9] device: Don't override the ATT MTU over BR/EDR Simon Mikuda
` (6 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Simon Mikuda @ 2026-12-01 19:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
On an L2CAP channel with a dynamic CID (BR/EDR, EATT) bt_att uses the
outgoing MTU as ATT_MTU and reads into a buffer of that size. The
ATT_MTU is the smaller of the two MTUs of the channel (Core Vol 3,
Part G, 5.1.1 for BR/EDR and 5.3.1 for EATT), and a PDU the remote
sends up to our incoming MTU is cut short.
Use the smaller MTU as ATT_MTU, and read up to the incoming MTU.
Assisted-by: Claude:claude-opus-5-5
---
src/shared/att.c | 43 ++++++++++++++++++++++++++++++++++++-------
1 file changed, 36 insertions(+), 7 deletions(-)
diff --git a/src/shared/att.c b/src/shared/att.c
index 366ee83d8..45ae9698e 100644
--- a/src/shared/att.c
+++ b/src/shared/att.c
@@ -53,6 +53,7 @@ struct bt_att_chan {
bool in_req; /* There's a pending incoming request */
uint8_t *buf;
+ uint16_t buf_len;
uint16_t mtu;
};
@@ -1104,7 +1105,7 @@ static bool can_read_data(struct io *io, void *user_data)
uint8_t *pdu;
ssize_t bytes_read;
- bytes_read = read(chan->fd, chan->buf, chan->mtu);
+ bytes_read = read(chan->fd, chan->buf, chan->buf_len);
if (bytes_read < 0)
return false;
@@ -1237,6 +1238,21 @@ static uint16_t io_get_mtu(int fd)
return 0;
}
+static uint16_t io_get_imtu(int fd)
+{
+ socklen_t len;
+ struct l2cap_options l2o;
+
+ len = sizeof(l2o);
+ if (!getsockopt(fd, SOL_L2CAP, L2CAP_OPTIONS, &l2o, &len))
+ return l2o.imtu;
+
+ if (!getsockopt(fd, SOL_BLUETOOTH, BT_RCVMTU, &l2o.imtu, &len))
+ return l2o.imtu;
+
+ return 0;
+}
+
static uint8_t io_get_type(int fd)
{
struct sockaddr_l2 src;
@@ -1259,6 +1275,7 @@ static uint8_t io_get_type(int fd)
static struct bt_att_chan *bt_att_chan_new(int fd, uint8_t type)
{
struct bt_att_chan *chan;
+ uint16_t imtu;
if (fd < 0)
return NULL;
@@ -1283,15 +1300,24 @@ static struct bt_att_chan *bt_att_chan_new(int fd, uint8_t type)
/* fall through */
case BT_ATT_LE:
chan->mtu = BT_ATT_DEFAULT_LE_MTU;
+ chan->buf_len = chan->mtu;
break;
default:
+ /* The ATT_MTU of an L2CAP channel is the smaller of its two
+ * MTUs (Core Vol 3, Part G, 5.1.1 and 5.3.1). Read up to the
+ * incoming one, as L2CAP lets the remote send that much.
+ */
chan->mtu = io_get_mtu(chan->fd);
+ imtu = io_get_imtu(chan->fd);
+ if (imtu)
+ chan->mtu = MIN(chan->mtu, imtu);
+ chan->buf_len = MAX(chan->mtu, imtu);
}
if (chan->mtu < BT_ATT_DEFAULT_LE_MTU)
goto fail;
- chan->buf = malloc(chan->mtu);
+ chan->buf = malloc(chan->buf_len);
if (!chan->buf)
goto fail;
@@ -1487,14 +1513,17 @@ bool bt_att_set_mtu(struct bt_att *att, uint16_t mtu)
if (!chan)
return -ENOTCONN;
- buf = malloc(mtu);
- if (!buf)
- return false;
+ if (mtu > chan->buf_len) {
+ buf = malloc(mtu);
+ if (!buf)
+ return false;
- free(chan->buf);
+ free(chan->buf);
+ chan->buf = buf;
+ chan->buf_len = mtu;
+ }
chan->mtu = mtu;
- chan->buf = buf;
if (chan->mtu > att->mtu) {
att->mtu = chan->mtu;
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH BlueZ v3 3/9] device: Don't override the ATT MTU over BR/EDR
2026-12-01 19:53 [PATCH BlueZ v3 0/9] Fix GATT over BR/EDR Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 1/9] tools/btgatt-client: Add BR/EDR support Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 2/9] shared/att: Use the smaller L2CAP MTU as ATT MTU Simon Mikuda
@ 2026-12-01 19:53 ` Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 4/9] device: Don't resolve services on GATT " Simon Mikuda
` (5 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Simon Mikuda @ 2026-12-01 19:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
device_attach_att() sets the ATT_MTU of a BR/EDR channel to our incoming
L2CAP MTU, as g_attrib_new() did before commit 9d09a446ace8 ("device:
Use bt_att instead of GAttrib"). The ATT_MTU is the smaller of the two
MTUs of the channel (Core Vol 3, Part G, 5.1.1), so when the remote's
incoming MTU is smaller, bluetoothd sends PDUs it can't take.
On the remote, paired over BR/EDR:
btgatt-client -t bredr -d <address> -m 48
[GATT client]# services
The discovery never completes, and bluetoothd logs:
bt_att_chan_write() (chan 0x...) write failed: Message too long
bt_att already uses the smaller MTU: leave it.
Fixes: e758ebb6a144 ("src/device.c : Fix BREDR-ATT MTU issue")
Assisted-by: Claude:claude-opus-5-5
---
src/device.c | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/src/device.c b/src/device.c
index 720b4af69..288ae92fd 100644
--- a/src/device.c
+++ b/src/device.c
@@ -6677,14 +6677,12 @@ bool device_attach_att(struct btd_device *dev, GIOChannel *io)
struct bt_att *att;
BtIOSecLevel sec_level;
uint16_t mtu;
- uint16_t cid;
struct btd_gatt_database *database;
const bdaddr_t *dst;
char dstaddr[18];
bt_io_get(io, &gerr, BT_IO_OPT_SEC_LEVEL, &sec_level,
BT_IO_OPT_IMTU, &mtu,
- BT_IO_OPT_CID, &cid,
BT_IO_OPT_INVALID);
if (gerr) {
@@ -6731,13 +6729,6 @@ bool device_attach_att(struct btd_device *dev, GIOChannel *io)
return false;
}
- if (!bt_att_set_mtu(att, cid == BT_ATT_CID ? BT_ATT_DEFAULT_LE_MTU :
- dev->att_mtu)) {
- error("Unable to set ATT MTU");
- bt_att_unref(att);
- return false;
- }
-
/* The fd is closed once the ATT instance is freed */
g_io_channel_set_close_on_unref(io, FALSE);
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH BlueZ v3 4/9] device: Don't resolve services on GATT over BR/EDR
2026-12-01 19:53 [PATCH BlueZ v3 0/9] Fix GATT over BR/EDR Simon Mikuda
` (2 preceding siblings ...)
2026-12-01 19:53 ` [PATCH BlueZ v3 3/9] device: Don't override the ATT MTU over BR/EDR Simon Mikuda
@ 2026-12-01 19:53 ` Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 5/9] gatt-client: Don't connect EATT on an ATT bearer " Simon Mikuda
` (4 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Simon Mikuda @ 2026-12-01 19:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
When GATT discovery over BR/EDR completes, gatt_client_ready_cb() calls
device_svc_resolved() for device->bdaddr_type. For a BR/EDR device this
marks the bearer resolved and runs the device_wait_for_svc_complete()
callbacks while SDP may still be running, so they find none of the
device's profiles. For a device with an LE address type it resolves the
LE bearer instead. iOS opens ATT over BR/EDR right after pairing.
Over BR/EDR, leave resolving the services to SDP.
Fixes: 4b5bb941c380 ("core/device: Use shared/gatt-client for GATT")
Assisted-by: Claude:claude-opus-5-5
---
src/device.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/device.c b/src/device.c
index 288ae92fd..b1e7a35c6 100644
--- a/src/device.c
+++ b/src/device.c
@@ -6430,12 +6430,15 @@ static void gatt_client_ready_cb(bool success, uint8_t att_ecode,
void *user_data)
{
struct btd_device *device = user_data;
+ bool bredr = bt_att_get_link_type(device->att) == BT_ATT_BREDR;
DBG("status: %s, error: %u", success ? "success" : "failed", att_ecode);
+ /* Over BR/EDR, SDP resolves the services of the bearer */
if (!success) {
- device_svc_resolved(device, BROWSE_GATT, device->bdaddr_type,
- -EIO);
+ if (!bredr)
+ device_svc_resolved(device, BROWSE_GATT,
+ device->bdaddr_type, -EIO);
return;
}
@@ -6443,7 +6446,9 @@ static void gatt_client_ready_cb(bool success, uint8_t att_ecode,
btd_gatt_client_ready(device->client_dbus);
- device_svc_resolved(device, BROWSE_GATT, device->bdaddr_type, 0);
+ if (!bredr)
+ device_svc_resolved(device, BROWSE_GATT, device->bdaddr_type,
+ 0);
store_gatt_db(device);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH BlueZ v3 5/9] gatt-client: Don't connect EATT on an ATT bearer over BR/EDR
2026-12-01 19:53 [PATCH BlueZ v3 0/9] Fix GATT over BR/EDR Simon Mikuda
` (3 preceding siblings ...)
2026-12-01 19:53 ` [PATCH BlueZ v3 4/9] device: Don't resolve services on GATT " Simon Mikuda
@ 2026-12-01 19:53 ` Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 6/9] profiles: Set the LE bearer for TMAP, GMAP and RAP Simon Mikuda
` (3 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Simon Mikuda @ 2026-12-01 19:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
With Channels set above 1, btd_gatt_client_eatt_connect() connects the
EATT channels to the device's LE address also when ATT runs over BR/EDR:
EATT bt_io_connect(<addr>): connect to <addr>: Invalid argument (22)
Only connect EATT channels next to an ATT bearer over LE.
Fixes: 45219190617b ("gatt: Enable EATT bearer support")
Assisted-by: Claude:claude-opus-5-5
---
src/gatt-client.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/gatt-client.c b/src/gatt-client.c
index 2d58ee2e5..449f85fc4 100644
--- a/src/gatt-client.c
+++ b/src/gatt-client.c
@@ -2361,6 +2361,10 @@ void btd_gatt_client_eatt_connect(struct btd_gatt_client *client)
if (bt_att_get_channels(att) == btd_opts.gatt_channels)
return;
+ /* EATT channels are connected over LE only */
+ if (bt_att_get_link_type(att) == BT_ATT_BREDR)
+ return;
+
ba2str(device_get_address(dev), addr);
for (i = bt_att_get_channels(att); i < btd_opts.gatt_channels; i++) {
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH BlueZ v3 6/9] profiles: Set the LE bearer for TMAP, GMAP and RAP
2026-12-01 19:53 [PATCH BlueZ v3 0/9] Fix GATT over BR/EDR Simon Mikuda
` (4 preceding siblings ...)
2026-12-01 19:53 ` [PATCH BlueZ v3 5/9] gatt-client: Don't connect EATT on an ATT bearer " Simon Mikuda
@ 2026-12-01 19:53 ` Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 7/9] device: Don't accept LE profiles over ATT on BR/EDR Simon Mikuda
` (2 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Simon Mikuda @ 2026-12-01 19:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
TMAP and GMAP are LE Audio roles and RAP uses Channel Sounding, which
all run over LE only, but unlike the other LE Audio profiles they don't
set the bearer.
Assisted-by: Claude:claude-opus-5-5
---
profiles/audio/gmap.c | 1 +
profiles/audio/tmap.c | 1 +
profiles/ranging/rap.c | 1 +
3 files changed, 3 insertions(+)
diff --git a/profiles/audio/gmap.c b/profiles/audio/gmap.c
index cf9b43ca1..c196da8a3 100644
--- a/profiles/audio/gmap.c
+++ b/profiles/audio/gmap.c
@@ -169,6 +169,7 @@ static void gmap_adapter_remove(struct btd_profile *p,
static struct btd_profile gmap_profile = {
.name = "gmap",
.priority = BTD_PROFILE_PRIORITY_MEDIUM,
+ .bearer = BTD_PROFILE_BEARER_LE,
.remote_uuid = GMAS_UUID_STR,
.device_probe = gmap_probe,
diff --git a/profiles/audio/tmap.c b/profiles/audio/tmap.c
index 23e72165e..5c1e07b4e 100644
--- a/profiles/audio/tmap.c
+++ b/profiles/audio/tmap.c
@@ -172,6 +172,7 @@ static void tmap_adapter_remove(struct btd_profile *p,
static struct btd_profile tmap_profile = {
.name = "tmap",
.priority = BTD_PROFILE_PRIORITY_MEDIUM,
+ .bearer = BTD_PROFILE_BEARER_LE,
.remote_uuid = TMAS_UUID_STR,
.device_probe = tmap_probe,
diff --git a/profiles/ranging/rap.c b/profiles/ranging/rap.c
index f1717d932..727bba155 100644
--- a/profiles/ranging/rap.c
+++ b/profiles/ranging/rap.c
@@ -1216,6 +1216,7 @@ static void rap_server_remove(struct btd_profile *p,
static struct btd_profile rap_profile = {
.name = "rap",
.priority = BTD_PROFILE_PRIORITY_MEDIUM,
+ .bearer = BTD_PROFILE_BEARER_LE,
.remote_uuid = RAS_UUID,
.local_uuid = RAS_UUID,
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH BlueZ v3 7/9] device: Don't accept LE profiles over ATT on BR/EDR
2026-12-01 19:53 [PATCH BlueZ v3 0/9] Fix GATT over BR/EDR Simon Mikuda
` (5 preceding siblings ...)
2026-12-01 19:53 ` [PATCH BlueZ v3 6/9] profiles: Set the LE bearer for TMAP, GMAP and RAP Simon Mikuda
@ 2026-12-01 19:53 ` Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 8/9] shared/att: Add bt_att_shutdown Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 9/9] device: Connect GATT over BR/EDR with ConnectProfile Simon Mikuda
8 siblings, 0 replies; 15+ messages in thread
From: Simon Mikuda @ 2026-12-01 19:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
When ATT runs over BR/EDR, every profile accepts the GATT services found
on it, LE only ones included: BAP reads the PACs, VCP, MCP and BASS
attach, MCP creates a player and RAP a ChannelSounding1 interface for a
device without an LE link.
Skip the profiles of the LE bearer when ATT runs over BR/EDR.
Assisted-by: Claude:claude-opus-5-5
---
src/device.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/src/device.c b/src/device.c
index b1e7a35c6..0d6f2a4ce 100644
--- a/src/device.c
+++ b/src/device.c
@@ -4813,6 +4813,19 @@ static bool device_match_profile(struct btd_device *device,
return true;
}
+static void device_accept_gatt_service(struct btd_device *device,
+ struct btd_service *service)
+{
+ struct btd_profile *profile = btd_service_get_profile(service);
+
+ /* A profile of the LE bearer doesn't run over ATT on BR/EDR */
+ if (profile->bearer == BTD_PROFILE_BEARER_LE &&
+ bt_att_get_link_type(device->att) == BT_ATT_BREDR)
+ return;
+
+ service_accept(service, btd_device_is_initiator(device));
+}
+
static void add_gatt_service(struct gatt_db_attribute *attr, void *user_data)
{
struct btd_device *device = user_data;
@@ -4852,7 +4865,7 @@ done:
}
/* Notify driver about the new connection */
- service_accept(service, btd_device_is_initiator(device));
+ device_accept_gatt_service(device, service);
}
@@ -4914,17 +4927,16 @@ static void device_add_gatt_services(struct btd_device *device)
static void device_accept_gatt_profiles(struct btd_device *device)
{
GSList *l;
- bool initiator = btd_device_is_initiator(device);
GSList *services;
- DBG("initiator %s", initiator ? "true" : "false");
+ DBG("initiator %s", btd_device_is_initiator(device) ? "true" : "false");
/* Accept in profile priority order */
services = g_slist_copy(device->services);
services = btd_profile_sort_list(services, get_service_profile, NULL);
for (l = services; l != NULL; l = g_slist_next(l))
- service_accept(l->data, initiator);
+ device_accept_gatt_service(device, l->data);
g_slist_free(services);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH BlueZ v3 8/9] shared/att: Add bt_att_shutdown
2026-12-01 19:53 [PATCH BlueZ v3 0/9] Fix GATT over BR/EDR Simon Mikuda
` (6 preceding siblings ...)
2026-12-01 19:53 ` [PATCH BlueZ v3 7/9] device: Don't accept LE profiles over ATT on BR/EDR Simon Mikuda
@ 2026-12-01 19:53 ` Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 9/9] device: Connect GATT over BR/EDR with ConnectProfile Simon Mikuda
8 siblings, 0 replies; 15+ messages in thread
From: Simon Mikuda @ 2026-12-01 19:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
A bt_att user can't close the bearer itself and have the disconnect
handlers run. shutdown() on the fd isn't enough: the read handler then
reads end of file, takes it for a short PDU and keeps its watch, so it
runs again and again and the disconnect watch, at idle priority, never
does.
bt_att_shutdown() closes every channel the way a timeout or a protocol
error does, and the disconnect handlers run from the I/O event.
Assisted-by: Claude:claude-opus-5-5
---
src/shared/att.c | 20 ++++++++++++++++++++
src/shared/att.h | 1 +
2 files changed, 21 insertions(+)
diff --git a/src/shared/att.c b/src/shared/att.c
index 45ae9698e..369666a83 100644
--- a/src/shared/att.c
+++ b/src/shared/att.c
@@ -1451,6 +1451,26 @@ int bt_att_get_fd(struct bt_att *att)
return chan->fd;
}
+/* Close every channel, as on a timeout: the disconnect handlers then run from
+ * the I/O disconnect event.
+ */
+bool bt_att_shutdown(struct bt_att *att)
+{
+ const struct queue_entry *entry;
+
+ if (!att || queue_isempty(att->chans))
+ return false;
+
+ for (entry = queue_get_entries(att->chans); entry;
+ entry = entry->next) {
+ struct bt_att_chan *chan = entry->data;
+
+ io_shutdown(chan->io);
+ }
+
+ return true;
+}
+
int bt_att_get_channels(struct bt_att *att)
{
if (!att)
diff --git a/src/shared/att.h b/src/shared/att.h
index 4bee694e4..f2dd00ef2 100644
--- a/src/shared/att.h
+++ b/src/shared/att.h
@@ -34,6 +34,7 @@ const char *bt_att_ecode2str(uint8_t ecode);
int bt_att_attach_fd(struct bt_att *att, int fd);
int bt_att_get_channels(struct bt_att *att);
+bool bt_att_shutdown(struct bt_att *att);
typedef void (*bt_att_response_func_t)(uint8_t opcode, const void *pdu,
uint16_t length, void *user_data);
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH BlueZ v3 9/9] device: Connect GATT over BR/EDR with ConnectProfile
2026-12-01 19:53 [PATCH BlueZ v3 0/9] Fix GATT over BR/EDR Simon Mikuda
` (7 preceding siblings ...)
2026-12-01 19:53 ` [PATCH BlueZ v3 8/9] shared/att: Add bt_att_shutdown Simon Mikuda
@ 2026-12-01 19:53 ` Simon Mikuda
8 siblings, 0 replies; 15+ messages in thread
From: Simon Mikuda @ 2026-12-01 19:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
bluetoothd runs GATT over BR/EDR only when the remote opens the ATT
channel, so the GATT services a BR/EDR device lists in SDP can't be
discovered from our side, as the TODO in search_cb() says.
Add a gatt-bredr profile for a device whose SDP has the GATT service:
ConnectProfile and DisconnectProfile with the GATT UUID open and close
ATT over BR/EDR, and its state follows an ATT channel the remote opens.
It isn't connected automatically, so Connect() works as before.
bluetoothctl connect <address> 00001801-0000-1000-8000-00805f9b34fb
Assisted-by: Claude:claude-opus-5-5
---
src/device.c | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 135 insertions(+)
diff --git a/src/device.c b/src/device.c
index 0d6f2a4ce..c35d3af39 100644
--- a/src/device.c
+++ b/src/device.c
@@ -395,6 +395,14 @@ static GSList *find_service_with_uuid(GSList *list, char *uuid)
return NULL;
}
+/* The GATT service of a BR/EDR device, connected while ATT runs over BR/EDR */
+static struct btd_service *gatt_bredr_service(struct btd_device *dev)
+{
+ GSList *l = find_service_with_uuid(dev->services, GATT_UUID);
+
+ return l ? l->data : NULL;
+}
+
static const char *device_prefer_bearer_str(struct btd_device *device)
{
/* Check if both BR/EDR and LE bearer are supported */
@@ -6380,6 +6388,7 @@ static void disconnect_gatt_service(gpointer data, gpointer user_data)
static void att_disconnected_cb(int err, void *user_data)
{
struct btd_device *device = user_data;
+ struct btd_service *service;
DBG("");
@@ -6406,6 +6415,10 @@ static void att_disconnected_cb(int err, void *user_data)
adapter_connect_list_add(device->adapter, device);
done:
+ service = gatt_bredr_service(device);
+ if (service)
+ btd_service_disconnecting_complete(service, 0);
+
attio_cleanup(device);
}
@@ -6781,6 +6794,14 @@ bool device_attach_att(struct btd_device *dev, GIOChannel *io)
gatt_client_init(dev);
gatt_server_init(dev, database);
+ /* ATT over BR/EDR, opened by either side, is the GATT service */
+ if (bt_att_get_link_type(dev->att) == BT_ATT_BREDR) {
+ struct btd_service *service = gatt_bredr_service(dev);
+
+ if (service)
+ btd_service_connecting_complete(service, 0);
+ }
+
/*
* Remove the device from the connect_list and give the passive
* scanning another chance to be restarted in case there are
@@ -6868,6 +6889,116 @@ done:
}
}
+static void gatt_bredr_connect_cb(GIOChannel *io, GError *gerr,
+ gpointer user_data)
+{
+ struct btd_device *dev = user_data;
+ struct btd_service *service = gatt_bredr_service(dev);
+
+ g_io_channel_unref(dev->att_io);
+ dev->att_io = NULL;
+
+ if (gerr) {
+ DBG("%s", gerr->message);
+ if (service)
+ btd_service_connecting_complete(service, -EIO);
+ return;
+ }
+
+ if (!device_attach_att(dev, io) && service)
+ btd_service_connecting_complete(service, -EIO);
+}
+
+static struct btd_profile gatt_bredr_profile;
+
+/* The SDP record is checked on connect: the UUID can come from EIR first, and
+ * a service is not probed again when SDP lists it too.
+ */
+static int gatt_bredr_probe(struct btd_service *service)
+{
+ return 0;
+}
+
+static void gatt_bredr_remove(struct btd_service *service)
+{
+}
+
+static int gatt_bredr_connect(struct btd_service *service)
+{
+ struct btd_device *dev = btd_service_get_device(service);
+ GError *gerr = NULL;
+ char addr[18];
+
+ /* The remote opened it before this service was probed */
+ if (dev->att && bt_att_get_link_type(dev->att) == BT_ATT_BREDR) {
+ btd_service_connecting_complete(service, 0);
+ return -EALREADY;
+ }
+
+ /* A device has one ATT bearer, over LE or BR/EDR */
+ if (dev->att || dev->att_io)
+ return -EBUSY;
+
+ /* Only a device that lists the GATT service in SDP */
+ if (!btd_device_get_record(dev, GATT_UUID))
+ return -ENOTSUP;
+
+ ba2str(&dev->bdaddr, addr);
+ DBG("Connection attempt to: %s", addr);
+
+ dev->att_io = bt_io_connect(gatt_bredr_connect_cb, dev, NULL, &gerr,
+ BT_IO_OPT_SOURCE_BDADDR,
+ btd_adapter_get_address(dev->adapter),
+ BT_IO_OPT_DEST_BDADDR, &dev->bdaddr,
+ BT_IO_OPT_PSM, BT_ATT_PSM,
+ BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
+ BT_IO_OPT_MTU, btd_opts.gatt_mtu,
+ BT_IO_OPT_INVALID);
+ if (!dev->att_io) {
+ error("ATT bt_io_connect(%s): %s", addr, gerr->message);
+ g_error_free(gerr);
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static int gatt_bredr_disconnect(struct btd_service *service)
+{
+ struct btd_device *dev = btd_service_get_device(service);
+
+ /* Cancel a pending connect, its callback isn't called then, so
+ * ConnectProfile is answered here.
+ */
+ if (dev->att_io) {
+ g_io_channel_shutdown(dev->att_io, FALSE, NULL);
+ g_io_channel_unref(dev->att_io);
+ dev->att_io = NULL;
+ device_profile_connected(dev, &gatt_bredr_profile,
+ -ECONNABORTED);
+ }
+
+ if (!dev->att || bt_att_get_link_type(dev->att) != BT_ATT_BREDR)
+ return -ENOTCONN;
+
+ /* att_disconnected_cb() cleans up, as on a remote disconnection */
+ if (!bt_att_shutdown(dev->att))
+ return -ENOTCONN;
+
+ return 0;
+}
+
+/* GATT over BR/EDR is only connected on request, with ConnectProfile */
+static struct btd_profile gatt_bredr_profile = {
+ .name = "gatt-bredr",
+ .bearer = BTD_PROFILE_BEARER_BREDR,
+ .remote_uuid = GATT_UUID,
+ .device_probe = gatt_bredr_probe,
+ .device_remove = gatt_bredr_remove,
+ .connect = gatt_bredr_connect,
+ .disconnect = gatt_bredr_disconnect,
+};
+
int device_connect_le(struct btd_device *dev)
{
struct btd_adapter *adapter = dev->adapter;
@@ -8511,11 +8642,15 @@ void btd_device_init(void)
dbus_conn = btd_get_dbus_connection();
service_state_cb_id = btd_service_add_state_cb(
service_state_changed, NULL);
+
+ btd_profile_register(&gatt_bredr_profile);
}
void btd_device_cleanup(void)
{
btd_service_remove_state_cb(service_state_cb_id);
+
+ btd_profile_unregister(&gatt_bredr_profile);
}
void btd_device_set_volume(struct btd_device *device, int8_t volume)
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* RE: Fix GATT over BR/EDR
2026-12-01 19:53 ` [PATCH BlueZ v3 1/9] tools/btgatt-client: Add BR/EDR support Simon Mikuda
@ 2026-12-02 10:06 ` bluez.test.bot
0 siblings, 0 replies; 15+ messages in thread
From: bluez.test.bot @ 2026-12-02 10:06 UTC (permalink / raw)
To: linux-bluetooth, simon.mikuda
[-- Attachment #1: Type: text/plain, Size: 1019 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1228586/
---Test result---
Test Summary:
CheckPatch PASS 3.48 seconds
GitLint PASS 2.27 seconds
BuildEll PASS 13.63 seconds
BluezMake PASS 201.79 seconds
MakeCheck PASS 2.56 seconds
MakeDistcheck PASS 109.23 seconds
CheckValgrind PASS 109.38 seconds
CheckSmatch PASS 181.64 seconds
bluezmakeextell PASS 65.20 seconds
TestFunctional PASS 908.41 seconds
IncrementalBuild PASS 291.39 seconds
ScanBuild PASS 795.10 seconds
https://github.com/bluez/bluez/pull/2956
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2026-12-02 10:06 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 19:53 [PATCH BlueZ v3 0/9] Fix GATT over BR/EDR Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 1/9] tools/btgatt-client: Add BR/EDR support Simon Mikuda
2026-12-02 10:06 ` Fix GATT over BR/EDR bluez.test.bot
2026-12-01 19:53 ` [PATCH BlueZ v3 2/9] shared/att: Use the smaller L2CAP MTU as ATT MTU Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 3/9] device: Don't override the ATT MTU over BR/EDR Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 4/9] device: Don't resolve services on GATT " Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 5/9] gatt-client: Don't connect EATT on an ATT bearer " Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 6/9] profiles: Set the LE bearer for TMAP, GMAP and RAP Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 7/9] device: Don't accept LE profiles over ATT on BR/EDR Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 8/9] shared/att: Add bt_att_shutdown Simon Mikuda
2026-12-01 19:53 ` [PATCH BlueZ v3 9/9] device: Connect GATT over BR/EDR with ConnectProfile Simon Mikuda
-- strict thread matches above, loose matches on Subject: below --
2026-11-25 16:58 [PATCH BlueZ v2 1/8] tools/btgatt-client: Add BR/EDR support Simon Mikuda
2026-11-25 23:31 ` Fix GATT over BR/EDR bluez.test.bot
2026-12-01 16:00 ` Luiz Augusto von Dentz
2026-11-24 14:46 [PATCH BlueZ 1/8] tools/btgatt-client: Add BR/EDR support Simon Mikuda
2026-11-24 20:44 ` Fix GATT over BR/EDR bluez.test.bot
2026-11-25 15:07 ` Luiz Augusto von Dentz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox