Rename Bluetooth stack function parameters to clearly indicate what sort of Bluetooth...
authorDean Camera <dean@fourwalledcubicle.com>
Sun, 11 Jul 2010 07:29:27 +0000 (07:29 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Sun, 11 Jul 2010 07:29:27 +0000 (07:29 +0000)
Add a new RFCOMM_ChannelSignalsReceived() Bluetooth stack callback from the RFCOMM layer for when the remote device sends new terminal control signals.

Fix RFCOMM_SendData() not aborting correctly when the requested RFCOMM channel is not found.

12 files changed:
Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.c
Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.h
Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c
Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c
Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.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
Demos/Host/Incomplete/BluetoothHost/Lib/SDP.c
Demos/Host/Incomplete/BluetoothHost/Lib/SDP.h

index 5996f30..82e347f 100644 (file)
 /** Pointer to the opened Bluetooth ACL channel structure for RFCOMM, used to send and receive data between the\r
  *  local and remote device once a RFCOMM channel has been opened.\r
  */\r
 /** Pointer to the opened Bluetooth ACL channel structure for RFCOMM, used to send and receive data between the\r
  *  local and remote device once a RFCOMM channel has been opened.\r
  */\r
-Bluetooth_Channel_t* RFCOMMChannel = NULL;\r
+Bluetooth_Channel_t* SerialChannel_ACL    = NULL;\r
 \r
 /** Pointer to the opened RFCOMM logical channel between local and remote device, once a RFCOMM ACL channel has been\r
  *  negotiated and a logical RFCOMM channel requested.\r
  */\r
 \r
 /** Pointer to the opened RFCOMM logical channel between local and remote device, once a RFCOMM ACL channel has been\r
  *  negotiated and a logical RFCOMM channel requested.\r
  */\r
-RFCOMM_Channel_t* SerialPortChannel = NULL;\r
+RFCOMM_Channel_t*    SerialChannel_RFCOMM = NULL;\r
 \r
 /** Bluetooth stack callback event for when the Bluetooth stack has fully initialized using the attached\r
  *  Bluetooth dongle.\r
 \r
 /** Bluetooth stack callback event for when the Bluetooth stack has fully initialized using the attached\r
  *  Bluetooth dongle.\r
@@ -115,8 +115,8 @@ void Bluetooth_DisconnectionComplete(void)
  */\r
 bool Bluetooth_ChannelConnectionRequest(const uint16_t PSM)\r
 {\r
  */\r
 bool Bluetooth_ChannelConnectionRequest(const uint16_t PSM)\r
 {\r
-       /* Always accept channel connection requests regardless of PSM */\r
-       return true;\r
+       /* Only accept connections for channels that will be used for RFCOMM or SDP data */\r
+       return ((PSM == CHANNEL_PSM_RFCOMM) || (PSM == CHANNEL_PSM_SDP));\r
 }\r
 \r
 /** Bluetooth stack callback event for when a Bluetooth ACL channel has been fully created and configured,\r
 }\r
 \r
 /** Bluetooth stack callback event for when a Bluetooth ACL channel has been fully created and configured,\r
@@ -124,11 +124,11 @@ bool Bluetooth_ChannelConnectionRequest(const uint16_t PSM)
  *\r
  *  \param[in] Channel  Bluetooth ACL data channel information structure for the channel that can now be used\r
  */\r
  *\r
  *  \param[in] Channel  Bluetooth ACL data channel information structure for the channel that can now be used\r
  */\r
-void Bluetooth_ChannelOpened(Bluetooth_Channel_t* const Channel)\r
+void Bluetooth_ChannelOpened(Bluetooth_Channel_t* const ACLChannel)\r
 {\r
        /* Save the RFCOMM channel for later use when we want to send RFCOMM data */\r
 {\r
        /* Save the RFCOMM channel for later use when we want to send RFCOMM data */\r
-       if (Channel->PSM == CHANNEL_PSM_RFCOMM)\r
-         RFCOMMChannel = Channel;\r
+       if (ACLChannel->PSM == CHANNEL_PSM_RFCOMM)\r
+         SerialChannel_ACL = ACLChannel;\r
 }\r
 \r
 /** Bluetooth stack callback event for a non-signal ACL packet reception. This callback fires once a connection\r
 }\r
 \r
 /** Bluetooth stack callback event for a non-signal ACL packet reception. This callback fires once a connection\r
@@ -138,31 +138,26 @@ void Bluetooth_ChannelOpened(Bluetooth_Channel_t* const Channel)
  *  \param[in] DataLen  Length of the packet data, in bytes\r
  *  \param[in] Channel  Bluetooth ACL data channel information structure for the packet's destination channel\r
  */\r
  *  \param[in] DataLen  Length of the packet data, in bytes\r
  *  \param[in] Channel  Bluetooth ACL data channel information structure for the packet's destination channel\r
  */\r
-void Bluetooth_PacketReceived(void* Data, uint16_t DataLen, Bluetooth_Channel_t* const Channel)\r
+void Bluetooth_PacketReceived(void* Data, uint16_t DataLen, Bluetooth_Channel_t* const ACLChannel)\r
 {\r
        /* Run the correct packet handler based on the received packet's PSM, which indicates the service being carried */\r
 {\r
        /* Run the correct packet handler based on the received packet's PSM, which indicates the service being carried */\r
-       switch (Channel->PSM)\r
+       switch (ACLChannel->PSM)\r
        {\r
                case CHANNEL_PSM_SDP:\r
                        /* Service Discovery Protocol packet */\r
        {\r
                case CHANNEL_PSM_SDP:\r
                        /* Service Discovery Protocol packet */\r
-                       SDP_ProcessPacket(Data, Channel);\r
+                       SDP_ProcessPacket(Data, ACLChannel);\r
                        break;\r
                case CHANNEL_PSM_RFCOMM:\r
                        /* RFCOMM (Serial Port) Protocol packet */\r
                        break;\r
                case CHANNEL_PSM_RFCOMM:\r
                        /* RFCOMM (Serial Port) Protocol packet */\r
-                       RFCOMM_ProcessPacket(Data, Channel);\r
-                       break;\r
-               default:\r
-                       /* Unknown Protocol packet */\r
-                       printf_P(PSTR("Unknown Packet Received (Channel 0x%04X, PSM: 0x%02X, Len: 0x%04X):\r\n"),\r
-                                     Channel->LocalNumber, Channel->PSM, DataLen);                     \r
+                       RFCOMM_ProcessPacket(Data, ACLChannel);\r
                        break;\r
        }\r
 }\r
 \r
                        break;\r
        }\r
 }\r
 \r
-void RFCOMM_ChannelOpened(RFCOMM_Channel_t* const Channel)\r
+void RFCOMM_ChannelOpened(RFCOMM_Channel_t* const RFCOMMChannel)\r
 {\r
        /* Save the serial port RFCOMM logical channel for later use */\r
 {\r
        /* Save the serial port RFCOMM logical channel for later use */\r
-       SerialPortChannel = Channel;\r
+       SerialChannel_RFCOMM = RFCOMMChannel;\r
 }\r
 \r
 /** RFCOMM layer callback for when a packet is received on an open RFCOMM channel.\r
 }\r
 \r
 /** RFCOMM layer callback for when a packet is received on an open RFCOMM channel.\r
@@ -171,12 +166,17 @@ void RFCOMM_ChannelOpened(RFCOMM_Channel_t* const Channel)
  *  \param[in] DataLen  Length of the received data, in bytes\r
  *  \param[in] Data     Pointer to a buffer where the received data is stored\r
  */\r
  *  \param[in] DataLen  Length of the received data, in bytes\r
  *  \param[in] Data     Pointer to a buffer where the received data is stored\r
  */\r
-void RFCOMM_DataReceived(RFCOMM_Channel_t* const Channel, uint16_t DataLen, const uint8_t* Data)\r
+void RFCOMM_DataReceived(RFCOMM_Channel_t* const ACLChannel, uint16_t DataLen, const uint8_t* Data)\r
 {\r
        /* Write the received bytes to the serial port */\r
        for (uint8_t i = 0; i < DataLen; i++)\r
          putchar(Data[i]);\r
        \r
        /* Echo the data back to the sending device */\r
 {\r
        /* Write the received bytes to the serial port */\r
        for (uint8_t i = 0; i < DataLen; i++)\r
          putchar(Data[i]);\r
        \r
        /* Echo the data back to the sending device */\r
-       RFCOMM_SendData(DataLen, Data, Channel, RFCOMMChannel);\r
+       RFCOMM_SendData(DataLen, Data, SerialChannel_RFCOMM, SerialChannel_ACL);\r
+}\r
+\r
+void RFCOMM_ChannelSignalsReceived(RFCOMM_Channel_t* const RFCOMMChannel)\r
+{\r
+       // Currently do nothing in response to the remote device sending new terminal control signals\r
 }\r
 }\r
index 1cb104a..336f61d 100644 (file)
@@ -65,6 +65,7 @@
                #define LEDMASK_USB_BUSY          LEDS_LED2\r
        \r
        /* External Variables: */\r
                #define LEDMASK_USB_BUSY          LEDS_LED2\r
        \r
        /* External Variables: */\r
-               extern Bluetooth_Channel_t* RFCOMMChannel;\r
+               extern Bluetooth_Channel_t* SerialChannel_ACL;\r
+               extern RFCOMM_Channel_t*    SerialChannel_RFCOMM;\r
                \r
 #endif\r
                \r
 #endif\r
index 486a023..55c3997 100644 (file)
@@ -58,8 +58,7 @@ int main(void)
 
        for (;;)
        {
 
        for (;;)
        {
-               if ((RFCOMMChannel != NULL) && (RFCOMMChannel->State == BT_Channel_Open))
-                 RFCOMM_ServiceChannels(RFCOMMChannel);
+               RFCOMM_ServiceChannels(SerialChannel_ACL);
                
                Bluetooth_Host_Task();
                Bluetooth_Stack_USBTask();
                
                Bluetooth_Host_Task();
                Bluetooth_Stack_USBTask();
index d4b951d..b868689 100644 (file)
@@ -38,7 +38,6 @@
 /*
        TODO: Make SendPacket respect receiver's MTU
        TODO: Make ReceivePacket stitch together MTU fragments (?)
 /*
        TODO: Make SendPacket respect receiver's MTU
        TODO: Make ReceivePacket stitch together MTU fragments (?)
-       TODO: Add channel opened/closed callbacks
  */
 
 #define  INCLUDE_FROM_BLUETOOTH_ACLPACKETS_C
  */
 
 #define  INCLUDE_FROM_BLUETOOTH_ACLPACKETS_C
@@ -205,6 +204,46 @@ static void Bluetooth_ProcessIncommingACLPackets(void)
        }
 }
 
        }
 }
 
+/** Retrieves the channel information structure with the given local or remote channel number from the channel list.
+ *
+ *  \param[in] SearchValue  Value to search for in the channel structure list
+ *  \param[in] SearchKey    Key to search within the channel structure, a CHANNEL_SEARCH_* mask
+ *
+ *  \return Pointer to the matching channel information structure in the channel table if found, NULL otherwise
+ */
+Bluetooth_Channel_t* Bluetooth_GetChannelData(const uint16_t SearchValue, const uint8_t SearchKey)
+{
+       for (uint8_t i = 0; i < BLUETOOTH_MAX_OPEN_CHANNELS; i++)
+       {
+               Bluetooth_Channel_t* ChannelData = &Bluetooth_Connection.Channels[i];
+
+               /* Closed channels should be ignored as they are not considered valid data */
+               if (ChannelData->State == BT_Channel_Closed)
+                 continue;
+       
+               bool FoundMatch = false;
+               
+               /* Search the current channel for the search key to see if it matches */
+               switch (SearchKey)
+               {
+                       case CHANNEL_SEARCH_LOCALNUMBER:
+                               FoundMatch = (SearchValue == ChannelData->LocalNumber);
+                               break;
+                       case CHANNEL_SEARCH_REMOTENUMBER:
+                               FoundMatch = (SearchValue == ChannelData->RemoteNumber);
+                               break;
+                       case CHANNEL_SEARCH_PSM:
+                               FoundMatch = (SearchValue == ChannelData->PSM);
+                               break;
+               }
+       
+               if (FoundMatch)
+                 return ChannelData;
+       }
+
+       return NULL;
+}
+
 /** Sends a packet to the remote device on the specified channel.
  *
  * \param[in] Data     Pointer to a buffer where the data is to be sourced from
 /** Sends a packet to the remote device on the specified channel.
  *
  * \param[in] Data     Pointer to a buffer where the data is to be sourced from
@@ -214,7 +253,7 @@ static void Bluetooth_ProcessIncommingACLPackets(void)
  *
  * \return A value from the \ref BT_SendPacket_ErrorCodes_t enum
  */
  *
  * \return A value from the \ref BT_SendPacket_ErrorCodes_t enum
  */
-uint8_t Bluetooth_SendPacket(void* Data, const uint16_t DataLen, Bluetooth_Channel_t* const Channel)
+uint8_t Bluetooth_SendPacket(void* Data, const uint16_t DataLen, Bluetooth_Channel_t* const ACLChannel)
 {
        BT_ACL_Header_t        ACLPacketHeader;
        BT_DataPacket_Header_t DataHeader;
 {
        BT_ACL_Header_t        ACLPacketHeader;
        BT_DataPacket_Header_t DataHeader;
@@ -224,14 +263,14 @@ 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 */
          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 != BT_Channel_Open))
+       if ((ACLChannel == NULL) || (ACLChannel->State != BT_Channel_Open))
          return BT_SENDPACKET_ChannelNotOpen;
 
        /* Fill out the packet's header from the remote device connection information structure */
        ACLPacketHeader.ConnectionHandle      = (Bluetooth_Connection.ConnectionHandle | BT_ACL_FIRST_AUTOFLUSH);
        ACLPacketHeader.DataLength            = sizeof(DataHeader) + DataLen;
        DataHeader.PayloadLength              = DataLen;
          return BT_SENDPACKET_ChannelNotOpen;
 
        /* Fill out the packet's header from the remote device connection information structure */
        ACLPacketHeader.ConnectionHandle      = (Bluetooth_Connection.ConnectionHandle | BT_ACL_FIRST_AUTOFLUSH);
        ACLPacketHeader.DataLength            = sizeof(DataHeader) + DataLen;
        DataHeader.PayloadLength              = DataLen;
-       DataHeader.DestinationChannel         = (Channel == NULL) ? BT_CHANNEL_SIGNALING : Channel->RemoteNumber;
+       DataHeader.DestinationChannel         = (ACLChannel == NULL) ? BT_CHANNEL_SIGNALING : ACLChannel->RemoteNumber;
 
        Pipe_SelectPipe(BLUETOOTH_DATA_OUT_PIPE);
 
 
        Pipe_SelectPipe(BLUETOOTH_DATA_OUT_PIPE);
 
@@ -329,14 +368,14 @@ Bluetooth_Channel_t* Bluetooth_OpenChannel(const uint16_t PSM)
  *
  * \param[in,out] Channel  Channel information structure of the channel to close
  */
  *
  * \param[in,out] Channel  Channel information structure of the channel to close
  */
-void Bluetooth_CloseChannel(Bluetooth_Channel_t* const Channel)
+void Bluetooth_CloseChannel(Bluetooth_Channel_t* const ACLChannel)
 {
        /* Don't try to close a non-existing or already closed channel */
 {
        /* Don't try to close a non-existing or already closed channel */
-       if ((Channel == NULL) || (Channel->State == BT_Channel_Closed))
+       if ((ACLChannel == NULL) || (ACLChannel->State == BT_Channel_Closed))
          return;
 
        /* Set the channel's state to the start of the teardown process */
          return;
 
        /* Set the channel's state to the start of the teardown process */
-       Channel->State = BT_Channel_WaitDisconnect;
+       ACLChannel->State = BT_Channel_WaitDisconnect;
 
        struct
        {
 
        struct
        {
@@ -350,8 +389,8 @@ void Bluetooth_CloseChannel(Bluetooth_Channel_t* const Channel)
        PacketData.SignalCommandHeader.Length          = sizeof(PacketData.DisconnectionRequest);
 
        /* Fill out the Disconnection Request in the response packet */
        PacketData.SignalCommandHeader.Length          = sizeof(PacketData.DisconnectionRequest);
 
        /* Fill out the Disconnection Request in the response packet */
-       PacketData.DisconnectionRequest.DestinationChannel = Channel->RemoteNumber;
-       PacketData.DisconnectionRequest.SourceChannel Channel->LocalNumber;
+       PacketData.DisconnectionRequest.DestinationChannel = ACLChannel->RemoteNumber;
+       PacketData.DisconnectionRequest.SourceChannel      = ACLChannel->LocalNumber;
 
        Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL);
        
 
        Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL);
        
index 07d867b..1fa8079 100644 (file)
@@ -55,7 +55,7 @@ Bluetooth_Stack_State_t Bluetooth_State     = { IsInitialized: false };
  */
 void Bluetooth_Stack_Init(void)
 {
  */
 void Bluetooth_Stack_Init(void)
 {
-       /* Reset the HCI state machine - this will eventually reset the adapter and stack when the Bluetooth stack task is called */
+       /* Reset the HCI state machine - this will reset the adapter and stack when the Bluetooth stack task is called */
        Bluetooth_State.CurrentHCIState = Bluetooth_Init;
        Bluetooth_State.NextHCIState    = Bluetooth_Init;
 }
        Bluetooth_State.CurrentHCIState = Bluetooth_Init;
        Bluetooth_State.NextHCIState    = Bluetooth_Init;
 }
@@ -71,43 +71,3 @@ void Bluetooth_Stack_USBTask(void)
        Bluetooth_HCITask();
        Bluetooth_ACLTask();
 }
        Bluetooth_HCITask();
        Bluetooth_ACLTask();
 }
-
-/** Retrieves the channel information structure with the given local or remote channel number from the channel list.
- *
- *  \param[in] SearchValue  Value to search for in the channel structure list
- *  \param[in] SearchKey    Key to search within the channel structure, a CHANNEL_SEARCH_* mask
- *
- *  \return Pointer to the matching channel information structure in the channel table if found, NULL otherwise
- */
-Bluetooth_Channel_t* Bluetooth_GetChannelData(const uint16_t SearchValue, const uint8_t SearchKey)
-{
-       for (uint8_t i = 0; i < BLUETOOTH_MAX_OPEN_CHANNELS; i++)
-       {
-               Bluetooth_Channel_t* ChannelData = &Bluetooth_Connection.Channels[i];
-
-               /* Closed channels should be ignored as they are not considered valid data */
-               if (ChannelData->State == BT_Channel_Closed)
-                 continue;
-       
-               bool FoundMatch = false;
-               
-               /* Search the current channel for the search key to see if it matches */
-               switch (SearchKey)
-               {
-                       case CHANNEL_SEARCH_LOCALNUMBER:
-                               FoundMatch = (SearchValue == ChannelData->LocalNumber);
-                               break;
-                       case CHANNEL_SEARCH_REMOTENUMBER:
-                               FoundMatch = (SearchValue == ChannelData->RemoteNumber);
-                               break;
-                       case CHANNEL_SEARCH_PSM:
-                               FoundMatch = (SearchValue == ChannelData->PSM);
-                               break;
-               }
-       
-               if (FoundMatch)
-                 return ChannelData;
-       }
-
-       return NULL;
-}
index c1c9386..f74580e 100644 (file)
                void                 Bluetooth_ConnectionComplete(void);
                void                 Bluetooth_DisconnectionComplete(void);
                bool                 Bluetooth_ChannelConnectionRequest(const uint16_t PSM);
                void                 Bluetooth_ConnectionComplete(void);
                void                 Bluetooth_DisconnectionComplete(void);
                bool                 Bluetooth_ChannelConnectionRequest(const uint16_t PSM);
-               void                 Bluetooth_PacketReceived(void* Data, uint16_t DataLen, Bluetooth_Channel_t* const Channel);
-               void                 Bluetooth_ChannelOpened(Bluetooth_Channel_t* const Channel);
+               void                 Bluetooth_PacketReceived(void* Data, uint16_t DataLen, Bluetooth_Channel_t* const ACLChannel);
+               void                 Bluetooth_ChannelOpened(Bluetooth_Channel_t* const ACLChannel);
 
                Bluetooth_Channel_t* Bluetooth_GetChannelData(const uint16_t SearchValue, const uint8_t SearchKey);
                Bluetooth_Channel_t* Bluetooth_OpenChannel(const uint16_t PSM);
 
                Bluetooth_Channel_t* Bluetooth_GetChannelData(const uint16_t SearchValue, const uint8_t SearchKey);
                Bluetooth_Channel_t* Bluetooth_OpenChannel(const uint16_t PSM);
-               void                 Bluetooth_CloseChannel(Bluetooth_Channel_t* const Channel);
-               uint8_t              Bluetooth_SendPacket(void* Data, uint16_t DataLen, Bluetooth_Channel_t* const Channel);
+               void                 Bluetooth_CloseChannel(Bluetooth_Channel_t* const ACLChannel);
+               uint8_t              Bluetooth_SendPacket(void* Data, uint16_t DataLen, Bluetooth_Channel_t* const ACLChannel);
 
        /* External Variables: */
                extern Bluetooth_Device_t      Bluetooth_DeviceConfiguration;
 
        /* External Variables: */
                extern Bluetooth_Device_t      Bluetooth_DeviceConfiguration;
index c4aeb15..907342e 100644 (file)
@@ -73,8 +73,13 @@ void RFCOMM_Initialize(void)
          RFCOMM_Channels[i].State = RFCOMM_Channel_Closed;
 }
 
          RFCOMM_Channels[i].State = RFCOMM_Channel_Closed;
 }
 
-void RFCOMM_ServiceChannels(Bluetooth_Channel_t* const BluetoothChannel)
+void RFCOMM_ServiceChannels(Bluetooth_Channel_t* const ACLChannel)
 {
 {
+       /* Abort if the RFCOMM ACL channel is not currently open */
+       if ((ACLChannel == NULL) || (ACLChannel->State != BT_Channel_Open))
+         return;
+
+       /* Loop through each of the RFCOMM channels, send any required RFCOMM control commands */
        for (uint8_t i = 0; i < RFCOMM_MAX_OPEN_CHANNELS; i++)
        {
                RFCOMM_Channel_t* RFCOMMChannel = &RFCOMM_Channels[i];
        for (uint8_t i = 0; i < RFCOMM_MAX_OPEN_CHANNELS; i++)
        {
                RFCOMM_Channel_t* RFCOMMChannel = &RFCOMM_Channels[i];
@@ -86,7 +91,7 @@ void RFCOMM_ServiceChannels(Bluetooth_Channel_t* const BluetoothChannel)
                        {
                                /* Indicate that the local signals have been sent, transmit them to the remote device */
                                RFCOMMChannel->ConfigFlags |= RFCOMM_CONFIG_LOCALSIGNALSSENT;
                        {
                                /* Indicate that the local signals have been sent, transmit them to the remote device */
                                RFCOMMChannel->ConfigFlags |= RFCOMM_CONFIG_LOCALSIGNALSSENT;
-                               RFCOMM_SendChannelSignals(RFCOMMChannel, BluetoothChannel);
+                               RFCOMM_SendChannelSignals(RFCOMMChannel, ACLChannel);
                        }
 
                        /* If signals have been configured in both directions, progress to the open state */
                        }
 
                        /* If signals have been configured in both directions, progress to the open state */
@@ -100,7 +105,7 @@ void RFCOMM_ServiceChannels(Bluetooth_Channel_t* const BluetoothChannel)
        }
 }
 
        }
 }
 
-void RFCOMM_ProcessPacket(void* Data, Bluetooth_Channel_t* const Channel)
+void RFCOMM_ProcessPacket(void* Data, Bluetooth_Channel_t* const ACLChannel)
 {
        const RFCOMM_Header_t* FrameHeader  = (const RFCOMM_Header_t*)Data;
        const uint8_t*         FrameData    = (const uint8_t*)Data + sizeof(RFCOMM_Header_t);
 {
        const RFCOMM_Header_t* FrameHeader  = (const RFCOMM_Header_t*)Data;
        const uint8_t*         FrameData    = (const uint8_t*)Data + sizeof(RFCOMM_Header_t);
@@ -110,19 +115,19 @@ void RFCOMM_ProcessPacket(void* Data, Bluetooth_Channel_t* const Channel)
        switch (FrameHeader->Control & ~FRAME_POLL_FINAL)
        {
                case RFCOMM_Frame_DM:
        switch (FrameHeader->Control & ~FRAME_POLL_FINAL)
        {
                case RFCOMM_Frame_DM:
-                       RFCOMM_ProcessDM(&FrameHeader->Address, Channel);
+                       RFCOMM_ProcessDM(&FrameHeader->Address, ACLChannel);
                        break;
                case RFCOMM_Frame_DISC:
                        break;
                case RFCOMM_Frame_DISC:
-                       RFCOMM_ProcessDISC(&FrameHeader->Address, Channel);
+                       RFCOMM_ProcessDISC(&FrameHeader->Address, ACLChannel);
                        break;
                case RFCOMM_Frame_SABM:
                        break;
                case RFCOMM_Frame_SABM:
-                       RFCOMM_ProcessSABM(&FrameHeader->Address, Channel);
+                       RFCOMM_ProcessSABM(&FrameHeader->Address, ACLChannel);
                        break;
                case RFCOMM_Frame_UA:
                        break;
                case RFCOMM_Frame_UA:
-                       RFCOMM_ProcessUA(&FrameHeader->Address, Channel);
+                       RFCOMM_ProcessUA(&FrameHeader->Address, ACLChannel);
                        break;
                case RFCOMM_Frame_UIH:
                        break;
                case RFCOMM_Frame_UIH:
-                       RFCOMM_ProcessUIH(&FrameHeader->Address, FrameDataLen, FrameData, Channel);
+                       RFCOMM_ProcessUIH(&FrameHeader->Address, FrameDataLen, FrameData, ACLChannel);
                        break;
                default:
                        BT_RFCOMM_DEBUG(1, "<< Unknown Frame Received");
                        break;
                default:
                        BT_RFCOMM_DEBUG(1, "<< Unknown Frame Received");
@@ -130,7 +135,7 @@ void RFCOMM_ProcessPacket(void* Data, Bluetooth_Channel_t* const Channel)
        }
 }
 
        }
 }
 
-void RFCOMM_SendChannelSignals(const RFCOMM_Channel_t* const RFCOMMChannel, Bluetooth_Channel_t* const BluetoothChannel)
+void RFCOMM_SendChannelSignals(const RFCOMM_Channel_t* const RFCOMMChannel, Bluetooth_Channel_t* const ACLChannel)
 {
        BT_RFCOMM_DEBUG(1, ">> MSC Command");
        BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", RFCOMMChannel->DLCI);
 {
        BT_RFCOMM_DEBUG(1, ">> MSC Command");
        BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", RFCOMMChannel->DLCI);
@@ -149,11 +154,11 @@ void RFCOMM_SendChannelSignals(const RFCOMM_Channel_t* const RFCOMMChannel, Blue
        MSCommand.Params.BreakSignal = RFCOMMChannel->Local.BreakSignal;
 
        /* Send the MSC command to the remote device */
        MSCommand.Params.BreakSignal = RFCOMMChannel->Local.BreakSignal;
 
        /* Send the MSC command to the remote device */
-       RFCOMM_SendFrame(RFCOMM_CONTROL_DLCI, true, RFCOMM_Frame_UIH, sizeof(MSCommand), &MSCommand, BluetoothChannel); 
+       RFCOMM_SendFrame(RFCOMM_CONTROL_DLCI, true, RFCOMM_Frame_UIH, sizeof(MSCommand), &MSCommand, ACLChannel);       
 }
 
 void RFCOMM_SendData(const uint16_t DataLen, const uint8_t* Data, const RFCOMM_Channel_t* const RFCOMMChannel,
 }
 
 void RFCOMM_SendData(const uint16_t DataLen, const uint8_t* Data, const RFCOMM_Channel_t* const RFCOMMChannel,
-                     Bluetooth_Channel_t* const BluetoothChannel)
+                     Bluetooth_Channel_t* const ACLChannel)
 {
        if (RFCOMMChannel->State != RFCOMM_Channel_Open)
          return;
 {
        if (RFCOMMChannel->State != RFCOMM_Channel_Open)
          return;
@@ -162,7 +167,7 @@ void RFCOMM_SendData(const uint16_t DataLen, const uint8_t* Data, const RFCOMM_C
        BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", RFCOMMChannel->DLCI);
 
        /* Send the MSC command to the remote device */
        BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", RFCOMMChannel->DLCI);
 
        /* Send the MSC command to the remote device */
-       RFCOMM_SendFrame(RFCOMMChannel->DLCI, false, RFCOMM_Frame_UIH, DataLen, Data, BluetoothChannel);                
+       RFCOMM_SendFrame(RFCOMMChannel->DLCI, false, RFCOMM_Frame_UIH, DataLen, Data, ACLChannel);              
 }
 
 RFCOMM_Channel_t* RFCOMM_GetFreeChannelEntry(const uint8_t DLCI)
 }
 
 RFCOMM_Channel_t* RFCOMM_GetFreeChannelEntry(const uint8_t DLCI)
@@ -232,7 +237,7 @@ uint16_t RFCOMM_GetVariableFieldValue(const uint8_t** BufferPos)
 }
 
 void RFCOMM_SendFrame(const uint8_t DLCI, const bool CommandResponse, const uint8_t Control, const uint16_t DataLen,
 }
 
 void RFCOMM_SendFrame(const uint8_t DLCI, const bool CommandResponse, const uint8_t Control, const uint16_t DataLen,
-                      const void* Data, Bluetooth_Channel_t* const Channel)
+                      const void* Data, Bluetooth_Channel_t* const ACLChannel)
 {
        struct
        {
 {
        struct
        {
@@ -269,7 +274,7 @@ void RFCOMM_SendFrame(const uint8_t DLCI, const bool CommandResponse, const uint
        ResponsePacket.FCS = RFCOMM_GetFCSValue(&ResponsePacket, CRCLength);
 
        /* Send the completed response packet to the sender */
        ResponsePacket.FCS = RFCOMM_GetFCSValue(&ResponsePacket, CRCLength);
 
        /* Send the completed response packet to the sender */
-       Bluetooth_SendPacket(&ResponsePacket, sizeof(ResponsePacket), Channel);
+       Bluetooth_SendPacket(&ResponsePacket, sizeof(ResponsePacket), ACLChannel);
 }
 
 static uint8_t RFCOMM_GetFCSValue(const void* FrameStart, uint8_t Length)
 }
 
 static uint8_t RFCOMM_GetFCSValue(const void* FrameStart, uint8_t Length)
@@ -278,18 +283,18 @@ static uint8_t RFCOMM_GetFCSValue(const void* FrameStart, uint8_t Length)
        
        /* Calculate new Frame CRC value via the given data bytes and the CRC table */
        for (uint8_t i = 0; i < Length; i++)
        
        /* Calculate new Frame CRC value via the given data bytes and the CRC table */
        for (uint8_t i = 0; i < Length; i++)
-         FCS = pgm_read_byte(&CRC8_Table[FCS ^ ((uint8_t*)FrameStart)[i]]);
+         FCS = pgm_read_byte(&CRC8_Table[FCS ^ ((const uint8_t*)FrameStart)[i]]);
 
        return ~FCS;
 }
 
 
        return ~FCS;
 }
 
-static void RFCOMM_ProcessDM(const RFCOMM_Address_t* const FrameAddress, Bluetooth_Channel_t* const Channel)
+static void RFCOMM_ProcessDM(const RFCOMM_Address_t* const FrameAddress, Bluetooth_Channel_t* const ACLChannel)
 {
        BT_RFCOMM_DEBUG(1, "<< DM Received");
        BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", FrameAddress->DLCI);
 }
 
 {
        BT_RFCOMM_DEBUG(1, "<< DM Received");
        BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", FrameAddress->DLCI);
 }
 
-static void RFCOMM_ProcessDISC(const RFCOMM_Address_t* const FrameAddress, Bluetooth_Channel_t* const Channel)
+static void RFCOMM_ProcessDISC(const RFCOMM_Address_t* const FrameAddress, Bluetooth_Channel_t* const ACLChannel)
 {
        BT_RFCOMM_DEBUG(1, "<< DISC Received");
        BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", FrameAddress->DLCI);
 {
        BT_RFCOMM_DEBUG(1, "<< DISC Received");
        BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", FrameAddress->DLCI);
@@ -301,10 +306,10 @@ static void RFCOMM_ProcessDISC(const RFCOMM_Address_t* const FrameAddress, Bluet
          RFCOMMChannel->State = RFCOMM_Channel_Closed;
 
        BT_RFCOMM_DEBUG(1, ">> UA Sent");
          RFCOMMChannel->State = RFCOMM_Channel_Closed;
 
        BT_RFCOMM_DEBUG(1, ">> UA Sent");
-       RFCOMM_SendFrame(FrameAddress->DLCI, true, (RFCOMM_Frame_UA | FRAME_POLL_FINAL), 0, NULL, Channel);
+       RFCOMM_SendFrame(FrameAddress->DLCI, true, (RFCOMM_Frame_UA | FRAME_POLL_FINAL), 0, NULL, ACLChannel);
 }
 
 }
 
-static void RFCOMM_ProcessSABM(const RFCOMM_Address_t* const FrameAddress, Bluetooth_Channel_t* const Channel)
+static void RFCOMM_ProcessSABM(const RFCOMM_Address_t* const FrameAddress, Bluetooth_Channel_t* const ACLChannel)
 {
        BT_RFCOMM_DEBUG(1, "<< SABM Received");
        BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", FrameAddress->DLCI);
 {
        BT_RFCOMM_DEBUG(1, "<< SABM Received");
        BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", FrameAddress->DLCI);
@@ -314,7 +319,7 @@ static void RFCOMM_ProcessSABM(const RFCOMM_Address_t* const FrameAddress, Bluet
                BT_RFCOMM_DEBUG(1, ">> UA Sent");
                
                /* Free channel found, or request was to the control channel - accept SABM by sending a UA frame */
                BT_RFCOMM_DEBUG(1, ">> UA Sent");
                
                /* Free channel found, or request was to the control channel - accept SABM by sending a UA frame */
-               RFCOMM_SendFrame(FrameAddress->DLCI, true, (RFCOMM_Frame_UA | FRAME_POLL_FINAL), 0, NULL, Channel);
+               RFCOMM_SendFrame(FrameAddress->DLCI, true, (RFCOMM_Frame_UA | FRAME_POLL_FINAL), 0, NULL, ACLChannel);
 
                return;
        }
 
                return;
        }
@@ -332,29 +337,29 @@ static void RFCOMM_ProcessSABM(const RFCOMM_Address_t* const FrameAddress, Bluet
                BT_RFCOMM_DEBUG(1, ">> UA Sent");
                
                /* Free channel found, or request was to the control channel - accept SABM by sending a UA frame */
                BT_RFCOMM_DEBUG(1, ">> UA Sent");
                
                /* Free channel found, or request was to the control channel - accept SABM by sending a UA frame */
-               RFCOMM_SendFrame(FrameAddress->DLCI, true, (RFCOMM_Frame_UA | FRAME_POLL_FINAL), 0, NULL, Channel);
+               RFCOMM_SendFrame(FrameAddress->DLCI, true, (RFCOMM_Frame_UA | FRAME_POLL_FINAL), 0, NULL, ACLChannel);
        }
        else
        {
                BT_RFCOMM_DEBUG(1, ">> DM Sent");
 
                /* No free channel in the multiplexer - decline the SABM by sending a DM frame */
        }
        else
        {
                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);
+               RFCOMM_SendFrame(FrameAddress->DLCI, true, (RFCOMM_Frame_DM | FRAME_POLL_FINAL), 0, NULL, ACLChannel);
        }
 }
 
        }
 }
 
-static void RFCOMM_ProcessUA(const RFCOMM_Address_t* const FrameAddress, Bluetooth_Channel_t* const Channel)
+static void RFCOMM_ProcessUA(const RFCOMM_Address_t* const FrameAddress, Bluetooth_Channel_t* const ACLChannel)
 {
        BT_RFCOMM_DEBUG(1, "<< UA Received");
        BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", FrameAddress->DLCI);
 }
 
 static void RFCOMM_ProcessUIH(const RFCOMM_Address_t* const FrameAddress, const uint16_t FrameLength, 
 {
        BT_RFCOMM_DEBUG(1, "<< UA Received");
        BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", FrameAddress->DLCI);
 }
 
 static void RFCOMM_ProcessUIH(const RFCOMM_Address_t* const FrameAddress, const uint16_t FrameLength, 
-                              const uint8_t* FrameData, Bluetooth_Channel_t* const Channel)
+                              const uint8_t* FrameData, Bluetooth_Channel_t* const ACLChannel)
 {
        if (FrameAddress->DLCI == RFCOMM_CONTROL_DLCI)
        {
 {
        if (FrameAddress->DLCI == RFCOMM_CONTROL_DLCI)
        {
-               RFCOMM_ProcessControlCommand(FrameData, Channel);
+               RFCOMM_ProcessControlCommand(FrameData, ACLChannel);
                return;
        }
 
                return;
        }
 
index a30385f..5d22e38 100644 (file)
 
        /* Function Prototypes: */
                void              RFCOMM_Initialize(void);
 
        /* Function Prototypes: */
                void              RFCOMM_Initialize(void);
-               void              RFCOMM_ServiceChannels(Bluetooth_Channel_t* const Channel);
-               void              RFCOMM_ProcessPacket(void* Data, Bluetooth_Channel_t* const BluetoothChannel);
+               void              RFCOMM_ServiceChannels(Bluetooth_Channel_t* const ACLChannel);
+               void              RFCOMM_ProcessPacket(void* Data, Bluetooth_Channel_t* const ACLChannel);
                
                void              RFCOMM_SendChannelSignals(const RFCOMM_Channel_t* const RFCOMMChannel,
                
                void              RFCOMM_SendChannelSignals(const RFCOMM_Channel_t* const RFCOMMChannel,
-                                                           Bluetooth_Channel_t* const BluetoothChannel);
+                                                           Bluetooth_Channel_t* const ACLChannel);
                void              RFCOMM_SendData(const uint16_t DataLen, const uint8_t* Data,
                                                  const RFCOMM_Channel_t* const RFCOMMChannel,
                void              RFCOMM_SendData(const uint16_t DataLen, const uint8_t* Data,
                                                  const RFCOMM_Channel_t* const RFCOMMChannel,
-                                                 Bluetooth_Channel_t* const BluetoothChannel);
+                                                 Bluetooth_Channel_t* const ACLChannel);
 
 
-               void              RFCOMM_ChannelOpened(RFCOMM_Channel_t* const Channel);
-               void              RFCOMM_DataReceived(RFCOMM_Channel_t* const Channel, uint16_t DataLen, const uint8_t* Data);
+               void              RFCOMM_ChannelOpened(RFCOMM_Channel_t* const RFCOMMChannel);
+               void              RFCOMM_DataReceived(RFCOMM_Channel_t* const RFCOMMChannel, uint16_t DataLen, const uint8_t* Data);
+               void              RFCOMM_ChannelSignalsReceived(RFCOMM_Channel_t* const RFCOMMChannel);
 
                RFCOMM_Channel_t* RFCOMM_GetFreeChannelEntry(const uint8_t DLCI);
                RFCOMM_Channel_t* RFCOMM_GetChannelData(const uint8_t DLCI);
                uint16_t          RFCOMM_GetVariableFieldValue(const uint8_t** BufferPos);
                void              RFCOMM_SendFrame(const uint8_t DLCI, const bool CommandResponse, const uint8_t Control,
 
                RFCOMM_Channel_t* RFCOMM_GetFreeChannelEntry(const uint8_t DLCI);
                RFCOMM_Channel_t* RFCOMM_GetChannelData(const uint8_t DLCI);
                uint16_t          RFCOMM_GetVariableFieldValue(const uint8_t** BufferPos);
                void              RFCOMM_SendFrame(const uint8_t DLCI, const bool CommandResponse, const uint8_t Control,
-                                                      const uint16_t DataLen, const void* Data, Bluetooth_Channel_t* const Channel);
+                                                      const uint16_t DataLen, const void* Data, Bluetooth_Channel_t* const ACLChannel);
 
                #if defined(INCLUDE_FROM_RFCOMM_C)
                        static uint8_t RFCOMM_GetFCSValue(const void* FrameStart, uint8_t Length);
 
 
                #if defined(INCLUDE_FROM_RFCOMM_C)
                        static uint8_t RFCOMM_GetFCSValue(const void* FrameStart, uint8_t Length);
 
-                       static void RFCOMM_ProcessDM(const RFCOMM_Address_t* const FrameAddress, Bluetooth_Channel_t* const Channel);
-                       static void RFCOMM_ProcessDISC(const RFCOMM_Address_t* const FrameAddress, Bluetooth_Channel_t* const Channel);
-                       static void RFCOMM_ProcessSABM(const RFCOMM_Address_t* const FrameAddress, Bluetooth_Channel_t* const Channel);
-                       static void RFCOMM_ProcessUA(const RFCOMM_Address_t* const FrameAddress, Bluetooth_Channel_t* const Channel);
+                       static void RFCOMM_ProcessDM(const RFCOMM_Address_t* const FrameAddress, Bluetooth_Channel_t* const ACLChannel);
+                       static void RFCOMM_ProcessDISC(const RFCOMM_Address_t* const FrameAddress, Bluetooth_Channel_t* const ACLChannel);
+                       static void RFCOMM_ProcessSABM(const RFCOMM_Address_t* const FrameAddress, Bluetooth_Channel_t* const ACLChannel);
+                       static void RFCOMM_ProcessUA(const RFCOMM_Address_t* const FrameAddress, Bluetooth_Channel_t* const ACLChannel);
                        static void RFCOMM_ProcessUIH(const RFCOMM_Address_t* const FrameAddress, const uint16_t FrameLength, 
                        static void RFCOMM_ProcessUIH(const RFCOMM_Address_t* const FrameAddress, const uint16_t FrameLength, 
-                                          const uint8_t* FrameData, Bluetooth_Channel_t* const Channel);
+                                          const uint8_t* FrameData, Bluetooth_Channel_t* const ACLChannel);
                #endif
                
 #endif
                #endif
                
 #endif
index e5bce54..c9bd07a 100644 (file)
@@ -38,7 +38,7 @@
 #define  INCLUDE_FROM_RFCOMM_CONTROL_C\r
 #include "RFCOMMControl.h"\r
 \r
 #define  INCLUDE_FROM_RFCOMM_CONTROL_C\r
 #include "RFCOMMControl.h"\r
 \r
-void RFCOMM_ProcessControlCommand(const uint8_t* Command, Bluetooth_Channel_t* const Channel)\r
+void RFCOMM_ProcessControlCommand(const uint8_t* Command, Bluetooth_Channel_t* const ACLChannel)\r
 {\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
 {\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
@@ -47,25 +47,25 @@ void RFCOMM_ProcessControlCommand(const uint8_t* Command, Bluetooth_Channel_t* c
        switch (CommandHeader->Command)\r
        {\r
                case RFCOMM_Control_Test:\r
        switch (CommandHeader->Command)\r
        {\r
                case RFCOMM_Control_Test:\r
-                       RFCOMM_ProcessTestCommand(CommandHeader, CommandDataLen, CommandData, Channel);\r
+                       RFCOMM_ProcessTestCommand(CommandHeader, CommandDataLen, CommandData, ACLChannel);\r
                        break;\r
                case RFCOMM_Control_FlowControlEnable:\r
                        break;\r
                case RFCOMM_Control_FlowControlEnable:\r
-                       RFCOMM_ProcessFCECommand(CommandHeader, CommandData, Channel);\r
+                       RFCOMM_ProcessFCECommand(CommandHeader, CommandData, ACLChannel);\r
                        break;\r
                case RFCOMM_Control_FlowControlDisable:\r
                        break;\r
                case RFCOMM_Control_FlowControlDisable:\r
-                       RFCOMM_ProcessFCDCommand(CommandHeader, CommandData, Channel);\r
+                       RFCOMM_ProcessFCDCommand(CommandHeader, CommandData, ACLChannel);\r
                        break;\r
                case RFCOMM_Control_ModemStatus:\r
                        break;\r
                case RFCOMM_Control_ModemStatus:\r
-                       RFCOMM_ProcessMSCCommand(CommandHeader, CommandDataLen, CommandData, Channel);\r
+                       RFCOMM_ProcessMSCCommand(CommandHeader, CommandDataLen, CommandData, ACLChannel);\r
                        break;\r
                case RFCOMM_Control_RemotePortNegotiation:\r
                        break;\r
                case RFCOMM_Control_RemotePortNegotiation:\r
-                       RFCOMM_ProcessRPNCommand(CommandHeader, CommandData, Channel);\r
+                       RFCOMM_ProcessRPNCommand(CommandHeader, CommandData, ACLChannel);\r
                        break;\r
                case RFCOMM_Control_RemoteLineStatus:\r
                        break;\r
                case RFCOMM_Control_RemoteLineStatus:\r
-                       RFCOMM_ProcessRLSCommand(CommandHeader, CommandData, Channel);\r
+                       RFCOMM_ProcessRLSCommand(CommandHeader, CommandData, ACLChannel);\r
                        break;\r
                case RFCOMM_Control_DLCParameterNegotiation:\r
                        break;\r
                case RFCOMM_Control_DLCParameterNegotiation:\r
-                       RFCOMM_ProcessDPNCommand(CommandHeader, CommandData, Channel);\r
+                       RFCOMM_ProcessDPNCommand(CommandHeader, CommandData, ACLChannel);\r
                        break;\r
                default:\r
                        BT_RFCOMM_DEBUG(1, "<< Unknown Command");               \r
                        break;\r
                default:\r
                        BT_RFCOMM_DEBUG(1, "<< Unknown Command");               \r
@@ -74,7 +74,7 @@ void RFCOMM_ProcessControlCommand(const uint8_t* Command, Bluetooth_Channel_t* c
 }\r
 \r
 static void RFCOMM_ProcessTestCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t CommandDataLen,\r
 }\r
 \r
 static void RFCOMM_ProcessTestCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t CommandDataLen,\r
-                                      const uint8_t* CommandData, Bluetooth_Channel_t* const Channel)\r
+                                      const uint8_t* CommandData, Bluetooth_Channel_t* const ACLChannel)\r
 {\r
        const uint8_t* Params = (const uint8_t*)CommandData;\r
 \r
 {\r
        const uint8_t* Params = (const uint8_t*)CommandData;\r
 \r
@@ -95,23 +95,23 @@ static void RFCOMM_ProcessTestCommand(const RFCOMM_Command_t* const CommandHeade
        BT_RFCOMM_DEBUG(1, ">> TEST Response");\r
 \r
        /* Send the PDN response to acknowledge the command */\r
        BT_RFCOMM_DEBUG(1, ">> TEST Response");\r
 \r
        /* Send the PDN response to acknowledge the command */\r
-       RFCOMM_SendFrame(RFCOMM_CONTROL_DLCI, false, RFCOMM_Frame_UIH, sizeof(TestResponse), &TestResponse, Channel);\r
+       RFCOMM_SendFrame(RFCOMM_CONTROL_DLCI, false, RFCOMM_Frame_UIH, sizeof(TestResponse), &TestResponse, ACLChannel);\r
 }\r
 \r
 static void RFCOMM_ProcessFCECommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
 }\r
 \r
 static void RFCOMM_ProcessFCECommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
-                                                Bluetooth_Channel_t* const Channel)\r
+                                                Bluetooth_Channel_t* const ACLChannel)\r
 {\r
        BT_RFCOMM_DEBUG(1, "<< FCE Command");\r
 }\r
 \r
 static void RFCOMM_ProcessFCDCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
 {\r
        BT_RFCOMM_DEBUG(1, "<< FCE Command");\r
 }\r
 \r
 static void RFCOMM_ProcessFCDCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
-                                                Bluetooth_Channel_t* const Channel)\r
+                                                Bluetooth_Channel_t* const ACLChannel)\r
 {\r
        BT_RFCOMM_DEBUG(1, "<< FCD Command");\r
 }\r
 \r
 static void RFCOMM_ProcessMSCCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t CommandDataLen,\r
 {\r
        BT_RFCOMM_DEBUG(1, "<< FCD Command");\r
 }\r
 \r
 static void RFCOMM_ProcessMSCCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t CommandDataLen,\r
-                                     const uint8_t* CommandData, Bluetooth_Channel_t* const Channel)\r
+                                     const uint8_t* CommandData, Bluetooth_Channel_t* const ACLChannel)\r
 {\r
        const RFCOMM_MSC_Parameters_t* Params = (const RFCOMM_MSC_Parameters_t*)CommandData;\r
 \r
 {\r
        const RFCOMM_MSC_Parameters_t* Params = (const RFCOMM_MSC_Parameters_t*)CommandData;\r
 \r
@@ -139,6 +139,9 @@ static void RFCOMM_ProcessMSCCommand(const RFCOMM_Command_t* const CommandHeader
                /* If the command contains the optional break signals field, store the value */\r
                if (CommandDataLen == sizeof(RFCOMM_MSC_Parameters_t))\r
                  RFCOMMChannel->Remote.BreakSignal = Params->BreakSignal;\r
                /* If the command contains the optional break signals field, store the value */\r
                if (CommandDataLen == sizeof(RFCOMM_MSC_Parameters_t))\r
                  RFCOMMChannel->Remote.BreakSignal = Params->BreakSignal;\r
+\r
+               /* Notify the user application that the signals have been received */\r
+               RFCOMM_ChannelSignalsReceived(RFCOMMChannel);\r
                  \r
                struct\r
                {\r
                  \r
                struct\r
                {\r
@@ -156,7 +159,7 @@ static void RFCOMM_ProcessMSCCommand(const RFCOMM_Command_t* const CommandHeader
 \r
                /* Send the MSC response to acknowledge the command */\r
                RFCOMM_SendFrame(RFCOMM_CONTROL_DLCI, false, RFCOMM_Frame_UIH,\r
 \r
                /* Send the MSC response to acknowledge the command */\r
                RFCOMM_SendFrame(RFCOMM_CONTROL_DLCI, false, RFCOMM_Frame_UIH,\r
-                                                (sizeof(MSResponse) - sizeof(MSResponse.Params) + CommandDataLen), &MSResponse, Channel);\r
+                                                (sizeof(MSResponse) - sizeof(MSResponse.Params) + CommandDataLen), &MSResponse, ACLChannel);\r
        }\r
        else\r
        {\r
        }\r
        else\r
        {\r
@@ -166,19 +169,19 @@ static void RFCOMM_ProcessMSCCommand(const RFCOMM_Command_t* const CommandHeader
 }\r
 \r
 static void RFCOMM_ProcessRPNCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
 }\r
 \r
 static void RFCOMM_ProcessRPNCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
-                                                Bluetooth_Channel_t* const Channel)\r
+                                                Bluetooth_Channel_t* const ACLChannel)\r
 {\r
        BT_RFCOMM_DEBUG(1, "<< RPN Command");\r
 }\r
 \r
 static void RFCOMM_ProcessRLSCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
 {\r
        BT_RFCOMM_DEBUG(1, "<< RPN Command");\r
 }\r
 \r
 static void RFCOMM_ProcessRLSCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
-                                                Bluetooth_Channel_t* const Channel)\r
+                                                Bluetooth_Channel_t* const ACLChannel)\r
 {\r
        BT_RFCOMM_DEBUG(1, "<< RLS Command");\r
 }\r
 \r
 static void RFCOMM_ProcessDPNCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
 {\r
        BT_RFCOMM_DEBUG(1, "<< RLS Command");\r
 }\r
 \r
 static void RFCOMM_ProcessDPNCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t* CommandData,\r
-                                                Bluetooth_Channel_t* const Channel)\r
+                                                Bluetooth_Channel_t* const ACLChannel)\r
 {\r
        const RFCOMM_DPN_Parameters_t* Params = (const RFCOMM_DPN_Parameters_t*)CommandData;\r
 \r
 {\r
        const RFCOMM_DPN_Parameters_t* Params = (const RFCOMM_DPN_Parameters_t*)CommandData;\r
 \r
@@ -227,5 +230,5 @@ static void RFCOMM_ProcessDPNCommand(const RFCOMM_Command_t* const CommandHeader
        BT_RFCOMM_DEBUG(1, ">> DPN Response");\r
 \r
        /* Send the DPN response to acknowledge the command */\r
        BT_RFCOMM_DEBUG(1, ">> DPN Response");\r
 \r
        /* Send the DPN response to acknowledge the command */\r
-       RFCOMM_SendFrame(RFCOMM_CONTROL_DLCI, false, RFCOMM_Frame_UIH, sizeof(DPNResponse), &DPNResponse, Channel);\r
+       RFCOMM_SendFrame(RFCOMM_CONTROL_DLCI, false, RFCOMM_Frame_UIH, sizeof(DPNResponse), &DPNResponse, ACLChannel);\r
 }\r
 }\r
index a5e3fbe..9b02f7b 100644 (file)
 \r
                #if defined(INCLUDE_FROM_RFCOMM_CONTROL_C)\r
                        static void RFCOMM_ProcessTestCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t CommandDataLen, \r
 \r
                #if defined(INCLUDE_FROM_RFCOMM_CONTROL_C)\r
                        static void RFCOMM_ProcessTestCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t CommandDataLen, \r
-                                                             const uint8_t* CommandData, Bluetooth_Channel_t* const Channel);\r
+                                                             const uint8_t* CommandData, Bluetooth_Channel_t* const ACLChannel);\r
                        static void RFCOMM_ProcessFCECommand(const RFCOMM_Command_t* const 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
+                                                            Bluetooth_Channel_t* const ACLChannel);\r
                        static void RFCOMM_ProcessFCDCommand(const RFCOMM_Command_t* const 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
+                                                            Bluetooth_Channel_t* const ACLChannel);\r
                        static void RFCOMM_ProcessMSCCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t CommandDataLen,\r
                        static void RFCOMM_ProcessMSCCommand(const RFCOMM_Command_t* const CommandHeader, const uint8_t CommandDataLen,\r
-                                                            const uint8_t* CommandData, Bluetooth_Channel_t* const Channel);\r
+                                                            const uint8_t* CommandData, Bluetooth_Channel_t* const ACLChannel);\r
                        static void RFCOMM_ProcessRPNCommand(const RFCOMM_Command_t* const 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
+                                                            Bluetooth_Channel_t* const ACLChannel);\r
                        static void RFCOMM_ProcessRLSCommand(const RFCOMM_Command_t* const 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
+                                                            Bluetooth_Channel_t* const ACLChannel);\r
                        static void RFCOMM_ProcessDPNCommand(const RFCOMM_Command_t* const 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
+                                                            Bluetooth_Channel_t* const ACLChannel);\r
                #endif\r
                \r
 #endif\r
                #endif\r
                \r
 #endif\r
index 4529e8f..1c55959 100644 (file)
@@ -90,7 +90,7 @@ void SDP_ProcessPacket(void* Data, Bluetooth_Channel_t* const Channel)
  */
 static void SDP_ProcessServiceSearch(const SDP_PDUHeader_t* const SDPHeader, Bluetooth_Channel_t* const Channel)
 {
  */
 static void SDP_ProcessServiceSearch(const SDP_PDUHeader_t* const SDPHeader, Bluetooth_Channel_t* const Channel)
 {
-       const void* CurrentParameter = ((void*)SDPHeader + sizeof(SDP_PDUHeader_t));
+       const void* CurrentParameter = ((const void*)SDPHeader + sizeof(SDP_PDUHeader_t));
 
        BT_SDP_DEBUG(1, "<< Service Search");
 
 
        BT_SDP_DEBUG(1, "<< Service Search");
 
@@ -171,7 +171,7 @@ static void SDP_ProcessServiceSearch(const SDP_PDUHeader_t* const SDPHeader, Blu
  */
 static void SDP_ProcessServiceAttribute(const SDP_PDUHeader_t* const SDPHeader, Bluetooth_Channel_t* const Channel)
 {
  */
 static void SDP_ProcessServiceAttribute(const SDP_PDUHeader_t* const SDPHeader, Bluetooth_Channel_t* const Channel)
 {
-       const void* CurrentParameter = ((void*)SDPHeader + sizeof(SDP_PDUHeader_t));
+       const void* CurrentParameter = ((const void*)SDPHeader + sizeof(SDP_PDUHeader_t));
 
        BT_SDP_DEBUG(1, "<< Service Attribute");
 
 
        BT_SDP_DEBUG(1, "<< Service Attribute");
 
@@ -261,7 +261,7 @@ static void SDP_ProcessServiceAttribute(const SDP_PDUHeader_t* const SDPHeader,
  */
 static void SDP_ProcessServiceSearchAttribute(const SDP_PDUHeader_t* const SDPHeader, Bluetooth_Channel_t* const Channel)
 {
  */
 static void SDP_ProcessServiceSearchAttribute(const SDP_PDUHeader_t* const SDPHeader, Bluetooth_Channel_t* const Channel)
 {
-       const void* CurrentParameter = ((void*)SDPHeader + sizeof(SDP_PDUHeader_t));
+       const void* CurrentParameter = ((const void*)SDPHeader + sizeof(SDP_PDUHeader_t));
        
        BT_SDP_DEBUG(1, "<< Service Search Attribute");
 
        
        BT_SDP_DEBUG(1, "<< Service Search Attribute");
 
index 809d0f8..52795b8 100644 (file)
                 */
                static inline uint8_t SDP_ReadData8(const void** BufferPos)
                {
                 */
                static inline uint8_t SDP_ReadData8(const void** BufferPos)
                {
-                       uint8_t Data = *((uint8_t*)*BufferPos);
+                       uint8_t Data = *((const uint8_t*)*BufferPos);
                        *BufferPos += sizeof(uint8_t);
                        
                        return Data;
                        *BufferPos += sizeof(uint8_t);
                        
                        return Data;
                 */
                static inline uint16_t SDP_ReadData16(const void** BufferPos)
                {
                 */
                static inline uint16_t SDP_ReadData16(const void** BufferPos)
                {
-                       uint16_t Data = SwapEndian_16(*((uint16_t*)*BufferPos));
+                       uint16_t Data = SwapEndian_16(*((const uint16_t*)*BufferPos));
                        *BufferPos += sizeof(uint16_t);
                        
                        return Data;
                        *BufferPos += sizeof(uint16_t);
                        
                        return Data;
                 */
                static inline uint32_t SDP_ReadData32(const void** BufferPos)
                {
                 */
                static inline uint32_t SDP_ReadData32(const void** BufferPos)
                {
-                       uint32_t Data = SwapEndian_32(*((uint32_t*)*BufferPos));
+                       uint32_t Data = SwapEndian_32(*((const uint32_t*)*BufferPos));
                        *BufferPos += sizeof(uint32_t);
                        
                        return Data;
                        *BufferPos += sizeof(uint32_t);
                        
                        return Data;