Skip to content

Commit 575251f

Browse files
committed
usb-device: Default bDeviceClass, bDeviceSubClass, bDeviceProtocol to 0.
These values are apparently interpreted as "interface defined", which is a good fit for what happens here (more than one interface might show up in the device). It works as expected for the examples in Linux and Windows 10. There will probably be some scenarios where a different value needs to be explicitly passed in for the device. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
1 parent e40dd53 commit 575251f

File tree

1 file changed

+6
-6
lines changed
  • micropython/usb/usb-device/usb/device

1 file changed

+6
-6
lines changed

micropython/usb/usb-device/usb/device/impl.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ def config( # noqa: PLR0913
9595
id_vendor=None,
9696
id_product=None,
9797
bcd_device=None,
98-
device_class=None,
99-
device_subclass=None,
100-
device_protocol=None,
98+
device_class=0,
99+
device_subclass=0,
100+
device_protocol=0,
101101
config_str=None,
102102
max_power_ma=None,
103103
):
@@ -137,9 +137,9 @@ def maybe_set(value, idx):
137137
f[0], # bLength
138138
f[1], # bDescriptorType
139139
f[2], # bcdUSB
140-
maybe_set(device_class, 3), # bDeviceClass
141-
maybe_set(device_subclass, 4), # bDeviceSubClass
142-
maybe_set(device_protocol, 5), # bDeviceProtocol
140+
device_class, # bDeviceClass
141+
device_subclass, # bDeviceSubClass
142+
device_protocol, # bDeviceProtocol
143143
f[6], # bMaxPacketSize0, TODO: allow overriding this value?
144144
maybe_set(id_vendor, 7), # idVendor
145145
maybe_set(id_product, 8), # idProduct

0 commit comments

Comments
 (0)