From 5263a2a3e71ed849cecf320295eaa7be37420eaa Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 17 Jun 2024 11:41:39 +0200 Subject: [PATCH] rfcomm: shut down multiplexer after closing last channel --- src/classic/rfcomm.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/classic/rfcomm.c b/src/classic/rfcomm.c index ae57b4f1b..f45aadd40 100644 --- a/src/classic/rfcomm.c +++ b/src/classic/rfcomm.c @@ -2201,6 +2201,15 @@ static void rfcomm_channel_state_machine_with_channel(rfcomm_channel_t *channel, channel->state = RFCOMM_CHANNEL_CLOSED; rfcomm_emit_channel_closed(channel); rfcomm_channel_finalize(channel); + // RFCOMM v1.2, 5.2.2. Close-Down Procedure + // The device closing the last connection (DLC) on a particular session shall close the + // multiplexer by closing the corresponding L2CAP channel. + if (rfcomm_multiplexer_has_channels(multiplexer) == false){ + log_info("Closed last DLC, shut-down multiplexer"); + uint16_t l2cap_cid = multiplexer->l2cap_cid; + rfcomm_multiplexer_finalize(multiplexer); + l2cap_disconnect(l2cap_cid); + } *out_channel_valid = 0; break; default: