#pragma once // --------------------------------------------------------------------------- // LegacyAdapter — v1 → v2 command translation // // When a client sends { "v": 1 } (or omits "v"), the envelope arrives here // before reaching the CommandBus registry. The adapter maps the old flat/ // umbrella command shape to the new namespaced v2 command. // // Translation logic: // 1. If the v1 message has an "action" field inside contents, combine // cmd + action → v2 flat command name, then strip "action" from contents. // 2. If no action, map the top-level cmd name directly (e.g. "ping" → "ping"). // 3. Special cases: // - clock_setup → set_enabled uses contents["enabled"] bool to pick // clock.enable vs clock.disable // - system → set_mqtt_enabled uses contents["enabled"] bool to pick // mqtt.enable vs mqtt.disable // - system_info → sync_time_to_lcd is remapped to system.get_time // (LCD now uses request/response; old push model retired) // // To delete legacy support in one PR: remove the #include and the single // call in CommandBus::dispatch(), then delete this file. // --------------------------------------------------------------------------- #include "CommandEnvelope.hpp" // Translate an envelope whose version == 1 into its v2 equivalent. // Mutates envelope.command and (where needed) envelope.contents in place. // Sets envelope.version = 2 on return. // No-op if the command is already valid v2 (unknown v1 commands are left // unchanged so the bus returns a proper "Unknown command" error). void translateLegacyEnvelope(CommandEnvelope& envelope);