From 5da82d5adfd0753bcdbbd27cb54a20c1235d643f Mon Sep 17 00:00:00 2001
From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com>
Date: Wed, 6 Mar 2024 13:25:41 -0300
Subject: [PATCH 1/5] Add WebUSB console
---
cores/esp32/USB.cpp | 2 +-
docs/_static/webusb.html | 126 ++++++++++++++++++
docs/en/api/usb.rst | 2 +-
.../USB/examples/USBVendor/USBVendor.ino | 2 +-
libraries/USB/examples/USBVendor/index.html | 126 ++++++++++++++++++
variants/esp32s2usb/pins_arduino.h | 2 +-
6 files changed, 256 insertions(+), 4 deletions(-)
create mode 100644 docs/_static/webusb.html
create mode 100644 libraries/USB/examples/USBVendor/index.html
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..eb251dec234
--- /dev/null
+++ b/docs/_static/webusb.html
@@ -0,0 +1,126 @@
+
+
+
+ WebUSB Serial Sample Application
+
+
+
+
+
+
+
+
+
+
+
+
+
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..6642751d11a 100644
--- a/libraries/USB/examples/USBVendor/USBVendor.ino
+++ b/libraries/USB/examples/USBVendor/USBVendor.ino
@@ -164,7 +164,7 @@ void setup() {
USB.onEvent(usbEventCallback);
USB.webUSB(true);
- USB.webUSBURL("http://localhost/webusb");
+ USB.webUSBURL("https://docs.espressif.com/projects/arduino-esp32/en/latest/_static/webusb.html");
USB.begin();
}
diff --git a/libraries/USB/examples/USBVendor/index.html b/libraries/USB/examples/USBVendor/index.html
new file mode 100644
index 00000000000..eb251dec234
--- /dev/null
+++ b/libraries/USB/examples/USBVendor/index.html
@@ -0,0 +1,126 @@
+
+
+
+ WebUSB Serial Sample Application
+
+
+
+
+
+
+
+
+
+
+
+
+
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
From a0d97ad1343afb14c620cdbc7759b7a9a6688463 Mon Sep 17 00:00:00 2001
From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com>
Date: Wed, 6 Mar 2024 13:37:17 -0300
Subject: [PATCH 2/5] Improve Console Page
---
docs/_static/webusb.html | 226 ++++++++++++++++++++-------------------
1 file changed, 114 insertions(+), 112 deletions(-)
diff --git a/docs/_static/webusb.html b/docs/_static/webusb.html
index eb251dec234..34eb986ba72 100644
--- a/docs/_static/webusb.html
+++ b/docs/_static/webusb.html
@@ -1,126 +1,128 @@
+
+
- WebUSB Serial Sample Application
+ Espressif WebUSB Console Example
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
From 0c052b9ce35a1649550c2fe2903642921fc2b07a Mon Sep 17 00:00:00 2001
From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com>
Date: Wed, 6 Mar 2024 13:38:13 -0300
Subject: [PATCH 3/5] Improve example
---
libraries/USB/examples/USBVendor/index.html | 226 ++++++++++----------
1 file changed, 114 insertions(+), 112 deletions(-)
diff --git a/libraries/USB/examples/USBVendor/index.html b/libraries/USB/examples/USBVendor/index.html
index eb251dec234..34eb986ba72 100644
--- a/libraries/USB/examples/USBVendor/index.html
+++ b/libraries/USB/examples/USBVendor/index.html
@@ -1,126 +1,128 @@
+
+
- WebUSB Serial Sample Application
+ Espressif WebUSB Console Example
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
From f4fec8630656d42f7b16d58381e6069c3c1dc02a Mon Sep 17 00:00:00 2001
From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com>
Date: Wed, 6 Mar 2024 13:42:35 -0300
Subject: [PATCH 4/5] Add comments
---
libraries/USB/examples/USBVendor/USBVendor.ino | 1 +
libraries/USB/examples/USBVendor/index.html | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/libraries/USB/examples/USBVendor/USBVendor.ino b/libraries/USB/examples/USBVendor/USBVendor.ino
index 6642751d11a..8a1cbb13f1b 100644
--- a/libraries/USB/examples/USBVendor/USBVendor.ino
+++ b/libraries/USB/examples/USBVendor/USBVendor.ino
@@ -164,6 +164,7 @@ void setup() {
USB.onEvent(usbEventCallback);
USB.webUSB(true);
+ // Set the URL for your WebUSB landing page
USB.webUSBURL("https://docs.espressif.com/projects/arduino-esp32/en/latest/_static/webusb.html");
USB.begin();
}
diff --git a/libraries/USB/examples/USBVendor/index.html b/libraries/USB/examples/USBVendor/index.html
index 34eb986ba72..23831bb4582 100644
--- a/libraries/USB/examples/USBVendor/index.html
+++ b/libraries/USB/examples/USBVendor/index.html
@@ -1,5 +1,10 @@
+
+
From d9aeb3c8b9df8edb27b6c51c94c2d11cd7685028 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Proch=C3=A1zka?=
<90197375+P-R-O-C-H-Y@users.noreply.github.com>
Date: Fri, 8 Mar 2024 13:32:20 -0300
Subject: [PATCH 5/5] Add flush method
---
libraries/USB/examples/USBVendor/USBVendor.ino | 5 ++++-
libraries/USB/src/USBVendor.cpp | 4 +++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/libraries/USB/examples/USBVendor/USBVendor.ino b/libraries/USB/examples/USBVendor/USBVendor.ino
index 8a1cbb13f1b..350c532b50d 100644
--- a/libraries/USB/examples/USBVendor/USBVendor.ino
+++ b/libraries/USB/examples/USBVendor/USBVendor.ino
@@ -177,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);
}
@@ -189,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/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 */