fix: update DALI double send delay and increase SPIRAM malloc reserve size

This commit fix the crash risk when bus abnormal.

Signed-off-by: Tony <tonylu@tony-cloud.com>
This commit is contained in:
Tony
2026-06-16 06:07:06 +08:00
parent 49dcd8785b
commit 3fca7161fc
11 changed files with 321 additions and 35 deletions
@@ -20,6 +20,7 @@ struct GatewayUsbSetupBridgeConfig {
size_t tx_buffer_size{256};
uint32_t read_timeout_ms{20};
uint32_t write_timeout_ms{20};
uint32_t reset_pulse_ms{10};
uint32_t task_stack_size{4096};
UBaseType_t task_priority{4};
};
@@ -45,4 +46,4 @@ class GatewayUsbSetupBridge {
bool started_{false};
};
} // namespace gateway
} // namespace gateway
@@ -89,6 +89,22 @@ void GatewayUsbSetupBridge::handleBytes(const uint8_t* data, size_t len) {
}
const uint8_t gateway_id = setupGatewayId();
if (len == 3 && data[0] == 0x01 && data[1] == 0x00 && data[2] == 0x00) {
const bool ok = dali_domain_.pulseBusLow(gateway_id, config_.reset_pulse_ms);
const uint8_t response[2] = {static_cast<uint8_t>(ok ? 0x01 : 0xFD), 0x00};
const int written = usb_serial_jtag_write_bytes(response, sizeof(response),
pdMS_TO_TICKS(config_.write_timeout_ms));
if (written < 0 || static_cast<size_t>(written) != sizeof(response)) {
ESP_LOGW(kTag, "failed to write USB bus reset response channel=%u ok=%u",
config_.channel_index, ok ? 1 : 0);
}
if (!ok) {
ESP_LOGW(kTag, "failed to pulse DALI bus low for USB reset channel=%u gateway=%u",
config_.channel_index, gateway_id);
}
return;
}
if (data[0] == 0x12) {
const auto response = dali_domain_.transactBridgeFrame(gateway_id, data, len);
if (!response.empty()) {
@@ -131,4 +147,4 @@ uint8_t GatewayUsbSetupBridge::setupGatewayId() const {
return config_.channel_index;
}
} // namespace gateway
} // namespace gateway