Clean up incomplete BluetoothHost debugging commands to use GCC extension to avoid NULL parameters when no formatting is required.
\r
Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL);\r
\r
- BT_ACL_DEBUG(1, ">> L2CAP Configuration Request", NULL);\r
+ BT_ACL_DEBUG(1, ">> L2CAP Configuration Request");\r
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", PacketData.ConfigurationRequest.DestinationChannel);\r
}\r
}\r
Pipe_Read_Stream_LE(&ACLPacketHeader, sizeof(ACLPacketHeader));\r
Pipe_Read_Stream_LE(&DataHeader, sizeof(DataHeader));\r
\r
- BT_ACL_DEBUG(2, "", NULL);\r
- BT_ACL_DEBUG(2, "Packet Received", NULL);\r
+ BT_ACL_DEBUG(2, "");\r
+ BT_ACL_DEBUG(2, "Packet Received");\r
BT_ACL_DEBUG(2, "-- Connection Handle: 0x%04X", (ACLPacketHeader.ConnectionHandle & 0x0FFF));\r
BT_ACL_DEBUG(2, "-- Data Length: 0x%04X", ACLPacketHeader.DataLength);\r
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DataHeader.DestinationChannel);\r
Bluetooth_Signal_InformationReq(&SignalCommandHeader);\r
break;\r
case BT_SIGNAL_COMMAND_REJECT:\r
- BT_ACL_DEBUG(1, "<< Command Reject", NULL);\r
+ BT_ACL_DEBUG(1, "<< Command Reject");\r
\r
uint16_t RejectReason;\r
Pipe_Read_Stream_LE(&RejectReason, sizeof(RejectReason));\r
\r
Pipe_Freeze();\r
\r
- BT_ACL_DEBUG(2, "", NULL);\r
- BT_ACL_DEBUG(2, "Packet Sent", NULL);\r
+ BT_ACL_DEBUG(2, "");\r
+ BT_ACL_DEBUG(2, "Packet Sent");\r
BT_ACL_DEBUG(2, "-- Connection Handle: 0x%04X", (ACLPacketHeader.ConnectionHandle & 0x0FFF));\r
BT_ACL_DEBUG(2, "-- Data Length: 0x%04X", ACLPacketHeader.DataLength);\r
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DataHeader.DestinationChannel);\r
\r
Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL);\r
\r
- BT_ACL_DEBUG(1, ">> L2CAP Connection Request", NULL);\r
+ BT_ACL_DEBUG(1, ">> L2CAP Connection Request");\r
BT_ACL_DEBUG(2, "-- PSM 0x%04X", PacketData.ConnectionRequest.PSM);\r
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", PacketData.ConnectionRequest.SourceChannel);\r
\r
\r
Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL);\r
\r
- BT_ACL_DEBUG(1, ">> L2CAP Disconnection Request", NULL);\r
+ BT_ACL_DEBUG(1, ">> L2CAP Disconnection Request");\r
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", PacketData.DisconnectionRequest.DestinationChannel); \r
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", PacketData.DisconnectionRequest.SourceChannel); \r
}\r
Pipe_ClearIN();\r
Pipe_Freeze();\r
\r
- BT_ACL_DEBUG(1, "<< L2CAP Connection Request", NULL);\r
+ BT_ACL_DEBUG(1, "<< L2CAP Connection Request");\r
BT_ACL_DEBUG(2, "-- PSM: 0x%04X", ConnectionRequest.PSM);\r
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionRequest.SourceChannel);\r
\r
\r
Bluetooth_SendPacket(&ResponsePacket, sizeof(ResponsePacket), NULL);\r
\r
- BT_ACL_DEBUG(1, ">> L2CAP Connection Response", NULL);\r
+ BT_ACL_DEBUG(1, ">> L2CAP Connection Response");\r
BT_ACL_DEBUG(2, "-- Result: 0x%02X", ResponsePacket.ConnectionResponse.Result);\r
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ResponsePacket.ConnectionResponse.DestinationChannel);\r
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ResponsePacket.ConnectionResponse.SourceChannel);\r
Pipe_ClearIN();\r
Pipe_Freeze();\r
\r
- BT_ACL_DEBUG(1, "<< L2CAP Connection Response", NULL);\r
+ BT_ACL_DEBUG(1, "<< L2CAP Connection Response");\r
BT_ACL_DEBUG(2, "-- Result: 0x%02X", ConnectionResponse.Result); \r
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionResponse.SourceChannel); \r
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ConnectionResponse.DestinationChannel); \r
/* Search for the referenced channel in the channel information list */\r
Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(ConfigurationRequest.DestinationChannel, false);\r
\r
- BT_ACL_DEBUG(1, "<< L2CAP Configuration Request", NULL);\r
+ BT_ACL_DEBUG(1, "<< L2CAP Configuration Request");\r
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ConfigurationRequest.DestinationChannel);\r
BT_ACL_DEBUG(2, "-- Remote MTU: 0x%04X", ChannelData->RemoteMTU);\r
BT_ACL_DEBUG(2, "-- Options Len: 0x%04X", OptionsLen);\r
}\r
}\r
\r
- BT_ACL_DEBUG(1, ">> L2CAP Configuration Response", NULL);\r
+ BT_ACL_DEBUG(1, ">> L2CAP Configuration Response");\r
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ResponsePacket.ConfigurationResponse.SourceChannel);\r
BT_ACL_DEBUG(2, "-- Result: 0x%02X", ResponsePacket.ConfigurationResponse.Result);\r
}\r
Pipe_ClearIN();\r
Pipe_Freeze();\r
\r
- BT_ACL_DEBUG(1, "<< L2CAP Configuration Response", NULL);\r
+ BT_ACL_DEBUG(1, "<< L2CAP Configuration Response");\r
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConfigurationResponse.SourceChannel);\r
BT_ACL_DEBUG(2, "-- Result: 0x%02X", ConfigurationResponse.Result);\r
\r
\r
Pipe_Read_Stream_LE(&DisconnectionRequest, sizeof(DisconnectionRequest));\r
\r
- BT_ACL_DEBUG(1, "<< L2CAP Disconnection Request", NULL);\r
+ BT_ACL_DEBUG(1, "<< L2CAP Disconnection Request");\r
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DisconnectionRequest.DestinationChannel);\r
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", DisconnectionRequest.SourceChannel);\r
\r
if (ChannelData != NULL)\r
ChannelData->State = Channel_Closed;\r
\r
- BT_ACL_DEBUG(1, ">> L2CAP Disconnection Response", NULL);\r
+ BT_ACL_DEBUG(1, ">> L2CAP Disconnection Response");\r
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ResponsePacket.DisconnectionResponse.SourceChannel);\r
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ResponsePacket.DisconnectionResponse.DestinationChannel);\r
}\r
\r
Pipe_Read_Stream_LE(&DisconnectionResponse, sizeof(DisconnectionResponse));\r
\r
- BT_ACL_DEBUG(1, "<< L2CAP Disconnection Response", NULL);\r
+ BT_ACL_DEBUG(1, "<< L2CAP Disconnection Response");\r
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DisconnectionResponse.DestinationChannel);\r
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", DisconnectionResponse.SourceChannel);\r
\r
*/\r
static inline void Bluetooth_Signal_EchoReq(const BT_Signal_Header_t* const SignalCommandHeader)\r
{\r
- BT_ACL_DEBUG(1, "<< L2CAP Echo Request", NULL);\r
+ BT_ACL_DEBUG(1, "<< L2CAP Echo Request");\r
\r
Pipe_ClearIN();\r
Pipe_Freeze();\r
\r
Bluetooth_SendPacket(&ResponsePacket, sizeof(ResponsePacket), NULL);\r
\r
- BT_ACL_DEBUG(1, ">> L2CAP Echo Response", NULL);\r
+ BT_ACL_DEBUG(1, ">> L2CAP Echo Response");\r
}\r
\r
/** Internal Bluetooth stack Signal Command processing routine for an Information Request command.\r
\r
Pipe_Read_Stream_LE(&InformationRequest, sizeof(InformationRequest));\r
\r
- BT_ACL_DEBUG(1, "<< L2CAP Information Request", NULL);\r
+ BT_ACL_DEBUG(1, "<< L2CAP Information Request");\r
BT_ACL_DEBUG(2, "-- Info Type: 0x%04X", InformationRequest.InfoType);\r
\r
Pipe_ClearIN();\r
\r
Bluetooth_SendPacket(&ResponsePacket, (sizeof(ResponsePacket) - sizeof(ResponsePacket.Data) + DataLen), NULL);\r
\r
- BT_ACL_DEBUG(1, ">> L2CAP Information Response", NULL); \r
+ BT_ACL_DEBUG(1, ">> L2CAP Information Response"); \r
BT_ACL_DEBUG(2, "-- Result: 0x%02X", ResponsePacket.InformationResponse.Result);\r
}\r
#include "BluetoothStack.h"\r
\r
/* Macros: */\r
- #define BT_ACL_DEBUG(l, s, ...) do { if (ACL_DEBUG_LEVEL >= l) printf_P(PSTR("(ACL) " s "\r\n"), __VA_ARGS__); } while (0)\r
+ #define BT_ACL_DEBUG(l, s, ...) do { if (ACL_DEBUG_LEVEL >= l) printf_P(PSTR("(ACL) " s "\r\n"), ##__VA_ARGS__); } while (0)\r
#define ACL_DEBUG_LEVEL 0\r
\r
#define BT_CHANNELNUMBER_BASEOFFSET 0x0040\r
switch (HCIEventHeader.EventCode)\r
{\r
case EVENT_COMMAND_COMPLETE:\r
- BT_HCI_DEBUG(1, "<< Command Complete", NULL);\r
+ BT_HCI_DEBUG(1, "<< Command Complete");\r
Bluetooth_HCIProcessingState = Bluetooth_HCINextState;\r
break;\r
case EVENT_COMMAND_STATUS:\r
- BT_HCI_DEBUG(1, "<< Command Status", NULL);\r
+ BT_HCI_DEBUG(1, "<< Command Status");\r
BT_HCI_DEBUG(2, "-- Status Code: 0x%02X", (((BT_HCIEvent_CommandStatus_t*)&EventParams)->Status));\r
\r
/* If the execution of a command failed, reset the stack */\r
Bluetooth_HCIProcessingState = Bluetooth_Init;\r
break;\r
case EVENT_CONNECTION_REQUEST:\r
- BT_HCI_DEBUG(1, "<< Connection Request", NULL);\r
+ BT_HCI_DEBUG(1, "<< Connection Request");\r
BT_HCI_DEBUG(2, "-- Link Type: 0x%02X", (((BT_HCIEvent_ConnectionRequest_t*)&EventParams)->LinkType));\r
\r
/* Need to store the remote device's BT address in a temporary buffer for later use */\r
\r
break;\r
case EVENT_PIN_CODE_REQUEST:\r
- BT_HCI_DEBUG(1, "<< Pin Code Request", NULL);\r
+ BT_HCI_DEBUG(1, "<< Pin Code Request");\r
\r
/* Need to store the remote device's BT address in a temporary buffer for later use */\r
memcpy(Bluetooth_TempDeviceAddress,\r
Bluetooth_HCIProcessingState = Bluetooth_Conn_SendPINCode;\r
break;\r
case EVENT_LINK_KEY_REQUEST:\r
- BT_HCI_DEBUG(1, "<< Link Key Request", NULL);\r
+ BT_HCI_DEBUG(1, "<< Link Key Request");\r
\r
/* Need to store the remote device's BT address in a temporary buffer for later use */\r
memcpy(Bluetooth_TempDeviceAddress,\r
Bluetooth_HCIProcessingState = Bluetooth_Conn_SendLinkKeyNAK;\r
break;\r
case EVENT_CONNECTION_COMPLETE:\r
- BT_HCI_DEBUG(1, "<< Connection Complete", NULL);\r
+ BT_HCI_DEBUG(1, "<< Connection Complete");\r
BT_HCI_DEBUG(2, "-- Handle: 0x%04X", ((BT_HCIEvent_ConnectionComplete_t*)&EventParams)->ConnectionHandle);\r
\r
/* Need to store the remote device's BT address in a temporary buffer for later use */\r
Bluetooth_ConnectionComplete(); \r
break;\r
case EVENT_DISCONNECTION_COMPLETE:\r
- BT_HCI_DEBUG(1, "<< Disconnection Complete", NULL);\r
+ BT_HCI_DEBUG(1, "<< Disconnection Complete");\r
\r
/* Device disconnected, indicate connection information no longer valid */\r
Bluetooth_Connection.IsConnected = false;\r
\r
break;\r
case Bluetooth_Init:\r
- BT_HCI_DEBUG(1, "# Init", NULL);\r
+ BT_HCI_DEBUG(1, "# Init");\r
\r
/* Reset the connection information structure to destroy any previous connection state */\r
memset(&Bluetooth_Connection, 0x00, sizeof(Bluetooth_Connection));\r
Bluetooth_HCIProcessingState = Bluetooth_Init_Reset; \r
break;\r
case Bluetooth_Init_Reset:\r
- BT_HCI_DEBUG(1, "# Reset", NULL);\r
+ BT_HCI_DEBUG(1, "# Reset");\r
\r
HCICommandHeader = (BT_HCICommand_Header_t)\r
{\r
Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents;\r
break;\r
case Bluetooth_Init_SetLocalName:\r
- BT_HCI_DEBUG(1, "# Set Local Name", NULL);\r
+ BT_HCI_DEBUG(1, "# Set Local Name");\r
\r
HCICommandHeader = (BT_HCICommand_Header_t)\r
{\r
Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents;\r
break;\r
case Bluetooth_Init_SetDeviceClass:\r
- BT_HCI_DEBUG(1, "# Set Device Class", NULL);\r
+ BT_HCI_DEBUG(1, "# Set Device Class");\r
\r
HCICommandHeader = (BT_HCICommand_Header_t)\r
{\r
Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents;\r
break;\r
case Bluetooth_Init_WriteScanEnable:\r
- BT_HCI_DEBUG(1, "# Write Scan Enable", NULL);\r
+ BT_HCI_DEBUG(1, "# Write Scan Enable");\r
\r
HCICommandHeader = (BT_HCICommand_Header_t)\r
{\r
Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents;\r
break;\r
case Bluetooth_Conn_AcceptConnection:\r
- BT_HCI_DEBUG(1, "# Accept Connection", NULL);\r
+ BT_HCI_DEBUG(1, "# Accept Connection");\r
\r
HCICommandHeader = (BT_HCICommand_Header_t)\r
{\r
Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents;\r
break;\r
case Bluetooth_Conn_RejectConnection:\r
- BT_HCI_DEBUG(1, "# Reject Connection", NULL);\r
+ BT_HCI_DEBUG(1, "# Reject Connection");\r
\r
HCICommandHeader = (BT_HCICommand_Header_t)\r
{\r
Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents;\r
break;\r
case Bluetooth_Conn_SendPINCode:\r
- BT_HCI_DEBUG(1, "# Send Pin Code", NULL);\r
+ BT_HCI_DEBUG(1, "# Send Pin Code");\r
\r
HCICommandHeader = (BT_HCICommand_Header_t)\r
{\r
Bluetooth_HCIProcessingState = Bluetooth_ProcessEvents;\r
break;\r
case Bluetooth_Conn_SendLinkKeyNAK:\r
- BT_HCI_DEBUG(1, "# Send Link Key NAK", NULL);\r
+ BT_HCI_DEBUG(1, "# Send Link Key NAK");\r
\r
HCICommandHeader = (BT_HCICommand_Header_t)\r
{\r
#include "BluetoothClassCodes.h"\r
\r
/* Macros: */\r
- #define BT_HCI_DEBUG(l, s, ...) do { if (HCI_DEBUG_LEVEL >= l) printf_P(PSTR("(HCI) " s "\r\n"), __VA_ARGS__); } while (0)\r
+ #define BT_HCI_DEBUG(l, s, ...) do { if (HCI_DEBUG_LEVEL >= l) printf_P(PSTR("(HCI) " s "\r\n"), ##__VA_ARGS__); } while (0)\r
#define HCI_DEBUG_LEVEL 0\r
\r
#define OGF_LINK_CONTROL 0x01\r
SDP_PDUHeader_t* SDPHeader = (SDP_PDUHeader_t*)Data;\r
SDPHeader->ParameterLength = SwapEndian_16(SDPHeader->ParameterLength);\r
\r
- BT_SDP_DEBUG(1, "SDP Packet Received", NULL);\r
+ BT_SDP_DEBUG(1, "SDP Packet Received");\r
BT_SDP_DEBUG(2, "-- PDU ID: 0x%02X", SDPHeader->PDU);\r
BT_SDP_DEBUG(2, "-- Param Length: 0x%04X", SDPHeader->ParameterLength);\r
\r
\r
static void ServiceDiscovery_ProcessServiceSearch(SDP_PDUHeader_t* SDPHeader)\r
{\r
- BT_SDP_DEBUG(1, "<< Service Search", NULL);\r
+ BT_SDP_DEBUG(1, "<< Service Search");\r
}\r
\r
static void ServiceDiscovery_ProcessServiceAttribute(SDP_PDUHeader_t* SDPHeader)\r
{\r
- BT_SDP_DEBUG(1, "<< Service Attribute", NULL);\r
+ BT_SDP_DEBUG(1, "<< Service Attribute");\r
}\r
\r
static void ServiceDiscovery_ProcessServiceSearchAttribute(SDP_PDUHeader_t* SDPHeader)\r
{\r
void* CurrentParameter = ((void*)SDPHeader + sizeof(SDP_PDUHeader_t));\r
\r
- BT_SDP_DEBUG(1, "<< Service Search Attribute", NULL);\r
+ BT_SDP_DEBUG(1, "<< Service Search Attribute");\r
\r
uint8_t ElementHeaderSize;\r
\r
#include "BluetoothStack.h"\r
\r
/* Macros: */\r
- #define BT_SDP_DEBUG(l, s, ...) do { if (SDP_DEBUG_LEVEL >= l) printf_P(PSTR("(SDP) " s "\r\n"), __VA_ARGS__); } while (0)\r
+ #define BT_SDP_DEBUG(l, s, ...) do { if (SDP_DEBUG_LEVEL >= l) printf_P(PSTR("(SDP) " s "\r\n"), ##__VA_ARGS__); } while (0)\r
#define SDP_DEBUG_LEVEL 2\r
\r
#define SDP_PDU_ERRORRESPONSE 0x01\r
uint16_t ReportINSize = 0;\r
uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF);\r
uint8_t ReportType = (USB_ControlRequest.wValue >> 8) - 1;\r
+ uint8_t ReportINData[HIDInterfaceInfo->Config.PrevReportINBufferSize];\r
+\r
+ memset(ReportINData, 0, sizeof(ReportINData));\r
\r
- memset(HIDInterfaceInfo->Config.PrevReportINBuffer, 0, HIDInterfaceInfo->Config.PrevReportINBufferSize);\r
- \r
CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportType,\r
HIDInterfaceInfo->Config.PrevReportINBuffer, &ReportINSize);\r
+ \r
+ if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL)\r
+ memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINData, HIDInterfaceInfo->Config.PrevReportINBufferSize);\r
\r
Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
Endpoint_Write_Control_Stream_LE(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize);\r
if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL)\r
{\r
StatesChanged = (memcmp(ReportINData, HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize) != 0);\r
- memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINData, ReportINSize);\r
+ memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINData, HIDInterfaceInfo->Config.PrevReportINBufferSize);\r
}\r
\r
if (ReportINSize && (ForceSend || StatesChanged || IdlePeriodElapsed))\r
uint8_t PrevReportINBufferSize; /**< Size in bytes of the given input report buffer. This is used to create a\r
* second buffer of the same size within the driver so that subsequent reports\r
* can be compared. If the user app is to determine when reports are to be sent\r
- * exclusively (i.e. \ref PrevReportINBuffer is NULL) this value is ignored.\r
+ * exclusively (i.e. \ref PrevReportINBuffer is NULL) this value must still be\r
+ * set to the size of the largest report the device can issue to the host.\r
*/\r
} Config; /**< Config data for the USB class interface within the device. All elements in this section\r
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
* a valid session ID to the device\r
* - Removed invalid dfu and flip related targets from the bootloaders - bootloaders can only be replaced with an external programmer\r
* - Fixed Set/Clear Feature requests directed to a non-configured endpoint not returning a stall to the host\r
+ * - Fixed HID Device Class Driver not allocating a temporary buffer when the host requests a report via the control endpoint and the\r
+ * user has set the PrevReportINBuffer driver configuration element to NULL (thanks to Lars Noschinski)\r
*\r
* \section Sec_ChangeLog100219 Version 100219\r
*\r