+/** Services all the logical RFCOMM channels on the given ACL channel, sending any RFCOMM control requests to
+ * the remote device as needed to establish new logical RFCOMM channels. This function should be called repeatedly
+ * in the main program loop when an ACL channel with an RFCOMM PSM has been established between the local and remote
+ * device.
+ *
+ * \param[in] ACLChannel ACL channel which has been previously opened to handle RFCOMM traffic between devices
+ */
+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];
+
+ if (RFCOMMChannel->State == RFCOMM_Channel_Configure)
+ {
+ /* Check if the local signals have not yet been sent on the current channel */
+ if (!(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, ACLChannel);
+ }
+
+ /* If signals have been configured in both directions, progress to the open state */
+ if ((RFCOMMChannel->ConfigFlags & (RFCOMM_CONFIG_REMOTESIGNALS | RFCOMM_CONFIG_LOCALSIGNALS)) ==
+ (RFCOMM_CONFIG_REMOTESIGNALS | RFCOMM_CONFIG_LOCALSIGNALS))
+ {
+ RFCOMMChannel->State = RFCOMM_Channel_Open;
+ RFCOMM_ChannelOpened(RFCOMMChannel);
+ }
+ }
+ }
+}
+
+/** Processes an incoming RFCOMM packet on an ACL channel which has been previously opened between the local and
+ * a remote device to handle RFCOMM traffic.
+ *
+ * \param[in] Data Incoming packet data containing the RFCOMM packet
+ * \param[in] ACLChannel ACL channel the request was issued to by the remote device
+ */
+void RFCOMM_ProcessPacket(void* Data,
+ Bluetooth_Channel_t* const ACLChannel)