Refactor channel binding configuration and validation

- Introduced `NativeChannelConfig` and `SerialChannelConfig` functions to streamline the creation of `ChannelBindingConfig` instances.
- Replaced manual channel configuration with macros `GATEWAY_CONFIGURE_NATIVE_CHANNEL` and `GATEWAY_CONFIGURE_SERIAL_CHANNEL` for better maintainability.
- Updated `BuildChannelBindings` to utilize the new configuration functions, reducing redundancy.
- Enhanced `ValidateChannelBindings` to check for required TX and RX GPIO pins for native channels.
- Simplified `BindConfiguredChannels` to iterate over the built channel bindings, improving readability and reducing code duplication.
- Adjusted the handling of reserved UART ports in `app_main` to dynamically include all serial channels.
- Updated SDK configuration for channel 1 gateway ID and modified KNX-related configurations for enhanced functionality.
- Removed obsolete NVS flash initialization code and replaced it with a more streamlined approach for managing runtime data.
- Added a new command in `GatewayController` to publish gateway IDs when requested.
- Defined a constant for maximum KNX instance count to improve clarity in the codebase.

Signed-off-by: Tony <tonylu@tony-cloud.com>
This commit is contained in:
Tony
2026-05-27 18:08:53 +08:00
parent 7a820e700c
commit 6d0b36b60a
8 changed files with 1579 additions and 161 deletions
@@ -742,6 +742,14 @@ void GatewayController::dispatchCommand(const std::vector<uint8_t>& command) {
const uint8_t opcode = command[3];
const uint8_t addr = command[4];
const uint8_t data = command[5];
if (opcode == 0x09 && addr == 0x00) {
const auto ids = gatewayIds();
const auto count = std::min<size_t>(ids.size(), 16);
std::vector<uint8_t> payload{0x09, static_cast<uint8_t>(count)};
payload.insert(payload.end(), ids.begin(), ids.begin() + count);
publishPayload(gateway_id, payload);
return;
}
if (!hasGateway(gateway_id)) {
ESP_LOGW(kTag, "command for unknown gateway=%u opcode=0x%02x", gateway_id, opcode);
return;