[usb] Microsoft OS String Descriptor v1

Change-Id: I7f77656b714f8c1bbe5f0b6d535d8df1cf3d36bb
This commit is contained in:
Léa Saviot
2018-03-29 16:10:34 +02:00
parent 28c6cfbade
commit c890b34cd5
6 changed files with 59 additions and 16 deletions

View File

@@ -17,6 +17,7 @@ usb_objs += $(addprefix ion/src/device/usb/stack/, \
dfu_functional_descriptor.o\
interface_descriptor.o\
language_id_string_descriptor.o \
microsoft_os_string_descriptor.o\
platform_device_capability_descriptor.o\
streamable.o\
string_descriptor.o\

View File

@@ -25,6 +25,11 @@ void Calculator::Poll() {
}
Descriptor * Calculator::descriptor(uint8_t type, uint8_t index) {
/* Special case: Microsoft OS String Descriptor should be returned when
* searching for string descriptor at index 0xEE. */
if (type == m_microsoftOSStringDescriptor.type() && index == 0xEE) {
return &m_microsoftOSStringDescriptor;
}
int typeCount = 0;
for (size_t i=0; i<sizeof(m_descriptors)/sizeof(m_descriptors[0]); i++) {
Descriptor * descriptor = m_descriptors[i];

View File

@@ -10,6 +10,7 @@
#include "stack/dfu_functional_descriptor.h"
#include "stack/interface_descriptor.h"
#include "stack/language_id_string_descriptor.h"
#include "stack/microsoft_os_string_descriptor.h"
#include "stack/string_descriptor.h"
#include "stack/url_descriptor.h"
#include "stack/webusb_platform_descriptor.h"
@@ -88,6 +89,7 @@ public:
m_serialNumberStringDescriptor("12345"),
m_interfaceStringDescriptor("@Flash/0x08000000/04*016Kg,01*064Kg,07*128Kg"),
//m_interfaceStringDescriptor("@SRAM/0x20000000/01*256Ke"), //TODO: Add this descriptor to use dfu-util to write in the SRAM
m_microsoftOSStringDescriptor(k_microsoftOSVendorCode),
m_workshopURLDescriptor(URLDescriptor::Scheme::HTTPS, "workshop.numworks.com"),
m_descriptors{
&m_deviceDescriptor, // Type = Device, Index = 0
@@ -117,6 +119,7 @@ private:
static constexpr uint8_t k_dfuInterfaceAlternateSetting = 0;
static constexpr uint8_t k_webUSBVendorCode = 1;
static constexpr uint8_t k_webUSBLandingPageIndex = 1;
static constexpr uint8_t k_microsoftOSVendorCode = 2;
bool getURLCommand(uint8_t * transferBuffer, uint16_t * transferBufferLength, uint16_t transferBufferMaxLength);
DeviceDescriptor m_deviceDescriptor;
DFUFunctionalDescriptor m_dfuFunctionalDescriptor;
@@ -129,6 +132,7 @@ private:
StringDescriptor m_productStringDescriptor;
StringDescriptor m_serialNumberStringDescriptor;
StringDescriptor m_interfaceStringDescriptor;
MicrosoftOSStringDescriptor m_microsoftOSStringDescriptor;
URLDescriptor m_workshopURLDescriptor;
Descriptor * m_descriptors[8];

View File

@@ -0,0 +1,19 @@
#include "microsoft_os_string_descriptor.h"
namespace Ion {
namespace USB {
namespace Device {
void MicrosoftOSStringDescriptor::push(Channel * c) const {
StringDescriptor::push(c);
c->push(m_bMSVendorCode);
c->push(m_bPad);
}
uint8_t MicrosoftOSStringDescriptor::bLength() const {
return StringDescriptor::bLength() + 2 * sizeof(uint8_t);
}
}
}
}

View File

@@ -0,0 +1,30 @@
#ifndef ION_DEVICE_USB_STACK_MICROSOFT_OS_STRING_DESCRIPTOR_H
#define ION_DEVICE_USB_STACK_MICROSOFT_OS_STRING_DESCRIPTOR_H
#include "string_descriptor.h"
namespace Ion {
namespace USB {
namespace Device {
class MicrosoftOSStringDescriptor : public StringDescriptor {
public:
constexpr MicrosoftOSStringDescriptor(uint8_t bMSVendorCode) :
StringDescriptor("MSFT100"),
m_bMSVendorCode(bMSVendorCode),
m_bPad(0)
{
}
protected:
void push(Channel * c) const override;
virtual uint8_t bLength() const override;
private:
uint8_t m_bMSVendorCode;
uint8_t m_bPad;
};
}
}
}
#endif

View File

@@ -1,16 +0,0 @@
class OSStringDescriptor : public Descriptor {
public:
StringDescriptor(const char * string);
void copy(void * target) override {
memcpy(this, target, sizeof(Descriptor));
// Ensuite, on veut pousser le compat ID et les extended properties
;
}
private:
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t qwSignature[14];
uint8_t bMS_VendorCode;
uint8_t bPad;
};