diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2010-07-08 08:05:14 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2010-07-08 08:05:14 +0000 |
commit | c37fd0ef91c58003eab6f3a5461d970ea1a22602 (patch) | |
tree | 3616120a404ffe5229aa5411505b2b769f422bc7 /Demos/Host/Incomplete/BluetoothHost | |
parent | 70983caea5dc6d817c3a887d66a2f43fce535bbd (diff) | |
download | lufa-c37fd0ef91c58003eab6f3a5461d970ea1a22602.tar.gz lufa-c37fd0ef91c58003eab6f3a5461d970ea1a22602.tar.bz2 lufa-c37fd0ef91c58003eab6f3a5461d970ea1a22602.zip |
Add a new RFCOMM service callback for when new data has been received on a valid RFCOMM channel.
Diffstat (limited to 'Demos/Host/Incomplete/BluetoothHost')
-rw-r--r-- | Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.c | 13 | ||||
-rw-r--r-- | Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c | 8 | ||||
-rw-r--r-- | Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h | 2 |
3 files changed, 18 insertions, 5 deletions
diff --git a/Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.c b/Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.c index 17cf7ede4..1b7997adc 100644 --- a/Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.c +++ b/Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.c @@ -154,3 +154,16 @@ void Bluetooth_PacketReceived(void* Data, uint16_t DataLen, Bluetooth_Channel_t* break;
}
}
+
+/** RFCOMM layer callback for when a packet is received on an open RFCOMM channel.
+ *
+ * \param[in] RFCOMMChannel RFCOMM channel that the data was directed to
+ * \param[in] DataLen Length of the received data, in bytes
+ * \param[in] Data Pointer to a buffer where the received data is stored
+ */
+void RFCOMM_DataReceived(RFCOMM_Channel_t* const RFCOMMChannel, uint16_t DataLen, const uint8_t* Data)
+{
+ /* Write the received bytes to the serial port */
+ for (uint8_t i = 0; i < DataLen; i++)
+ putchar(Data[i]);
+}
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c index e0446c0e7..ae4e78328 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c @@ -352,11 +352,9 @@ static void RFCOMM_ProcessUIH(const RFCOMM_Address_t* const FrameAddress, const 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]); + RFCOMM_Channel_t* RFCOMMChannel = RFCOMM_GetChannelData(FrameAddress->DLCI); - printf("\r\n"); + if (RFCOMMChannel != NULL) + RFCOMM_DataReceived(RFCOMMChannel, FrameLength, FrameData); } diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h index e557858f2..d23d63501 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h @@ -107,6 +107,8 @@ void RFCOMM_SendChannelSignals(const RFCOMM_Channel_t* const RFCOMMChannel, Bluetooth_Channel_t* const BluetoothChannel); + void RFCOMM_DataReceived(RFCOMM_Channel_t* const RFCOMMChannel, uint16_t DataLen, const uint8_t* Data); + RFCOMM_Channel_t* RFCOMM_GetFreeChannelEntry(const uint8_t DLCI); RFCOMM_Channel_t* RFCOMM_GetChannelData(const uint8_t DLCI); uint16_t RFCOMM_GetVariableFieldValue(const uint8_t** BufferPos); |