Make Bluetooth ACL channel searches skip over closed (invalid) channels. RFCOMM chann...
[pub/USBasp.git] / Demos / Host / Incomplete / BluetoothHost / Lib / RFCOMMControl.c
index 01fab78..5e9c86b 100644 (file)
@@ -188,12 +188,12 @@ static void RFCOMM_ProcessDPNCommand(const RFCOMM_Command_t* const CommandHeader
                /* Find a free entry in the RFCOMM channel multiplexer state array */\r
                for (uint8_t i = 0; i < RFCOMM_MAX_OPEN_CHANNELS; i++)\r
                {\r
-                       /* If the channel's DLCI is zero, the channel state entry is free */\r
-                       if (!(RFCOMM_Channels[i].DLCI))\r
+                       /* If the channel's state is closed, the channel state entry is free */\r
+                       if (RFCOMMChannel->State == RFCOMM_Channel_Closed)\r
                        {\r
-                               RFCOMMChannel       = &RFCOMM_Channels[i];\r
-                               RFCOMMChannel->DLCI = Params->DLCI;\r
-                               RFCOMMChannel->MTU  = 0xFFFF;\r
+                               RFCOMMChannel        = &RFCOMM_Channels[i];\r
+                               RFCOMMChannel->DLCI  = Params->DLCI;\r
+                               RFCOMMChannel->MTU   = 0xFFFF;\r
                                RFCOMMChannel->Remote.Signals     = 0 | (1 << 0);\r
                                RFCOMMChannel->Remote.BreakSignal = 0 | (1 << 0);\r
                                RFCOMMChannel->Local.Signals      = RFCOMM_SIGNAL_RTC | RFCOMM_SIGNAL_RTR | RFCOMM_SIGNAL_DV | (1 << 0);\r
@@ -230,6 +230,6 @@ static void RFCOMM_ProcessDPNCommand(const RFCOMM_Command_t* const CommandHeader
        \r
        BT_RFCOMM_DEBUG(1, ">> DPN Response");\r
 \r
-       /* Send the PDN response to acknowledge the command */\r
+       /* Send the DPN response to acknowledge the command */\r
        RFCOMM_SendFrame(RFCOMM_CONTROL_DLCI, false, RFCOMM_Frame_UIH, sizeof(DPNResponse), &DPNResponse, Channel);\r
 }\r