#pragma once #include namespace esphome { namespace grub_boot_switch { // Built at runtime from configuration values so VID/PID/strings can be tuned // from YAML. Lifetime: descriptors live forever once built (single device). struct UsbDescriptorBundle { // tusb_desc_device_t struct (18 bytes), kept opaque here to avoid leaking // tusb headers into the rest of the component. uint8_t device[18]; // Configuration descriptor: 9 (config) + 9 (interface) + 2*7 (endpoints) = 32 bytes. uint8_t config[32]; // String descriptors: index 0 = lang (English), 1 = manufacturer, // 2 = product, 3 = serial. ASCII C-strings, null terminated. const char *strings[4]; char serial_buf[24]; // backing store for the auto-generated serial. }; // Populate the bundle from runtime values. The serial_buf is filled with the // chip's MAC address ("E072A1D54520") if `serial_override` is null/empty. void usb_descriptors_build(UsbDescriptorBundle *bundle, uint16_t vid, uint16_t pid, const char *manufacturer, const char *product, const char *serial_override); } // namespace grub_boot_switch } // namespace esphome