From f1caea3bee679ea2cff266eb4f1fea8859939e4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cornelius=20K=C3=B6pp?= Date: Sun, 14 Sep 2025 14:48:41 +0200 Subject: [PATCH 1/3] Draft: Show Module Help when Configured Only as Default Use same behaviour as for `Base::setup` and `Base::loop` --- src/OpenKNX/Console.cpp | 2 +- src/OpenKNX/Module.cpp | 5 +++++ src/OpenKNX/Module.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/OpenKNX/Console.cpp b/src/OpenKNX/Console.cpp index 16ece9a0..a1baeb65 100644 --- a/src/OpenKNX/Console.cpp +++ b/src/OpenKNX/Console.cpp @@ -596,7 +596,7 @@ namespace OpenKNX #endif for (uint8_t i = 0; i < openknx.modules.count; i++) - openknx.modules.list[i]->showHelp(); + openknx.modules.list[i]->showHelp(knx.configured()); openknx.logger.logDividingLine(); logEnd(); diff --git a/src/OpenKNX/Module.cpp b/src/OpenKNX/Module.cpp index d5ed7a24..f9f9f63d 100644 --- a/src/OpenKNX/Module.cpp +++ b/src/OpenKNX/Module.cpp @@ -46,6 +46,11 @@ namespace OpenKNX return false; } + void Module::showHelp(bool configured) + { + if (configured) showHelp(); + } + void Module::showHelp() { // Example usage: diff --git a/src/OpenKNX/Module.h b/src/OpenKNX/Module.h index 05b292e5..2f904a7d 100644 --- a/src/OpenKNX/Module.h +++ b/src/OpenKNX/Module.h @@ -104,6 +104,7 @@ namespace OpenKNX /** * This method prints out information over the command it can handle */ + virtual void showHelp(bool configured); virtual void showHelp(); /** From 533fc5db855de035b3c337073b6e4e4156822b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cornelius=20K=C3=B6pp?= Date: Sun, 14 Sep 2025 17:13:05 +0200 Subject: [PATCH 2/3] fixup! Draft: Show Module Help when Configured Only as Default Reduce repeated calls of knx.configured() in for-loop --- src/OpenKNX/Console.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OpenKNX/Console.cpp b/src/OpenKNX/Console.cpp index a1baeb65..10392d82 100644 --- a/src/OpenKNX/Console.cpp +++ b/src/OpenKNX/Console.cpp @@ -595,8 +595,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(knx.configured()); + openknx.modules.list[i]->showHelp(configured); openknx.logger.logDividingLine(); logEnd(); From 5a5914170e0260928fe63ee208bd078ba7889d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cornelius=20K=C3=B6pp?= Date: Sun, 14 Sep 2025 17:23:51 +0200 Subject: [PATCH 3/3] Process Module Commands when is Configured Only as Default --- src/OpenKNX/Console.cpp | 3 ++- src/OpenKNX/Module.cpp | 8 ++++++++ src/OpenKNX/Module.h | 20 ++++++++++++++++++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/OpenKNX/Console.cpp b/src/OpenKNX/Console.cpp index 10392d82..0d85d76e 100644 --- a/src/OpenKNX/Console.cpp +++ b/src/OpenKNX/Console.cpp @@ -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; } diff --git a/src/OpenKNX/Module.cpp b/src/OpenKNX/Module.cpp index f9f9f63d..d08a74f2 100644 --- a/src/OpenKNX/Module.cpp +++ b/src/OpenKNX/Module.cpp @@ -41,6 +41,14 @@ 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; diff --git a/src/OpenKNX/Module.h b/src/OpenKNX/Module.h index 2f904a7d..e6e1c832 100644 --- a/src/OpenKNX/Module.h +++ b/src/OpenKNX/Module.h @@ -92,12 +92,28 @@ 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);