* [PATCH] [BlueZ,v1,1/1] avdtp: ignore Discover cmd when host sends before
@ 2026-04-02 7:56 zhangchen200426
2026-04-02 9:25 ` bluez.test.bot
2026-04-02 16:34 ` [PATCH] " Luiz Augusto von Dentz
0 siblings, 2 replies; 4+ messages in thread
From: zhangchen200426 @ 2026-04-02 7:56 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Zhang Chen
From: Zhang Chen <zhangchen01@kylinos.cn>
Theoretically, the party that initiates the connection should send the DISCOVER
command. However, some devices, even though they are the connected party, still
send the DISCOVER command. In such cases, there is a probability of connection
failure.
Fails:
< ACL Data TX: Handle 10 flags 0x00 dlen 6
Channel: 71 len 2 [PSM 25 mode Basic (0x00)] {chan 1}
AVDTP: Discover (0x01) Command (0x00) type 0x00 label 4 nosp 0
> ACL Data RX: Handle 10 flags 0x02 dlen 8
Channel: 64 len 4 [PSM 25 mode Basic (0x00)] {chan 1}
AVDTP: Discover (0x01) Response Accept (0x02) type 0x00 label 4 nosp 0
ACP SEID: 1
Media Type: Audio (0x00)
SEP Type: SRC (0x00)
In use: No
< ACL Data TX: Handle 10 flags 0x00 dlen 18
Channel: 71 len 14 [PSM 25 mode Basic (0x00)] {chan 1}
AVDTP: Set Configuration (0x03) Command (0x00) type 0x00 label 5 nosp 0
ACP SEID: 1
INT SEID: 37
Service Category: Media Transport (0x01)
Service Category: Media Codec (0x07)
Media Type: Audio (0x00)
Media Codec: SBC (0x00)
Frequency: 44100 (0x20)
Channel Mode: Joint Stereo (0x01)
Block Length: 16 (0x10)
Subbands: 8 (0x04)
Allocation Method: Loudness (0x01)
Minimum Bitpool: 2
Maximum Bitpool: 53
> ACL Data RX: Handle 10 flags 0x02 dlen 6
Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 1}
AVDTP: Set Configuration (0x03) Response Accept (0x02) type 0x00 label 5 >
> ACL Data RX: Handle 10 flags 0x02 dlen 6
Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 1}
AVDTP: Discover (0x01) Command (0x00) type 0x00 label 0 nosp 0
< ACL Data TX: Handle 10 flags 0x00 dlen 10
Channel: 71 len 6 [PSM 25 mode Basic (0x00)] {chan 1}
AVDTP: Discover (0x01) Response Accept (0x02) type 0x00 label 0 nosp 0
ACP SEID: 25
Media Type: Audio (0x00)
SEP Type: SNK (0x01)
In use: No
ACP SEID: 38
Media Type: Audio (0x00)
SEP Type: SRC (0x00)
In use: No
< ACL Data TX: Handle 10 flags 0x00 dlen 7
Channel: 71 len 3 [PSM 25 mode Basic (0x00)] {chan 1}
AVDTP: Open (0x06) Command (0x00) type 0x00 label 6 nosp 0
ACP SEID: 1
> ACL Data RX: Handle 10 flags 0x02 dlen 6
Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 1}
AVDTP: Open (0x06) Response Accept (0x02) type 0x00 label 6 nosp 0
< ACL Data TX: Handle 10 flags 0x00 dlen 12
L2CAP: Connection Request (0x02) ident 5 len 4
PSM: 25 (0x0019)
Source CID: 65
> ACL Data RX: Handle 10 flags 0x02 dlen 12
L2CAP: Disconnection Request (0x06) ident 5 len 4
Destination CID: 64
Source CID: 71
< ACL Data TX: Handle 10 flags 0x00 dlen 12
L2CAP: Disconnection Response (0x07) ident 5 len 4
Destination CID: 64
Source CID: 71
> ACL Data RX: Handle 10 flags 0x02 dlen 16
L2CAP: Connection Response (0x03) ident 5 len 8
Destination CID: 127
Source CID: 65
Result: Connection refused - PSM not supported (0x0002)
Status: No further information available (0x0000)
Works:
< ACL Data TX: Handle 12 flags 0x00 dlen 6
Channel: 77 len 2 [PSM 25 mode Basic (0x00)] {chan 0}
AVDTP: Discover (0x01) Command (0x00) type 0x00 label 11 nosp 0
> ACL Data RX: Handle 12 flags 0x02 dlen 8
Channel: 64 len 4 [PSM 25 mode Basic (0x00)] {chan 0}
AVDTP: Discover (0x01) Response Accept (0x02) type 0x00 label 11 nosp 0
ACP SEID: 1
Media Type: Audio (0x00)
SEP Type: SRC (0x00)
In use: No
< ACL Data TX: Handle 12 flags 0x00 dlen 18
Channel: 77 len 14 [PSM 25 mode Basic (0x00)] {chan 0}
AVDTP: Set Configuration (0x03) Command (0x00) type 0x00 label 12 nosp 0
ACP SEID: 1
INT SEID: 13
Service Category: Media Transport (0x01)
Service Category: Media Codec (0x07)
Media Type: Audio (0x00)
Media Codec: SBC (0x00)
Frequency: 44100 (0x20)
Channel Mode: Joint Stereo (0x01)
Block Length: 16 (0x10)
Subbands: 8 (0x04)
Allocation Method: Loudness (0x01)
Minimum Bitpool: 2
Maximum Bitpool: 53
> ACL Data RX: Handle 12 flags 0x02 dlen 6
Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 0}
AVDTP: Set Configuration (0x03) Response Accept (0x02) type 0x00 label 12>
> ACL Data RX: Handle 12 flags 0x02 dlen 6
Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 0}
AVDTP: Discover (0x01) Command (0x00) type 0x00 label 0 nosp 0
< ACL Data TX: Handle 12 flags 0x00 dlen 7
Channel: 77 len 3 [PSM 25 mode Basic (0x00)] {chan 0}
AVDTP: Open (0x06) Command (0x00) type 0x00 label 13 nosp 0
ACP SEID: 1
> HCI Event: Number of Completed... (0x13) plen 5
Num handles: 1
Handle: 12
Count: 1
> ACL Data RX: Handle 12 flags 0x02 dlen 6
Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 0}
AVDTP: Open (0x06) Response Accept (0x02) type 0x00 label 13 nosp 0
Signed-off-by: Zhang Chen <zhangchen01@kylinos.cn>
---
profiles/audio/avdtp.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index d475a545e..243c828bf 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -413,6 +413,8 @@ struct avdtp {
/* Attempt stream setup instead of disconnecting */
gboolean stream_setup;
+
+ gboolean discover_start;
};
static GSList *state_callbacks = NULL;
@@ -1418,6 +1420,11 @@ static gboolean avdtp_discover_cmd(struct avdtp *session, uint8_t transaction,
struct seid_info *seps, *p;
gboolean ret;
+ if (session->discover_start) {
+ DBG("DISCOVER_CMD has been sent before.");
+ return TRUE;
+ }
+
sep_count = queue_length(session->lseps);
if (sep_count == 0) {
@@ -2496,6 +2503,8 @@ struct avdtp *avdtp_new(GIOChannel *chan, struct btd_device *device,
* with respect to the disconnect timer */
session->stream_setup = TRUE;
+ session->discover_start = FALSE;
+
session->dc_timeout = DISCONNECT_TIMEOUT;
avdtp_connect_cb(chan, NULL, session);
@@ -3484,6 +3493,7 @@ int avdtp_discover(struct avdtp *session, avdtp_discover_cb_t cb,
if (err == 0) {
session->discover->cb = cb;
session->discover->user_data = user_data;
+ session->discover_start = TRUE;
} else if (session->discover) {
g_free(session->discover);
session->discover = NULL;
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [BlueZ,v1,1/1] avdtp: ignore Discover cmd when host sends before
2026-04-02 7:56 [PATCH] [BlueZ,v1,1/1] avdtp: ignore Discover cmd when host sends before zhangchen200426
@ 2026-04-02 9:25 ` bluez.test.bot
2026-04-02 16:34 ` [PATCH] " Luiz Augusto von Dentz
1 sibling, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2026-04-02 9:25 UTC (permalink / raw)
To: linux-bluetooth, zhangchen200426
[-- Attachment #1: Type: text/plain, Size: 1311 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/project/bluetooth/list/?series=1076276
---Test result---
Test Summary:
CheckPatch PENDING 0.32 seconds
GitLint PENDING 0.35 seconds
BuildEll PASS 20.21 seconds
BluezMake PASS 637.29 seconds
MakeCheck PASS 18.22 seconds
MakeDistcheck PASS 250.00 seconds
CheckValgrind PASS 296.97 seconds
CheckSmatch PASS 353.67 seconds
bluezmakeextell PASS 182.43 seconds
IncrementalBuild PENDING 0.34 seconds
ScanBuild PASS 1039.20 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
https://github.com/bluez/bluez/pull/2004/checks
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] [BlueZ,v1,1/1] avdtp: ignore Discover cmd when host sends before
2026-04-02 7:56 [PATCH] [BlueZ,v1,1/1] avdtp: ignore Discover cmd when host sends before zhangchen200426
2026-04-02 9:25 ` bluez.test.bot
@ 2026-04-02 16:34 ` Luiz Augusto von Dentz
2026-04-03 6:42 ` zhangchen200426
1 sibling, 1 reply; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2026-04-02 16:34 UTC (permalink / raw)
To: zhangchen200426; +Cc: linux-bluetooth, Zhang Chen
Hi,
On Thu, Apr 2, 2026 at 3:58 AM <zhangchen200426@163.com> wrote:
>
> From: Zhang Chen <zhangchen01@kylinos.cn>
>
> Theoretically, the party that initiates the connection should send the DISCOVER
> command. However, some devices, even though they are the connected party, still
> send the DISCOVER command. In such cases, there is a probability of connection
> failure.
>
> Fails:
>
> < ACL Data TX: Handle 10 flags 0x00 dlen 6
> Channel: 71 len 2 [PSM 25 mode Basic (0x00)] {chan 1}
> AVDTP: Discover (0x01) Command (0x00) type 0x00 label 4 nosp 0
> > ACL Data RX: Handle 10 flags 0x02 dlen 8
> Channel: 64 len 4 [PSM 25 mode Basic (0x00)] {chan 1}
> AVDTP: Discover (0x01) Response Accept (0x02) type 0x00 label 4 nosp 0
> ACP SEID: 1
> Media Type: Audio (0x00)
> SEP Type: SRC (0x00)
> In use: No
> < ACL Data TX: Handle 10 flags 0x00 dlen 18
> Channel: 71 len 14 [PSM 25 mode Basic (0x00)] {chan 1}
> AVDTP: Set Configuration (0x03) Command (0x00) type 0x00 label 5 nosp 0
> ACP SEID: 1
> INT SEID: 37
> Service Category: Media Transport (0x01)
> Service Category: Media Codec (0x07)
> Media Type: Audio (0x00)
> Media Codec: SBC (0x00)
> Frequency: 44100 (0x20)
> Channel Mode: Joint Stereo (0x01)
> Block Length: 16 (0x10)
> Subbands: 8 (0x04)
> Allocation Method: Loudness (0x01)
> Minimum Bitpool: 2
> Maximum Bitpool: 53
> > ACL Data RX: Handle 10 flags 0x02 dlen 6
> Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 1}
> AVDTP: Set Configuration (0x03) Response Accept (0x02) type 0x00 label 5 >
> > ACL Data RX: Handle 10 flags 0x02 dlen 6
> Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 1}
> AVDTP: Discover (0x01) Command (0x00) type 0x00 label 0 nosp 0
> < ACL Data TX: Handle 10 flags 0x00 dlen 10
> Channel: 71 len 6 [PSM 25 mode Basic (0x00)] {chan 1}
> AVDTP: Discover (0x01) Response Accept (0x02) type 0x00 label 0 nosp 0
> ACP SEID: 25
> Media Type: Audio (0x00)
> SEP Type: SNK (0x01)
> In use: No
> ACP SEID: 38
> Media Type: Audio (0x00)
> SEP Type: SRC (0x00)
> In use: No
> < ACL Data TX: Handle 10 flags 0x00 dlen 7
> Channel: 71 len 3 [PSM 25 mode Basic (0x00)] {chan 1}
> AVDTP: Open (0x06) Command (0x00) type 0x00 label 6 nosp 0
> ACP SEID: 1
> > ACL Data RX: Handle 10 flags 0x02 dlen 6
> Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 1}
> AVDTP: Open (0x06) Response Accept (0x02) type 0x00 label 6 nosp 0
> < ACL Data TX: Handle 10 flags 0x00 dlen 12
> L2CAP: Connection Request (0x02) ident 5 len 4
> PSM: 25 (0x0019)
> Source CID: 65
> > ACL Data RX: Handle 10 flags 0x02 dlen 12
> L2CAP: Disconnection Request (0x06) ident 5 len 4
> Destination CID: 64
> Source CID: 71
> < ACL Data TX: Handle 10 flags 0x00 dlen 12
> L2CAP: Disconnection Response (0x07) ident 5 len 4
> Destination CID: 64
> Source CID: 71
> > ACL Data RX: Handle 10 flags 0x02 dlen 16
> L2CAP: Connection Response (0x03) ident 5 len 8
> Destination CID: 127
> Source CID: 65
> Result: Connection refused - PSM not supported (0x0002)
> Status: No further information available (0x0000)
You may consider throwing away the device you got, it is prefectly
valid to have a discovery both ways, AVDTP does allows either way to
setup a stream after all.
> Works:
>
> < ACL Data TX: Handle 12 flags 0x00 dlen 6
> Channel: 77 len 2 [PSM 25 mode Basic (0x00)] {chan 0}
> AVDTP: Discover (0x01) Command (0x00) type 0x00 label 11 nosp 0
> > ACL Data RX: Handle 12 flags 0x02 dlen 8
> Channel: 64 len 4 [PSM 25 mode Basic (0x00)] {chan 0}
> AVDTP: Discover (0x01) Response Accept (0x02) type 0x00 label 11 nosp 0
> ACP SEID: 1
> Media Type: Audio (0x00)
> SEP Type: SRC (0x00)
> In use: No
> < ACL Data TX: Handle 12 flags 0x00 dlen 18
> Channel: 77 len 14 [PSM 25 mode Basic (0x00)] {chan 0}
> AVDTP: Set Configuration (0x03) Command (0x00) type 0x00 label 12 nosp 0
> ACP SEID: 1
> INT SEID: 13
> Service Category: Media Transport (0x01)
> Service Category: Media Codec (0x07)
> Media Type: Audio (0x00)
> Media Codec: SBC (0x00)
> Frequency: 44100 (0x20)
> Channel Mode: Joint Stereo (0x01)
> Block Length: 16 (0x10)
> Subbands: 8 (0x04)
> Allocation Method: Loudness (0x01)
> Minimum Bitpool: 2
> Maximum Bitpool: 53
> > ACL Data RX: Handle 12 flags 0x02 dlen 6
> Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 0}
> AVDTP: Set Configuration (0x03) Response Accept (0x02) type 0x00 label 12>
> > ACL Data RX: Handle 12 flags 0x02 dlen 6
> Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 0}
> AVDTP: Discover (0x01) Command (0x00) type 0x00 label 0 nosp 0
Yeah, and that just breaks the command sequence in the process, so
this is a pretty bad idea if you ask me.
> < ACL Data TX: Handle 12 flags 0x00 dlen 7
> Channel: 77 len 3 [PSM 25 mode Basic (0x00)] {chan 0}
> AVDTP: Open (0x06) Command (0x00) type 0x00 label 13 nosp 0
> ACP SEID: 1
> > HCI Event: Number of Completed... (0x13) plen 5
> Num handles: 1
> Handle: 12
> Count: 1
> > ACL Data RX: Handle 12 flags 0x02 dlen 6
> Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 0}
> AVDTP: Open (0x06) Response Accept (0x02) type 0x00 label 13 nosp 0
>
> Signed-off-by: Zhang Chen <zhangchen01@kylinos.cn>
> ---
> profiles/audio/avdtp.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
> index d475a545e..243c828bf 100644
> --- a/profiles/audio/avdtp.c
> +++ b/profiles/audio/avdtp.c
> @@ -413,6 +413,8 @@ struct avdtp {
>
> /* Attempt stream setup instead of disconnecting */
> gboolean stream_setup;
> +
> + gboolean discover_start;
> };
>
> static GSList *state_callbacks = NULL;
> @@ -1418,6 +1420,11 @@ static gboolean avdtp_discover_cmd(struct avdtp *session, uint8_t transaction,
> struct seid_info *seps, *p;
> gboolean ret;
>
> + if (session->discover_start) {
> + DBG("DISCOVER_CMD has been sent before.");
> + return TRUE;
> + }
> +
> sep_count = queue_length(session->lseps);
>
> if (sep_count == 0) {
> @@ -2496,6 +2503,8 @@ struct avdtp *avdtp_new(GIOChannel *chan, struct btd_device *device,
> * with respect to the disconnect timer */
> session->stream_setup = TRUE;
>
> + session->discover_start = FALSE;
> +
> session->dc_timeout = DISCONNECT_TIMEOUT;
>
> avdtp_connect_cb(chan, NULL, session);
> @@ -3484,6 +3493,7 @@ int avdtp_discover(struct avdtp *session, avdtp_discover_cb_t cb,
> if (err == 0) {
> session->discover->cb = cb;
> session->discover->user_data = user_data;
> + session->discover_start = TRUE;
> } else if (session->discover) {
> g_free(session->discover);
> session->discover = NULL;
> --
> 2.25.1
>
>
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] [BlueZ,v1,1/1] avdtp: ignore Discover cmd when host sends before
2026-04-02 16:34 ` [PATCH] " Luiz Augusto von Dentz
@ 2026-04-03 6:42 ` zhangchen200426
0 siblings, 0 replies; 4+ messages in thread
From: zhangchen200426 @ 2026-04-03 6:42 UTC (permalink / raw)
To: luiz.dentz; +Cc: linux-bluetooth, zhangchen01, zhangchen200426
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 8750 bytes --]
On Thu, 2 Apr 2026 12:34:46 -0400, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote:
>
> Hi,
>
> On Thu, Apr 2, 2026 at 3:58 AM <zhangchen200426@163.com> wrote:
> >
> > From: Zhang Chen <zhangchen01@kylinos.cn>
> >
> > Theoretically, the party that initiates the connection should send the DISCOVER
> > command. However, some devices, even though they are the connected party, still
> > send the DISCOVER command. In such cases, there is a probability of connection
> > failure.
> >
> > Fails:
> >
> > < ACL Data TX: Handle 10 flags 0x00 dlen 6
> > Channel: 71 len 2 [PSM 25 mode Basic (0x00)] {chan 1}
> > AVDTP: Discover (0x01) Command (0x00) type 0x00 label 4 nosp 0
> > > ACL Data RX: Handle 10 flags 0x02 dlen 8
> > Channel: 64 len 4 [PSM 25 mode Basic (0x00)] {chan 1}
> > AVDTP: Discover (0x01) Response Accept (0x02) type 0x00 label 4 nosp 0
> > ACP SEID: 1
> > Media Type: Audio (0x00)
> > SEP Type: SRC (0x00)
> > In use: No
> > < ACL Data TX: Handle 10 flags 0x00 dlen 18
> > Channel: 71 len 14 [PSM 25 mode Basic (0x00)] {chan 1}
> > AVDTP: Set Configuration (0x03) Command (0x00) type 0x00 label 5 nosp 0
> > ACP SEID: 1
> > INT SEID: 37
> > Service Category: Media Transport (0x01)
> > Service Category: Media Codec (0x07)
> > Media Type: Audio (0x00)
> > Media Codec: SBC (0x00)
> > Frequency: 44100 (0x20)
> > Channel Mode: Joint Stereo (0x01)
> > Block Length: 16 (0x10)
> > Subbands: 8 (0x04)
> > Allocation Method: Loudness (0x01)
> > Minimum Bitpool: 2
> > Maximum Bitpool: 53
> > > ACL Data RX: Handle 10 flags 0x02 dlen 6
> > Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 1}
> > AVDTP: Set Configuration (0x03) Response Accept (0x02) type 0x00 label 5 >
> > > ACL Data RX: Handle 10 flags 0x02 dlen 6
> > Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 1}
> > AVDTP: Discover (0x01) Command (0x00) type 0x00 label 0 nosp 0
> > < ACL Data TX: Handle 10 flags 0x00 dlen 10
> > Channel: 71 len 6 [PSM 25 mode Basic (0x00)] {chan 1}
> > AVDTP: Discover (0x01) Response Accept (0x02) type 0x00 label 0 nosp 0
> > ACP SEID: 25
> > Media Type: Audio (0x00)
> > SEP Type: SNK (0x01)
> > In use: No
> > ACP SEID: 38
> > Media Type: Audio (0x00)
> > SEP Type: SRC (0x00)
> > In use: No
> > < ACL Data TX: Handle 10 flags 0x00 dlen 7
> > Channel: 71 len 3 [PSM 25 mode Basic (0x00)] {chan 1}
> > AVDTP: Open (0x06) Command (0x00) type 0x00 label 6 nosp 0
> > ACP SEID: 1
> > > ACL Data RX: Handle 10 flags 0x02 dlen 6
> > Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 1}
> > AVDTP: Open (0x06) Response Accept (0x02) type 0x00 label 6 nosp 0
> > < ACL Data TX: Handle 10 flags 0x00 dlen 12
> > L2CAP: Connection Request (0x02) ident 5 len 4
> > PSM: 25 (0x0019)
> > Source CID: 65
> > > ACL Data RX: Handle 10 flags 0x02 dlen 12
> > L2CAP: Disconnection Request (0x06) ident 5 len 4
> > Destination CID: 64
> > Source CID: 71
> > < ACL Data TX: Handle 10 flags 0x00 dlen 12
> > L2CAP: Disconnection Response (0x07) ident 5 len 4
> > Destination CID: 64
> > Source CID: 71
> > > ACL Data RX: Handle 10 flags 0x02 dlen 16
> > L2CAP: Connection Response (0x03) ident 5 len 8
> > Destination CID: 127
> > Source CID: 65
> > Result: Connection refused - PSM not supported (0x0002)
> > Status: No further information available (0x0000)
>
> You may consider throwing away the device you got, it is prefectly
> valid to have a discovery both ways, AVDTP does allows either way to
> setup a stream after all.
>
Both sides do have the ability to setup a streams. The AVDTP profile
has two roles, namely the initiator and the acceptor. The AVDTP
specification stipulates that the establishment of a stream is initiated
by the initiator, and the acceptor is the responding party. Therefore,
in a single connection, AVDTP streams should only be established by the
party that initiates the connection.
> > Works:
> >
> > < ACL Data TX: Handle 12 flags 0x00 dlen 6
> > Channel: 77 len 2 [PSM 25 mode Basic (0x00)] {chan 0}
> > AVDTP: Discover (0x01) Command (0x00) type 0x00 label 11 nosp 0
> > > ACL Data RX: Handle 12 flags 0x02 dlen 8
> > Channel: 64 len 4 [PSM 25 mode Basic (0x00)] {chan 0}
> > AVDTP: Discover (0x01) Response Accept (0x02) type 0x00 label 11 nosp 0
> > ACP SEID: 1
> > Media Type: Audio (0x00)
> > SEP Type: SRC (0x00)
> > In use: No
> > < ACL Data TX: Handle 12 flags 0x00 dlen 18
> > Channel: 77 len 14 [PSM 25 mode Basic (0x00)] {chan 0}
> > AVDTP: Set Configuration (0x03) Command (0x00) type 0x00 label 12 nosp 0
> > ACP SEID: 1
> > INT SEID: 13
> > Service Category: Media Transport (0x01)
> > Service Category: Media Codec (0x07)
> > Media Type: Audio (0x00)
> > Media Codec: SBC (0x00)
> > Frequency: 44100 (0x20)
> > Channel Mode: Joint Stereo (0x01)
> > Block Length: 16 (0x10)
> > Subbands: 8 (0x04)
> > Allocation Method: Loudness (0x01)
> > Minimum Bitpool: 2
> > Maximum Bitpool: 53
> > > ACL Data RX: Handle 12 flags 0x02 dlen 6
> > Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 0}
> > AVDTP: Set Configuration (0x03) Response Accept (0x02) type 0x00 label 12>
> > > ACL Data RX: Handle 12 flags 0x02 dlen 6
> > Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 0}
> > AVDTP: Discover (0x01) Command (0x00) type 0x00 label 0 nosp 0
>
> Yeah, and that just breaks the command sequence in the process, so
> this is a pretty bad idea if you ask me.
>
In this connection, the host acts as the initiator, so only the host needs
to send the discover command. The slave only needs to respond, and it is
unnecessary and unreasonable for the slave to send the discover command again.
This modification is to ignore the discover command sent by the slave in this
connection. If the slave acts as the initiator next time, this discover
command will not be ignored.
> > < ACL Data TX: Handle 12 flags 0x00 dlen 7
> > Channel: 77 len 3 [PSM 25 mode Basic (0x00)] {chan 0}
> > AVDTP: Open (0x06) Command (0x00) type 0x00 label 13 nosp 0
> > ACP SEID: 1
> > > HCI Event: Number of Completed... (0x13) plen 5
> > Num handles: 1
> > Handle: 12
> > Count: 1
> > > ACL Data RX: Handle 12 flags 0x02 dlen 6
> > Channel: 64 len 2 [PSM 25 mode Basic (0x00)] {chan 0}
> > AVDTP: Open (0x06) Response Accept (0x02) type 0x00 label 13 nosp 0
> >
> > Signed-off-by: Zhang Chen <zhangchen01@kylinos.cn>
> > ---
> > profiles/audio/avdtp.c | 10 ++++++++++
> > 1 file changed, 10 insertions(+)
> >
> > diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
> > index d475a545e..243c828bf 100644
> > --- a/profiles/audio/avdtp.c
> > +++ b/profiles/audio/avdtp.c
> > @@ -413,6 +413,8 @@ struct avdtp {
> >
> > /* Attempt stream setup instead of disconnecting */
> > gboolean stream_setup;
> > +
> > + gboolean discover_start;
> > };
> >
> > static GSList *state_callbacks = NULL;
> > @@ -1418,6 +1420,11 @@ static gboolean avdtp_discover_cmd(struct avdtp *session, uint8_t transaction,
> > struct seid_info *seps, *p;
> > gboolean ret;
> >
> > + if (session->discover_start) {
> > + DBG("DISCOVER_CMD has been sent before.");
> > + return TRUE;
> > + }
> > +
> > sep_count = queue_length(session->lseps);
> >
> > if (sep_count == 0) {
> > @@ -2496,6 +2503,8 @@ struct avdtp *avdtp_new(GIOChannel *chan, struct btd_device *device,
> > * with respect to the disconnect timer */
> > session->stream_setup = TRUE;
> >
> > + session->discover_start = FALSE;
> > +
> > session->dc_timeout = DISCONNECT_TIMEOUT;
> >
> > avdtp_connect_cb(chan, NULL, session);
> > @@ -3484,6 +3493,7 @@ int avdtp_discover(struct avdtp *session, avdtp_discover_cb_t cb,
> > if (err == 0) {
> > session->discover->cb = cb;
> > session->discover->user_data = user_data;
> > + session->discover_start = TRUE;
> > } else if (session->discover) {
> > g_free(session->discover);
> > session->discover = NULL;
> > --
> > 2.25.1
> >
> >
>
>
--
Regards,
Zhang Chen
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-03 6:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-02 7:56 [PATCH] [BlueZ,v1,1/1] avdtp: ignore Discover cmd when host sends before zhangchen200426
2026-04-02 9:25 ` bluez.test.bot
2026-04-02 16:34 ` [PATCH] " Luiz Augusto von Dentz
2026-04-03 6:42 ` zhangchen200426
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox