aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-06-15 09:32:35 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-06-15 09:32:35 +0000
commit3125fd5f4fe79b6acc89aea9f51b159db2dfd3ff (patch)
tree816f6c01fc561fb9bdf346c433a1915fc61e737d /Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c
parentdcedde012341a7cfff88c85203e735e99332627e (diff)
downloadlufa-3125fd5f4fe79b6acc89aea9f51b159db2dfd3ff.tar.gz
lufa-3125fd5f4fe79b6acc89aea9f51b159db2dfd3ff.tar.bz2
lufa-3125fd5f4fe79b6acc89aea9f51b159db2dfd3ff.zip
Add RFCOMM channel configuration parsing and channel states to the incomplete BluetoothHost demo.
Add missing BT_* prefix to the Bluetooth stack's channel state enum values.
Diffstat (limited to 'Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c')
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c
index f9aff8eb2..5968a6929 100644
--- a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c
+++ b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c
@@ -70,7 +70,7 @@ void RFCOMM_Initialize(void)
{
/* Reset the RFCOMM channel structures, to invalidate any confiured RFCOMM channels */
for (uint8_t i = 0; i < RFCOMM_MAX_OPEN_CHANNELS; i++)
- RFCOMM_Channels[i].DLCI = 0x00;
+ RFCOMM_Channels[i].State = RFCOMM_Channel_Closed;
}
void RFCOMM_ProcessPacket(void* Data, Bluetooth_Channel_t* const Channel)
@@ -220,8 +220,11 @@ static void RFCOMM_ProcessSABM(const RFCOMM_Address_t* const FrameAddress, Bluet
/* If the channel's DLCI is zero, the channel state entry is free */
if (!(CurrRFCOMMChannel->DLCI))
{
- CurrRFCOMMChannel->DLCI = FrameAddress->DLCI;
- CurrRFCOMMChannel->Configured = false;
+ CurrRFCOMMChannel->DLCI = FrameAddress->DLCI;
+ CurrRFCOMMChannel->State = RFCOMM_Channel_Open;
+ CurrRFCOMMChannel->Priority = 7 + (CurrRFCOMMChannel->DLCI >> 3) + ((CurrRFCOMMChannel->DLCI >> 3) * 7);
+ CurrRFCOMMChannel->UseUIFrames = false;
+ CurrRFCOMMChannel->RemoteMTU = 0xFFFF;
BT_RFCOMM_DEBUG(1, ">> UA Sent");
RFCOMM_SendFrame(FrameAddress->DLCI, true, (RFCOMM_Frame_UA | FRAME_POLL_FINAL), 0, NULL, Channel);
@@ -244,15 +247,20 @@ static void RFCOMM_ProcessUA(const RFCOMM_Address_t* const FrameAddress, Bluetoo
static void RFCOMM_ProcessUIH(const RFCOMM_Address_t* const FrameAddress, const uint16_t FrameLength,
const uint8_t* FrameData, Bluetooth_Channel_t* const Channel)
{
- BT_RFCOMM_DEBUG(1, "<< UIH Received");
- BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", FrameAddress->DLCI);
- BT_RFCOMM_DEBUG(2, "-- Length 0x%02X", FrameLength);
-
if (FrameAddress->DLCI == RFCOMM_CONTROL_DLCI)
{
RFCOMM_ProcessControlCommand(FrameData, Channel);
return;
}
- // TODO: Handle regular channel data here
+ BT_RFCOMM_DEBUG(1, "<< UIH Received");
+ BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", FrameAddress->DLCI);
+ BT_RFCOMM_DEBUG(2, "-- Length 0x%02X", FrameLength);
+
+ puts("RFCOMM Data: ");
+
+ for (uint8_t i = 0; i < FrameLength; i++)
+ printf("0x%02X (%c) ", FrameData[i], FrameData[i]);
+
+ printf("\r\n");
}