fix: enhance command frame validation and add DALI bus configuration options

Signed-off-by: Tony <tonylu@tony-cloud.com>
This commit is contained in:
Tony
2026-06-16 06:17:15 +08:00
parent 3fca7161fc
commit a2ea9e5bbe
3 changed files with 31 additions and 1 deletions
+28
View File
@@ -1171,6 +1171,34 @@ extern "C" void app_main(void) {
if (s_controller == nullptr) {
return out;
}
if (!gateway::GatewayRuntime::isGatewayCommandFrame(frame) ||
!gateway::GatewayRuntime::hasValidChecksum(frame) ||
frame.size() < 5) {
out.status = gateway::GatewayKnxGatewayTransactionStatus::kInvalidFrame;
return out;
}
const auto is_write_only_dali_frame =
[](const std::vector<uint8_t>& command) {
if (command.size() < 5) {
return false;
}
switch (command[3]) {
case 0x12:
case 0x13:
return command.size() >= 7;
case 0x60:
case 0x61:
return command.size() >= 8;
default:
return false;
}
};
if (is_write_only_dali_frame(frame)) {
out.status = s_controller->enqueueCommandFrame(frame)
? gateway::GatewayKnxGatewayTransactionStatus::kOk
: gateway::GatewayKnxGatewayTransactionStatus::kQueueRejected;
return out;
}
const auto result = s_controller->transactCommandFrame(frame, timeout_ms);
switch (result.status) {
case gateway::GatewayCommandTransactionStatus::kOk:
+2
View File
@@ -2925,7 +2925,9 @@ CONFIG_DALI_FORWARD_AFTER_BACKWARD_WAIT_MS=10
CONFIG_DALI_FORWARD_MAX_WAIT_MS=50
CONFIG_DALI_BACKWARD_IDLE_TIMEOUT_MS=10
CONFIG_DALI_BUS_POWER_CHECK_INTERVAL_MS=500
CONFIG_DALI_BUS_FAIL_EVENT_DELAY_MS=45
CONFIG_DALI_BUS_ABNORMAL_REPORT_INTERVAL_MS=3000
CONFIG_DALI_BUS_RESET_PULSE_MS=10
# CONFIG_DALI_LOG_LEVEL_NONE is not set
# CONFIG_DALI_LOG_LEVEL_ERROR is not set
# CONFIG_DALI_LOG_LEVEL_WARN is not set
@@ -696,7 +696,7 @@ bool GatewayKnxBridge::handleDalimasterDiscoveryState(const uint8_t*, size_t,
response->push_back('G');
response->push_back(0x01);
response->push_back(kDalimasterTransferChunkBytes);
uint16_t feature_flags = 0x0100 | 0x0080;
uint16_t feature_flags = 0x0100 | 0x0080 | 0x0200;
if (config_.tunnel_enabled) {
feature_flags |= 0x0001;
}