Is there a way to set the manufacturer and product description strings for the ESP32-S2 when using Adafruit_TinyUSB_Arduino?
If we look in Adafruit_USBD_Device.cpp we see that a number of functions are stubbed out when you are using the ESP32-S2, so calling setProductDescriptor() and setManufacturerDescriptor() won't work. Indeed we see this comment at line 139:
// EPS32 use built-in core descriptor builder.
So can anyone point me to how one uses the built-in core descriptor builder to set these strings?
ESP32-S2 TinyUSB Set Manufacturer and product strings
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- jockm
- Posts: 65
- Joined: Mon May 13, 2013 11:43 pm
- hathach
- Posts: 1271
- Joined: Tue Apr 23, 2013 1:02 am
Re: ESP32-S2 TinyUSB Set Manufacturer and product strings
use these API from arduino-esp32 https://github.com/espressif/arduino-es ... /USB.h#L83
- jockm
- Posts: 65
- Joined: Mon May 13, 2013 11:43 pm
Re: ESP32-S2 TinyUSB Set Manufacturer and product strings
Following the lead of Adafruit_USBD_WebUSB.cpp, where USB.usbVersion() is set in the constructor:
I placed the following code in startup():
And saw no change in System Monitor.
I am sorry to be a pest, but this is all under-documented. I would gladly R the TFM if I could simply find one.
Code: Select all
Adafruit_USBD_WebUSB::Adafruit_USBD_WebUSB(const void *url) {
_connected = false;
_url = (const uint8_t *)url;
_linestate_cb = NULL;
#ifdef ARDUINO_ARCH_ESP32
// ESP32 requires setup configuration descriptor within constructor
// WebUSB requires USB version at least 2.1 (or 3.x)
USB.usbVersion(0x0210);
_webusb_dev = this;
uint16_t const desc_len = getInterfaceDescriptor(0, NULL, 0);
tinyusb_enable_interface(USB_INTERFACE_VENDOR, desc_len,
webusb_load_descriptor);
#endif
}
Code: Select all
Adafruit_USBD_HID *usb_hid;
// the setup function runs once when you press reset or power the board
void setup()
{
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
TinyUSB_Device_Init(0);
#endif
linxBufferPos = 0;
currentChannel = 255;
USB.productName("productName");
USB.manufacturerName("manufacturerName");
USB.serialNumber("serialNumber");
USB.webUSBURL("webUSBURL");
// USB.begin();
usb_hid = new Adafruit_USBD_HID(hidReportDescriptor, sizeof(hidReportDescriptor), HID_ITF_PROTOCOL_NONE, 2, true);
usb_hid->setReportCallback(get_report_callback, set_report_callback);
usb_hid->begin();
// wait until device mounted
while( !TinyUSBDevice.mounted() ) delay(1);
}
I am sorry to be a pest, but this is all under-documented. I would gladly R the TFM if I could simply find one.
- hathach
- Posts: 1271
- Joined: Tue Apr 23, 2013 1:02 am
Re: ESP32-S2 TinyUSB Set Manufacturer and product strings
by epressif design, all the descriptors cannot be changed one USB.begin() is called which is done before setup(). You have to do it within an object constructor to make sure it is invoked before USB.begin() (like webusb does). This behavior is specific to esp32 and annoying to me as well. You should look at their usb code in the core for more information
Please be positive and constructive with your questions and comments.