Skip to content

Commit 5f26930

Browse files
committed
bring over previous work
1 parent 7e75112 commit 5f26930

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/arduino/Adafruit_USBD_Device.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ void Adafruit_USBD_Device::setProductDescriptor(const char *s) {
122122
_desc_str_arr[STRID_PRODUCT] = s;
123123
}
124124

125+
void Adafruit_USBD_Device::setSerialDescriptor(const char *s) {
126+
_desc_str_arr[STRID_SERIAL] = s;
127+
}
128+
125129
void Adafruit_USBD_Device::task(void) { tud_task(); }
126130

127131
bool Adafruit_USBD_Device::mounted(void) { return tud_mounted(); }
@@ -206,6 +210,7 @@ void Adafruit_USBD_Device::clearConfiguration(void) {
206210
_desc_str_arr[STRID_LANGUAGE] = (const char *)((uint32_t)USB_LANGUAGE);
207211
_desc_str_arr[STRID_MANUFACTURER] = USB_MANUFACTURER;
208212
_desc_str_arr[STRID_PRODUCT] = USB_PRODUCT;
213+
_desc_str_arr[STRID_SERIAL] = nullptr;
209214
// STRID_SERIAL is platform dependent
210215

211216
_desc_str_count = 4;
@@ -316,8 +321,11 @@ uint16_t const *Adafruit_USBD_Device::descriptor_string_cb(uint8_t index,
316321
break;
317322

318323
case STRID_SERIAL:
319-
chr_count = getSerialDescriptor(_desc_str);
320-
break;
324+
if (!_desc_str_arr[STRID_SERIAL]) {
325+
chr_count = getSerialDescriptor(_desc_str);
326+
break;
327+
}
328+
// else we have a serial string, treat as all others, fall through
321329

322330
default:
323331
// Invalid index

src/arduino/Adafruit_USBD_Device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class Adafruit_USBD_Device {
8585
void setLanguageDescriptor(uint16_t language_id);
8686
void setManufacturerDescriptor(const char *s);
8787
void setProductDescriptor(const char *s);
88+
void setSerialDescriptor(const char *s);
8889
uint8_t getSerialDescriptor(uint16_t *serial_utf16);
8990

9091
//------------- Control -------------//

0 commit comments

Comments
 (0)