+\r
+ BT_ACL_DEBUG(1, "<< L2CAP Connection Response", NULL);\r
+ BT_ACL_DEBUG(2, "-- Result: 0x%02X", ConnectionResponse.Result); \r
+ BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionResponse.SourceChannel); \r
+ BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ConnectionResponse.DestinationChannel); \r
+\r
+ /* Search for the referenced channel in the channel information list */\r
+ Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(ConnectionResponse.SourceChannel, false);\r
+\r
+ /* Only progress if the referenced channel data was found */\r
+ if (ChannelData != NULL)\r
+ {\r
+ /* Set the channel structure's remote channel number to the channel allocated on the remote device */\r
+ ChannelData->RemoteNumber = ConnectionResponse.SourceChannel;\r
+ ChannelData->State = (ConnectionResponse.Result == BT_CONNECTION_SUCCESSFUL) ?\r
+ Channel_Config_WaitConfig : Channel_Closed;\r
+ }\r
+}\r
+\r
+/** Internal Bluetooth stack Signal Command processing routine for a Configuration Request command.\r
+ *\r
+ * \param SignalCommandHeader Pointer to the start of the received packet's Signal Command header\r
+ */\r
+static inline void Bluetooth_Signal_ConfigurationReq(BT_Signal_Header_t* SignalCommandHeader)\r
+{\r
+ BT_Signal_ConfigurationReq_t ConfigurationRequest;\r
+ \r
+ /* Allocate a buffer large enough to hold the variable number of configuration options in the request */\r
+ uint8_t OptionsLen = (SignalCommandHeader->Length - sizeof(ConfigurationRequest));\r
+ uint8_t Options[OptionsLen];\r
+\r
+ Pipe_Read_Stream_LE(&ConfigurationRequest, sizeof(ConfigurationRequest)); \r
+ Pipe_Read_Stream_LE(&Options, sizeof(Options));\r
+\r
+ Pipe_ClearIN();\r
+ Pipe_Freeze();\r
+\r
+ /* Search for the referenced channel in the channel information list */\r
+ Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(ConfigurationRequest.DestinationChannel, false);\r
+\r
+ BT_ACL_DEBUG(1, "<< L2CAP Configuration Request", NULL);\r
+ BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ConfigurationRequest.DestinationChannel);\r
+ BT_ACL_DEBUG(2, "-- Remote MTU: 0x%04X", ChannelData->RemoteMTU);\r
+ BT_ACL_DEBUG(2, "-- Options Len: 0x%04X", OptionsLen);\r
+\r
+ /* Only look at the channel configuration options if a valid channel entry for the local channel number was found */\r
+ if (ChannelData != NULL)\r
+ {\r
+ /* Iterate through each option in the configuration request to look for ones which can be processed */\r
+ uint8_t OptionPos = 0;\r
+ while (OptionPos < OptionsLen)\r
+ {\r
+ BT_Config_Option_Header_t* OptionHeader = (BT_Config_Option_Header_t*)&Options[OptionPos];\r
+ void* OptionData = &Options[OptionPos + sizeof(*OptionHeader)];\r
+\r
+ BT_ACL_DEBUG(2, "-- Option Type: 0x%04X", OptionHeader->Type);\r
+ BT_ACL_DEBUG(2, "-- Option Length: 0x%04X", (sizeof(*OptionHeader) + OptionHeader->Length));\r
+ \r
+ /* Store the remote MTU option's value if present */\r
+ if (OptionHeader->Type == BT_CONFIG_OPTION_MTU)\r
+ ChannelData->RemoteMTU = *((uint16_t*)OptionData);\r
+\r
+ /* Progress to the next option in the packet */\r
+ OptionPos += (sizeof(*OptionHeader) + OptionHeader->Length);\r
+ }\r
+ }\r