- BT_RFCOMM_DEBUG(1, ">> UA Sent");
- RFCOMM_SendFrame(FrameAddress->DLCI, true, (RFCOMM_Frame_UA | FRAME_POLL_FINAL), 0, NULL, Channel);
+ /* If the channel's DLCI is zero, the channel state entry is free */
+ if (!(CurrRFCOMMChannel->DLCI))
+ {
+ CurrRFCOMMChannel->DLCI = FrameAddress->DLCI;
+ CurrRFCOMMChannel->Configured = false;
+
+ BT_RFCOMM_DEBUG(1, ">> UA Sent");
+ RFCOMM_SendFrame(FrameAddress->DLCI, true, (RFCOMM_Frame_UA | FRAME_POLL_FINAL), 0, NULL, Channel);
+ return;
+ }
+ }
+
+ BT_RFCOMM_DEBUG(1, ">> DM Sent");
+
+ /* No free channel in the multiplexer - decline the SABM by sending a DM frame */
+ RFCOMM_SendFrame(FrameAddress->DLCI, true, (RFCOMM_Frame_DM | FRAME_POLL_FINAL), 0, NULL, Channel);