From 2b0e86243f8fb4554c037d25fe134592b02d1007 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Thu, 8 Jul 2010 08:48:52 +0000 Subject: Add a new RFCOMM_ChannelOpened() callback event for when logical RFCOMM channels are opened in the BluetoothHost demo. Make the demo echo back sent characters to the remote device. --- .../Incomplete/BluetoothHost/BluetoothEvents.c | 25 ++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.c') diff --git a/Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.c b/Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.c index 1b7997adc..5996f30ba 100644 --- a/Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.c +++ b/Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.c @@ -37,11 +37,15 @@ #include "BluetoothEvents.h" -/** Bluetooth RFCOMM channel structure - used to send and receive RFCOMM data between the local and remote - * device once a RFCOMM channel has been opened. +/** Pointer to the opened Bluetooth ACL channel structure for RFCOMM, used to send and receive data between the + * local and remote device once a RFCOMM channel has been opened. */ Bluetooth_Channel_t* RFCOMMChannel = NULL; +/** Pointer to the opened RFCOMM logical channel between local and remote device, once a RFCOMM ACL channel has been + * negotiated and a logical RFCOMM channel requested. + */ +RFCOMM_Channel_t* SerialPortChannel = NULL; /** Bluetooth stack callback event for when the Bluetooth stack has fully initialized using the attached * Bluetooth dongle. @@ -155,15 +159,24 @@ void Bluetooth_PacketReceived(void* Data, uint16_t DataLen, Bluetooth_Channel_t* } } +void RFCOMM_ChannelOpened(RFCOMM_Channel_t* const Channel) +{ + /* Save the serial port RFCOMM logical channel for later use */ + SerialPortChannel = Channel; +} + /** 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 + * \param[in] Channel 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) +void RFCOMM_DataReceived(RFCOMM_Channel_t* const Channel, 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]); + + /* Echo the data back to the sending device */ + RFCOMM_SendData(DataLen, Data, Channel, RFCOMMChannel); } -- cgit v1.2.3