diff --git a/Firmware/src/Messages/Parser.cpp b/Firmware/src/Messages/Parser.cpp index 55c663d..ab2cc09 100644 --- a/Firmware/src/Messages/Parser.cpp +++ b/Firmware/src/Messages/Parser.cpp @@ -334,6 +334,8 @@ auto message::parser::StateVisitor::operator()(state::Command) -> State { return state::CommandHelp{}; case static_cast(protocol::Command::Version): return state::CommandVersion{}; + case static_cast(protocol::Command::Reset): + return state::CommandReset{}; default: // invalidCallback("Command: Invalid index"); return state::Invalid{}; @@ -388,6 +390,15 @@ auto message::parser::StateVisitor::operator()(state::CommandVersion) -> State { return state::Complete{}; } +auto message::parser::StateVisitor::operator()(state::CommandReset) -> State { + if (stream.available_bytes() > 0) { + // invalidCallback("CommandVersion: Too many bytes left"); + return state::Invalid{}; + } + + return state::Invalid{}; +} + auto message::parser::StateVisitor::operator()(state::Complete) -> State { return state::Complete{}; } diff --git a/Firmware/src/Messages/Parser.h b/Firmware/src/Messages/Parser.h index 845a956..dac6ef5 100644 --- a/Firmware/src/Messages/Parser.h +++ b/Firmware/src/Messages/Parser.h @@ -38,6 +38,7 @@ struct CommandExitConsoleFlashing {}; struct CommandPairBluetooth {}; struct CommandHelp {}; struct CommandVersion {}; +struct CommandReset {}; struct Complete {}; } // namespace state @@ -51,7 +52,8 @@ using State = etl::variant< state::LightControlIncrease, state::LightControlDecrease, state::Command, state::CommandRequestLightData, state::CommandEnterConsoleFlashing, state::CommandExitConsoleFlashing, state::CommandPairBluetooth, - state::CommandHelp, state::CommandVersion, state::Complete>; + state::CommandHelp, state::CommandVersion, state::CommandReset, + state::Complete>; void parse(message::Message *message, freertos::Queue &lightActionQueue); @@ -86,6 +88,7 @@ public: State operator()(state::CommandPairBluetooth); State operator()(state::CommandHelp); State operator()(state::CommandVersion); + State operator()(state::CommandReset); State operator()(state::Complete); State operator()(state::Invalid); diff --git a/Firmware/src/Messages/Protocol.h b/Firmware/src/Messages/Protocol.h index 7afcf2b..0587849 100644 --- a/Firmware/src/Messages/Protocol.h +++ b/Firmware/src/Messages/Protocol.h @@ -47,6 +47,7 @@ enum class Command : uint8_t { PairBluetooth = 0x3, Help = 0x4, Version = 0x5, + Reset = 0x6, }; using Submode = etl::variant;