24 #if !defined(_usb_h_) || defined(__CONFDESCPARSER_H__)
25 #error "Never include confdescparser.h directly; include Usb.h instead"
28 #define __CONFDESCPARSER_H__
35 virtual void EndpointXtract(uint8_t conf __attribute__((unused)), uint8_t iface __attribute__((unused)), uint8_t alt __attribute__((unused)), uint8_t proto __attribute__((unused)),
const USB_ENDPOINT_DESCRIPTOR *ep __attribute__((unused))) {
39 #define CP_MASK_COMPARE_CLASS 1
40 #define CP_MASK_COMPARE_SUBCLASS 2
41 #define CP_MASK_COMPARE_PROTOCOL 4
42 #define CP_MASK_COMPARE_ALL 7
46 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
52 uint8_t varBuffer[16 ];
54 uint8_t stateParseDescr;
66 bool ParseDescriptor(uint8_t **pp, uint16_t *pcntdn);
75 void Parse(
const uint16_t len,
const uint8_t *pbuf,
const uint16_t &offset);
78 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
80 theXtractor(xtractor),
85 theBuffer.
pValue = varBuffer;
90 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
92 uint16_t cntdn = (uint16_t)len;
93 uint8_t *p = (uint8_t*)pbuf;
96 if(!ParseDescriptor(&p, &cntdn))
102 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
106 switch(stateParseDescr) {
108 theBuffer.valueSize = 2;
109 valParser.Initialize(&theBuffer);
113 if(!valParser.Parse(pp, pcntdn))
115 dscrLen = *((uint8_t*)theBuffer.pValue);
116 dscrType = *((uint8_t*)theBuffer.pValue + 1);
125 theBuffer.pValue = varBuffer + 2;
131 isGoodInterface =
false;
138 theBuffer.valueSize = dscrLen - 2;
139 valParser.Initialize(&theBuffer);
145 if(!valParser.Parse(pp, pcntdn))
150 if(!valParser.Parse(pp, pcntdn))
163 isGoodInterface =
true;
169 if(!valParser.Parse(pp, pcntdn))
173 theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (
USB_ENDPOINT_DESCRIPTOR*)varBuffer);
181 if(!theSkipper.Skip(pp, pcntdn, dscrLen - 2))
184 theBuffer.pValue = varBuffer;
190 template <const u
int8_t CLASS_ID, const u
int8_t SUBCLASS_ID, const u
int8_t PROTOCOL_ID, const u
int8_t MASK>
192 Notify(
PSTR(
"\r\n\r\nHID Descriptor:\r\n"), 0x80);
194 PrintHex<uint8_t > (pDesc->
bLength, 0x80);
200 PrintHex<uint16_t > (pDesc->
bcdHID, 0x80);
212 PrintHex<uint8_t > (pLT[i].bDescrType, 0x80);
214 Notify(
PSTR(
"\r\nwDescriptorLength:\t"), 0x80);
215 PrintHex<uint16_t > (pLT[i].wDescriptorLength, 0x80);
void Initialize(MultiValueBuffer *pbuf)
void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset)
ConfigDescParser(UsbConfigXtracter *xtractor)
void Initialize(MultiValueBuffer *const pbuf)
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
#define CP_MASK_COMPARE_PROTOCOL
#define CP_MASK_COMPARE_SUBCLASS
#define CP_MASK_COMPARE_CLASS
uint8_t bConfigurationValue
uint8_t bAlternateSetting
uint8_t bInterfaceSubClass
uint8_t bInterfaceProtocol
#define USB_DESCRIPTOR_INTERFACE
#define HID_DESCRIPTOR_HID
#define USB_DESCRIPTOR_CONFIGURATION
#define USB_DESCRIPTOR_ENDPOINT