From 8252b4febd928718c4b416d7be262afa6a39075f Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Tue, 20 Apr 2010 08:52:51 +0000 Subject: [PATCH] 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. --- .../BluetoothHost/Lib/BluetoothACLPackets.c | 42 +++++++++---------- .../BluetoothHost/Lib/BluetoothACLPackets.h | 2 +- .../BluetoothHost/Lib/BluetoothHCICommands.c | 32 +++++++------- .../BluetoothHost/Lib/BluetoothHCICommands.h | 2 +- .../Lib/ServiceDiscoveryProtocol.c | 8 ++-- .../Lib/ServiceDiscoveryProtocol.h | 2 +- LUFA/Drivers/USB/Class/Device/HID.c | 10 +++-- LUFA/Drivers/USB/Class/Device/HID.h | 3 +- LUFA/ManPages/ChangeLog.txt | 2 + 9 files changed, 55 insertions(+), 48 deletions(-) diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c index 87ef652a9a..1a8cf06c08 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c @@ -90,7 +90,7 @@ void Bluetooth_ACLTask(void) 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); } } @@ -118,8 +118,8 @@ static void Bluetooth_ProcessIncommingACLPackets(void) Pipe_Read_Stream_LE(&ACLPacketHeader, sizeof(ACLPacketHeader)); Pipe_Read_Stream_LE(&DataHeader, sizeof(DataHeader)); - BT_ACL_DEBUG(2, "", NULL); - BT_ACL_DEBUG(2, "Packet Received", NULL); + BT_ACL_DEBUG(2, ""); + BT_ACL_DEBUG(2, "Packet Received"); 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, "-- Destination Channel: 0x%04X", DataHeader.DestinationChannel); @@ -160,7 +160,7 @@ static void Bluetooth_ProcessIncommingACLPackets(void) Bluetooth_Signal_InformationReq(&SignalCommandHeader); break; case BT_SIGNAL_COMMAND_REJECT: - BT_ACL_DEBUG(1, "<< Command Reject", NULL); + BT_ACL_DEBUG(1, "<< Command Reject"); uint16_t 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(); - BT_ACL_DEBUG(2, "", NULL); - BT_ACL_DEBUG(2, "Packet Sent", NULL); + BT_ACL_DEBUG(2, ""); + BT_ACL_DEBUG(2, "Packet Sent"); 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, "-- 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); - 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, "-- 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); - 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, "-- 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_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, "-- 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); - 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, "-- Destination Channel: 0x%04X", ResponsePacket.ConnectionResponse.DestinationChannel); 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_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, "-- Source Channel: 0x%04X", ConnectionResponse.SourceChannel); 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 */ 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, "-- Remote MTU: 0x%04X", ChannelData->RemoteMTU); 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, "-- Result: 0x%02X", ResponsePacket.ConfigurationResponse.Result); } @@ -559,7 +559,7 @@ static inline void Bluetooth_Signal_ConfigurationResp(const BT_Signal_Header_t* Pipe_ClearIN(); 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, "-- 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)); - 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, "-- 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) 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, "-- 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)); - 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, "-- 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) { - BT_ACL_DEBUG(1, "<< L2CAP Echo Request", NULL); + BT_ACL_DEBUG(1, "<< L2CAP Echo Request"); Pipe_ClearIN(); 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); - 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. @@ -697,7 +697,7 @@ static inline void Bluetooth_Signal_InformationReq(const BT_Signal_Header_t* con 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); 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); - 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); } diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h index 01da758b47..1a72cede34 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h @@ -43,7 +43,7 @@ #include "BluetoothStack.h" /* 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 BT_CHANNELNUMBER_BASEOFFSET 0x0040 diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c index 55c7518144..2f78621a14 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c @@ -73,11 +73,11 @@ void Bluetooth_HCITask(void) switch (HCIEventHeader.EventCode) { case EVENT_COMMAND_COMPLETE: - BT_HCI_DEBUG(1, "<< Command Complete", NULL); + BT_HCI_DEBUG(1, "<< Command Complete"); Bluetooth_HCIProcessingState = Bluetooth_HCINextState; break; 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)); /* If the execution of a command failed, reset the stack */ @@ -85,7 +85,7 @@ void Bluetooth_HCITask(void) Bluetooth_HCIProcessingState = Bluetooth_Init; break; 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)); /* 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; 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 */ memcpy(Bluetooth_TempDeviceAddress, @@ -116,7 +116,7 @@ void Bluetooth_HCITask(void) Bluetooth_HCIProcessingState = Bluetooth_Conn_SendPINCode; break; 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 */ memcpy(Bluetooth_TempDeviceAddress, @@ -126,7 +126,7 @@ void Bluetooth_HCITask(void) Bluetooth_HCIProcessingState = Bluetooth_Conn_SendLinkKeyNAK; break; 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); /* 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(); break; 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 */ Bluetooth_Connection.IsConnected = false; @@ -157,7 +157,7 @@ void Bluetooth_HCITask(void) break; 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 */ memset(&Bluetooth_Connection, 0x00, sizeof(Bluetooth_Connection)); @@ -165,7 +165,7 @@ void Bluetooth_HCITask(void) Bluetooth_HCIProcessingState = Bluetooth_Init_Reset; break; case Bluetooth_Init_Reset: - BT_HCI_DEBUG(1, "# Reset", NULL); + BT_HCI_DEBUG(1, "# Reset"); HCICommandHeader = (BT_HCICommand_Header_t) { @@ -180,7 +180,7 @@ void Bluetooth_HCITask(void) Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents; break; case Bluetooth_Init_SetLocalName: - BT_HCI_DEBUG(1, "# Set Local Name", NULL); + BT_HCI_DEBUG(1, "# Set Local Name"); HCICommandHeader = (BT_HCICommand_Header_t) { @@ -195,7 +195,7 @@ void Bluetooth_HCITask(void) Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents; break; case Bluetooth_Init_SetDeviceClass: - BT_HCI_DEBUG(1, "# Set Device Class", NULL); + BT_HCI_DEBUG(1, "# Set Device Class"); HCICommandHeader = (BT_HCICommand_Header_t) { @@ -210,7 +210,7 @@ void Bluetooth_HCITask(void) Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents; break; case Bluetooth_Init_WriteScanEnable: - BT_HCI_DEBUG(1, "# Write Scan Enable", NULL); + BT_HCI_DEBUG(1, "# Write Scan Enable"); HCICommandHeader = (BT_HCICommand_Header_t) { @@ -227,7 +227,7 @@ void Bluetooth_HCITask(void) Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents; break; case Bluetooth_Conn_AcceptConnection: - BT_HCI_DEBUG(1, "# Accept Connection", NULL); + BT_HCI_DEBUG(1, "# Accept Connection"); HCICommandHeader = (BT_HCICommand_Header_t) { @@ -248,7 +248,7 @@ void Bluetooth_HCITask(void) Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents; break; case Bluetooth_Conn_RejectConnection: - BT_HCI_DEBUG(1, "# Reject Connection", NULL); + BT_HCI_DEBUG(1, "# Reject Connection"); HCICommandHeader = (BT_HCICommand_Header_t) { @@ -268,7 +268,7 @@ void Bluetooth_HCITask(void) Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents; break; case Bluetooth_Conn_SendPINCode: - BT_HCI_DEBUG(1, "# Send Pin Code", NULL); + BT_HCI_DEBUG(1, "# Send Pin Code"); HCICommandHeader = (BT_HCICommand_Header_t) { @@ -289,7 +289,7 @@ void Bluetooth_HCITask(void) Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents; break; 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) { diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.h b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.h index 71b87dd38c..282fcbc7f1 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.h @@ -44,7 +44,7 @@ #include "BluetoothClassCodes.h" /* 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 OGF_LINK_CONTROL 0x01 diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.c b/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.c index 58f47a1eb6..49645163e1 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.c +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.c @@ -71,7 +71,7 @@ void ServiceDiscovery_ProcessPacket(void* Data, Bluetooth_Channel_t* Channel) SDP_PDUHeader_t* SDPHeader = (SDP_PDUHeader_t*)Data; 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, "-- 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) { - BT_SDP_DEBUG(1, "<< Service Search", NULL); + BT_SDP_DEBUG(1, "<< Service Search"); } 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) { 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; diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h b/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h index 26b3c109dc..397d10bffb 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/ServiceDiscoveryProtocol.h @@ -43,7 +43,7 @@ #include "BluetoothStack.h" /* 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_PDU_ERRORRESPONSE 0x01 diff --git a/LUFA/Drivers/USB/Class/Device/HID.c b/LUFA/Drivers/USB/Class/Device/HID.c index cc1ad43b5b..7ff32498bc 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.c +++ b/LUFA/Drivers/USB/Class/Device/HID.c @@ -53,11 +53,15 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter uint16_t ReportINSize = 0; uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF); uint8_t ReportType = (USB_ControlRequest.wValue >> 8) - 1; + uint8_t ReportINData[HIDInterfaceInfo->Config.PrevReportINBufferSize]; + + memset(ReportINData, 0, sizeof(ReportINData)); - memset(HIDInterfaceInfo->Config.PrevReportINBuffer, 0, HIDInterfaceInfo->Config.PrevReportINBufferSize); - CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportType, HIDInterfaceInfo->Config.PrevReportINBuffer, &ReportINSize); + + if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL) + memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINData, HIDInterfaceInfo->Config.PrevReportINBufferSize); Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); Endpoint_Write_Control_Stream_LE(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize); @@ -169,7 +173,7 @@ void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL) { 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)) diff --git a/LUFA/Drivers/USB/Class/Device/HID.h b/LUFA/Drivers/USB/Class/Device/HID.h index 1ab71771fb..92751241b9 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.h +++ b/LUFA/Drivers/USB/Class/Device/HID.h @@ -106,7 +106,8 @@ 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 * 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 * must be set or the interface will fail to enumerate and operate correctly. diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt index f4c995f172..fe59357a65 100644 --- a/LUFA/ManPages/ChangeLog.txt +++ b/LUFA/ManPages/ChangeLog.txt @@ -43,6 +43,8 @@ * 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 * - 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 *