mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-07 10:21:30 +00:00
Merge pull request #645 from ipopov/webserial-fix
Fix unintended control transfers in webserial example.
This commit is contained in:
commit
dc64d6ad55
@ -151,52 +151,54 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
|
|||||||
// nothing to with DATA & ACK stage
|
// nothing to with DATA & ACK stage
|
||||||
if (stage != CONTROL_STAGE_SETUP ) return true;
|
if (stage != CONTROL_STAGE_SETUP ) return true;
|
||||||
|
|
||||||
switch (request->bRequest)
|
if (request->bmRequestType_bit.type == TUSB_REQ_TYPE_VENDOR) {
|
||||||
{
|
switch (request->bRequest)
|
||||||
case VENDOR_REQUEST_WEBUSB:
|
{
|
||||||
// match vendor request in BOS descriptor
|
case VENDOR_REQUEST_WEBUSB:
|
||||||
// Get landing page url
|
// match vendor request in BOS descriptor
|
||||||
return tud_control_xfer(rhport, request, (void*) &desc_url, desc_url.bLength);
|
// Get landing page url
|
||||||
|
return tud_control_xfer(rhport, request, (void*) &desc_url, desc_url.bLength);
|
||||||
|
|
||||||
case VENDOR_REQUEST_MICROSOFT:
|
case VENDOR_REQUEST_MICROSOFT:
|
||||||
if ( request->wIndex == 7 )
|
if ( request->wIndex == 7 )
|
||||||
{
|
{
|
||||||
// Get Microsoft OS 2.0 compatible descriptor
|
// Get Microsoft OS 2.0 compatible descriptor
|
||||||
uint16_t total_len;
|
uint16_t total_len;
|
||||||
memcpy(&total_len, desc_ms_os_20+8, 2);
|
memcpy(&total_len, desc_ms_os_20+8, 2);
|
||||||
|
|
||||||
return tud_control_xfer(rhport, request, (void*) desc_ms_os_20, total_len);
|
return tud_control_xfer(rhport, request, (void*) desc_ms_os_20, total_len);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} else if (
|
||||||
|
request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS &&
|
||||||
|
request->bRequest == 0x22) {
|
||||||
|
// Webserial simulate the CDC_REQUEST_SET_CONTROL_LINE_STATE (0x22) to
|
||||||
|
// connect and disconnect.
|
||||||
|
web_serial_connected = (request->wValue != 0);
|
||||||
|
|
||||||
case 0x22:
|
// Always lit LED if connected
|
||||||
// Webserial simulate the CDC_REQUEST_SET_CONTROL_LINE_STATE (0x22) to
|
if ( web_serial_connected ) {
|
||||||
// connect and disconnect.
|
board_led_write(true);
|
||||||
web_serial_connected = (request->wValue != 0);
|
blink_interval_ms = BLINK_ALWAYS_ON;
|
||||||
|
|
||||||
// Always lit LED if connected
|
tud_vendor_write_str("\r\nTinyUSB WebUSB device example\r\n");
|
||||||
if ( web_serial_connected )
|
}else
|
||||||
{
|
{
|
||||||
board_led_write(true);
|
blink_interval_ms = BLINK_MOUNTED;
|
||||||
blink_interval_ms = BLINK_ALWAYS_ON;
|
}
|
||||||
|
|
||||||
tud_vendor_write_str("\r\nTinyUSB WebUSB device example\r\n");
|
// response with status OK
|
||||||
}else
|
return tud_control_status(rhport, request);
|
||||||
{
|
|
||||||
blink_interval_ms = BLINK_MOUNTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
// response with status OK
|
|
||||||
return tud_control_status(rhport, request);
|
|
||||||
|
|
||||||
default:
|
|
||||||
// stall unknown request
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
// stall unknown request
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void webserial_task(void)
|
void webserial_task(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user