diff options
Diffstat (limited to 'Demos/Host/Incomplete/BluetoothHost/Lib')
4 files changed, 35 insertions, 17 deletions
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c index 17503ea54..c2c990214 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c @@ -91,21 +91,35 @@ void Bluetooth_ProcessACLPackets(void) }
else
{
- uint8_t DataPayload[DataHeader.PayloadLength];
- Pipe_Read_Stream_LE(&DataPayload, sizeof(DataPayload));
- DataHeader.PayloadLength = 0;
+ Bluetooth_PacketReceived(&DataHeader.PayloadLength, Bluetooth_GetChannelData(DataHeader.DestinationChannel, true));
- BT_ACL_DEBUG("-- Data Payload: ", NULL);
- for (uint16_t B = 0; B < sizeof(DataPayload); B++)
- printf("0x%02X ", DataPayload[B]);
- printf("\r\n");
-
- Pipe_Discard_Stream(ACLPacketHeader.DataLength);
- Pipe_ClearIN();
+ Pipe_SelectPipe(BLUETOOTH_DATA_IN_PIPE);
+ Pipe_Discard_Stream(DataHeader.PayloadLength);
+ Pipe_ClearIN();
Pipe_Freeze();
}
}
+void Bluetooth_SendPacket(uint8_t* Data, uint16_t DataLen, Bluetooth_Channel_t* Channel)
+{
+ Bluetooth_ACL_Header_t ACLPacketHeader;
+ Bluetooth_DataPacket_Header_t DataHeader;
+
+ ACLPacketHeader.ConnectionHandle = Bluetooth_Connection.ConnectionHandle;
+ ACLPacketHeader.DataLength = sizeof(DataHeader) + DataLen;
+ DataHeader.PayloadLength = DataLen;
+ DataHeader.DestinationChannel = Channel->RemoteNumber;
+
+ Pipe_SelectPipe(BLUETOOTH_DATA_OUT_PIPE);
+ Pipe_Unfreeze();
+
+ Pipe_Write_Stream_LE(&ACLPacketHeader, sizeof(ACLPacketHeader));
+ Pipe_Write_Stream_LE(&DataHeader, sizeof(DataHeader));
+ Pipe_Write_Stream_LE(Data, DataLen);
+
+ Pipe_Freeze();
+}
+
static inline void Bluetooth_SignalPacket_ConnectionRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,
Bluetooth_DataPacket_Header_t* DataHeader,
Bluetooth_SignalCommand_Header_t* SignalCommandHeader)
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h index 46d323f00..f6f8f769d 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h @@ -143,7 +143,8 @@ /* Function Prototypes: */
void Bluetooth_ProcessACLPackets(void);
-
+ void Bluetooth_SendPacket(uint8_t* Data, uint16_t DataLen, Bluetooth_Channel_t* Channel);
+
#if defined(INCLUDE_FROM_BLUETOOTH_ACLPACKETS_C)
static inline void Bluetooth_SignalPacket_ConnectionRequest(Bluetooth_ACL_Header_t* ACLPacketHeader,
Bluetooth_DataPacket_Header_t* DataHeader,
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.h b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.h index 2295e558c..f64bba016 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.h @@ -190,10 +190,6 @@ /* Function Prototypes: */
void Bluetooth_ProcessHCICommands(void);
void Bluetooth_ProcessHCIEvents(void);
-
- bool Bluetooth_ConnectionRequest(uint8_t* RemoteAddress);
- void Bluetooth_ConnectionComplete(void);
- void Bluetooth_DisconnectionComplete(void);
#if defined(INCLUDE_FROM_BLUETOOTHHCICOMMANDS_C)
static uint8_t Bluetooth_SendHCICommand(void* Parameters, uint16_t ParameterLength);
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h index 1cc0d9242..b529ea483 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h @@ -35,8 +35,6 @@ #include <LUFA/Drivers/USB/USB.h>
#include "BluetoothHost.h"
- #include "BluetoothHCICommands.h"
- #include "BluetoothACLPackets.h"
/* Macros: */
#define BLUETOOTH_DATA_IN_PIPE 1
@@ -84,6 +82,10 @@ char PINCode[16];
char Name[];
} Bluetooth_Device_t;
+
+ /* Includes: */
+ #include "BluetoothHCICommands.h"
+ #include "BluetoothACLPackets.h"
/* Function Prototypes: */
Bluetooth_Channel_t* Bluetooth_GetChannelData(uint16_t ChannelNumber, bool SearchBySource);
@@ -92,6 +94,11 @@ void Bluetooth_Stack_Init(void);
void Bluetooth_Stack_USBTask(void);
+ bool Bluetooth_ConnectionRequest(uint8_t* RemoteAddress);
+ void Bluetooth_ConnectionComplete(void);
+ void Bluetooth_DisconnectionComplete(void);
+ void Bluetooth_PacketReceived(uint16_t* PacketLength, Bluetooth_Channel_t* Channel);
+
/* External Variables: */
extern Bluetooth_Device_t Bluetooth_DeviceConfiguration;
extern Bluetooth_Connection_t Bluetooth_Connection;
|