Skip to content

Commit 52b5394

Browse files
committed
[Commands] Fix accepting invalid commands
1 parent c23b40c commit 52b5394

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/src/Commands/InternalCommands.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ bool ExecuteCommand(taskIndex_t taskIndex,
643643
}
644644

645645
if (handled) {
646+
// addLog(LOG_LEVEL_INFO, F("executeInternalCommand accepted"));
646647
return true;
647648
}
648649
}
@@ -657,6 +658,7 @@ bool ExecuteCommand(taskIndex_t taskIndex,
657658
// alter the string.
658659
String tmpAction(action);
659660
bool handled = PluginCall(PLUGIN_WRITE, &TempEvent, tmpAction);
661+
// if (handled) addLog(LOG_LEVEL_INFO, F("PLUGIN_WRITE accepted"));
660662

661663
#ifndef BUILD_NO_DEBUG
662664
if (!tmpAction.equals(action)) {
@@ -673,7 +675,7 @@ bool ExecuteCommand(taskIndex_t taskIndex,
673675
if (!handled) {
674676
// Try a controller
675677
handled = CPluginCall(CPlugin::Function::CPLUGIN_WRITE, &TempEvent, tmpAction);
676-
678+
// if (handled) addLog(LOG_LEVEL_INFO, F("CPLUGIN_WRITE accepted"));
677679
}
678680

679681
if (handled) {
@@ -685,6 +687,8 @@ bool ExecuteCommand(taskIndex_t taskIndex,
685687
if (tryRemoteConfig) {
686688
if (remoteConfig(&TempEvent, action)) {
687689
SendStatus(&TempEvent, return_command_success());
690+
// addLog(LOG_LEVEL_INFO, F("remoteConfig accepted"));
691+
688692
return true;
689693
}
690694
}

src/src/DataStructs/PluginStats.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,15 +289,15 @@ bool PluginStats_array::plugin_write_base(struct EventStruct *event, const Strin
289289
const bool clearSamples = cmd.equals(F("clearsamples")); // Command: "taskname.clearSamples"
290290

291291
if (resetPeaks || clearSamples) {
292-
success = true;
293-
294292
for (size_t i = 0; i < VARS_PER_TASK; ++i) {
295293
if (_plugin_stats[i] != nullptr) {
296294
if (resetPeaks) {
295+
success = true;
297296
_plugin_stats[i]->resetPeaks();
298297
}
299298

300299
if (clearSamples) {
300+
success = true;
301301
_plugin_stats[i]->clearSamples();
302302
}
303303
}

src/src/Globals/CPlugins.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ bool CPluginCall(CPlugin::Function Function, struct EventStruct *event, String&
9797
case CPlugin::Function::CPLUGIN_TEN_PER_SECOND:
9898
case CPlugin::Function::CPLUGIN_FIFTY_PER_SECOND:
9999
case CPlugin::Function::CPLUGIN_WRITE:
100+
{
101+
// Only CPLUGIN_WRITE might return a false
102+
bool success = Function != CPlugin::Function::CPLUGIN_WRITE;
100103

101104
if (Function == CPlugin::Function::CPLUGIN_INIT_ALL) {
102105
Function = CPlugin::Function::CPLUGIN_INIT;
@@ -107,13 +110,14 @@ bool CPluginCall(CPlugin::Function Function, struct EventStruct *event, String&
107110
protocolIndex_t ProtocolIndex = getProtocolIndex_from_ControllerIndex(x);
108111
event->ControllerIndex = x;
109112
String dummy;
110-
const bool success = CPluginCall(ProtocolIndex, Function, event, dummy);
113+
success = CPluginCall(ProtocolIndex, Function, event, dummy);
111114
if (success && Function == CPlugin::Function::CPLUGIN_WRITE) {
112115
return success;
113116
}
114117
}
115118
}
116-
return true;
119+
return success;
120+
}
117121

118122
// calls to specific controller
119123
case CPlugin::Function::CPLUGIN_INIT:

0 commit comments

Comments
 (0)