From c7147e7aeeb29b459641cd3d790144be93e16033 Mon Sep 17 00:00:00 2001 From: Matti Airas Date: Tue, 15 Oct 2024 19:49:14 +0300 Subject: [PATCH 1/2] Provide default null ConfigSchema for classes with hardcoded UI --- src/sensesp/net/http_server.h | 4 ++++ src/sensesp/net/networking.h | 4 ++++ src/sensesp/signalk/signalk_ws_client.h | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/src/sensesp/net/http_server.h b/src/sensesp/net/http_server.h index 99c22ea76..6834e9b78 100644 --- a/src/sensesp/net/http_server.h +++ b/src/sensesp/net/http_server.h @@ -179,6 +179,10 @@ class HTTPServer : public FileSystemSaveable { friend esp_err_t call_request_dispatcher(httpd_req_t* req); }; +inline const String ConfigSchema(const HTTPServer& obj) { + return "null"; +} + inline bool ConfigRequiresRestart(const HTTPServer& obj) { return true; } } // namespace sensesp diff --git a/src/sensesp/net/networking.h b/src/sensesp/net/networking.h index 8c92a0d7a..51e60f8a7 100644 --- a/src/sensesp/net/networking.h +++ b/src/sensesp/net/networking.h @@ -283,6 +283,10 @@ class Networking : public FileSystemSaveable, std::shared_ptr> wifi_state_emitter_; }; +inline const String ConfigSchema(const Networking& obj) { + return "null"; +} + inline bool ConfigRequiresRestart(const Networking& obj) { return true; } } // namespace sensesp diff --git a/src/sensesp/signalk/signalk_ws_client.h b/src/sensesp/signalk/signalk_ws_client.h index c357ea194..d76e862df 100644 --- a/src/sensesp/signalk/signalk_ws_client.h +++ b/src/sensesp/signalk/signalk_ws_client.h @@ -162,6 +162,10 @@ class SKWSClient : public FileSystemSaveable, SKWSConnectionState get_connection_state() { return task_connection_state_; } }; +inline const String ConfigSchema(const SKWSClient& obj) { + return "null"; +} + inline bool ConfigRequiresRestart(const SKWSClient& obj) { return true; } } // namespace sensesp From 67dfb39e9baaef05c0828c145b98775cc08749c4 Mon Sep 17 00:00:00 2001 From: Matti Airas Date: Tue, 15 Oct 2024 19:49:26 +0300 Subject: [PATCH 2/2] Remove the default ConfigSchema --- src/sensesp/ui/config_item.h | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/sensesp/ui/config_item.h b/src/sensesp/ui/config_item.h index 028c530c8..172451773 100644 --- a/src/sensesp/ui/config_item.h +++ b/src/sensesp/ui/config_item.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "Arduino.h" #include "ArduinoJson.h" @@ -33,23 +34,20 @@ template <> const char* get_schema_type_string(const bool dummy); /** - * @brief Template function to provide a configuration schema for a - * ConfigItemT. + * @brief Provide a configuration schema for a + * ConfigItemT. + * + * For this to work, an overload or a specialization of this function must + * be provided for each type T that is used in a ConfigItemT. * * @tparam T * @param obj * @return const char* */ -template -const String ConfigSchema(const T& obj) { +inline const String ConfigSchema(const std::nullptr_t& obj) { return "null"; } -template -const String ConfigSchema(const std::shared_ptr& obj) { - return ConfigSchema(*obj); -} - template bool ConfigRequiresRestart(const T& obj) { return false; @@ -271,7 +269,6 @@ class ConfigItemT : public ConfigItemBase { String schema = ConfigSchema(*config_object_); return schema; } - }; /**