Add RFCOMM channel configuration parsing and channel states to the incomplete Bluetoo...
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 15 Jun 2010 09:32:35 +0000 (09:32 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 15 Jun 2010 09:32:35 +0000 (09:32 +0000)
Add missing BT_* prefix to the Bluetooth stack's channel state enum values.

Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c
Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h
Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c
Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h
Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMMControl.c
Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMMControl.h

index df8dfc5..ec85aab 100644 (file)
@@ -62,11 +62,11 @@ void Bluetooth_ACLTask(void)
                /* Check if we are in a channel state which requires a configuration request to be sent */
                switch (ChannelData->State)
                {
-                       case Channel_Config_WaitConfig:
-                               ChannelData->State = Channel_Config_WaitReqResp;
+                       case BT_Channel_Config_WaitConfig:
+                               ChannelData->State = BT_Channel_Config_WaitReqResp;
                                break;
-                       case Channel_Config_WaitSendConfig:
-                               ChannelData->State = Channel_Config_WaitResp;
+                       case BT_Channel_Config_WaitSendConfig:
+                               ChannelData->State = BT_Channel_Config_WaitResp;
                                break;
                        default:
                                MustSendConfigReq  = false;
@@ -224,7 +224,7 @@ uint8_t Bluetooth_SendPacket(void* Data, const uint16_t DataLen, Bluetooth_Chann
          return BT_SENDPACKET_NotConnected;
 
        /* If the destination channel is not the signalling channel and it is not currently fully open, abort */
-       if ((Channel != NULL) && (Channel->State != Channel_Open))
+       if ((Channel != NULL) && (Channel->State != BT_Channel_Open))
          return BT_SENDPACKET_ChannelNotOpen;
 
        /* Fill out the packet's header from the remote device connection information structure */
@@ -274,7 +274,7 @@ Bluetooth_Channel_t* Bluetooth_OpenChannel(const uint16_t PSM)
        /* Search through the channel information list for a free channel item */
        for (uint8_t i = 0; i < BLUETOOTH_MAX_OPEN_CHANNELS; i++)
        {
-               if (Bluetooth_Connection.Channels[i].State == Channel_Closed)
+               if (Bluetooth_Connection.Channels[i].State == BT_Channel_Closed)
                {
                        ChannelData = &Bluetooth_Connection.Channels[i];
                        
@@ -293,7 +293,7 @@ Bluetooth_Channel_t* Bluetooth_OpenChannel(const uint16_t PSM)
        ChannelData->RemoteNumber = 0;
        ChannelData->PSM          = PSM;
        ChannelData->LocalMTU     = MAXIMUM_CHANNEL_MTU;
-       ChannelData->State        = Channel_WaitConnectRsp;
+       ChannelData->State        = BT_Channel_WaitConnectRsp;
          
        struct
        {
@@ -332,11 +332,11 @@ Bluetooth_Channel_t* Bluetooth_OpenChannel(const uint16_t PSM)
 void Bluetooth_CloseChannel(Bluetooth_Channel_t* const Channel)
 {
        /* Don't try to close a non-existing or already closed channel */
-       if ((Channel == NULL) || (Channel->State == Channel_Closed))
+       if ((Channel == NULL) || (Channel->State == BT_Channel_Closed))
          return;
 
        /* Set the channel's state to the start of the teardown process */
-       Channel->State = Channel_WaitDisconnect;
+       Channel->State = BT_Channel_WaitDisconnect;
 
        struct
        {
@@ -386,7 +386,7 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons
                /* Look through the channel information list for a free entry */
                for (uint8_t i = 0; i < BLUETOOTH_MAX_OPEN_CHANNELS; i++)
                {
-                       if (Bluetooth_Connection.Channels[i].State == Channel_Closed)
+                       if (Bluetooth_Connection.Channels[i].State == BT_Channel_Closed)
                        {
                                ChannelData = &Bluetooth_Connection.Channels[i];
 
@@ -409,7 +409,7 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons
                        ChannelData->RemoteNumber = ConnectionRequest.SourceChannel;
                        ChannelData->PSM          = ConnectionRequest.PSM;
                        ChannelData->LocalMTU     = MAXIMUM_CHANNEL_MTU;
-                       ChannelData->State        = Channel_Config_WaitConfig;
+                       ChannelData->State        = BT_Channel_Config_WaitConfig;
                        
                        ChannelStatus = BT_CONNECTION_SUCCESSFUL;
                }
@@ -471,7 +471,7 @@ static inline void Bluetooth_Signal_ConnectionResp(const BT_Signal_Header_t* con
                /* Set the channel structure's remote channel number to the channel allocated on the remote device */
                ChannelData->RemoteNumber = ConnectionResponse.SourceChannel;
                ChannelData->State        = (ConnectionResponse.Result == BT_CONNECTION_SUCCESSFUL) ?
-                                            Channel_Config_WaitConfig : Channel_Closed;
+                                            BT_Channel_Config_WaitConfig : BT_Channel_Closed;
        }
 }
 
@@ -544,14 +544,14 @@ static inline void Bluetooth_Signal_ConfigurationReq(const BT_Signal_Header_t* c
        {
                switch (ChannelData->State)
                {
-                       case Channel_Config_WaitConfig:
-                               ChannelData->State = Channel_Config_WaitSendConfig;
+                       case BT_Channel_Config_WaitConfig:
+                               ChannelData->State = BT_Channel_Config_WaitSendConfig;
                                break;
-                       case Channel_Config_WaitReqResp:
-                               ChannelData->State = Channel_Config_WaitResp;
+                       case BT_Channel_Config_WaitReqResp:
+                               ChannelData->State = BT_Channel_Config_WaitResp;
                                break;
-                       case Channel_Config_WaitReq:
-                               ChannelData->State = Channel_Open;
+                       case BT_Channel_Config_WaitReq:
+                               ChannelData->State = BT_Channel_Open;
                                break;
                }
        }
@@ -589,18 +589,18 @@ static inline void Bluetooth_Signal_ConfigurationResp(const BT_Signal_Header_t*
                {
                        switch (ChannelData->State)
                        {
-                               case Channel_Config_WaitReqResp:
-                                       ChannelData->State = Channel_Config_WaitReq;
+                               case BT_Channel_Config_WaitReqResp:
+                                       ChannelData->State = BT_Channel_Config_WaitReq;
                                        break;
-                               case Channel_Config_WaitResp:
-                                       ChannelData->State = Channel_Open;
+                               case BT_Channel_Config_WaitResp:
+                                       ChannelData->State = BT_Channel_Open;
                                        break;
                        }       
                }
                else
                {
                        /* Configuration failed - close the channel */
-                       ChannelData->State = Channel_Closed;
+                       ChannelData->State = BT_Channel_Closed;
                }
        }
 }
@@ -644,7 +644,7 @@ static inline void Bluetooth_Signal_DisconnectionReq(const BT_Signal_Header_t* c
 
        /* If the channel was found in the channel list, close it */
        if (ChannelData != NULL)
-         ChannelData->State = Channel_Closed;
+         ChannelData->State = BT_Channel_Closed;
 
        BT_ACL_DEBUG(1, ">> L2CAP Disconnection Response");
        BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ResponsePacket.DisconnectionResponse.SourceChannel);
@@ -673,7 +673,7 @@ static inline void Bluetooth_Signal_DisconnectionResp(const BT_Signal_Header_t*
        
        /* If the channel was found in the channel list, close it */    
        if (ChannelData != NULL)
-         ChannelData->State = Channel_Closed;
+         ChannelData->State = BT_Channel_Closed;
 }
 
 /** Internal Bluetooth stack Signal Command processing routine for an Echo Request command.
index 060f4ff..131c4aa 100644 (file)
                /** Enum for the possible states for a Bluetooth ACL channel. */
                enum BT_ChannelStates_t
                {
-                       Channel_Closed                = 0, /**< Channel is closed and inactive. No data may be sent or received. */
-                       Channel_WaitConnect           = 1, /**< A connection request has been received, but a response has not been sent. */
-                       Channel_WaitConnectRsp        = 2, /**< A connection request has been sent, but a response has not been received. */
-                       Channel_Config_WaitConfig     = 3, /**< Channel has been connected, but not yet configured on either end. */
-                       Channel_Config_WaitSendConfig = 4, /**< Channel configuration has been received and accepted, but not yet sent. */
-                       Channel_Config_WaitReqResp    = 5, /**< Channel configuration has been sent but not responded to, and a configuration
-                                                               request from the remote end has not yet been received. */
-                       Channel_Config_WaitResp       = 6, /**< Channel configuration has been sent but not accepted, but a configuration request
-                                                               from the remote end has been accepted. */
-                       Channel_Config_WaitReq        = 7, /**< Channel configuration has been sent and accepted, but a configuration request
-                                                               from the remote end has not yet been accepted. */
-                       Channel_Open                  = 8, /**< Channel is open and ready to send or receive data */
-                       Channel_WaitDisconnect        = 9, /**< A disconnection request has been sent, but not yet acknowledged. */
+                       BT_Channel_Closed                = 0, /**< Channel is closed and inactive. No data may be sent or received. */
+                       BT_Channel_WaitConnect           = 1, /**< A connection request has been received, but a response has not been sent. */
+                       BT_Channel_WaitConnectRsp        = 2, /**< A connection request has been sent, but a response has not been received. */
+                       BT_Channel_Config_WaitConfig     = 3, /**< Channel has been connected, but not yet configured on either end. */
+                       BT_Channel_Config_WaitSendConfig = 4, /**< Channel configuration has been received and accepted, but not yet sent. */
+                       BT_Channel_Config_WaitReqResp    = 5, /**< Channel configuration has been sent but not responded to, and a configuration
+                                                              *   request from the remote end has not yet been received.
+                                                              */
+                       BT_Channel_Config_WaitResp       = 6, /**< Channel configuration has been sent but not accepted, but a configuration request
+                                                              *   from the remote end has been accepted.
+                                                              */
+                       BT_Channel_Config_WaitReq        = 7, /**< Channel configuration has been sent and accepted, but a configuration request
+                                                              *   from the remote end has not yet been accepted.
+                                                              */
+                       BT_Channel_Open                  = 8, /**< Channel is open and ready to send or receive data */
+                       BT_Channel_WaitDisconnect        = 9, /**< A disconnection request has been sent, but not yet acknowledged. */
                };
 
                /** Enum for the possible error codes returned by the \ref Bluetooth_SendPacket() function. */
index f9aff8e..5968a69 100644 (file)
@@ -70,7 +70,7 @@ void RFCOMM_Initialize(void)
 {
        /* Reset the RFCOMM channel structures, to invalidate any confiured RFCOMM channels */
        for (uint8_t i = 0; i < RFCOMM_MAX_OPEN_CHANNELS; i++)
-         RFCOMM_Channels[i].DLCI = 0x00;
+         RFCOMM_Channels[i].State = RFCOMM_Channel_Closed;
 }
 
 void RFCOMM_ProcessPacket(void* Data, Bluetooth_Channel_t* const Channel)
@@ -220,8 +220,11 @@ static void RFCOMM_ProcessSABM(const RFCOMM_Address_t* const FrameAddress, Bluet
                /* If the channel's DLCI is zero, the channel state entry is free */
                if (!(CurrRFCOMMChannel->DLCI))
                {
-                       CurrRFCOMMChannel->DLCI       = FrameAddress->DLCI;
-                       CurrRFCOMMChannel->Configured = false;
+                       CurrRFCOMMChannel->DLCI        = FrameAddress->DLCI;
+                       CurrRFCOMMChannel->State       = RFCOMM_Channel_Open;
+                       CurrRFCOMMChannel->Priority    = 7 + (CurrRFCOMMChannel->DLCI >> 3) + ((CurrRFCOMMChannel->DLCI >> 3) * 7);
+                       CurrRFCOMMChannel->UseUIFrames = false;
+                       CurrRFCOMMChannel->RemoteMTU   = 0xFFFF;
                
                        BT_RFCOMM_DEBUG(1, ">> UA Sent");
                        RFCOMM_SendFrame(FrameAddress->DLCI, true, (RFCOMM_Frame_UA | FRAME_POLL_FINAL), 0, NULL, Channel);
@@ -244,15 +247,20 @@ static void RFCOMM_ProcessUA(const RFCOMM_Address_t* const FrameAddress, Bluetoo
 static void RFCOMM_ProcessUIH(const RFCOMM_Address_t* const FrameAddress, const uint16_t FrameLength, 
                               const uint8_t* FrameData, Bluetooth_Channel_t* const Channel)
 {
-       BT_RFCOMM_DEBUG(1, "<< UIH Received");
-       BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", FrameAddress->DLCI);
-       BT_RFCOMM_DEBUG(2, "-- Length 0x%02X", FrameLength);
-       
        if (FrameAddress->DLCI == RFCOMM_CONTROL_DLCI)
        {
                RFCOMM_ProcessControlCommand(FrameData, Channel);
                return;
        }
 
-       // TODO: Handle regular channel data here
+       BT_RFCOMM_DEBUG(1, "<< UIH Received");
+       BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", FrameAddress->DLCI);
+       BT_RFCOMM_DEBUG(2, "-- Length 0x%02X", FrameLength);
+               
+       puts("RFCOMM Data: ");
+       
+       for (uint8_t i = 0; i < FrameLength; i++)
+         printf("0x%02X (%c) ", FrameData[i], FrameData[i]);
+       
+       printf("\r\n");
 }
index 68f0cf1..5ccfc2d 100644 (file)
                        RFCOMM_Frame_UIH   = 0xEF, /**< Unnumbered Information with Header check Field */
                };
                
-       /* Type Defines: */
-               typedef struct
-               {
-                       unsigned char EA   : 1;
-                       unsigned char CR   : 1;
-                       unsigned char DLCI : 6;
-               } RFCOMM_Address_t;
-       
-               typedef struct
+               enum RFCOMM_Channel_States_t
                {
-                       RFCOMM_Address_t Address;
-                       uint8_t          Control;
-               } RFCOMM_Header_t;
+                       RFCOMM_Channel_Closed      = 0,
+                       RFCOMM_Channel_Create      = 1,
+                       RFCOMM_Channel_Creating    = 2,
+                       RFCOMM_Channel_Configure   = 3,
+                       RFCOMM_Channel_Configuring = 4,
+                       RFCOMM_Channel_Open        = 5,
+               };
                
+       /* Type Defines: */
                typedef struct
                {
-                       uint8_t DLCI;
-                       bool    Configured;
+                       uint8_t  DLCI;
+                       uint8_t  State;
+                       uint8_t  Priority;
+                       bool     UseUIFrames;
+                       uint16_t RemoteMTU;
                } RFCOMM_Channel_t;
                
        /* External Variables: */
index 2321c25..23a1876 100644 (file)
@@ -42,29 +42,33 @@ void RFCOMM_ProcessControlCommand(const uint8_t* Command, Bluetooth_Channel_t* c
 {\r
        const RFCOMM_Command_t* CommandHeader  = (const RFCOMM_Command_t*)Command;\r
        const uint8_t*          CommandData    = (const uint8_t*)Command + sizeof(RFCOMM_Command_t);\r
+       uint16_t                ControlDataLen = RFCOMM_GetFrameDataLength(CommandData);\r
+\r
+       /* Adjust the command data pointer to skip over the variable size field */\r
+       CommandData += (ControlDataLen < 128) ? 1 : 2;\r
 \r
        switch (CommandHeader->Command)\r
        {\r
                case RFCOMM_Control_Test:\r
-                       RFCOMM_ProcessTestCommand(CommandHeader, CommandData);\r
+                       RFCOMM_ProcessTestCommand(CommandHeader, CommandData, Channel);\r
                        break;\r
                case RFCOMM_Control_FlowControlEnable:\r
-                       RFCOMM_ProcessFCECommand(CommandHeader, CommandData);\r
+                       RFCOMM_ProcessFCECommand(CommandHeader, CommandData, Channel);\r
                        break;\r
                case RFCOMM_Control_FlowControlDisable:\r
-                       RFCOMM_ProcessFCDCommand(CommandHeader, CommandData);\r
+                       RFCOMM_ProcessFCDCommand(CommandHeader, CommandData, Channel);\r
                        break;\r
                case RFCOMM_Control_ModemStatus:\r
-                       RFCOMM_ProcessMSCommand(CommandHeader, CommandData);\r
+                       RFCOMM_ProcessMSCommand(CommandHeader, CommandData, Channel);\r
                        break;\r
                case RFCOMM_Control_RemotePortNegotiation:\r
-                       RFCOMM_ProcessRPNCommand(CommandHeader, CommandData);\r
+                       RFCOMM_ProcessRPNCommand(CommandHeader, CommandData, Channel);\r
                        break;\r
                case RFCOMM_Control_RemoteLineStatus:\r
-                       RFCOMM_ProcessRLSCommand(CommandHeader, CommandData);\r
+                       RFCOMM_ProcessRLSCommand(CommandHeader, CommandData, Channel);\r
                        break;\r
                case RFCOMM_Control_DLCParameterNegotiation:\r
-                       RFCOMM_ProcessDPNCommand(CommandHeader, CommandData);\r
+                       RFCOMM_ProcessDPNCommand(CommandHeader, CommandData, Channel);\r
                        break;\r
                default:\r
                        BT_RFCOMM_DEBUG(1, "<< Unknown Command");               \r
@@ -72,49 +76,101 @@ void RFCOMM_ProcessControlCommand(const uint8_t* Command, Bluetooth_Channel_t* c
        }\r
 }\r
 \r
-static void RFCOMM_ProcessTestCommand(const RFCOMM_Command_t* CommandHeader, const uint8_t* CommandData)\r
+static void RFCOMM_ProcessTestCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
+                                                 Bluetooth_Channel_t* const Channel)\r
 {\r
        BT_RFCOMM_DEBUG(1, "<< TEST Command");\r
 }\r
 \r
-static void RFCOMM_ProcessFCECommand(const RFCOMM_Command_t* CommandHeader, const uint8_t* CommandData)\r
+static void RFCOMM_ProcessFCECommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
+                                                Bluetooth_Channel_t* const Channel)\r
 {\r
        BT_RFCOMM_DEBUG(1, "<< FCE Command");\r
 }\r
 \r
-static void RFCOMM_ProcessFCDCommand(const RFCOMM_Command_t* CommandHeader, const uint8_t* CommandData)\r
+static void RFCOMM_ProcessFCDCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
+                                                Bluetooth_Channel_t* const Channel)\r
 {\r
        BT_RFCOMM_DEBUG(1, "<< FCD Command");\r
 }\r
 \r
-static void RFCOMM_ProcessMSCommand(const RFCOMM_Command_t* CommandHeader, const uint8_t* CommandData)\r
+static void RFCOMM_ProcessMSCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
+                                               Bluetooth_Channel_t* const Channel)\r
 {\r
        BT_RFCOMM_DEBUG(1, "<< MS Command");\r
 }\r
 \r
-static void RFCOMM_ProcessRPNCommand(const RFCOMM_Command_t* CommandHeader, const uint8_t* CommandData)\r
+static void RFCOMM_ProcessRPNCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
+                                                Bluetooth_Channel_t* const Channel)\r
 {\r
        BT_RFCOMM_DEBUG(1, "<< RPN Command");\r
 }\r
 \r
-static void RFCOMM_ProcessRLSCommand(const RFCOMM_Command_t* CommandHeader, const uint8_t* CommandData)\r
+static void RFCOMM_ProcessRLSCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
+                                                Bluetooth_Channel_t* const Channel)\r
 {\r
        BT_RFCOMM_DEBUG(1, "<< RLS Command");\r
 }\r
 \r
-static void RFCOMM_ProcessDPNCommand(const RFCOMM_Command_t* CommandHeader, const uint8_t* CommandData)\r
+static void RFCOMM_ProcessDPNCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
+                                                Bluetooth_Channel_t* const Channel)\r
 {\r
+       const RFCOMM_DPN_Parameters_t* Params = (const RFCOMM_DPN_Parameters_t*)CommandData;\r
+\r
        BT_RFCOMM_DEBUG(1, "<< DPN Command");\r
+       BT_RFCOMM_DEBUG(2, "-- Config DLCI: 0x%02X", Params->DLCI);\r
        \r
-       /* Skip over the first data byte (Length field) since its size and value are fixed */\r
-       RFCOMM_Channel_t* RFCOMMChannel = RFCOMM_GetChannelData(CommandData[2]);\r
+       /* Ignore parameter negotiations to the control channel */\r
+       if (Params->DLCI == RFCOMM_CONTROL_DLCI)\r
+         return;\r
        \r
+       /* Retrieve existing channel configuration data, if already opened */\r
+       RFCOMM_Channel_t* RFCOMMChannel = RFCOMM_GetChannelData(Params->DLCI);\r
+       \r
+       /* Check if the channel has no corresponding entry - remote did not open it first */\r
        if (RFCOMMChannel == NULL)\r
        {\r
-               // TODO: Channel does not exist - create it\r
+               /* 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
+                       {\r
+                               RFCOMMChannel       = &RFCOMM_Channels[i];\r
+                               RFCOMMChannel->DLCI = Params->DLCI;\r
+                               break;\r
+                       }\r
+               }\r
+               \r
+               /* No free entry was found, discard the request */\r
+               if (RFCOMMChannel == NULL)\r
+               {\r
+                       BT_RFCOMM_DEBUG(2, "-- No Free Channel");\r
+                       return;\r
+               }\r
        }\r
        \r
-       RFCOMMChannel->Configured = true;\r
+       /* Save the new channel configuration */\r
+       RFCOMMChannel->State       = RFCOMM_Channel_Open;\r
+       RFCOMMChannel->Priority    = Params->Priority;\r
+       RFCOMMChannel->UseUIFrames = (Params->FrameType != 0);\r
+       RFCOMMChannel->RemoteMTU   = Params->MaximumFrameSize;\r
        \r
-       // TODO: Read in channel data, ACK request\r
+       struct\r
+       {\r
+               RFCOMM_Command_t        CommandHeader;\r
+               uint8_t                 Length;\r
+               RFCOMM_DPN_Parameters_t Params;\r
+       } DPNResponse;\r
+       \r
+       /* Fill out the DPN response data */\r
+       DPNResponse.CommandHeader.Command = CommandHeader->Command;\r
+       DPNResponse.CommandHeader.EA      = true;\r
+       DPNResponse.Length                = (sizeof(DPNResponse.Params) << 1) | 0x01;\r
+       DPNResponse.Params                = *Params;\r
+       \r
+       BT_RFCOMM_DEBUG(1, ">> DPN Response");\r
+\r
+       /* Send the PDN response to acknowledge the command */\r
+       RFCOMM_SendFrame(RFCOMM_CONTROL_DLCI, false, RFCOMM_Frame_UIH, sizeof(DPNResponse), &DPNResponse, Channel);\r
 }\r
index 79e3dcd..e12c74c 100644 (file)
@@ -48,6 +48,9 @@
 \r
                #include "BluetoothStack.h"\r
                #include "RFCOMM.h"\r
+               \r
+       /* Macros: */\r
+               #define RFCOMM_\r
 \r
        /* Enums: */\r
                enum RFCOMM_Control_Commands_t\r
        /* Type Defines: */\r
                typedef struct\r
                {\r
+                       unsigned char EA   : 1;\r
+                       unsigned char CR   : 1;\r
+                       unsigned char DLCI : 6;\r
+               } RFCOMM_Address_t;\r
+\r
+               typedef struct\r
+               {\r
+                       RFCOMM_Address_t Address;\r
+                       uint8_t          Control;\r
+               } RFCOMM_Header_t;\r
+\r
+               typedef struct\r
+               {\r
                        unsigned char EA      : 1;\r
                        unsigned char CR      : 1;\r
                        unsigned char Command : 6;\r
                } RFCOMM_Command_t;\r
+               \r
+               typedef struct\r
+               {\r
+                       uint8_t          DLCI;\r
+                       unsigned char    FrameType        : 4;\r
+                       unsigned char    ConvergenceLayer : 4;\r
+                       uint8_t          Priority;\r
+                       uint8_t          ACKTimerTicks;\r
+                       uint16_t         MaximumFrameSize;\r
+                       uint8_t          MaxRetransmissions;\r
+                       uint8_t          RecoveryWindowSize;                    \r
+               } RFCOMM_DPN_Parameters_t;\r
 \r
        /* Function Prototypes: */\r
                void RFCOMM_ProcessControlCommand(const uint8_t* Command, Bluetooth_Channel_t* const Channel);\r
 \r
                #if defined(INCLUDE_FROM_RFCOMM_CONTROL_C)\r
-                       static void RFCOMM_ProcessTestCommand(const RFCOMM_Command_t* CommandHeader, const uint8_t* CommandData);\r
-                       static void RFCOMM_ProcessFCECommand(const RFCOMM_Command_t* CommandHeader, const uint8_t* CommandData);\r
-                       static void RFCOMM_ProcessFCDCommand(const RFCOMM_Command_t* CommandHeader, const uint8_t* CommandData);\r
-                       static void RFCOMM_ProcessMSCommand(const RFCOMM_Command_t* CommandHeader, const uint8_t* CommandData);\r
-                       static void RFCOMM_ProcessRPNCommand(const RFCOMM_Command_t* CommandHeader, const uint8_t* CommandData);\r
-                       static void RFCOMM_ProcessRLSCommand(const RFCOMM_Command_t* CommandHeader, const uint8_t* CommandData);\r
-                       static void RFCOMM_ProcessDPNCommand(const RFCOMM_Command_t* CommandHeader, const uint8_t* CommandData);\r
+                       static void RFCOMM_ProcessTestCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
+                                                             Bluetooth_Channel_t* const Channel);\r
+                       static void RFCOMM_ProcessFCECommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
+                                                            Bluetooth_Channel_t* const Channel);\r
+                       static void RFCOMM_ProcessFCDCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
+                                                            Bluetooth_Channel_t* const Channel);\r
+                       static void RFCOMM_ProcessMSCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
+                                                           Bluetooth_Channel_t* const Channel);\r
+                       static void RFCOMM_ProcessRPNCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
+                                                            Bluetooth_Channel_t* const Channel);\r
+                       static void RFCOMM_ProcessRLSCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
+                                                            Bluetooth_Channel_t* const Channel);\r
+                       static void RFCOMM_ProcessDPNCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
+                                                            Bluetooth_Channel_t* const Channel);\r
                #endif\r
                \r
 #endif\r