refactor(ups-hid): clean abstraction layers, strategy pattern for protocol selection and proper data structure

Signed-off-by: bullshit <coding@ow-software.pl>
This commit is contained in:
bullshit committed 2025-08-23 14:22:02 +02:00
1 parent 0c1e540bb9
commit 7015fd2239
41 files changed
+4768 -3013

No files matched your search

@@ -0,0 +1,27 @@
#include "usb_transport_factory.h"
#include "usb_transport_interface.h"
#include "simulated_transport.h"
#ifdef USE_ESP32
#include "esp32_usb_transport.h"
#endif
namespace esphome {
namespace ups_hid {
std::unique_ptr<IUsbTransport> UsbTransportFactory::create(TransportType type, bool simulation_mode) {
if (simulation_mode || type == SIMULATION) {
return std::make_unique<SimulatedTransport>();
}
#ifdef USE_ESP32
if (type == ESP32_HARDWARE) {
return std::make_unique<Esp32UsbTransport>();
}
#endif
// Default fallback to simulation if ESP32 not available
return std::make_unique<SimulatedTransport>();
}
} // namespace ups_hid
} // namespace esphome