2323 * 
2424 */ 
2525
26+ #include  "pico/unique_id.h" 
2627#include  "tusb.h" 
2728#include  "usb_descriptors.h" 
2829
@@ -177,13 +178,16 @@ uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
177178// String Descriptors 
178179//--------------------------------------------------------------------+ 
179180
181+ // buffer to hold flash ID 
182+ char  serial [2  *  PICO_UNIQUE_BOARD_ID_SIZE_BYTES  +  1 ];
183+ 
180184// array of pointer to string descriptors 
181185char  const *  string_desc_arr  [] = 
182186{
183187  (const  char []) { 0x09 , 0x04  }, // 0: is supported language is English (0x0409) 
184188  "TinyUSB" ,                     // 1: Manufacturer 
185189  "TinyUSB Device" ,              // 2: Product 
186-   "123456" ,                      // 3: Serials, should use chip  ID 
190+   serial ,                         // 3: Serials, uses the flash  ID 
187191};
188192
189193static  uint16_t  _desc_str [32 ];
@@ -205,6 +209,8 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
205209    // Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors. 
206210    // https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors 
207211
212+     if  (index  ==  3 ) pico_get_unique_board_id_string (serial , sizeof (serial ));
213+     
208214    if  ( !(index  <  sizeof (string_desc_arr )/sizeof (string_desc_arr [0 ])) ) return  NULL ;
209215
210216    const  char *  str  =  string_desc_arr [index ];
0 commit comments