Fix LCD Communicaiton infinite looping upon failed commands

This commit is contained in:
2026-02-10 18:45:41 +02:00
parent 980de08584
commit c656835d8e
5 changed files with 76 additions and 25 deletions

View File

@@ -343,9 +343,29 @@ void CommunicationRouter::onWebSocketMessage(uint32_t clientId, const JsonDocume
}
void CommunicationRouter::onUartMessage(JsonDocument& message) {
// Extract command for logging
String cmd = message["cmd"] | "unknown";
LOG_INFO("🔌 UART message received: cmd=%s", cmd.c_str());
// Extract command and action for filtering
String cmd = message["cmd"] | "";
String action = message["contents"]["action"] | "";
// UART COMMAND WHITELIST: Only allow specific commands
// This prevents feedback loops between devices when bad messages occur.
// To re-enable full UART command support, remove this filter.
bool allowed = false;
if (cmd == "system_info" && action == "sync_time_to_lcd") {
allowed = true;
} else if (cmd == "playback" && (action == "play" || action == "stop")) {
allowed = true;
}
if (!allowed) {
// Silently ignore - do NOT send error response to avoid feedback loop
LOG_DEBUG("UART: Ignoring non-whitelisted command (cmd=%s, action=%s)",
cmd.c_str(), action.c_str());
return;
}
LOG_INFO("🔌 UART command received: cmd=%s, action=%s", cmd.c_str(), action.c_str());
// Create message context for UART
CommandHandler::MessageContext context(CommandHandler::MessageSource::UART);