From df3724830871b66b3a2d1edb57d09b8b2e340141 Mon Sep 17 00:00:00 2001 From: Tomasz Duda Date: Tue, 1 Oct 2024 17:50:54 +0200 Subject: [PATCH] fix s2 implementation --- esphome/components/usb_device/__init__.py | 2 -- esphome/components/usb_device/usb_device.cpp | 23 +++++++------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/esphome/components/usb_device/__init__.py b/esphome/components/usb_device/__init__.py index b82faebb07..3ffedbbf0d 100644 --- a/esphome/components/usb_device/__init__.py +++ b/esphome/components/usb_device/__init__.py @@ -42,5 +42,3 @@ CONFIG_SCHEMA = cv.All( async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) await cg.register_component(var, config) - cg.add_build_flag("-Wl,--wrap=tud_mount_cb") - cg.add_build_flag("-Wl,--wrap=tud_umount_cb") diff --git a/esphome/components/usb_device/usb_device.cpp b/esphome/components/usb_device/usb_device.cpp index 500b573b53..929a3f6518 100644 --- a/esphome/components/usb_device/usb_device.cpp +++ b/esphome/components/usb_device/usb_device.cpp @@ -9,19 +9,6 @@ #endif #endif -extern "C" { -bool configured; - -void __wrap_tud_mount_cb(void){ - configured = true; -} - -void __wrap_tud_umount_cb(void){ - configured = false; -} - -} - namespace esphome { namespace usb_device { @@ -30,14 +17,12 @@ static const char *const TAG = "usb_device"; void UsbDevice::update() { #ifdef USE_BINARY_SENSOR if (configured_ != nullptr) { - // bool configured = USB; configured_->publish_state(get_configured_()); } #endif } void UsbDevice::dump_config() { - // bool configured = USB; ESP_LOGCONFIG(TAG, "USB device - configured: %s", YESNO(get_configured_())); } @@ -54,7 +39,15 @@ bool UsbDevice::get_configured_() { #else return USBSerial; #endif +#else +// this is subject of change by other components so make sure that we won't fail to report silently +#error Not implemented #endif +#elif USE_ESP32_VARIANT_ESP32S2 + return USB; +#else +// this is subject of change by other components so make sure that we won't fail to report silently +#error Not implemented #endif return false; }