@ -31,10 +31,78 @@
# define INCLUDE_FROM_BLUETOOTH_ACLPACKETS_C
# define INCLUDE_FROM_BLUETOOTH_ACLPACKETS_C
# include "BluetoothACLPackets.h"
# include "BluetoothACLPackets.h"
void Bluetooth_ ProcessACLPackets ( void )
void Bluetooth_ ACLTask ( void )
{
{
Bluetooth_ACL_Header_t ACLPacketHeader ;
Bluetooth_ProcessACLPackets ( ) ;
Bluetooth_DataPacket_Header_t DataHeader ;
for ( uint8_t i = 0 ; i < BLUETOOTH_MAX_OPEN_CHANNELS ; i + + )
{
Bluetooth_Channel_t * ChannelData = & Bluetooth_Connection . Channels [ i ] ;
bool MustSendConfigReq = true ;
switch ( ChannelData - > State )
{
case Channel_Config_WaitConfig :
ChannelData - > State = Channel_Config_WaitReqResp ;
break ;
case Channel_Config_WaitSendConfig :
ChannelData - > State = Channel_Config_WaitResp ;
break ;
default :
MustSendConfigReq = false ;
break ;
}
if ( MustSendConfigReq )
{
BT_ACL_Header_t ACLPacketHeader ;
BT_DataPacket_Header_t DataHeader ;
BT_Signal_Header_t SignalCommandHeader ;
BT_Signal_ConfigurationReq_t ConfigurationRequest ;
ACLPacketHeader . ConnectionHandle = Bluetooth_Connection . ConnectionHandle ;
ACLPacketHeader . DataLength = sizeof ( DataHeader ) + sizeof ( SignalCommandHeader ) + sizeof ( ConfigurationRequest ) ;
DataHeader . PayloadLength = sizeof ( SignalCommandHeader ) + sizeof ( ConfigurationRequest ) ;
DataHeader . DestinationChannel = BT_CHANNEL_SIGNALING ;
SignalCommandHeader . Code = BT_SIGNAL_CONFIGURATION_REQUEST ;
SignalCommandHeader . Identifier = + + Bluetooth_Connection . SignallingIdentifier ;
SignalCommandHeader . Length = sizeof ( ConfigurationRequest ) ;
ConfigurationRequest . DestinationChannel = ChannelData - > RemoteNumber ;
ConfigurationRequest . Flags = 0 ;
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 ( & SignalCommandHeader , sizeof ( SignalCommandHeader ) ) ;
Pipe_Write_Stream_LE ( & ConfigurationRequest , sizeof ( ConfigurationRequest ) ) ;
Pipe_Freeze ( ) ;
# if (ACL_DEBUG_LEVEL > 1)
BT_ACL_DEBUG ( " Packet Sent " , NULL ) ;
BT_ACL_DEBUG ( " -- Connection Handle: 0x%04X " , ( ACLPacketHeader . ConnectionHandle & 0x0FFF ) ) ;
BT_ACL_DEBUG ( " -- Data Length: 0x%04X " , ACLPacketHeader . DataLength ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , DataHeader . DestinationChannel ) ;
BT_ACL_DEBUG ( " -- Payload Length: 0x%04X " , DataHeader . PayloadLength ) ;
# endif
# if (ACL_DEBUG_LEVEL > 0)
BT_ACL_DEBUG ( " >> L2CAP Configuration Request " , NULL ) ;
# endif
# if (ACL_DEBUG_LEVEL > 1)
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , ConfigurationRequest . DestinationChannel ) ;
# endif
}
}
}
static void Bluetooth_ProcessACLPackets ( void )
{
BT_ACL_Header_t ACLPacketHeader ;
BT_DataPacket_Header_t DataHeader ;
Pipe_SelectPipe ( BLUETOOTH_DATA_IN_PIPE ) ;
Pipe_SelectPipe ( BLUETOOTH_DATA_IN_PIPE ) ;
Pipe_Unfreeze ( ) ;
Pipe_Unfreeze ( ) ;
@ -48,35 +116,35 @@ void Bluetooth_ProcessACLPackets(void)
Pipe_Read_Stream_LE ( & ACLPacketHeader , sizeof ( ACLPacketHeader ) ) ;
Pipe_Read_Stream_LE ( & ACLPacketHeader , sizeof ( ACLPacketHeader ) ) ;
Pipe_Read_Stream_LE ( & DataHeader , sizeof ( DataHeader ) ) ;
Pipe_Read_Stream_LE ( & DataHeader , sizeof ( DataHeader ) ) ;
# if (ACL_DEBUG_LEVEL > 1)
# if (ACL_DEBUG_LEVEL > 1)
BT_ACL_DEBUG ( " Packet Received " , NULL ) ;
BT_ACL_DEBUG ( " Packet Received " , NULL ) ;
BT_ACL_DEBUG ( " -- Connection Handle: 0x%04X " , ( ACLPacketHeader . ConnectionHandle & 0x0FFF ) ) ;
BT_ACL_DEBUG ( " -- Connection Handle: 0x%04X " , ( ACLPacketHeader . ConnectionHandle & 0x0FFF ) ) ;
BT_ACL_DEBUG ( " -- Data Length: 0x%04X " , ACLPacketHeader . DataLength ) ;
BT_ACL_DEBUG ( " -- Data Length: 0x%04X " , ACLPacketHeader . DataLength ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , DataHeader . DestinationChannel ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , DataHeader . DestinationChannel ) ;
BT_ACL_DEBUG ( " -- Payload Length: 0x%04X " , DataHeader . PayloadLength ) ;
BT_ACL_DEBUG ( " -- Payload Length: 0x%04X " , DataHeader . PayloadLength ) ;
# endif
# endif
if ( DataHeader . DestinationChannel = = BT_CHANNEL_SIGNALING )
if ( DataHeader . DestinationChannel = = BT_CHANNEL_SIGNALING )
{
{
B luetooth_SignalCommand _Header_t SignalCommandHeader ;
B T_Signal _Header_t SignalCommandHeader ;
Pipe_Read_Stream_LE ( & SignalCommandHeader , sizeof ( SignalCommandHeader ) ) ;
Pipe_Read_Stream_LE ( & SignalCommandHeader , sizeof ( SignalCommandHeader ) ) ;
switch ( SignalCommandHeader . Code )
switch ( SignalCommandHeader . Code )
{
{
case BT_SIGNAL_CONNECTION_REQUEST :
case BT_SIGNAL_CONNECTION_REQUEST :
Bluetooth_Signal Packet _ConnectionRequest ( & ACLPacketHeader , & DataHeader , & SignalCommandHeader ) ;
Bluetooth_Signal _ConnectionReq( & ACLPacketHeader , & DataHeader , & SignalCommandHeader ) ;
break ;
break ;
case BT_SIGNAL_CONFIGURATION_REQUEST :
case BT_SIGNAL_CONFIGURATION_REQUEST :
Bluetooth_Signal Packet _ConfigurationRequest ( & ACLPacketHeader , & DataHeader , & SignalCommandHeader ) ;
Bluetooth_Signal _ConfigurationReq( & ACLPacketHeader , & DataHeader , & SignalCommandHeader ) ;
break ;
break ;
case BT_SIGNAL_DISCONNECTION_REQUEST :
case BT_SIGNAL_DISCONNECTION_REQUEST :
Bluetooth_Signal Packet _DisconnectionRequest ( & ACLPacketHeader , & DataHeader , & SignalCommandHeader ) ;
Bluetooth_Signal _DisconnectionReq( & ACLPacketHeader , & DataHeader , & SignalCommandHeader ) ;
break ;
break ;
case BT_SIGNAL_ECHO_REQUEST :
case BT_SIGNAL_ECHO_REQUEST :
Bluetooth_Signal Packet _EchoRequest ( & ACLPacketHeader , & DataHeader , & SignalCommandHeader ) ;
Bluetooth_Signal _EchoReq( & ACLPacketHeader , & DataHeader , & SignalCommandHeader ) ;
break ;
break ;
case BT_SIGNAL_INFORMATION_REQUEST :
case BT_SIGNAL_INFORMATION_REQUEST :
Bluetooth_Signal Packet _InformationRequest ( & ACLPacketHeader , & DataHeader , & SignalCommandHeader ) ;
Bluetooth_Signal _InformationReq( & ACLPacketHeader , & DataHeader , & SignalCommandHeader ) ;
break ;
break ;
default :
default :
# if (ACL_DEBUG_LEVEL > 0)
# if (ACL_DEBUG_LEVEL > 0)
@ -100,15 +168,21 @@ void Bluetooth_ProcessACLPackets(void)
}
}
}
}
void Bluetooth_SendPacket ( uint8_t * Data , uint16_t DataLen , Bluetooth_Channel_t * Channel )
uint8_t Bluetooth_SendPacket ( uint8_t * Data , uint16_t DataLen , Bluetooth_Channel_t * Channel )
{
{
Bluetooth_ACL_Header_t ACLPacketHeader ;
BT_ACL_Header_t ACLPacketHeader ;
Bluetooth_DataPacket_Header_t DataHeader ;
BT_DataPacket_Header_t DataHeader ;
if ( Bluetooth_Connection . IsConnected )
return BT_SENDPACKET_NotConnected ;
if ( Channel - > State ! = Channel_Open )
return BT_SENDPACKET_ChannelNotOpen ;
ACLPacketHeader . ConnectionHandle = Bluetooth_Connection . ConnectionHandle ;
ACLPacketHeader . ConnectionHandle = Bluetooth_Connection . ConnectionHandle ;
ACLPacketHeader . DataLength = sizeof ( DataHeader ) + DataLen ;
ACLPacketHeader . DataLength = sizeof ( DataHeader ) + DataLen ;
DataHeader . PayloadLength = DataLen ;
DataHeader . DestinationChannel = Channel - > RemoteNumber ;
DataHeader . DestinationChannel = Channel - > RemoteNumber ;
DataHeader . PayloadLength = DataLen ;
Pipe_SelectPipe ( BLUETOOTH_DATA_OUT_PIPE ) ;
Pipe_SelectPipe ( BLUETOOTH_DATA_OUT_PIPE ) ;
Pipe_Unfreeze ( ) ;
Pipe_Unfreeze ( ) ;
@ -118,30 +192,32 @@ void Bluetooth_SendPacket(uint8_t* Data, uint16_t DataLen, Bluetooth_Channel_t*
Pipe_Write_Stream_LE ( Data , DataLen ) ;
Pipe_Write_Stream_LE ( Data , DataLen ) ;
Pipe_Freeze ( ) ;
Pipe_Freeze ( ) ;
return BT_SENDPACKET_NoError ;
}
}
static inline void Bluetooth_Signal Packet_ConnectionRequest( Bluetooth _ACL_Header_t* ACLPacketHeader ,
static inline void Bluetooth_Signal _ConnectionReq( BT _ACL_Header_t* ACLPacketHeader ,
Bluetooth _DataPacket_Header_t* DataHeader ,
BT _DataPacket_Header_t* DataHeader ,
Bluetooth_SignalCommand _Header_t* SignalCommandHeader )
BT_Signal _Header_t* SignalCommandHeader )
{
{
B luetooth_SignalCommand_ConnectionRequest _t ConnectionRequest ;
B T_Signal_ConnectionReq _t ConnectionRequest ;
Pipe_Read_Stream_LE ( & ConnectionRequest , sizeof ( ConnectionRequest ) ) ;
Pipe_Read_Stream_LE ( & ConnectionRequest , sizeof ( ConnectionRequest ) ) ;
# if (ACL_DEBUG_LEVEL > 0)
# if (ACL_DEBUG_LEVEL > 0)
BT_ACL_DEBUG ( " << L2CAP Connection Request " , NULL ) ;
BT_ACL_DEBUG ( " << L2CAP Connection Request " , NULL ) ;
# endif
# endif
# if (ACL_DEBUG_LEVEL > 1)
# if (ACL_DEBUG_LEVEL > 1)
BT_ACL_DEBUG ( " -- PSM: 0x%04X " , ConnectionRequest . PSM ) ;
BT_ACL_DEBUG ( " -- PSM: 0x%04X " , ConnectionRequest . PSM ) ;
BT_ACL_DEBUG ( " -- Source Channel: 0x%04X " , ConnectionRequest . SourceChannel ) ;
BT_ACL_DEBUG ( " -- Source Channel: 0x%04X " , ConnectionRequest . SourceChannel ) ;
# endif
# endif
Pipe_ClearIN ( ) ;
Pipe_ClearIN ( ) ;
Pipe_Freeze ( ) ;
Pipe_Freeze ( ) ;
Pipe_SelectPipe ( BLUETOOTH_DATA_OUT_PIPE ) ;
Pipe_SelectPipe ( BLUETOOTH_DATA_OUT_PIPE ) ;
Pipe_Unfreeze ( ) ;
Pipe_Unfreeze ( ) ;
B luetooth_SignalCommand_ConnectionResponse _t ConnectionResponse ;
B T_Signal_ConnectionResp _t ConnectionResponse ;
ACLPacketHeader - > DataLength = sizeof ( * DataHeader ) + sizeof ( * SignalCommandHeader ) + sizeof ( ConnectionResponse ) ;
ACLPacketHeader - > DataLength = sizeof ( * DataHeader ) + sizeof ( * SignalCommandHeader ) + sizeof ( ConnectionResponse ) ;
DataHeader - > PayloadLength = sizeof ( * SignalCommandHeader ) + sizeof ( ConnectionResponse ) ;
DataHeader - > PayloadLength = sizeof ( * SignalCommandHeader ) + sizeof ( ConnectionResponse ) ;
@ -164,44 +240,45 @@ static inline void Bluetooth_SignalPacket_ConnectionRequest(Bluetooth_ACL_Header
Pipe_ClearOUT ( ) ;
Pipe_ClearOUT ( ) ;
Pipe_Freeze ( ) ;
Pipe_Freeze ( ) ;
# if (ACL_DEBUG_LEVEL > 1)
# if (ACL_DEBUG_LEVEL > 1)
BT_ACL_DEBUG ( " Packet Sent " , NULL ) ;
BT_ACL_DEBUG ( " Packet Sent " , NULL ) ;
BT_ACL_DEBUG ( " -- Connection Handle: 0x%04X " , ( ACLPacketHeader - > ConnectionHandle & 0x0FFF ) ) ;
BT_ACL_DEBUG ( " -- Connection Handle: 0x%04X " , ( ACLPacketHeader - > ConnectionHandle & 0x0FFF ) ) ;
BT_ACL_DEBUG ( " -- Data Length: 0x%04X " , ACLPacketHeader - > DataLength ) ;
BT_ACL_DEBUG ( " -- Data Length: 0x%04X " , ACLPacketHeader - > DataLength ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , DataHeader - > DestinationChannel ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , DataHeader - > DestinationChannel ) ;
BT_ACL_DEBUG ( " -- Payload Length: 0x%04X " , DataHeader - > PayloadLength ) ;
BT_ACL_DEBUG ( " -- Payload Length: 0x%04X " , DataHeader - > PayloadLength ) ;
# endif
# endif
# if (ACL_DEBUG_LEVEL > 0)
# if (ACL_DEBUG_LEVEL > 0)
BT_ACL_DEBUG ( " >> L2CAP Connection Response " , NULL ) ;
BT_ACL_DEBUG ( " >> L2CAP Connection Response " , NULL ) ;
# endif
# endif
# if (ACL_DEBUG_LEVEL > 1)
# if (ACL_DEBUG_LEVEL > 1)
BT_ACL_DEBUG ( " -- Source Channel: 0x%04X " , ConnectionResponse . SourceChannel ) ;
BT_ACL_DEBUG ( " -- Source Channel: 0x%04X " , ConnectionResponse . SourceChannel ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , ConnectionResponse . DestinationChannel ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , ConnectionResponse . DestinationChannel ) ;
# endif
# endif
}
}
static inline void Bluetooth_Signal Packet_ConfigurationRequest( Bluetooth _ACL_Header_t* ACLPacketHeader ,
static inline void Bluetooth_Signal _ConfigurationReq( BT _ACL_Header_t* ACLPacketHeader ,
Bluetooth _DataPacket_Header_t* DataHeader ,
BT _DataPacket_Header_t* DataHeader ,
Bluetooth_SignalCommand _Header_t* SignalCommandHeader )
BT_Signal _Header_t* SignalCommandHeader )
{
{
B luetooth_SignalCommand_ConfigurationRequest _t ConfigurationRequest ;
B T_Signal_ConfigurationReq _t ConfigurationRequest ;
Pipe_Read_Stream_LE ( & ConfigurationRequest , sizeof ( ConfigurationRequest ) ) ;
Pipe_Read_Stream_LE ( & ConfigurationRequest , sizeof ( ConfigurationRequest ) ) ;
// TODO: Process/Discard configuration options here
// TODO: Process/Discard configuration options here
Pipe_Discard_Stream ( DataHeader - > PayloadLength - sizeof ( * SignalCommandHeader ) ) ;
# if (ACL_DEBUG_LEVEL > 0)
# if (ACL_DEBUG_LEVEL > 0)
BT_ACL_DEBUG ( " << L2CAP Configuration Request " , NULL ) ;
BT_ACL_DEBUG ( " << L2CAP Configuration Request " , NULL ) ;
# endif
# endif
# if (ACL_DEBUG_LEVEL > 1)
# if (ACL_DEBUG_LEVEL > 1)
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , ConfigurationRequest . DestinationChannel ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , ConfigurationRequest . DestinationChannel ) ;
# endif
# endif
Pipe_ClearIN ( ) ;
Pipe_ClearIN ( ) ;
Pipe_Freeze ( ) ;
Pipe_Freeze ( ) ;
Pipe_SelectPipe ( BLUETOOTH_DATA_OUT_PIPE ) ;
Pipe_SelectPipe ( BLUETOOTH_DATA_OUT_PIPE ) ;
Pipe_Unfreeze ( ) ;
Pipe_Unfreeze ( ) ;
B luetooth_SignalCommand_ConfigurationResponse _t ConfigurationResponse ;
B T_Signal_ConfigurationResp _t ConfigurationResponse ;
ACLPacketHeader - > DataLength = sizeof ( * DataHeader ) + sizeof ( * SignalCommandHeader ) + sizeof ( ConfigurationResponse ) ;
ACLPacketHeader - > DataLength = sizeof ( * DataHeader ) + sizeof ( * SignalCommandHeader ) + sizeof ( ConfigurationResponse ) ;
DataHeader - > PayloadLength = sizeof ( * SignalCommandHeader ) + sizeof ( ConfigurationResponse ) ;
DataHeader - > PayloadLength = sizeof ( * SignalCommandHeader ) + sizeof ( ConfigurationResponse ) ;
@ -212,7 +289,20 @@ static inline void Bluetooth_SignalPacket_ConfigurationRequest(Bluetooth_ACL_Hea
Bluetooth_Channel_t * ChannelData = Bluetooth_GetChannelData ( ConfigurationRequest . DestinationChannel , false ) ;
Bluetooth_Channel_t * ChannelData = Bluetooth_GetChannelData ( ConfigurationRequest . DestinationChannel , false ) ;
if ( ChannelData ! = NULL )
if ( ChannelData ! = NULL )
ChannelData - > State = Channel_Open ;
{
switch ( ChannelData - > State )
{
case Channel_Config_WaitConfig :
ChannelData - > State = Channel_Config_WaitSendConfig ;
break ;
case Channel_Config_WaitReqResp :
ChannelData - > State = Channel_Config_WaitResp ;
break ;
case Channel_Config_WaitReq :
ChannelData - > State = Channel_Open ;
break ;
}
}
// TODO: Add channel config data to the tail of ConfigurationResponse
// TODO: Add channel config data to the tail of ConfigurationResponse
@ -228,43 +318,43 @@ static inline void Bluetooth_SignalPacket_ConfigurationRequest(Bluetooth_ACL_Hea
Pipe_ClearOUT ( ) ;
Pipe_ClearOUT ( ) ;
Pipe_Freeze ( ) ;
Pipe_Freeze ( ) ;
# if (ACL_DEBUG_LEVEL > 1)
# if (ACL_DEBUG_LEVEL > 1)
BT_ACL_DEBUG ( " Packet Sent " , NULL ) ;
BT_ACL_DEBUG ( " Packet Sent " , NULL ) ;
BT_ACL_DEBUG ( " -- Connection Handle: 0x%04X " , ( ACLPacketHeader - > ConnectionHandle & 0x0FFF ) ) ;
BT_ACL_DEBUG ( " -- Connection Handle: 0x%04X " , ( ACLPacketHeader - > ConnectionHandle & 0x0FFF ) ) ;
BT_ACL_DEBUG ( " -- Data Length: 0x%04X " , ACLPacketHeader - > DataLength ) ;
BT_ACL_DEBUG ( " -- Data Length: 0x%04X " , ACLPacketHeader - > DataLength ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , DataHeader - > DestinationChannel ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , DataHeader - > DestinationChannel ) ;
BT_ACL_DEBUG ( " -- Payload Length: 0x%04X " , DataHeader - > PayloadLength ) ;
BT_ACL_DEBUG ( " -- Payload Length: 0x%04X " , DataHeader - > PayloadLength ) ;
# endif
# endif
# if (ACL_DEBUG_LEVEL > 0)
# if (ACL_DEBUG_LEVEL > 0)
BT_ACL_DEBUG ( " >> L2CAP Configuration Response " , NULL ) ;
BT_ACL_DEBUG ( " >> L2CAP Configuration Response " , NULL ) ;
# endif
# endif
# if (ACL_DEBUG_LEVEL > 1)
# if (ACL_DEBUG_LEVEL > 1)
BT_ACL_DEBUG ( " -- Result: 0x%02X " , ConfigurationResponse . Result ) ;
BT_ACL_DEBUG ( " -- Result: 0x%02X " , ConfigurationResponse . Result ) ;
# endif
# endif
}
}
static inline void Bluetooth_Signal Packet_DisconnectionRequest( Bluetooth _ACL_Header_t* ACLPacketHeader ,
static inline void Bluetooth_Signal _DisconnectionReq( BT _ACL_Header_t* ACLPacketHeader ,
Bluetooth _DataPacket_Header_t* DataHeader ,
BT _DataPacket_Header_t* DataHeader ,
Bluetooth_SignalCommand _Header_t* SignalCommandHeader )
BT_Signal _Header_t* SignalCommandHeader )
{
{
B luetooth_SignalCommand_DisconnectionRequest _t DisconnectionRequest ;
B T_Signal_DisconnectionReq _t DisconnectionRequest ;
Pipe_Read_Stream_LE ( & DisconnectionRequest , sizeof ( DisconnectionRequest ) ) ;
Pipe_Read_Stream_LE ( & DisconnectionRequest , sizeof ( DisconnectionRequest ) ) ;
# if (ACL_DEBUG_LEVEL > 0)
# if (ACL_DEBUG_LEVEL > 0)
BT_ACL_DEBUG ( " << L2CAP Disconnection Request " , NULL ) ;
BT_ACL_DEBUG ( " << L2CAP Disconnection Request " , NULL ) ;
# endif
# endif
# if (ACL_DEBUG_LEVEL > 1)
# if (ACL_DEBUG_LEVEL > 1)
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , DisconnectionRequest . DestinationChannel ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , DisconnectionRequest . DestinationChannel ) ;
BT_ACL_DEBUG ( " -- Source Channel: 0x%04X " , DisconnectionRequest . SourceChannel ) ;
BT_ACL_DEBUG ( " -- Source Channel: 0x%04X " , DisconnectionRequest . SourceChannel ) ;
# endif
# endif
Pipe_ClearIN ( ) ;
Pipe_ClearIN ( ) ;
Pipe_Freeze ( ) ;
Pipe_Freeze ( ) ;
Pipe_SelectPipe ( BLUETOOTH_DATA_OUT_PIPE ) ;
Pipe_SelectPipe ( BLUETOOTH_DATA_OUT_PIPE ) ;
Pipe_Unfreeze ( ) ;
Pipe_Unfreeze ( ) ;
B luetooth_SignalCommand_DisconnectionResponse _t DisconnectionResponse ;
B T_Signal_DisconnectionResp _t DisconnectionResponse ;
ACLPacketHeader - > DataLength = sizeof ( * DataHeader ) + sizeof ( * SignalCommandHeader ) + sizeof ( DisconnectionResponse ) ;
ACLPacketHeader - > DataLength = sizeof ( * DataHeader ) + sizeof ( * SignalCommandHeader ) + sizeof ( DisconnectionResponse ) ;
DataHeader - > PayloadLength = sizeof ( * SignalCommandHeader ) + sizeof ( DisconnectionResponse ) ;
DataHeader - > PayloadLength = sizeof ( * SignalCommandHeader ) + sizeof ( DisconnectionResponse ) ;
@ -288,29 +378,29 @@ static inline void Bluetooth_SignalPacket_DisconnectionRequest(Bluetooth_ACL_Hea
Pipe_ClearOUT ( ) ;
Pipe_ClearOUT ( ) ;
Pipe_Freeze ( ) ;
Pipe_Freeze ( ) ;
# if (ACL_DEBUG_LEVEL > 1)
# if (ACL_DEBUG_LEVEL > 1)
BT_ACL_DEBUG ( " Packet Sent " , NULL ) ;
BT_ACL_DEBUG ( " Packet Sent " , NULL ) ;
BT_ACL_DEBUG ( " -- Connection Handle: 0x%04X " , ( ACLPacketHeader - > ConnectionHandle & 0x0FFF ) ) ;
BT_ACL_DEBUG ( " -- Connection Handle: 0x%04X " , ( ACLPacketHeader - > ConnectionHandle & 0x0FFF ) ) ;
BT_ACL_DEBUG ( " -- Data Length: 0x%04X " , ACLPacketHeader - > DataLength ) ;
BT_ACL_DEBUG ( " -- Data Length: 0x%04X " , ACLPacketHeader - > DataLength ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , DataHeader - > DestinationChannel ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , DataHeader - > DestinationChannel ) ;
BT_ACL_DEBUG ( " -- Payload Length: 0x%04X " , DataHeader - > PayloadLength ) ;
BT_ACL_DEBUG ( " -- Payload Length: 0x%04X " , DataHeader - > PayloadLength ) ;
# endif
# endif
# if (ACL_DEBUG_LEVEL > 0)
# if (ACL_DEBUG_LEVEL > 0)
BT_ACL_DEBUG ( " >> L2CAP Disconnection Response " , NULL ) ;
BT_ACL_DEBUG ( " >> L2CAP Disconnection Response " , NULL ) ;
# endif
# endif
# if (ACL_DEBUG_LEVEL > 1)
# if (ACL_DEBUG_LEVEL > 1)
BT_ACL_DEBUG ( " -- Source Channel: 0x%04X " , DisconnectionResponse . SourceChannel ) ;
BT_ACL_DEBUG ( " -- Source Channel: 0x%04X " , DisconnectionResponse . SourceChannel ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , DisconnectionResponse . DestinationChannel ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , DisconnectionResponse . DestinationChannel ) ;
# endif
# endif
}
}
static inline void Bluetooth_Signal Packet_EchoRequest( Bluetooth _ACL_Header_t* ACLPacketHeader ,
static inline void Bluetooth_Signal _EchoReq( BT _ACL_Header_t* ACLPacketHeader ,
Bluetooth _DataPacket_Header_t* DataHeader ,
BT _DataPacket_Header_t* DataHeader ,
Bluetooth_SignalCommand _Header_t* SignalCommandHeader )
BT_Signal _Header_t* SignalCommandHeader )
{
{
# if (ACL_DEBUG_LEVEL > 0)
# if (ACL_DEBUG_LEVEL > 0)
BT_ACL_DEBUG ( " << L2CAP Echo Request " , NULL ) ;
BT_ACL_DEBUG ( " << L2CAP Echo Request " , NULL ) ;
# endif
# endif
Pipe_ClearIN ( ) ;
Pipe_ClearIN ( ) ;
Pipe_Freeze ( ) ;
Pipe_Freeze ( ) ;
@ -330,39 +420,39 @@ static inline void Bluetooth_SignalPacket_EchoRequest(Bluetooth_ACL_Header_t* AC
Pipe_ClearOUT ( ) ;
Pipe_ClearOUT ( ) ;
Pipe_Freeze ( ) ;
Pipe_Freeze ( ) ;
# if (ACL_DEBUG_LEVEL > 1)
# if (ACL_DEBUG_LEVEL > 1)
BT_ACL_DEBUG ( " Packet Sent " , NULL ) ;
BT_ACL_DEBUG ( " Packet Sent " , NULL ) ;
BT_ACL_DEBUG ( " -- Connection Handle: 0x%04X " , ( ACLPacketHeader - > ConnectionHandle & 0x0FFF ) ) ;
BT_ACL_DEBUG ( " -- Connection Handle: 0x%04X " , ( ACLPacketHeader - > ConnectionHandle & 0x0FFF ) ) ;
BT_ACL_DEBUG ( " -- Data Length: 0x%04X " , ACLPacketHeader - > DataLength ) ;
BT_ACL_DEBUG ( " -- Data Length: 0x%04X " , ACLPacketHeader - > DataLength ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , DataHeader - > DestinationChannel ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , DataHeader - > DestinationChannel ) ;
BT_ACL_DEBUG ( " -- Payload Length: 0x%04X " , DataHeader - > PayloadLength ) ;
BT_ACL_DEBUG ( " -- Payload Length: 0x%04X " , DataHeader - > PayloadLength ) ;
# endif
# endif
# if (ACL_DEBUG_LEVEL > 0)
# if (ACL_DEBUG_LEVEL > 0)
BT_ACL_DEBUG ( " >> L2CAP Echo Response " , NULL ) ;
BT_ACL_DEBUG ( " >> L2CAP Echo Response " , NULL ) ;
# endif
# endif
}
}
static inline void Bluetooth_Signal Packet_InformationRequest( Bluetooth _ACL_Header_t* ACLPacketHeader ,
static inline void Bluetooth_Signal _InformationReq( BT _ACL_Header_t* ACLPacketHeader ,
Bluetooth _DataPacket_Header_t* DataHeader ,
BT _DataPacket_Header_t* DataHeader ,
Bluetooth_SignalCommand _Header_t* SignalCommandHeader )
BT_Signal _Header_t* SignalCommandHeader )
{
{
B luetooth_SignalCommand_InformationRequest _t InformationRequest ;
B T_Signal_InformationReq _t InformationRequest ;
Pipe_Read_Stream_LE ( & InformationRequest , sizeof ( InformationRequest ) ) ;
Pipe_Read_Stream_LE ( & InformationRequest , sizeof ( InformationRequest ) ) ;
# if (ACL_DEBUG_LEVEL > 0)
# if (ACL_DEBUG_LEVEL > 0)
BT_ACL_DEBUG ( " << Information Request " , NULL ) ;
BT_ACL_DEBUG ( " << Information Request " , NULL ) ;
# endif
# endif
# if (ACL_DEBUG_LEVEL > 1)
# if (ACL_DEBUG_LEVEL > 1)
BT_ACL_DEBUG ( " -- Info Type: 0x%04X " , InformationRequest . InfoType ) ;
BT_ACL_DEBUG ( " -- Info Type: 0x%04X " , InformationRequest . InfoType ) ;
# endif
# endif
Pipe_ClearIN ( ) ;
Pipe_ClearIN ( ) ;
Pipe_Freeze ( ) ;
Pipe_Freeze ( ) ;
Pipe_SelectPipe ( BLUETOOTH_DATA_OUT_PIPE ) ;
Pipe_SelectPipe ( BLUETOOTH_DATA_OUT_PIPE ) ;
Pipe_Unfreeze ( ) ;
Pipe_Unfreeze ( ) ;
B luetooth_SignalCommand_InformationResponse _t InformationResponse ;
B T_Signal_InformationResp _t InformationResponse ;
uint8_t ResponseData [ 4 ] ;
uint8_t ResponseData [ 4 ] ;
uint8_t ResponseLen ;
uint8_t ResponseLen ;
@ -402,17 +492,17 @@ static inline void Bluetooth_SignalPacket_InformationRequest(Bluetooth_ACL_Heade
Pipe_ClearOUT ( ) ;
Pipe_ClearOUT ( ) ;
Pipe_Freeze ( ) ;
Pipe_Freeze ( ) ;
# if (ACL_DEBUG_LEVEL > 1)
# if (ACL_DEBUG_LEVEL > 1)
BT_ACL_DEBUG ( " Packet Sent " , NULL ) ;
BT_ACL_DEBUG ( " Packet Sent " , NULL ) ;
BT_ACL_DEBUG ( " -- Connection Handle: 0x%04X " , ( ACLPacketHeader - > ConnectionHandle & 0x0FFF ) ) ;
BT_ACL_DEBUG ( " -- Connection Handle: 0x%04X " , ( ACLPacketHeader - > ConnectionHandle & 0x0FFF ) ) ;
BT_ACL_DEBUG ( " -- Data Length: 0x%04X " , ACLPacketHeader - > DataLength ) ;
BT_ACL_DEBUG ( " -- Data Length: 0x%04X " , ACLPacketHeader - > DataLength ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , DataHeader - > DestinationChannel ) ;
BT_ACL_DEBUG ( " -- Destination Channel: 0x%04X " , DataHeader - > DestinationChannel ) ;
BT_ACL_DEBUG ( " -- Payload Length: 0x%04X " , DataHeader - > PayloadLength ) ;
BT_ACL_DEBUG ( " -- Payload Length: 0x%04X " , DataHeader - > PayloadLength ) ;
# endif
# endif
# if (ACL_DEBUG_LEVEL > 0)
# if (ACL_DEBUG_LEVEL > 0)
BT_ACL_DEBUG ( " >> L2CAP Information Response " , NULL ) ;
BT_ACL_DEBUG ( " >> L2CAP Information Response " , NULL ) ;
# endif
# endif
# if (ACL_DEBUG_LEVEL > 1)
# if (ACL_DEBUG_LEVEL > 1)
BT_ACL_DEBUG ( " -- Result: 0x%02X " , InformationResponse . Result ) ;
BT_ACL_DEBUG ( " -- Result: 0x%02X " , InformationResponse . Result ) ;
# endif
# endif
}
}