Add tag for the 120219 release.
[pub/USBasp.git] / Demos / Host / Incomplete / BluetoothHost / Lib / BluetoothACLPackets.c
index 68a02d4..15b9821 100644 (file)
@@ -1,21 +1,21 @@
 /*
              LUFA Library
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2010.
-              
+     Copyright (C) Dean Camera, 2012.
+
   dean [at] fourwalledcubicle [dot] com
   dean [at] fourwalledcubicle [dot] com
-      www.fourwalledcubicle.com
+           www.lufa-lib.org
 */
 
 /*
 */
 
 /*
-  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2012  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
 
-  Permission to use, copy, modify, distribute, and sell this 
+  Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
   software and its documentation for any purpose is hereby granted
-  without fee, provided that the above copyright notice appear in 
+  without fee, provided that the above copyright notice appear in
   all copies and that both that the copyright notice and this
   all copies and that both that the copyright notice and this
-  permission notice and warranty disclaimer appear in supporting 
-  documentation, and that the name of the author not be used in 
-  advertising or publicity pertaining to distribution of the 
+  permission notice and warranty disclaimer appear in supporting
+  documentation, and that the name of the author not be used in
+  advertising or publicity pertaining to distribution of the
   software without specific, written prior permission.
 
   The author disclaim all warranties with regard to this
   software without specific, written prior permission.
 
   The author disclaim all warranties with regard to this
@@ -50,14 +50,14 @@ void Bluetooth_ACLTask(void)
 {
        /* Process incoming ACL packets, if any */
        Bluetooth_ProcessIncomingACLPackets();
 {
        /* Process incoming ACL packets, if any */
        Bluetooth_ProcessIncomingACLPackets();
-       
+
        /* Check for any half-open channels, send configuration details to the remote device if found */
        for (uint8_t i = 0; i < BLUETOOTH_MAX_OPEN_CHANNELS; i++)
        {
                Bluetooth_Channel_t* ChannelData = &Bluetooth_Connection.Channels[i];
        /* Check for any half-open channels, send configuration details to the remote device if found */
        for (uint8_t i = 0; i < BLUETOOTH_MAX_OPEN_CHANNELS; i++)
        {
                Bluetooth_Channel_t* ChannelData = &Bluetooth_Connection.Channels[i];
-       
+
                bool MustSendConfigReq = true;
                bool MustSendConfigReq = true;
-       
+
                /* Check if we are in a channel state which requires a configuration request to be sent */
                switch (ChannelData->State)
                {
                /* Check if we are in a channel state which requires a configuration request to be sent */
                switch (ChannelData->State)
                {
@@ -71,7 +71,7 @@ void Bluetooth_ACLTask(void)
                                MustSendConfigReq  = false;
                                break;
                }
                                MustSendConfigReq  = false;
                                break;
                }
-               
+
                /* Only send a configuration request if it the channel was in a state which required it */
                if (MustSendConfigReq)
                {
                /* Only send a configuration request if it the channel was in a state which required it */
                if (MustSendConfigReq)
                {
@@ -79,14 +79,14 @@ void Bluetooth_ACLTask(void)
                        {
                                BT_Signal_Header_t           SignalCommandHeader;
                                BT_Signal_ConfigurationReq_t ConfigurationRequest;
                        {
                                BT_Signal_Header_t           SignalCommandHeader;
                                BT_Signal_ConfigurationReq_t ConfigurationRequest;
-                               
+
                                struct
                                {
                                        BT_Config_Option_Header_t Header;
                                        uint16_t Value;
                                } Option_LocalMTU;
                        } PacketData;
                                struct
                                {
                                        BT_Config_Option_Header_t Header;
                                        uint16_t Value;
                                } Option_LocalMTU;
                        } PacketData;
-                       
+
                        /* Fill out the Signal Command header in the response packet */
                        PacketData.SignalCommandHeader.Code            = BT_SIGNAL_CONFIGURATION_REQUEST;
                        PacketData.SignalCommandHeader.Identifier      = ++Bluetooth_Connection.SignalingIdentifier;
                        /* Fill out the Signal Command header in the response packet */
                        PacketData.SignalCommandHeader.Code            = BT_SIGNAL_CONFIGURATION_REQUEST;
                        PacketData.SignalCommandHeader.Identifier      = ++Bluetooth_Connection.SignalingIdentifier;
@@ -101,7 +101,7 @@ void Bluetooth_ACLTask(void)
                        PacketData.Option_LocalMTU.Value               = ChannelData->LocalMTU;
 
                        Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL);
                        PacketData.Option_LocalMTU.Value               = ChannelData->LocalMTU;
 
                        Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL);
-                       
+
                        BT_ACL_DEBUG(1, ">> L2CAP Configuration Request");
                        BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", PacketData.ConfigurationRequest.DestinationChannel);
                }
                        BT_ACL_DEBUG(1, ">> L2CAP Configuration Request");
                        BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", PacketData.ConfigurationRequest.DestinationChannel);
                }
@@ -119,16 +119,16 @@ static void Bluetooth_ProcessIncomingACLPackets(void)
 
        Pipe_SelectPipe(BLUETOOTH_DATA_IN_PIPE);
        Pipe_Unfreeze();
 
        Pipe_SelectPipe(BLUETOOTH_DATA_IN_PIPE);
        Pipe_Unfreeze();
-       
+
        if (!(Pipe_IsReadWriteAllowed()))
        {
                Pipe_Freeze();
                return;
        }
        if (!(Pipe_IsReadWriteAllowed()))
        {
                Pipe_Freeze();
                return;
        }
-         
+
        /* Read in the received ACL packet headers when it has been discovered that a packet has been received */
        /* Read in the received ACL packet headers when it has been discovered that a packet has been received */
-       Pipe_Read_Stream_LE(&ACLPacketHeader, sizeof(ACLPacketHeader));
-       Pipe_Read_Stream_LE(&DataHeader, sizeof(DataHeader));
+       Pipe_Read_Stream_LE(&ACLPacketHeader, sizeof(ACLPacketHeader), NULL);
+       Pipe_Read_Stream_LE(&DataHeader, sizeof(DataHeader), NULL);
 
        BT_ACL_DEBUG(2, "");
        BT_ACL_DEBUG(2, "Packet Received");
 
        BT_ACL_DEBUG(2, "");
        BT_ACL_DEBUG(2, "Packet Received");
@@ -142,8 +142,8 @@ static void Bluetooth_ProcessIncomingACLPackets(void)
        {
                /* Read in the Signal Command header of the incoming packet */
                BT_Signal_Header_t SignalCommandHeader;
        {
                /* Read in the Signal Command header of the incoming packet */
                BT_Signal_Header_t SignalCommandHeader;
-               Pipe_Read_Stream_LE(&SignalCommandHeader, sizeof(SignalCommandHeader));
-               
+               Pipe_Read_Stream_LE(&SignalCommandHeader, sizeof(SignalCommandHeader), NULL);
+
                /* Dispatch to the appropriate handler function based on the Signal message code */
                switch (SignalCommandHeader.Code)
                {
                /* Dispatch to the appropriate handler function based on the Signal message code */
                switch (SignalCommandHeader.Code)
                {
@@ -173,20 +173,20 @@ static void Bluetooth_ProcessIncomingACLPackets(void)
                                break;
                        case BT_SIGNAL_COMMAND_REJECT:
                                BT_ACL_DEBUG(1, "<< Command Reject");
                                break;
                        case BT_SIGNAL_COMMAND_REJECT:
                                BT_ACL_DEBUG(1, "<< Command Reject");
-                               
+
                                uint16_t RejectReason;
                                uint16_t RejectReason;
-                               Pipe_Read_Stream_LE(&RejectReason, sizeof(RejectReason));
-                               Pipe_Discard_Stream(ACLPacketHeader.DataLength - sizeof(RejectReason));
+                               Pipe_Read_Stream_LE(&RejectReason, sizeof(RejectReason), NULL);
+                               Pipe_Discard_Stream(ACLPacketHeader.DataLength - sizeof(RejectReason), NULL);
                                Pipe_ClearIN();
                                Pipe_ClearIN();
-                               Pipe_Freeze();                          
-                       
+                               Pipe_Freeze();
+
                                BT_ACL_DEBUG(2, "-- Reason: %d", RejectReason);
                                break;
                        default:
                                BT_ACL_DEBUG(1, "<< Unknown Signaling Command 0x%02X", SignalCommandHeader.Code);
                                BT_ACL_DEBUG(2, "-- Reason: %d", RejectReason);
                                break;
                        default:
                                BT_ACL_DEBUG(1, "<< Unknown Signaling Command 0x%02X", SignalCommandHeader.Code);
-       
-                               Pipe_Discard_Stream(ACLPacketHeader.DataLength);
-                               Pipe_ClearIN();         
+
+                               Pipe_Discard_Stream(ACLPacketHeader.DataLength, NULL);
+                               Pipe_ClearIN();
                                Pipe_Freeze();
                                break;
                }
                                Pipe_Freeze();
                                break;
                }
@@ -195,10 +195,10 @@ static void Bluetooth_ProcessIncomingACLPackets(void)
        {
                /* Non-signaling packet received, read in the packet contents and pass to the user application */
                uint8_t PacketData[DataHeader.PayloadLength];
        {
                /* Non-signaling packet received, read in the packet contents and pass to the user application */
                uint8_t PacketData[DataHeader.PayloadLength];
-               Pipe_Read_Stream_LE(PacketData, DataHeader.PayloadLength);
+               Pipe_Read_Stream_LE(PacketData, DataHeader.PayloadLength, NULL);
                Pipe_ClearIN();
                Pipe_Freeze();
                Pipe_ClearIN();
                Pipe_Freeze();
-       
+
                Bluetooth_PacketReceived(PacketData, DataHeader.PayloadLength,
                                         Bluetooth_GetChannelData(DataHeader.DestinationChannel, CHANNEL_SEARCH_LOCALNUMBER));
        }
                Bluetooth_PacketReceived(PacketData, DataHeader.PayloadLength,
                                         Bluetooth_GetChannelData(DataHeader.DestinationChannel, CHANNEL_SEARCH_LOCALNUMBER));
        }
@@ -207,11 +207,12 @@ static void Bluetooth_ProcessIncomingACLPackets(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
 /** 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
+ *  \param[in] SearchKey    Key to search within the channel structure, a \c CHANNEL_SEARCH_* mask
  *
  *  \return Pointer to the matching channel information structure in the channel table if found, NULL otherwise
  */
  *
  *  \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)
+Bluetooth_Channel_t* Bluetooth_GetChannelData(const uint16_t SearchValue,
+                                              const uint8_t SearchKey)
 {
        for (uint8_t i = 0; i < BLUETOOTH_MAX_OPEN_CHANNELS; i++)
        {
 {
        for (uint8_t i = 0; i < BLUETOOTH_MAX_OPEN_CHANNELS; i++)
        {
@@ -220,9 +221,9 @@ Bluetooth_Channel_t* Bluetooth_GetChannelData(const uint16_t SearchValue, const
                /* Closed channels should be ignored as they are not considered valid data */
                if (ChannelData->State == BT_Channel_Closed)
                  continue;
                /* Closed channels should be ignored as they are not considered valid data */
                if (ChannelData->State == BT_Channel_Closed)
                  continue;
-       
+
                bool FoundMatch = false;
                bool FoundMatch = false;
-               
+
                /* Search the current channel for the search key to see if it matches */
                switch (SearchKey)
                {
                /* Search the current channel for the search key to see if it matches */
                switch (SearchKey)
                {
@@ -236,7 +237,7 @@ Bluetooth_Channel_t* Bluetooth_GetChannelData(const uint16_t SearchValue, const
                                FoundMatch = (SearchValue == ChannelData->PSM);
                                break;
                }
                                FoundMatch = (SearchValue == ChannelData->PSM);
                                break;
                }
-       
+
                if (FoundMatch)
                  return ChannelData;
        }
                if (FoundMatch)
                  return ChannelData;
        }
@@ -253,7 +254,9 @@ Bluetooth_Channel_t* Bluetooth_GetChannelData(const uint16_t SearchValue, const
  *
  * \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 ACLChannel)
+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;
@@ -278,13 +281,13 @@ uint8_t Bluetooth_SendPacket(void* Data, const uint16_t DataLen, Bluetooth_Chann
        Pipe_Unfreeze();
 
        /* Write the packet contents to the pipe so that it can be sent to the remote device */
        Pipe_Unfreeze();
 
        /* Write the packet contents to the pipe so that it can be sent to the remote device */
-       Pipe_Write_Stream_LE(&ACLPacketHeader, sizeof(ACLPacketHeader));
-       Pipe_Write_Stream_LE(&DataHeader, sizeof(DataHeader));
-       Pipe_Write_Stream_LE(Data, DataLen);
+       Pipe_Write_Stream_LE(&ACLPacketHeader, sizeof(ACLPacketHeader), NULL);
+       Pipe_Write_Stream_LE(&DataHeader, sizeof(DataHeader), NULL);
+       Pipe_Write_Stream_LE(Data, DataLen, NULL);
        Pipe_ClearOUT();
        Pipe_ClearOUT();
-       
+
        Pipe_Freeze();
        Pipe_Freeze();
-       
+
        BT_ACL_DEBUG(2, "");
        BT_ACL_DEBUG(2, "Packet Sent");
        BT_ACL_DEBUG(2, "-- Connection Handle: 0x%04X", (ACLPacketHeader.ConnectionHandle & 0x0FFF));
        BT_ACL_DEBUG(2, "");
        BT_ACL_DEBUG(2, "Packet Sent");
        BT_ACL_DEBUG(2, "-- Connection Handle: 0x%04X", (ACLPacketHeader.ConnectionHandle & 0x0FFF));
@@ -316,7 +319,7 @@ Bluetooth_Channel_t* Bluetooth_OpenChannel(const uint16_t PSM)
                if (Bluetooth_Connection.Channels[i].State == BT_Channel_Closed)
                {
                        ChannelData = &Bluetooth_Connection.Channels[i];
                if (Bluetooth_Connection.Channels[i].State == BT_Channel_Closed)
                {
                        ChannelData = &Bluetooth_Connection.Channels[i];
-                       
+
                        /* Set the new channel structure's local channel number to a unique value within the connection orientated
                           channel address space */
                        ChannelData->LocalNumber = (BT_CHANNELNUMBER_BASEOFFSET + i);
                        /* Set the new channel structure's local channel number to a unique value within the connection orientated
                           channel address space */
                        ChannelData->LocalNumber = (BT_CHANNELNUMBER_BASEOFFSET + i);
@@ -333,7 +336,7 @@ Bluetooth_Channel_t* Bluetooth_OpenChannel(const uint16_t PSM)
        ChannelData->PSM          = PSM;
        ChannelData->LocalMTU     = MAXIMUM_CHANNEL_MTU;
        ChannelData->State        = BT_Channel_WaitConnectRsp;
        ChannelData->PSM          = PSM;
        ChannelData->LocalMTU     = MAXIMUM_CHANNEL_MTU;
        ChannelData->State        = BT_Channel_WaitConnectRsp;
-         
+
        struct
        {
                BT_Signal_Header_t        SignalCommandHeader;
        struct
        {
                BT_Signal_Header_t        SignalCommandHeader;
@@ -344,11 +347,11 @@ Bluetooth_Channel_t* Bluetooth_OpenChannel(const uint16_t PSM)
        PacketData.SignalCommandHeader.Code              = BT_SIGNAL_CONNECTION_REQUEST;
        PacketData.SignalCommandHeader.Identifier        = ++Bluetooth_Connection.SignalingIdentifier;
        PacketData.SignalCommandHeader.Length            = sizeof(PacketData.ConnectionRequest);
        PacketData.SignalCommandHeader.Code              = BT_SIGNAL_CONNECTION_REQUEST;
        PacketData.SignalCommandHeader.Identifier        = ++Bluetooth_Connection.SignalingIdentifier;
        PacketData.SignalCommandHeader.Length            = sizeof(PacketData.ConnectionRequest);
-       
+
        /* Fill out the Connection Request in the response packet */
        PacketData.ConnectionRequest.PSM                 = PSM;
        PacketData.ConnectionRequest.SourceChannel       = ChannelData->LocalNumber;
        /* Fill out the Connection Request in the response packet */
        PacketData.ConnectionRequest.PSM                 = PSM;
        PacketData.ConnectionRequest.SourceChannel       = ChannelData->LocalNumber;
-       
+
        Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL);
 
        BT_ACL_DEBUG(1, ">> L2CAP Connection Request");
        Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL);
 
        BT_ACL_DEBUG(1, ">> L2CAP Connection Request");
@@ -382,7 +385,7 @@ void Bluetooth_CloseChannel(Bluetooth_Channel_t* const ACLChannel)
                BT_Signal_Header_t           SignalCommandHeader;
                BT_Signal_DisconnectionReq_t DisconnectionRequest;
        } PacketData;
                BT_Signal_Header_t           SignalCommandHeader;
                BT_Signal_DisconnectionReq_t DisconnectionRequest;
        } PacketData;
-       
+
        /* Fill out the Signal Command header in the response packet */
        PacketData.SignalCommandHeader.Code            = BT_SIGNAL_DISCONNECTION_REQUEST;
        PacketData.SignalCommandHeader.Identifier      = ++Bluetooth_Connection.SignalingIdentifier;
        /* Fill out the Signal Command header in the response packet */
        PacketData.SignalCommandHeader.Code            = BT_SIGNAL_DISCONNECTION_REQUEST;
        PacketData.SignalCommandHeader.Identifier      = ++Bluetooth_Connection.SignalingIdentifier;
@@ -393,10 +396,10 @@ void Bluetooth_CloseChannel(Bluetooth_Channel_t* const ACLChannel)
        PacketData.DisconnectionRequest.SourceChannel      = ACLChannel->LocalNumber;
 
        Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL);
        PacketData.DisconnectionRequest.SourceChannel      = ACLChannel->LocalNumber;
 
        Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL);
-       
+
        BT_ACL_DEBUG(1, ">> L2CAP Disconnection Request");
        BT_ACL_DEBUG(1, ">> L2CAP Disconnection Request");
-       BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", PacketData.DisconnectionRequest.DestinationChannel);  
-       BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", PacketData.DisconnectionRequest.SourceChannel);    
+       BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", PacketData.DisconnectionRequest.DestinationChannel);
+       BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", PacketData.DisconnectionRequest.SourceChannel);
 }
 
 /** Internal Bluetooth stack Signal Command processing routine for a Connection Request command.
 }
 
 /** Internal Bluetooth stack Signal Command processing routine for a Connection Request command.
@@ -406,12 +409,12 @@ void Bluetooth_CloseChannel(Bluetooth_Channel_t* const ACLChannel)
 static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* const SignalCommandHeader)
 {
        BT_Signal_ConnectionReq_t ConnectionRequest;
 static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* const SignalCommandHeader)
 {
        BT_Signal_ConnectionReq_t ConnectionRequest;
-       
-       Pipe_Read_Stream_LE(&ConnectionRequest, sizeof(ConnectionRequest));
+
+       Pipe_Read_Stream_LE(&ConnectionRequest, sizeof(ConnectionRequest), NULL);
 
        Pipe_ClearIN();
        Pipe_Freeze();
 
        Pipe_ClearIN();
        Pipe_Freeze();
-       
+
        BT_ACL_DEBUG(1, "<< L2CAP Connection Request");
        BT_ACL_DEBUG(2, "-- PSM: 0x%04X", ConnectionRequest.PSM);
        BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionRequest.SourceChannel);
        BT_ACL_DEBUG(1, "<< L2CAP Connection Request");
        BT_ACL_DEBUG(2, "-- PSM: 0x%04X", ConnectionRequest.PSM);
        BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionRequest.SourceChannel);
@@ -436,7 +439,7 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons
                        }
                }
        }
                        }
                }
        }
-       
+
        uint8_t ChannelStatus = BT_CONNECTION_REFUSED_RESOURCES;
 
        /* Reset the channel item contents only if a channel entry was found for it */
        uint8_t ChannelStatus = BT_CONNECTION_REFUSED_RESOURCES;
 
        /* Reset the channel item contents only if a channel entry was found for it */
@@ -449,15 +452,15 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons
                        ChannelData->PSM          = ConnectionRequest.PSM;
                        ChannelData->LocalMTU     = MAXIMUM_CHANNEL_MTU;
                        ChannelData->State        = BT_Channel_Config_WaitConfig;
                        ChannelData->PSM          = ConnectionRequest.PSM;
                        ChannelData->LocalMTU     = MAXIMUM_CHANNEL_MTU;
                        ChannelData->State        = BT_Channel_Config_WaitConfig;
-                       
+
                        ChannelStatus = BT_CONNECTION_SUCCESSFUL;
                }
                else
                {
                        ChannelStatus = BT_CONNECTION_SUCCESSFUL;
                }
                else
                {
-                       ChannelStatus = BT_CONNECTION_REFUSED_PSM;              
+                       ChannelStatus = BT_CONNECTION_REFUSED_PSM;
                }
        }
                }
        }
-       
+
        struct
        {
                BT_Signal_Header_t         SignalCommandHeader;
        struct
        {
                BT_Signal_Header_t         SignalCommandHeader;
@@ -474,7 +477,7 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons
        ResponsePacket.ConnectionResponse.SourceChannel      = ChannelData->RemoteNumber;
        ResponsePacket.ConnectionResponse.Result             = ChannelStatus;
        ResponsePacket.ConnectionResponse.Status             = 0x00;
        ResponsePacket.ConnectionResponse.SourceChannel      = ChannelData->RemoteNumber;
        ResponsePacket.ConnectionResponse.Result             = ChannelStatus;
        ResponsePacket.ConnectionResponse.Status             = 0x00;
-       
+
        Bluetooth_SendPacket(&ResponsePacket, sizeof(ResponsePacket), NULL);
 
        BT_ACL_DEBUG(1, ">> L2CAP Connection Response");
        Bluetooth_SendPacket(&ResponsePacket, sizeof(ResponsePacket), NULL);
 
        BT_ACL_DEBUG(1, ">> L2CAP Connection Response");
@@ -490,16 +493,16 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons
 static inline void Bluetooth_Signal_ConnectionResp(const BT_Signal_Header_t* const SignalCommandHeader)
 {
        BT_Signal_ConnectionResp_t ConnectionResponse;
 static inline void Bluetooth_Signal_ConnectionResp(const BT_Signal_Header_t* const SignalCommandHeader)
 {
        BT_Signal_ConnectionResp_t ConnectionResponse;
-       
-       Pipe_Read_Stream_LE(&ConnectionResponse, sizeof(ConnectionResponse));
+
+       Pipe_Read_Stream_LE(&ConnectionResponse, sizeof(ConnectionResponse), NULL);
 
        Pipe_ClearIN();
        Pipe_Freeze();
 
        BT_ACL_DEBUG(1, "<< L2CAP Connection Response");
 
        Pipe_ClearIN();
        Pipe_Freeze();
 
        BT_ACL_DEBUG(1, "<< L2CAP Connection Response");
-       BT_ACL_DEBUG(2, "-- Result: 0x%02X", ConnectionResponse.Result);        
-       BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionResponse.SourceChannel); 
-       BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ConnectionResponse.DestinationChannel);       
+       BT_ACL_DEBUG(2, "-- Result: 0x%02X", ConnectionResponse.Result);
+       BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionResponse.SourceChannel);
+       BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ConnectionResponse.DestinationChannel);
 
        /* Search for the referenced channel in the channel information list */
        Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(ConnectionResponse.SourceChannel, CHANNEL_SEARCH_LOCALNUMBER);
 
        /* Search for the referenced channel in the channel information list */
        Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(ConnectionResponse.SourceChannel, CHANNEL_SEARCH_LOCALNUMBER);
@@ -521,13 +524,13 @@ static inline void Bluetooth_Signal_ConnectionResp(const BT_Signal_Header_t* con
 static inline void Bluetooth_Signal_ConfigurationReq(const BT_Signal_Header_t* const SignalCommandHeader)
 {
        BT_Signal_ConfigurationReq_t ConfigurationRequest;
 static inline void Bluetooth_Signal_ConfigurationReq(const BT_Signal_Header_t* const SignalCommandHeader)
 {
        BT_Signal_ConfigurationReq_t ConfigurationRequest;
-       
+
        /* Allocate a buffer large enough to hold the variable number of configuration options in the request */
        uint8_t OptionsLen = (SignalCommandHeader->Length - sizeof(ConfigurationRequest));
        uint8_t Options[OptionsLen];
 
        /* Allocate a buffer large enough to hold the variable number of configuration options in the request */
        uint8_t OptionsLen = (SignalCommandHeader->Length - sizeof(ConfigurationRequest));
        uint8_t Options[OptionsLen];
 
-       Pipe_Read_Stream_LE(&ConfigurationRequest, sizeof(ConfigurationRequest));       
-       Pipe_Read_Stream_LE(&Options, sizeof(Options));
+       Pipe_Read_Stream_LE(&ConfigurationRequest, sizeof(ConfigurationRequest), NULL);
+       Pipe_Read_Stream_LE(&Options, sizeof(Options), NULL);
 
        Pipe_ClearIN();
        Pipe_Freeze();
 
        Pipe_ClearIN();
        Pipe_Freeze();
@@ -551,7 +554,7 @@ static inline void Bluetooth_Signal_ConfigurationReq(const BT_Signal_Header_t* c
 
                        BT_ACL_DEBUG(2, "-- Option Type: 0x%04X", OptionHeader->Type);
                        BT_ACL_DEBUG(2, "-- Option Length: 0x%04X", (sizeof(BT_Config_Option_Header_t) + OptionHeader->Length));
 
                        BT_ACL_DEBUG(2, "-- Option Type: 0x%04X", OptionHeader->Type);
                        BT_ACL_DEBUG(2, "-- Option Length: 0x%04X", (sizeof(BT_Config_Option_Header_t) + OptionHeader->Length));
-                       
+
                        /* Store the remote MTU option's value if present */
                        if (OptionHeader->Type == BT_CONFIG_OPTION_MTU)
                          ChannelData->RemoteMTU = *((uint16_t*)OptionData);
                        /* Store the remote MTU option's value if present */
                        if (OptionHeader->Type == BT_CONFIG_OPTION_MTU)
                          ChannelData->RemoteMTU = *((uint16_t*)OptionData);
@@ -560,7 +563,7 @@ static inline void Bluetooth_Signal_ConfigurationReq(const BT_Signal_Header_t* c
                        OptionPos += (sizeof(BT_Config_Option_Header_t) + OptionHeader->Length);
                }
        }
                        OptionPos += (sizeof(BT_Config_Option_Header_t) + OptionHeader->Length);
                }
        }
-       
+
        struct
        {
                BT_Signal_Header_t            SignalCommandHeader;
        struct
        {
                BT_Signal_Header_t            SignalCommandHeader;
@@ -609,18 +612,18 @@ static inline void Bluetooth_Signal_ConfigurationResp(const BT_Signal_Header_t*
 {
        BT_Signal_ConfigurationResp_t ConfigurationResponse;
 
 {
        BT_Signal_ConfigurationResp_t ConfigurationResponse;
 
-       Pipe_Read_Stream_LE(&ConfigurationResponse, sizeof(ConfigurationResponse));
+       Pipe_Read_Stream_LE(&ConfigurationResponse, sizeof(ConfigurationResponse), NULL);
 
        Pipe_ClearIN();
        Pipe_Freeze();
 
        Pipe_ClearIN();
        Pipe_Freeze();
-       
+
        BT_ACL_DEBUG(1, "<< L2CAP Configuration Response");
        BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConfigurationResponse.SourceChannel);
        BT_ACL_DEBUG(2, "-- Result: 0x%02X", ConfigurationResponse.Result);
 
        /* Search for the referenced channel in the channel information list */
        Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(ConfigurationResponse.SourceChannel, CHANNEL_SEARCH_REMOTENUMBER);
        BT_ACL_DEBUG(1, "<< L2CAP Configuration Response");
        BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConfigurationResponse.SourceChannel);
        BT_ACL_DEBUG(2, "-- Result: 0x%02X", ConfigurationResponse.Result);
 
        /* Search for the referenced channel in the channel information list */
        Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(ConfigurationResponse.SourceChannel, CHANNEL_SEARCH_REMOTENUMBER);
-       
+
        /* Only update the channel's state if it was found in the channel list */
        if (ChannelData != NULL)
        {
        /* Only update the channel's state if it was found in the channel list */
        if (ChannelData != NULL)
        {
@@ -636,7 +639,7 @@ static inline void Bluetooth_Signal_ConfigurationResp(const BT_Signal_Header_t*
                                        ChannelData->State = BT_Channel_Open;
                                        Bluetooth_ChannelOpened(ChannelData);
                                        break;
                                        ChannelData->State = BT_Channel_Open;
                                        Bluetooth_ChannelOpened(ChannelData);
                                        break;
-                       }       
+                       }
                }
                else
                {
                }
                else
                {
@@ -653,16 +656,16 @@ static inline void Bluetooth_Signal_ConfigurationResp(const BT_Signal_Header_t*
 static inline void Bluetooth_Signal_DisconnectionReq(const BT_Signal_Header_t* const SignalCommandHeader)
 {
        BT_Signal_DisconnectionReq_t DisconnectionRequest;
 static inline void Bluetooth_Signal_DisconnectionReq(const BT_Signal_Header_t* const SignalCommandHeader)
 {
        BT_Signal_DisconnectionReq_t DisconnectionRequest;
-       
-       Pipe_Read_Stream_LE(&DisconnectionRequest, sizeof(DisconnectionRequest));
+
+       Pipe_Read_Stream_LE(&DisconnectionRequest, sizeof(DisconnectionRequest), NULL);
 
        BT_ACL_DEBUG(1, "<< L2CAP Disconnection Request");
        BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DisconnectionRequest.DestinationChannel);
        BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", DisconnectionRequest.SourceChannel);
 
        BT_ACL_DEBUG(1, "<< L2CAP Disconnection Request");
        BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DisconnectionRequest.DestinationChannel);
        BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", DisconnectionRequest.SourceChannel);
-       
+
        Pipe_ClearIN();
        Pipe_Freeze();
        Pipe_ClearIN();
        Pipe_Freeze();
-       
+
        /* Search for the referenced channel in the channel information list */
        Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(DisconnectionRequest.SourceChannel, CHANNEL_SEARCH_REMOTENUMBER);
 
        /* Search for the referenced channel in the channel information list */
        Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(DisconnectionRequest.SourceChannel, CHANNEL_SEARCH_REMOTENUMBER);
 
@@ -699,20 +702,20 @@ static inline void Bluetooth_Signal_DisconnectionReq(const BT_Signal_Header_t* c
 static inline void Bluetooth_Signal_DisconnectionResp(const BT_Signal_Header_t* const SignalCommandHeader)
 {
        BT_Signal_DisconnectionResp_t DisconnectionResponse;
 static inline void Bluetooth_Signal_DisconnectionResp(const BT_Signal_Header_t* const SignalCommandHeader)
 {
        BT_Signal_DisconnectionResp_t DisconnectionResponse;
-       
-       Pipe_Read_Stream_LE(&DisconnectionResponse, sizeof(DisconnectionResponse));
+
+       Pipe_Read_Stream_LE(&DisconnectionResponse, sizeof(DisconnectionResponse), NULL);
 
        BT_ACL_DEBUG(1, "<< L2CAP Disconnection Response");
        BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DisconnectionResponse.DestinationChannel);
        BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", DisconnectionResponse.SourceChannel);
 
        BT_ACL_DEBUG(1, "<< L2CAP Disconnection Response");
        BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DisconnectionResponse.DestinationChannel);
        BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", DisconnectionResponse.SourceChannel);
-       
+
        Pipe_ClearIN();
        Pipe_Freeze();
        Pipe_ClearIN();
        Pipe_Freeze();
-       
+
        /* Search for the referenced channel in the channel information list */
        Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(DisconnectionResponse.SourceChannel, CHANNEL_SEARCH_REMOTENUMBER);
        /* Search for the referenced channel in the channel information list */
        Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(DisconnectionResponse.SourceChannel, CHANNEL_SEARCH_REMOTENUMBER);
-       
-       /* If the channel was found in the channel list, close it */    
+
+       /* If the channel was found in the channel list, close it */
        if (ChannelData != NULL)
          ChannelData->State = BT_Channel_Closed;
 }
        if (ChannelData != NULL)
          ChannelData->State = BT_Channel_Closed;
 }
@@ -724,10 +727,10 @@ static inline void Bluetooth_Signal_DisconnectionResp(const BT_Signal_Header_t*
 static inline void Bluetooth_Signal_EchoReq(const BT_Signal_Header_t* const SignalCommandHeader)
 {
        BT_ACL_DEBUG(1, "<< L2CAP Echo Request");
 static inline void Bluetooth_Signal_EchoReq(const BT_Signal_Header_t* const SignalCommandHeader)
 {
        BT_ACL_DEBUG(1, "<< L2CAP Echo Request");
-       
+
        Pipe_ClearIN();
        Pipe_Freeze();
        Pipe_ClearIN();
        Pipe_Freeze();
-       
+
        struct
        {
                BT_Signal_Header_t SignalCommandHeader;
        struct
        {
                BT_Signal_Header_t SignalCommandHeader;
@@ -737,7 +740,7 @@ static inline void Bluetooth_Signal_EchoReq(const BT_Signal_Header_t* const Sign
        ResponsePacket.SignalCommandHeader.Code                 = BT_SIGNAL_ECHO_RESPONSE;
        ResponsePacket.SignalCommandHeader.Identifier           = SignalCommandHeader->Identifier;
        ResponsePacket.SignalCommandHeader.Length               = 0;
        ResponsePacket.SignalCommandHeader.Code                 = BT_SIGNAL_ECHO_RESPONSE;
        ResponsePacket.SignalCommandHeader.Identifier           = SignalCommandHeader->Identifier;
        ResponsePacket.SignalCommandHeader.Length               = 0;
-       
+
        Bluetooth_SendPacket(&ResponsePacket, sizeof(ResponsePacket), NULL);
 
        BT_ACL_DEBUG(1, ">> L2CAP Echo Response");
        Bluetooth_SendPacket(&ResponsePacket, sizeof(ResponsePacket), NULL);
 
        BT_ACL_DEBUG(1, ">> L2CAP Echo Response");
@@ -751,11 +754,11 @@ static inline void Bluetooth_Signal_InformationReq(const BT_Signal_Header_t* con
 {
        BT_Signal_InformationReq_t InformationRequest;
 
 {
        BT_Signal_InformationReq_t InformationRequest;
 
-       Pipe_Read_Stream_LE(&InformationRequest, sizeof(InformationRequest));
+       Pipe_Read_Stream_LE(&InformationRequest, sizeof(InformationRequest), NULL);
 
        BT_ACL_DEBUG(1, "<< L2CAP Information Request");
        BT_ACL_DEBUG(2, "-- Info Type: 0x%04X", InformationRequest.InfoType);
 
        BT_ACL_DEBUG(1, "<< L2CAP Information Request");
        BT_ACL_DEBUG(2, "-- Info Type: 0x%04X", InformationRequest.InfoType);
-       
+
        Pipe_ClearIN();
        Pipe_Freeze();
 
        Pipe_ClearIN();
        Pipe_Freeze();
 
@@ -763,25 +766,25 @@ static inline void Bluetooth_Signal_InformationReq(const BT_Signal_Header_t* con
        {
                BT_Signal_Header_t          SignalCommandHeader;
                BT_Signal_InformationResp_t InformationResponse;
        {
                BT_Signal_Header_t          SignalCommandHeader;
                BT_Signal_InformationResp_t InformationResponse;
-               
+
                uint8_t Data[4];
        } ResponsePacket;
                uint8_t Data[4];
        } ResponsePacket;
-       
+
        uint8_t DataLen = 0;
        uint8_t DataLen = 0;
-       
+
        /* Retrieve the requested information and store it in the outgoing packet, if found */
        switch (InformationRequest.InfoType)
        {
        /* Retrieve the requested information and store it in the outgoing packet, if found */
        switch (InformationRequest.InfoType)
        {
-               case BT_INFOREQ_MTU:            
+               case BT_INFOREQ_MTU:
                        ResponsePacket.InformationResponse.Result = BT_INFORMATION_SUCCESSFUL;
                        DataLen = 2;
                        ResponsePacket.InformationResponse.Result = BT_INFORMATION_SUCCESSFUL;
                        DataLen = 2;
-                       
+
                        *((uint16_t*)&ResponsePacket.Data) = MAXIMUM_CHANNEL_MTU;
                        break;
                case BT_INFOREQ_EXTENDEDFEATURES:
                        ResponsePacket.InformationResponse.Result = BT_INFORMATION_SUCCESSFUL;
                        DataLen = 4;
                        *((uint16_t*)&ResponsePacket.Data) = MAXIMUM_CHANNEL_MTU;
                        break;
                case BT_INFOREQ_EXTENDEDFEATURES:
                        ResponsePacket.InformationResponse.Result = BT_INFORMATION_SUCCESSFUL;
                        DataLen = 4;
-                       
+
                        *((uint32_t*)&ResponsePacket.Data) = 0;
                        break;
                default:
                        *((uint32_t*)&ResponsePacket.Data) = 0;
                        break;
                default:
@@ -789,7 +792,7 @@ static inline void Bluetooth_Signal_InformationReq(const BT_Signal_Header_t* con
                        DataLen = 0;
                        break;
        }
                        DataLen = 0;
                        break;
        }
-       
+
        /* Fill out the Signal Command header in the response packet */
        ResponsePacket.SignalCommandHeader.Code                 = BT_SIGNAL_INFORMATION_RESPONSE;
        ResponsePacket.SignalCommandHeader.Identifier           = SignalCommandHeader->Identifier;
        /* Fill out the Signal Command header in the response packet */
        ResponsePacket.SignalCommandHeader.Code                 = BT_SIGNAL_INFORMATION_RESPONSE;
        ResponsePacket.SignalCommandHeader.Identifier           = SignalCommandHeader->Identifier;
@@ -797,9 +800,10 @@ static inline void Bluetooth_Signal_InformationReq(const BT_Signal_Header_t* con
 
        /* Fill out the Information Response in the response packet */
        ResponsePacket.InformationResponse.InfoType = InformationRequest.InfoType;
 
        /* Fill out the Information Response in the response packet */
        ResponsePacket.InformationResponse.InfoType = InformationRequest.InfoType;
-       
+
        Bluetooth_SendPacket(&ResponsePacket, (sizeof(ResponsePacket) - sizeof(ResponsePacket.Data) + DataLen), NULL);
 
        Bluetooth_SendPacket(&ResponsePacket, (sizeof(ResponsePacket) - sizeof(ResponsePacket.Data) + DataLen), NULL);
 
-       BT_ACL_DEBUG(1, ">> L2CAP Information Response");       
+       BT_ACL_DEBUG(1, ">> L2CAP Information Response");
        BT_ACL_DEBUG(2, "-- Result: 0x%02X", ResponsePacket.InformationResponse.Result);
 }
        BT_ACL_DEBUG(2, "-- Result: 0x%02X", ResponsePacket.InformationResponse.Result);
 }
+