diff --git a/cores/esp32/USB.cpp b/cores/esp32/USB.cpp index ad1df4c22e8..8740bb71763 100644 --- a/cores/esp32/USB.cpp +++ b/cores/esp32/USB.cpp @@ -48,7 +48,7 @@ #define USB_WEBUSB_ENABLED false #endif #ifndef USB_WEBUSB_URL -#define USB_WEBUSB_URL "https://espressif.github.io/arduino-esp32/webusb.html" +#define USB_WEBUSB_URL "https://docs.espressif.com/projects/arduino-esp32/en/latest/_static/webusb.html" #endif #if CFG_TUD_DFU diff --git a/docs/_static/webusb.html b/docs/_static/webusb.html new file mode 100644 index 00000000000..34eb986ba72 --- /dev/null +++ b/docs/_static/webusb.html @@ -0,0 +1,128 @@ + + + + + + Espressif WebUSB Console Example + + + + + + +


+ +
+

+
+ + + diff --git a/docs/en/api/usb.rst b/docs/en/api/usb.rst index 94261185f61..056e3fcc1ae 100644 --- a/docs/en/api/usb.rst +++ b/docs/en/api/usb.rst @@ -303,7 +303,7 @@ This function is used to get the ``webUSBURL``. const char * webUSBURL(void); -The default ``webUSBURL`` is: https://espressif.github.io/arduino-esp32/webusb.html +The default ``webUSBURL`` is: https://docs.espressif.com/projects/arduino-esp32/en/latest/_static/webusb.html enableDFU ^^^^^^^^^ diff --git a/libraries/USB/examples/USBVendor/USBVendor.ino b/libraries/USB/examples/USBVendor/USBVendor.ino index a2b236d8f10..350c532b50d 100644 --- a/libraries/USB/examples/USBVendor/USBVendor.ino +++ b/libraries/USB/examples/USBVendor/USBVendor.ino @@ -164,7 +164,8 @@ void setup() { USB.onEvent(usbEventCallback); USB.webUSB(true); - USB.webUSBURL("http://localhost/webusb"); + // Set the URL for your WebUSB landing page + USB.webUSBURL("https://docs.espressif.com/projects/arduino-esp32/en/latest/_static/webusb.html"); USB.begin(); } @@ -176,9 +177,11 @@ void loop() { if (buttonState == LOW) { Serial.println("Button Pressed"); Vendor.println("Button Pressed"); + Vendor.flush(); //Without flushing the data will only be sent when the buffer is full (64 bytes) } else { - Vendor.println("Button Released"); Serial.println("Button Released"); + Vendor.println("Button Released"); + Vendor.flush(); //Without flushing the data will only be sent when the buffer is full (64 bytes) } delay(100); } @@ -188,6 +191,7 @@ void loop() { uint8_t b[l]; l = Serial.read(b, l); Vendor.write(b, l); + Vendor.flush(); //Without flushing the data will only be sent when the buffer is full (64 bytes) } } #endif /* ARDUINO_USB_MODE */ diff --git a/libraries/USB/examples/USBVendor/index.html b/libraries/USB/examples/USBVendor/index.html new file mode 100644 index 00000000000..23831bb4582 --- /dev/null +++ b/libraries/USB/examples/USBVendor/index.html @@ -0,0 +1,133 @@ + + + + + + + + Espressif WebUSB Console Example + + + + + + +


+ +
+

+
+ + + diff --git a/libraries/USB/src/USBVendor.cpp b/libraries/USB/src/USBVendor.cpp index da3d0e18653..d5dbd616b40 100644 --- a/libraries/USB/src/USBVendor.cpp +++ b/libraries/USB/src/USBVendor.cpp @@ -212,7 +212,9 @@ size_t USBVendor::read(uint8_t *buffer, size_t size){ return count; } -void USBVendor::flush(void){} +void USBVendor::flush(void){ + tud_vendor_n_write_flush(itf); +} #endif /* CONFIG_TINYUSB_VENDOR_ENABLED */ #endif /* SOC_USB_OTG_SUPPORTED */ diff --git a/variants/esp32s2usb/pins_arduino.h b/variants/esp32s2usb/pins_arduino.h index 636c62482a0..222c1de75e2 100644 --- a/variants/esp32s2usb/pins_arduino.h +++ b/variants/esp32s2usb/pins_arduino.h @@ -10,7 +10,7 @@ #define USB_PRODUCT "ESP32-S2-USB" #define USB_SERIAL "0" #define USB_WEBUSB_ENABLED false -#define USB_WEBUSB_URL "https://espressif.github.io/arduino-esp32/webusb.html" +#define USB_WEBUSB_URL "https://docs.espressif.com/projects/arduino-esp32/en/latest/_static/webusb.html" // Default USB FirmwareMSC Settings #define USB_FW_MSC_VENDOR_ID "ESP32-S2" //max 8 chars