Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/OpenKNX/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,9 @@ namespace OpenKNX
else
{
// check modules for command
bool configured = knx.configured();
for (uint8_t i = 0; i < openknx.modules.count; i++)
if (openknx.modules.list[i]->processCommand(cmd, diagnoseKo))
if (openknx.modules.list[i]->processCommand(configured, cmd, diagnoseKo))
return true;
return false;
}
Expand Down Expand Up @@ -595,8 +596,9 @@ namespace OpenKNX
printHelpLine("sun", "Shows sun information");
#endif

bool configured = knx.configured();
for (uint8_t i = 0; i < openknx.modules.count; i++)
openknx.modules.list[i]->showHelp();
openknx.modules.list[i]->showHelp(configured);

openknx.logger.logDividingLine();
logEnd();
Expand Down
13 changes: 13 additions & 0 deletions src/OpenKNX/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,24 @@ namespace OpenKNX
// logInfoP("Some-Integer: %i", myInteger);
}

bool Module::processCommand(bool configured, const std::string cmd, bool diagnoseKo)
{
if (configured)
return processCommand(cmd, diagnoseKo);
else
return false;
}

bool Module::processCommand(const std::string cmd, bool diagnoseKo)
{
return false;
}

void Module::showHelp(bool configured)
{
if (configured) showHelp();
}

void Module::showHelp()
{
// Example usage:
Expand Down
21 changes: 19 additions & 2 deletions src/OpenKNX/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,35 @@ namespace OpenKNX

/**
* This method is called when a command is entered in the console or the diagnoseKo.
* The first argument is the command, and the second argument indicates whether the call was made via diagnoseKo or the console.
*
* If a module feels responsible for this command, it returns true, and the processing will terminated.
* If a command is entered that requires an output, the module itself is responsible for handling it.
* It must then determine based on the arguments whether to display the output on the console or send a message via diagnoseKo.
*
* @param configured indicates whether the device is configured by ETS
* @param cmd the command string
* @param diagnoseKo true if called via diagnoseKo, false if called via console
* @return returns true if the module feels responsible for this command, to indicate the processing has to be terminated.
*/
virtual bool processCommand(bool configured, const std::string cmd, bool diagnoseKo);

/**
* This method is called when a command is entered in the console or the diagnoseKo.
*
* If a command is entered that requires an output, the module itself is responsible for handling it.
* It must then determine based on the arguments whether to display the output on the console or send a message via diagnoseKo.
*
* Will be called for knx.configured()==true by processCommand(bool configured, ...)
* Should be overwritten in module implementation, when dependant on configured state.
*
* @param cmd the command string
* @param diagnoseKo true if called via diagnoseKo, false if called via console
*/
virtual bool processCommand(const std::string cmd, bool diagnoseKo);

/**
* This method prints out information over the command it can handle
*/
virtual void showHelp(bool configured);
virtual void showHelp();

/**
Expand Down