Fixed HID Device Class Driver not allocating a temporary buffer when the host requests a report via the control endpoint and the user has set the PrevReportINBuffer driver configuration element to NULL (thanks to Lars Noschinski).

Clean up incomplete BluetoothHost debugging commands to use GCC extension to avoid NULL parameters when no formatting is required.
pull/1469/head
Dean Camera 15 years ago
parent d03d6513d0
commit 8252b4febd

@ -90,7 +90,7 @@ void Bluetooth_ACLTask(void)
Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL); Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL);
BT_ACL_DEBUG(1, ">> L2CAP Configuration Request", NULL); BT_ACL_DEBUG(1, ">> L2CAP Configuration Request");
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", PacketData.ConfigurationRequest.DestinationChannel); BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", PacketData.ConfigurationRequest.DestinationChannel);
} }
} }
@ -118,8 +118,8 @@ static void Bluetooth_ProcessIncommingACLPackets(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));
BT_ACL_DEBUG(2, "", NULL); BT_ACL_DEBUG(2, "");
BT_ACL_DEBUG(2, "Packet Received", NULL); BT_ACL_DEBUG(2, "Packet Received");
BT_ACL_DEBUG(2, "-- Connection Handle: 0x%04X", (ACLPacketHeader.ConnectionHandle & 0x0FFF)); BT_ACL_DEBUG(2, "-- Connection Handle: 0x%04X", (ACLPacketHeader.ConnectionHandle & 0x0FFF));
BT_ACL_DEBUG(2, "-- Data Length: 0x%04X", ACLPacketHeader.DataLength); BT_ACL_DEBUG(2, "-- Data Length: 0x%04X", ACLPacketHeader.DataLength);
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DataHeader.DestinationChannel); BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DataHeader.DestinationChannel);
@ -160,7 +160,7 @@ static void Bluetooth_ProcessIncommingACLPackets(void)
Bluetooth_Signal_InformationReq(&SignalCommandHeader); Bluetooth_Signal_InformationReq(&SignalCommandHeader);
break; break;
case BT_SIGNAL_COMMAND_REJECT: case BT_SIGNAL_COMMAND_REJECT:
BT_ACL_DEBUG(1, "<< Command Reject", NULL); BT_ACL_DEBUG(1, "<< Command Reject");
uint16_t RejectReason; uint16_t RejectReason;
Pipe_Read_Stream_LE(&RejectReason, sizeof(RejectReason)); Pipe_Read_Stream_LE(&RejectReason, sizeof(RejectReason));
@ -230,8 +230,8 @@ uint8_t Bluetooth_SendPacket(void* Data, const uint16_t DataLen, Bluetooth_Chann
Pipe_Freeze(); Pipe_Freeze();
BT_ACL_DEBUG(2, "", NULL); BT_ACL_DEBUG(2, "");
BT_ACL_DEBUG(2, "Packet Sent", NULL); BT_ACL_DEBUG(2, "Packet Sent");
BT_ACL_DEBUG(2, "-- Connection Handle: 0x%04X", (ACLPacketHeader.ConnectionHandle & 0x0FFF)); BT_ACL_DEBUG(2, "-- Connection Handle: 0x%04X", (ACLPacketHeader.ConnectionHandle & 0x0FFF));
BT_ACL_DEBUG(2, "-- Data Length: 0x%04X", ACLPacketHeader.DataLength); BT_ACL_DEBUG(2, "-- Data Length: 0x%04X", ACLPacketHeader.DataLength);
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DataHeader.DestinationChannel); BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DataHeader.DestinationChannel);
@ -296,7 +296,7 @@ Bluetooth_Channel_t* Bluetooth_OpenChannel(const uint16_t PSM)
Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL); Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL);
BT_ACL_DEBUG(1, ">> L2CAP Connection Request", NULL); BT_ACL_DEBUG(1, ">> L2CAP Connection Request");
BT_ACL_DEBUG(2, "-- PSM 0x%04X", PacketData.ConnectionRequest.PSM); BT_ACL_DEBUG(2, "-- PSM 0x%04X", PacketData.ConnectionRequest.PSM);
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", PacketData.ConnectionRequest.SourceChannel); BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", PacketData.ConnectionRequest.SourceChannel);
@ -339,7 +339,7 @@ void Bluetooth_CloseChannel(Bluetooth_Channel_t* const Channel)
Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL); Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL);
BT_ACL_DEBUG(1, ">> L2CAP Disconnection Request", NULL); BT_ACL_DEBUG(1, ">> L2CAP Disconnection Request");
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", PacketData.DisconnectionRequest.DestinationChannel); BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", PacketData.DisconnectionRequest.DestinationChannel);
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", PacketData.DisconnectionRequest.SourceChannel); BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", PacketData.DisconnectionRequest.SourceChannel);
} }
@ -357,7 +357,7 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons
Pipe_ClearIN(); Pipe_ClearIN();
Pipe_Freeze(); Pipe_Freeze();
BT_ACL_DEBUG(1, "<< L2CAP Connection Request", NULL); BT_ACL_DEBUG(1, "<< L2CAP Connection Request");
BT_ACL_DEBUG(2, "-- PSM: 0x%04X", ConnectionRequest.PSM); BT_ACL_DEBUG(2, "-- PSM: 0x%04X", ConnectionRequest.PSM);
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionRequest.SourceChannel); BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionRequest.SourceChannel);
@ -422,7 +422,7 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons
Bluetooth_SendPacket(&ResponsePacket, sizeof(ResponsePacket), NULL); Bluetooth_SendPacket(&ResponsePacket, sizeof(ResponsePacket), NULL);
BT_ACL_DEBUG(1, ">> L2CAP Connection Response", NULL); BT_ACL_DEBUG(1, ">> L2CAP Connection Response");
BT_ACL_DEBUG(2, "-- Result: 0x%02X", ResponsePacket.ConnectionResponse.Result); BT_ACL_DEBUG(2, "-- Result: 0x%02X", ResponsePacket.ConnectionResponse.Result);
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ResponsePacket.ConnectionResponse.DestinationChannel); BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ResponsePacket.ConnectionResponse.DestinationChannel);
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ResponsePacket.ConnectionResponse.SourceChannel); BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ResponsePacket.ConnectionResponse.SourceChannel);
@ -441,7 +441,7 @@ static inline void Bluetooth_Signal_ConnectionResp(const BT_Signal_Header_t* con
Pipe_ClearIN(); Pipe_ClearIN();
Pipe_Freeze(); Pipe_Freeze();
BT_ACL_DEBUG(1, "<< L2CAP Connection Response", NULL); BT_ACL_DEBUG(1, "<< L2CAP Connection Response");
BT_ACL_DEBUG(2, "-- Result: 0x%02X", ConnectionResponse.Result); BT_ACL_DEBUG(2, "-- Result: 0x%02X", ConnectionResponse.Result);
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionResponse.SourceChannel); BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionResponse.SourceChannel);
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ConnectionResponse.DestinationChannel); BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ConnectionResponse.DestinationChannel);
@ -480,7 +480,7 @@ static inline void Bluetooth_Signal_ConfigurationReq(const BT_Signal_Header_t* c
/* Search for the referenced channel in the channel information list */ /* Search for the referenced channel in the channel information list */
Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(ConfigurationRequest.DestinationChannel, false); Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(ConfigurationRequest.DestinationChannel, false);
BT_ACL_DEBUG(1, "<< L2CAP Configuration Request", NULL); BT_ACL_DEBUG(1, "<< L2CAP Configuration Request");
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ConfigurationRequest.DestinationChannel); BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ConfigurationRequest.DestinationChannel);
BT_ACL_DEBUG(2, "-- Remote MTU: 0x%04X", ChannelData->RemoteMTU); BT_ACL_DEBUG(2, "-- Remote MTU: 0x%04X", ChannelData->RemoteMTU);
BT_ACL_DEBUG(2, "-- Options Len: 0x%04X", OptionsLen); BT_ACL_DEBUG(2, "-- Options Len: 0x%04X", OptionsLen);
@ -541,7 +541,7 @@ static inline void Bluetooth_Signal_ConfigurationReq(const BT_Signal_Header_t* c
} }
} }
BT_ACL_DEBUG(1, ">> L2CAP Configuration Response", NULL); BT_ACL_DEBUG(1, ">> L2CAP Configuration Response");
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ResponsePacket.ConfigurationResponse.SourceChannel); BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ResponsePacket.ConfigurationResponse.SourceChannel);
BT_ACL_DEBUG(2, "-- Result: 0x%02X", ResponsePacket.ConfigurationResponse.Result); BT_ACL_DEBUG(2, "-- Result: 0x%02X", ResponsePacket.ConfigurationResponse.Result);
} }
@ -559,7 +559,7 @@ static inline void Bluetooth_Signal_ConfigurationResp(const BT_Signal_Header_t*
Pipe_ClearIN(); Pipe_ClearIN();
Pipe_Freeze(); Pipe_Freeze();
BT_ACL_DEBUG(1, "<< L2CAP Configuration Response", NULL); BT_ACL_DEBUG(1, "<< L2CAP Configuration Response");
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConfigurationResponse.SourceChannel); BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConfigurationResponse.SourceChannel);
BT_ACL_DEBUG(2, "-- Result: 0x%02X", ConfigurationResponse.Result); BT_ACL_DEBUG(2, "-- Result: 0x%02X", ConfigurationResponse.Result);
@ -600,7 +600,7 @@ static inline void Bluetooth_Signal_DisconnectionReq(const BT_Signal_Header_t* c
Pipe_Read_Stream_LE(&DisconnectionRequest, sizeof(DisconnectionRequest)); Pipe_Read_Stream_LE(&DisconnectionRequest, sizeof(DisconnectionRequest));
BT_ACL_DEBUG(1, "<< L2CAP Disconnection Request", NULL); BT_ACL_DEBUG(1, "<< L2CAP Disconnection Request");
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DisconnectionRequest.DestinationChannel); BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DisconnectionRequest.DestinationChannel);
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", DisconnectionRequest.SourceChannel); BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", DisconnectionRequest.SourceChannel);
@ -631,7 +631,7 @@ static inline void Bluetooth_Signal_DisconnectionReq(const BT_Signal_Header_t* c
if (ChannelData != NULL) if (ChannelData != NULL)
ChannelData->State = Channel_Closed; ChannelData->State = Channel_Closed;
BT_ACL_DEBUG(1, ">> L2CAP Disconnection Response", NULL); BT_ACL_DEBUG(1, ">> L2CAP Disconnection Response");
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ResponsePacket.DisconnectionResponse.SourceChannel); BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ResponsePacket.DisconnectionResponse.SourceChannel);
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ResponsePacket.DisconnectionResponse.DestinationChannel); BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ResponsePacket.DisconnectionResponse.DestinationChannel);
} }
@ -646,7 +646,7 @@ static inline void Bluetooth_Signal_DisconnectionResp(const BT_Signal_Header_t*
Pipe_Read_Stream_LE(&DisconnectionResponse, sizeof(DisconnectionResponse)); Pipe_Read_Stream_LE(&DisconnectionResponse, sizeof(DisconnectionResponse));
BT_ACL_DEBUG(1, "<< L2CAP Disconnection Response", NULL); BT_ACL_DEBUG(1, "<< L2CAP Disconnection Response");
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DisconnectionResponse.DestinationChannel); BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DisconnectionResponse.DestinationChannel);
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", DisconnectionResponse.SourceChannel); BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", DisconnectionResponse.SourceChannel);
@ -667,7 +667,7 @@ static inline void Bluetooth_Signal_DisconnectionResp(const BT_Signal_Header_t*
*/ */
static inline void Bluetooth_Signal_EchoReq(const BT_Signal_Header_t* const SignalCommandHeader) static inline void Bluetooth_Signal_EchoReq(const BT_Signal_Header_t* const SignalCommandHeader)
{ {
BT_ACL_DEBUG(1, "<< L2CAP Echo Request", NULL); BT_ACL_DEBUG(1, "<< L2CAP Echo Request");
Pipe_ClearIN(); Pipe_ClearIN();
Pipe_Freeze(); Pipe_Freeze();
@ -684,7 +684,7 @@ static inline void Bluetooth_Signal_EchoReq(const BT_Signal_Header_t* const Sign
Bluetooth_SendPacket(&ResponsePacket, sizeof(ResponsePacket), NULL); Bluetooth_SendPacket(&ResponsePacket, sizeof(ResponsePacket), NULL);
BT_ACL_DEBUG(1, ">> L2CAP Echo Response", NULL); BT_ACL_DEBUG(1, ">> L2CAP Echo Response");
} }
/** Internal Bluetooth stack Signal Command processing routine for an Information Request command. /** Internal Bluetooth stack Signal Command processing routine for an Information Request command.
@ -697,7 +697,7 @@ static inline void Bluetooth_Signal_InformationReq(const BT_Signal_Header_t* con
Pipe_Read_Stream_LE(&InformationRequest, sizeof(InformationRequest)); Pipe_Read_Stream_LE(&InformationRequest, sizeof(InformationRequest));
BT_ACL_DEBUG(1, "<< L2CAP Information Request", NULL); BT_ACL_DEBUG(1, "<< L2CAP Information Request");
BT_ACL_DEBUG(2, "-- Info Type: 0x%04X", InformationRequest.InfoType); BT_ACL_DEBUG(2, "-- Info Type: 0x%04X", InformationRequest.InfoType);
Pipe_ClearIN(); Pipe_ClearIN();
@ -744,6 +744,6 @@ static inline void Bluetooth_Signal_InformationReq(const BT_Signal_Header_t* con
Bluetooth_SendPacket(&ResponsePacket, (sizeof(ResponsePacket) - sizeof(ResponsePacket.Data) + DataLen), NULL); Bluetooth_SendPacket(&ResponsePacket, (sizeof(ResponsePacket) - sizeof(ResponsePacket.Data) + DataLen), NULL);
BT_ACL_DEBUG(1, ">> L2CAP Information Response", NULL); BT_ACL_DEBUG(1, ">> L2CAP Information Response");
BT_ACL_DEBUG(2, "-- Result: 0x%02X", ResponsePacket.InformationResponse.Result); BT_ACL_DEBUG(2, "-- Result: 0x%02X", ResponsePacket.InformationResponse.Result);
} }

@ -43,7 +43,7 @@
#include "BluetoothStack.h" #include "BluetoothStack.h"
/* Macros: */ /* Macros: */
#define BT_ACL_DEBUG(l, s, ...) do { if (ACL_DEBUG_LEVEL >= l) printf_P(PSTR("(ACL) " s "\r\n"), __VA_ARGS__); } while (0) #define BT_ACL_DEBUG(l, s, ...) do { if (ACL_DEBUG_LEVEL >= l) printf_P(PSTR("(ACL) " s "\r\n"), ##__VA_ARGS__); } while (0)
#define ACL_DEBUG_LEVEL 0 #define ACL_DEBUG_LEVEL 0
#define BT_CHANNELNUMBER_BASEOFFSET 0x0040 #define BT_CHANNELNUMBER_BASEOFFSET 0x0040

@ -73,11 +73,11 @@ void Bluetooth_HCITask(void)
switch (HCIEventHeader.EventCode) switch (HCIEventHeader.EventCode)
{ {
case EVENT_COMMAND_COMPLETE: case EVENT_COMMAND_COMPLETE:
BT_HCI_DEBUG(1, "<< Command Complete", NULL); BT_HCI_DEBUG(1, "<< Command Complete");
Bluetooth_HCIProcessingState = Bluetooth_HCINextState; Bluetooth_HCIProcessingState = Bluetooth_HCINextState;
break; break;
case EVENT_COMMAND_STATUS: case EVENT_COMMAND_STATUS:
BT_HCI_DEBUG(1, "<< Command Status", NULL); BT_HCI_DEBUG(1, "<< Command Status");
BT_HCI_DEBUG(2, "-- Status Code: 0x%02X", (((BT_HCIEvent_CommandStatus_t*)&EventParams)->Status)); BT_HCI_DEBUG(2, "-- Status Code: 0x%02X", (((BT_HCIEvent_CommandStatus_t*)&EventParams)->Status));
/* If the execution of a command failed, reset the stack */ /* If the execution of a command failed, reset the stack */
@ -85,7 +85,7 @@ void Bluetooth_HCITask(void)
Bluetooth_HCIProcessingState = Bluetooth_Init; Bluetooth_HCIProcessingState = Bluetooth_Init;
break; break;
case EVENT_CONNECTION_REQUEST: case EVENT_CONNECTION_REQUEST:
BT_HCI_DEBUG(1, "<< Connection Request", NULL); BT_HCI_DEBUG(1, "<< Connection Request");
BT_HCI_DEBUG(2, "-- Link Type: 0x%02X", (((BT_HCIEvent_ConnectionRequest_t*)&EventParams)->LinkType)); BT_HCI_DEBUG(2, "-- Link Type: 0x%02X", (((BT_HCIEvent_ConnectionRequest_t*)&EventParams)->LinkType));
/* Need to store the remote device's BT address in a temporary buffer for later use */ /* Need to store the remote device's BT address in a temporary buffer for later use */
@ -106,7 +106,7 @@ void Bluetooth_HCITask(void)
break; break;
case EVENT_PIN_CODE_REQUEST: case EVENT_PIN_CODE_REQUEST:
BT_HCI_DEBUG(1, "<< Pin Code Request", NULL); BT_HCI_DEBUG(1, "<< Pin Code Request");
/* Need to store the remote device's BT address in a temporary buffer for later use */ /* Need to store the remote device's BT address in a temporary buffer for later use */
memcpy(Bluetooth_TempDeviceAddress, memcpy(Bluetooth_TempDeviceAddress,
@ -116,7 +116,7 @@ void Bluetooth_HCITask(void)
Bluetooth_HCIProcessingState = Bluetooth_Conn_SendPINCode; Bluetooth_HCIProcessingState = Bluetooth_Conn_SendPINCode;
break; break;
case EVENT_LINK_KEY_REQUEST: case EVENT_LINK_KEY_REQUEST:
BT_HCI_DEBUG(1, "<< Link Key Request", NULL); BT_HCI_DEBUG(1, "<< Link Key Request");
/* Need to store the remote device's BT address in a temporary buffer for later use */ /* Need to store the remote device's BT address in a temporary buffer for later use */
memcpy(Bluetooth_TempDeviceAddress, memcpy(Bluetooth_TempDeviceAddress,
@ -126,7 +126,7 @@ void Bluetooth_HCITask(void)
Bluetooth_HCIProcessingState = Bluetooth_Conn_SendLinkKeyNAK; Bluetooth_HCIProcessingState = Bluetooth_Conn_SendLinkKeyNAK;
break; break;
case EVENT_CONNECTION_COMPLETE: case EVENT_CONNECTION_COMPLETE:
BT_HCI_DEBUG(1, "<< Connection Complete", NULL); BT_HCI_DEBUG(1, "<< Connection Complete");
BT_HCI_DEBUG(2, "-- Handle: 0x%04X", ((BT_HCIEvent_ConnectionComplete_t*)&EventParams)->ConnectionHandle); BT_HCI_DEBUG(2, "-- Handle: 0x%04X", ((BT_HCIEvent_ConnectionComplete_t*)&EventParams)->ConnectionHandle);
/* Need to store the remote device's BT address in a temporary buffer for later use */ /* Need to store the remote device's BT address in a temporary buffer for later use */
@ -141,7 +141,7 @@ void Bluetooth_HCITask(void)
Bluetooth_ConnectionComplete(); Bluetooth_ConnectionComplete();
break; break;
case EVENT_DISCONNECTION_COMPLETE: case EVENT_DISCONNECTION_COMPLETE:
BT_HCI_DEBUG(1, "<< Disconnection Complete", NULL); BT_HCI_DEBUG(1, "<< Disconnection Complete");
/* Device disconnected, indicate connection information no longer valid */ /* Device disconnected, indicate connection information no longer valid */
Bluetooth_Connection.IsConnected = false; Bluetooth_Connection.IsConnected = false;
@ -157,7 +157,7 @@ void Bluetooth_HCITask(void)
break; break;
case Bluetooth_Init: case Bluetooth_Init:
BT_HCI_DEBUG(1, "# Init", NULL); BT_HCI_DEBUG(1, "# Init");
/* Reset the connection information structure to destroy any previous connection state */ /* Reset the connection information structure to destroy any previous connection state */
memset(&Bluetooth_Connection, 0x00, sizeof(Bluetooth_Connection)); memset(&Bluetooth_Connection, 0x00, sizeof(Bluetooth_Connection));
@ -165,7 +165,7 @@ void Bluetooth_HCITask(void)
Bluetooth_HCIProcessingState = Bluetooth_Init_Reset; Bluetooth_HCIProcessingState = Bluetooth_Init_Reset;
break; break;
case Bluetooth_Init_Reset: case Bluetooth_Init_Reset:
BT_HCI_DEBUG(1, "# Reset", NULL); BT_HCI_DEBUG(1, "# Reset");
HCICommandHeader = (BT_HCICommand_Header_t) HCICommandHeader = (BT_HCICommand_Header_t)
{ {
@ -180,7 +180,7 @@ void Bluetooth_HCITask(void)
Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents; Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents;
break; break;
case Bluetooth_Init_SetLocalName: case Bluetooth_Init_SetLocalName:
BT_HCI_DEBUG(1, "# Set Local Name", NULL); BT_HCI_DEBUG(1, "# Set Local Name");
HCICommandHeader = (BT_HCICommand_Header_t) HCICommandHeader = (BT_HCICommand_Header_t)
{ {
@ -195,7 +195,7 @@ void Bluetooth_HCITask(void)
Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents; Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents;
break; break;
case Bluetooth_Init_SetDeviceClass: case Bluetooth_Init_SetDeviceClass:
BT_HCI_DEBUG(1, "# Set Device Class", NULL); BT_HCI_DEBUG(1, "# Set Device Class");
HCICommandHeader = (BT_HCICommand_Header_t) HCICommandHeader = (BT_HCICommand_Header_t)
{ {
@ -210,7 +210,7 @@ void Bluetooth_HCITask(void)
Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents; Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents;
break; break;
case Bluetooth_Init_WriteScanEnable: case Bluetooth_Init_WriteScanEnable:
BT_HCI_DEBUG(1, "# Write Scan Enable", NULL); BT_HCI_DEBUG(1, "# Write Scan Enable");
HCICommandHeader = (BT_HCICommand_Header_t) HCICommandHeader = (BT_HCICommand_Header_t)
{ {
@ -227,7 +227,7 @@ void Bluetooth_HCITask(void)
Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents; Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents;
break; break;
case Bluetooth_Conn_AcceptConnection: case Bluetooth_Conn_AcceptConnection:
BT_HCI_DEBUG(1, "# Accept Connection", NULL); BT_HCI_DEBUG(1, "# Accept Connection");
HCICommandHeader = (BT_HCICommand_Header_t) HCICommandHeader = (BT_HCICommand_Header_t)
{ {
@ -248,7 +248,7 @@ void Bluetooth_HCITask(void)
Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents; Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents;
break; break;
case Bluetooth_Conn_RejectConnection: case Bluetooth_Conn_RejectConnection:
BT_HCI_DEBUG(1, "# Reject Connection", NULL); BT_HCI_DEBUG(1, "# Reject Connection");
HCICommandHeader = (BT_HCICommand_Header_t) HCICommandHeader = (BT_HCICommand_Header_t)
{ {
@ -268,7 +268,7 @@ void Bluetooth_HCITask(void)
Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents; Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents;
break; break;
case Bluetooth_Conn_SendPINCode: case Bluetooth_Conn_SendPINCode:
BT_HCI_DEBUG(1, "# Send Pin Code", NULL); BT_HCI_DEBUG(1, "# Send Pin Code");
HCICommandHeader = (BT_HCICommand_Header_t) HCICommandHeader = (BT_HCICommand_Header_t)
{ {
@ -289,7 +289,7 @@ void Bluetooth_HCITask(void)
Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents; Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents;
break; break;
case Bluetooth_Conn_SendLinkKeyNAK: case Bluetooth_Conn_SendLinkKeyNAK:
BT_HCI_DEBUG(1, "# Send Link Key NAK", NULL); BT_HCI_DEBUG(1, "# Send Link Key NAK");
HCICommandHeader = (BT_HCICommand_Header_t) HCICommandHeader = (BT_HCICommand_Header_t)
{ {

@ -44,7 +44,7 @@
#include "BluetoothClassCodes.h" #include "BluetoothClassCodes.h"
/* Macros: */ /* Macros: */
#define BT_HCI_DEBUG(l, s, ...) do { if (HCI_DEBUG_LEVEL >= l) printf_P(PSTR("(HCI) " s "\r\n"), __VA_ARGS__); } while (0) #define BT_HCI_DEBUG(l, s, ...) do { if (HCI_DEBUG_LEVEL >= l) printf_P(PSTR("(HCI) " s "\r\n"), ##__VA_ARGS__); } while (0)
#define HCI_DEBUG_LEVEL 0 #define HCI_DEBUG_LEVEL 0
#define OGF_LINK_CONTROL 0x01 #define OGF_LINK_CONTROL 0x01

@ -71,7 +71,7 @@ void ServiceDiscovery_ProcessPacket(void* Data, Bluetooth_Channel_t* Channel)
SDP_PDUHeader_t* SDPHeader = (SDP_PDUHeader_t*)Data; SDP_PDUHeader_t* SDPHeader = (SDP_PDUHeader_t*)Data;
SDPHeader->ParameterLength = SwapEndian_16(SDPHeader->ParameterLength); SDPHeader->ParameterLength = SwapEndian_16(SDPHeader->ParameterLength);
BT_SDP_DEBUG(1, "SDP Packet Received", NULL); BT_SDP_DEBUG(1, "SDP Packet Received");
BT_SDP_DEBUG(2, "-- PDU ID: 0x%02X", SDPHeader->PDU); BT_SDP_DEBUG(2, "-- PDU ID: 0x%02X", SDPHeader->PDU);
BT_SDP_DEBUG(2, "-- Param Length: 0x%04X", SDPHeader->ParameterLength); BT_SDP_DEBUG(2, "-- Param Length: 0x%04X", SDPHeader->ParameterLength);
@ -91,19 +91,19 @@ void ServiceDiscovery_ProcessPacket(void* Data, Bluetooth_Channel_t* Channel)
static void ServiceDiscovery_ProcessServiceSearch(SDP_PDUHeader_t* SDPHeader) static void ServiceDiscovery_ProcessServiceSearch(SDP_PDUHeader_t* SDPHeader)
{ {
BT_SDP_DEBUG(1, "<< Service Search", NULL); BT_SDP_DEBUG(1, "<< Service Search");
} }
static void ServiceDiscovery_ProcessServiceAttribute(SDP_PDUHeader_t* SDPHeader) static void ServiceDiscovery_ProcessServiceAttribute(SDP_PDUHeader_t* SDPHeader)
{ {
BT_SDP_DEBUG(1, "<< Service Attribute", NULL); BT_SDP_DEBUG(1, "<< Service Attribute");
} }
static void ServiceDiscovery_ProcessServiceSearchAttribute(SDP_PDUHeader_t* SDPHeader) static void ServiceDiscovery_ProcessServiceSearchAttribute(SDP_PDUHeader_t* SDPHeader)
{ {
void* CurrentParameter = ((void*)SDPHeader + sizeof(SDP_PDUHeader_t)); void* CurrentParameter = ((void*)SDPHeader + sizeof(SDP_PDUHeader_t));
BT_SDP_DEBUG(1, "<< Service Search Attribute", NULL); BT_SDP_DEBUG(1, "<< Service Search Attribute");
uint8_t ElementHeaderSize; uint8_t ElementHeaderSize;

@ -43,7 +43,7 @@
#include "BluetoothStack.h" #include "BluetoothStack.h"
/* Macros: */ /* Macros: */
#define BT_SDP_DEBUG(l, s, ...) do { if (SDP_DEBUG_LEVEL >= l) printf_P(PSTR("(SDP) " s "\r\n"), __VA_ARGS__); } while (0) #define BT_SDP_DEBUG(l, s, ...) do { if (SDP_DEBUG_LEVEL >= l) printf_P(PSTR("(SDP) " s "\r\n"), ##__VA_ARGS__); } while (0)
#define SDP_DEBUG_LEVEL 2 #define SDP_DEBUG_LEVEL 2
#define SDP_PDU_ERRORRESPONSE 0x01 #define SDP_PDU_ERRORRESPONSE 0x01

@ -53,12 +53,16 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter
uint16_t ReportINSize = 0; uint16_t ReportINSize = 0;
uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF); uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF);
uint8_t ReportType = (USB_ControlRequest.wValue >> 8) - 1; uint8_t ReportType = (USB_ControlRequest.wValue >> 8) - 1;
uint8_t ReportINData[HIDInterfaceInfo->Config.PrevReportINBufferSize];
memset(HIDInterfaceInfo->Config.PrevReportINBuffer, 0, HIDInterfaceInfo->Config.PrevReportINBufferSize); memset(ReportINData, 0, sizeof(ReportINData));
CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportType, CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportType,
HIDInterfaceInfo->Config.PrevReportINBuffer, &ReportINSize); HIDInterfaceInfo->Config.PrevReportINBuffer, &ReportINSize);
if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL)
memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINData, HIDInterfaceInfo->Config.PrevReportINBufferSize);
Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
Endpoint_Write_Control_Stream_LE(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize); Endpoint_Write_Control_Stream_LE(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize);
Endpoint_ClearOUT(); Endpoint_ClearOUT();
@ -169,7 +173,7 @@ void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo)
if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL) if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL)
{ {
StatesChanged = (memcmp(ReportINData, HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize) != 0); StatesChanged = (memcmp(ReportINData, HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize) != 0);
memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINData, ReportINSize); memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINData, HIDInterfaceInfo->Config.PrevReportINBufferSize);
} }
if (ReportINSize && (ForceSend || StatesChanged || IdlePeriodElapsed)) if (ReportINSize && (ForceSend || StatesChanged || IdlePeriodElapsed))

@ -106,7 +106,8 @@
uint8_t PrevReportINBufferSize; /**< Size in bytes of the given input report buffer. This is used to create a uint8_t PrevReportINBufferSize; /**< Size in bytes of the given input report buffer. This is used to create a
* second buffer of the same size within the driver so that subsequent reports * second buffer of the same size within the driver so that subsequent reports
* can be compared. If the user app is to determine when reports are to be sent * can be compared. If the user app is to determine when reports are to be sent
* exclusively (i.e. \ref PrevReportINBuffer is NULL) this value is ignored. * exclusively (i.e. \ref PrevReportINBuffer is NULL) this value must still be
* set to the size of the largest report the device can issue to the host.
*/ */
} Config; /**< Config data for the USB class interface within the device. All elements in this section } Config; /**< Config data for the USB class interface within the device. All elements in this section
* <b>must</b> be set or the interface will fail to enumerate and operate correctly. * <b>must</b> be set or the interface will fail to enumerate and operate correctly.

@ -43,6 +43,8 @@
* a valid session ID to the device * a valid session ID to the device
* - Removed invalid dfu and flip related targets from the bootloaders - bootloaders can only be replaced with an external programmer * - Removed invalid dfu and flip related targets from the bootloaders - bootloaders can only be replaced with an external programmer
* - Fixed Set/Clear Feature requests directed to a non-configured endpoint not returning a stall to the host * - Fixed Set/Clear Feature requests directed to a non-configured endpoint not returning a stall to the host
* - Fixed HID Device Class Driver not allocating a temporary buffer when the host requests a report via the control endpoint and the
* user has set the PrevReportINBuffer driver configuration element to NULL (thanks to Lars Noschinski)
* *
* \section Sec_ChangeLog100219 Version 100219 * \section Sec_ChangeLog100219 Version 100219
* *

Loading…
Cancel
Save