aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-06-26 15:07:13 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-06-26 15:07:13 +0000
commitb6565404685fbac1698d256823abdbdb3d3ddaff (patch)
tree441d18429db23b2b4235122071de8a347fa69e4a /Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c
parentd29a408ffd906b537bcdce2a0cd98827ea5c27e3 (diff)
downloadlufa-b6565404685fbac1698d256823abdbdb3d3ddaff.tar.gz
lufa-b6565404685fbac1698d256823abdbdb3d3ddaff.tar.bz2
lufa-b6565404685fbac1698d256823abdbdb3d3ddaff.zip
Make Bluetooth ACL channel searches skip over closed (invalid) channels. RFCOMM channels are considered invalid when the channel state is closed, not when the DLCI is zero - fix incorrect code.
Diffstat (limited to 'Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c')
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c
index 7c39cb028..c7b3e8d8d 100644
--- a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c
+++ b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c
@@ -111,7 +111,7 @@ RFCOMM_Channel_t* RFCOMM_GetChannelData(const uint8_t DLCI)
RFCOMM_Channel_t* CurrRFCOMMChannel = &RFCOMM_Channels[i];
/* If the current non-closed channel's DLCI matches the search DLCI, return it to the caller */
- if ((CurrRFCOMMChannel->DLCI == DLCI) && (CurrRFCOMMChannel->State != RFCOMM_Channel_Closed))
+ if ((CurrRFCOMMChannel->State != RFCOMM_Channel_Closed) && (CurrRFCOMMChannel->DLCI == DLCI))
return CurrRFCOMMChannel;
}
@@ -192,6 +192,7 @@ static uint8_t RFCOMM_GetFCSValue(const void* FrameStart, uint8_t Length)
{
uint8_t FCS = 0xFF;
+ /* 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]]);
@@ -213,7 +214,7 @@ static void RFCOMM_ProcessDISC(const RFCOMM_Address_t* const FrameAddress, Bluet
/* If the requested channel is currently open, destroy it */
if (RFCOMMChannel != NULL)
- RFCOMMChannel->DLCI = 0x00;
+ 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);
@@ -229,8 +230,8 @@ static void RFCOMM_ProcessSABM(const RFCOMM_Address_t* const FrameAddress, Bluet
{
RFCOMM_Channel_t* CurrRFCOMMChannel = &RFCOMM_Channels[i];
- /* If the channel's DLCI is zero, the channel state entry is free */
- if (!(CurrRFCOMMChannel->DLCI))
+ /* If the channel's state is closed, the channel state entry is free */
+ if (CurrRFCOMMChannel->State == RFCOMM_Channel_Closed)
{
CurrRFCOMMChannel->DLCI = FrameAddress->DLCI;
CurrRFCOMMChannel->State = RFCOMM_Channel_Open;