@@ -122,40 +122,10 @@ TU_VERIFY_STATIC(sizeof(desc_ms_os_20) == MS_OS_20_DESC_LEN, "Incorrect size");
122
122
// --------------------------------------------------------------------+
123
123
// IMPLEMENTATION
124
124
// --------------------------------------------------------------------+
125
-
126
- #ifdef ARDUINO_ARCH_ESP32
127
- static uint16_t webusb_load_descriptor (uint8_t *dst, uint8_t *itf) {
128
- // uint8_t str_index = tinyusb_add_string_descriptor("TinyUSB MSC");
129
-
130
- uint8_t ep_in = tinyusb_get_free_in_endpoint ();
131
- uint8_t ep_out = tinyusb_get_free_out_endpoint ();
132
- TU_VERIFY (ep_in && ep_out);
133
- ep_in |= 0x80 ;
134
-
135
- uint16_t desc_len = _webusb_dev->getInterfaceDescriptorLen ();
136
- desc_len = _webusb_dev->makeItfDesc (*itf, dst, desc_len, ep_in, ep_out);
137
-
138
- *itf += 1 ;
139
- return desc_len;
140
- }
141
- #endif
142
-
143
125
Adafruit_USBD_WebUSB::Adafruit_USBD_WebUSB (const void *url) {
144
126
_connected = false ;
145
127
_url = (const uint8_t *)url;
146
128
_linestate_cb = NULL ;
147
-
148
- #ifdef ARDUINO_ARCH_ESP32
149
- // ESP32 requires setup configuration descriptor within constructor
150
-
151
- // WebUSB requires USB version at least 2.1 (or 3.x)
152
- USB.usbVersion (0x0210 );
153
-
154
- _webusb_dev = this ;
155
- uint16_t const desc_len = getInterfaceDescriptorLen ();
156
- tinyusb_enable_interface (USB_INTERFACE_VENDOR, desc_len,
157
- webusb_load_descriptor);
158
- #endif
159
129
}
160
130
161
131
bool Adafruit_USBD_WebUSB::begin (void ) {
@@ -179,29 +149,6 @@ void Adafruit_USBD_WebUSB::setLineStateCallback(linestate_callback_t fp) {
179
149
_linestate_cb = fp;
180
150
}
181
151
182
- uint16_t Adafruit_USBD_WebUSB::makeItfDesc (uint8_t itfnum, uint8_t *buf,
183
- uint16_t bufsize, uint8_t ep_in,
184
- uint8_t ep_out) {
185
- uint8_t desc[] = {
186
- TUD_VENDOR_DESCRIPTOR (itfnum, _strid, ep_out, ep_in, EPSIZE)};
187
- uint16_t const len = sizeof (desc);
188
-
189
- // null buffer for length only
190
- if (buf) {
191
- if (bufsize < len) {
192
- return 0 ;
193
- }
194
-
195
- memcpy (buf, desc, len);
196
-
197
- // update the bFirstInterface in MS OS 2.0 descriptor
198
- // that is binded to WinUSB driver
199
- desc_ms_os_20[0x0a + 0x08 + 4 ] = itfnum;
200
- }
201
-
202
- return len;
203
- }
204
-
205
152
uint16_t Adafruit_USBD_WebUSB::getInterfaceDescriptor (uint8_t itfnum_deprecated,
206
153
uint8_t *buf,
207
154
uint16_t bufsize) {
@@ -212,11 +159,25 @@ uint16_t Adafruit_USBD_WebUSB::getInterfaceDescriptor(uint8_t itfnum_deprecated,
212
159
}
213
160
214
161
uint8_t const itfnum = TinyUSBDevice.allocInterface (1 );
215
- ;
216
162
uint8_t const ep_in = TinyUSBDevice.allocEndpoint (TUSB_DIR_IN);
217
163
uint8_t const ep_out = TinyUSBDevice.allocEndpoint (TUSB_DIR_OUT);
218
164
219
- return makeItfDesc (itfnum, buf, bufsize, ep_in, ep_out);
165
+ uint8_t desc[] = {
166
+ TUD_VENDOR_DESCRIPTOR (itfnum, _strid, ep_out, ep_in, EPSIZE)};
167
+ uint16_t const len = sizeof (desc);
168
+
169
+ // null buffer for length only
170
+ if (bufsize < len) {
171
+ return 0 ;
172
+ }
173
+
174
+ memcpy (buf, desc, len);
175
+
176
+ // update the bFirstInterface in MS OS 2.0 descriptor
177
+ // that is bound to WinUSB driver
178
+ desc_ms_os_20[0x0a + 0x08 + 4 ] = itfnum;
179
+
180
+ return len;
220
181
}
221
182
222
183
bool Adafruit_USBD_WebUSB::connected (void ) {
0 commit comments