diff --git a/sw/include/usb-desc.h b/sw/include/usb-desc.h index 5d8ecce..8d706cf 100644 --- a/sw/include/usb-desc.h +++ b/sw/include/usb-desc.h @@ -90,6 +90,6 @@ extern const usb_descriptor_list_t usb_descriptor_list[]; #define LANDING_PAGE_DESCRIPTOR_SIZE (WEBUSB_DT_URL_DESCRIPTOR_SIZE \ + sizeof(LANDING_PAGE_URL) - 1) -extern const struct webusb_url_descriptor landing_url_descriptor; +const uint8_t *get_landing_url_descriptor(uint32_t *datalen); #endif diff --git a/sw/src/usb-desc.c b/sw/src/usb-desc.c index ce2afa6..0af26ec 100644 --- a/sw/src/usb-desc.c +++ b/sw/src/usb-desc.c @@ -166,13 +166,19 @@ const uint8_t usb_microsoft_wcid[MSFT_WCID_LEN] = { 0,0,0,0,0,0, // Reserved }; -const struct webusb_url_descriptor landing_url_descriptor = { +static const struct webusb_url_descriptor landing_url_descriptor = { .bLength = LANDING_PAGE_DESCRIPTOR_SIZE, .bDescriptorType = WEBUSB_DT_URL, .bScheme = WEBUSB_URL_SCHEME_HTTPS, .URL = LANDING_PAGE_URL }; +const uint8_t *get_landing_url_descriptor(uint32_t *datalen) { + // Return landing page URL descriptor + *datalen = LANDING_PAGE_DESCRIPTOR_SIZE; + return (const uint8_t*)&landing_url_descriptor; +} + struct full_bos { struct usb_bos_descriptor bos; struct webusb_platform_descriptor webusb; diff --git a/sw/src/usb-dev.c b/sw/src/usb-dev.c index 0293465..ed16acf 100644 --- a/sw/src/usb-dev.c +++ b/sw/src/usb-dev.c @@ -126,9 +126,7 @@ void usb_setup(const struct usb_setup_request *setup) { if (setup->wValue == 0x0001) { - // Return landing page URL descriptor - data = (uint8_t*)&landing_url_descriptor; - datalen = LANDING_PAGE_DESCRIPTOR_SIZE; + data = get_landing_url_descriptor(&datalen); break; } }