1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 17:38:39 +00:00

trezorhal: fix webusb landing page

This commit is contained in:
Pavol Rusnak 2018-01-23 02:21:35 +01:00
parent 919e2b9c3b
commit 089168209b
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 18 additions and 23 deletions

View File

@ -285,6 +285,21 @@ static uint8_t usb_class_setup(USBD_HandleTypeDef *dev, USBD_SetupReqTypedef *re
((req->bmRequest & USB_REQ_TYPE_MASK) != USB_REQ_TYPE_VENDOR)) {
return USBD_OK;
}
if ((req->bmRequest & USB_REQ_TYPE_MASK) == USB_REQ_TYPE_VENDOR) {
if (req->bRequest == USB_WEBUSB_VENDOR_CODE) {
if (req->wIndex == USB_WEBUSB_REQ_GET_URL && req->wValue == USB_WEBUSB_LANDING_PAGE) {
static const char webusb_url[] = {
3 + 15, // uint8_t bLength
USB_WEBUSB_DESCRIPTOR_TYPE_URL, // uint8_t bDescriptorType
USB_WEBUSB_URL_SCHEME_HTTPS, // uint8_t bScheme
't', 'r', 'e', 'z', 'o', 'r', '.', 'i', 'o', '/', 's', 't', 'a', 'r', 't', // char URL[]
};
USBD_CtlSendData(dev, UNCONST(webusb_url), sizeof(webusb_url));
} else {
return USBD_FAIL;
}
}
}
if (req->wIndex >= USBD_MAX_NUM_INTERFACES) {
return USBD_FAIL;
}

View File

@ -227,13 +227,6 @@ static void usb_webusb_class_deinit(USBD_HandleTypeDef *dev, usb_webusb_state_t
static int usb_webusb_class_setup(USBD_HandleTypeDef *dev, usb_webusb_state_t *state, USBD_SetupReqTypedef *req) {
static const char webusb_url[] = {
3 + 15, // uint8_t bLength
USB_WEBUSB_DESCRIPTOR_TYPE_URL, // uint8_t bDescriptorType
USB_WEBUSB_URL_SCHEME_HTTPS, // uint8_t bScheme
't', 'r', 'e', 'z', 'o', 'r', '.', 'i', 'o', '/', 's', 't', 'a', 'r', 't', // char URL[]
};
#if USE_WINUSB
static uint8_t winusb_wcid[] = {
// header
@ -267,22 +260,9 @@ static int usb_webusb_class_setup(USBD_HandleTypeDef *dev, usb_webusb_state_t *s
switch (req->bmRequest & USB_REQ_TYPE_MASK) {
case USB_REQ_TYPE_VENDOR: // Vendor request
switch (req->bRequest) {
case USB_WEBUSB_VENDOR_CODE:
switch (req->wIndex) {
case USB_WEBUSB_REQ_GET_URL:
// we should check whether req->wValue == USB_WEBUSB_LANDING_PAGE,
// but let's return always the same url for all indexes
USBD_CtlSendData(dev, UNCONST(webusb_url), sizeof(webusb_url));
break;
default:
USBD_CtlError(dev, req);
return USBD_FAIL;
}
break;
#if USE_WINUSB
case USB_REQ_TYPE_VENDOR: // Vendor request
switch (req->bRequest) {
case USB_WINUSB_VENDOR_CODE:
switch (req->bmRequest & USB_REQ_RECIPIENT_MASK) {
case USB_REQ_RECIPIENT_DEVICE:
@ -294,12 +274,12 @@ static int usb_webusb_class_setup(USBD_HandleTypeDef *dev, usb_webusb_state_t *s
break;
}
break;
#endif
default:
USBD_CtlError(dev, req);
return USBD_FAIL;
}
break;
#endif
case USB_REQ_TYPE_STANDARD: // Interface & Endpoint request