Add reset command

This commit is contained in:
GHOSCHT 2023-03-30 19:51:41 +02:00
parent a35ae616df
commit 08ca59099d
No known key found for this signature in database
3 changed files with 16 additions and 1 deletions

View file

@ -334,6 +334,8 @@ auto message::parser::StateVisitor::operator()(state::Command) -> State {
return state::CommandHelp{};
case static_cast<uint8_t>(protocol::Command::Version):
return state::CommandVersion{};
case static_cast<uint8_t>(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{};
}

View file

@ -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<LightController::LightAction> &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);

View file

@ -47,6 +47,7 @@ enum class Command : uint8_t {
PairBluetooth = 0x3,
Help = 0x4,
Version = 0x5,
Reset = 0x6,
};
using Submode = etl::variant<Mode, Message, Settings, LightControl, Command>;