feat(gateway): implement LegacyRawPayload function for DALI and USB components
Signed-off-by: Tony <tonylu@tony-cloud.com>
This commit is contained in:
@@ -12,6 +12,13 @@ namespace gateway {
|
||||
namespace {
|
||||
constexpr const char* kTag = "gateway_usb";
|
||||
constexpr size_t kCommandFrameMinLen = 7;
|
||||
|
||||
std::vector<uint8_t> LegacyRawPayload(const std::vector<uint8_t>& data) {
|
||||
if (data.size() == 1) {
|
||||
return {0xBE, data[0]};
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
GatewayUsbSetupBridge::GatewayUsbSetupBridge(GatewayController& controller,
|
||||
@@ -106,11 +113,12 @@ void GatewayUsbSetupBridge::handleRawFrame(const DaliRawFrame& frame) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int written = usb_serial_jtag_write_bytes(frame.data.data(), frame.data.size(),
|
||||
const auto payload = LegacyRawPayload(frame.data);
|
||||
const int written = usb_serial_jtag_write_bytes(payload.data(), payload.size(),
|
||||
pdMS_TO_TICKS(config_.write_timeout_ms));
|
||||
if (written < 0 || static_cast<size_t>(written) != frame.data.size()) {
|
||||
if (written < 0 || static_cast<size_t>(written) != payload.size()) {
|
||||
ESP_LOGW(kTag, "failed to forward USB raw setup frame channel=%u len=%u", frame.channel_index,
|
||||
static_cast<unsigned>(frame.data.size()));
|
||||
static_cast<unsigned>(payload.size()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user