From 575251fb0194e70f8427d230c96c3908ae073cc7 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Wed, 3 Apr 2024 16:08:26 +1100 Subject: [PATCH] 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 --- micropython/usb/usb-device/usb/device/impl.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/micropython/usb/usb-device/usb/device/impl.py b/micropython/usb/usb-device/usb/device/impl.py index b8b1786d..24a8df64 100644 --- a/micropython/usb/usb-device/usb/device/impl.py +++ b/micropython/usb/usb-device/usb/device/impl.py @@ -95,9 +95,9 @@ class _Device: id_vendor=None, id_product=None, bcd_device=None, - device_class=None, - device_subclass=None, - device_protocol=None, + device_class=0, + device_subclass=0, + device_protocol=0, config_str=None, max_power_ma=None, ): @@ -137,9 +137,9 @@ class _Device: f[0], # bLength f[1], # bDescriptorType f[2], # bcdUSB - maybe_set(device_class, 3), # bDeviceClass - maybe_set(device_subclass, 4), # bDeviceSubClass - maybe_set(device_protocol, 5), # bDeviceProtocol + device_class, # bDeviceClass + device_subclass, # bDeviceSubClass + device_protocol, # bDeviceProtocol f[6], # bMaxPacketSize0, TODO: allow overriding this value? maybe_set(id_vendor, 7), # idVendor maybe_set(id_product, 8), # idProduct