+/** Bluetooth ACL processing task. This task should be called repeatedly the main Bluetooth\r
+ * stack task to manage the ACL processing state.\r
+ */\r
+void Bluetooth_ACLTask(void)\r
+{\r
+ /* Process incomming ACL packets, if any */\r
+ Bluetooth_ProcessIncommingACLPackets();\r
+ \r
+ /* Check for any half-open channels, send configuration details to the remote device if found */\r
+ for (uint8_t i = 0; i < BLUETOOTH_MAX_OPEN_CHANNELS; i++)\r
+ {\r
+ Bluetooth_Channel_t* ChannelData = &Bluetooth_Connection.Channels[i];\r
+ \r
+ bool MustSendConfigReq = true;\r
+ \r
+ /* Check if we are in a channel state which requires a configuration request to be sent */\r
+ switch (ChannelData->State)\r
+ {\r
+ case Channel_Config_WaitConfig:\r
+ ChannelData->State = Channel_Config_WaitReqResp;\r
+ break;\r
+ case Channel_Config_WaitSendConfig:\r
+ ChannelData->State = Channel_Config_WaitResp;\r
+ break;\r
+ default:\r
+ MustSendConfigReq = false;\r
+ break;\r
+ }\r
+ \r
+ /* Only send a configuration request if it the channel was in a state which required it */\r
+ if (MustSendConfigReq)\r
+ {\r
+ struct\r
+ {\r
+ BT_Signal_Header_t SignalCommandHeader;\r
+ BT_Signal_ConfigurationReq_t ConfigurationRequest;\r
+ \r
+ struct\r
+ {\r
+ BT_Config_Option_Header_t Header;\r
+ uint16_t Value;\r
+ } Option_LocalMTU;\r
+ } PacketData;\r
+ \r
+ /* Fill out the Signal Command header in the response packet */\r
+ PacketData.SignalCommandHeader.Code = BT_SIGNAL_CONFIGURATION_REQUEST;\r
+ PacketData.SignalCommandHeader.Identifier = ++Bluetooth_Connection.SignallingIdentifier;\r
+ PacketData.SignalCommandHeader.Length = sizeof(PacketData.ConfigurationRequest) +\r
+ sizeof(PacketData.Option_LocalMTU);\r
+\r
+ /* Fill out the Configuration Request in the response packet, including local MTU information */\r
+ PacketData.ConfigurationRequest.DestinationChannel = ChannelData->RemoteNumber;\r
+ PacketData.ConfigurationRequest.Flags = 0;\r
+ PacketData.Option_LocalMTU.Header.Type = BT_CONFIG_OPTION_MTU;\r
+ PacketData.Option_LocalMTU.Header.Length = sizeof(PacketData.Option_LocalMTU.Value);\r
+ PacketData.Option_LocalMTU.Value = ChannelData->LocalMTU;\r
+\r
+ Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL);\r
+ \r
+ BT_ACL_DEBUG(1, ">> L2CAP Configuration Request", NULL);\r
+ BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", PacketData.ConfigurationRequest.DestinationChannel);\r
+ }\r
+ }\r
+}\r
+\r
+/** Incomming ACL packet processing task. This task is called by the main ACL processing task to read in and process\r
+ * any incomming ACL packets to the device, handling signal requests as they are received or passing along channel\r
+ * data to the user application.\r
+ */\r
+static void Bluetooth_ProcessIncommingACLPackets(void)\r