diff --git a/CLC-qthing/SiliconTorch/Service/ServiceManager.cpp b/CLC-qthing/SiliconTorch/Service/ServiceManager.cpp index f03941402e05ab64a31568aeabfcf2337cede479..a956ff280e795559451c0e8676676a2620f4983e 100644 --- a/CLC-qthing/SiliconTorch/Service/ServiceManager.cpp +++ b/CLC-qthing/SiliconTorch/Service/ServiceManager.cpp @@ -16,7 +16,7 @@ // #include <qthing> -const char* TAG = "ServiceManager"; +static const char* TAG = "ServiceManager"; namespace SiliconTorch { @@ -24,13 +24,29 @@ namespace SiliconTorch { namespace ServiceManager { + void registerSiliconTorchServices(ServiceManager* mgr); + + ServiceManager::ServiceManager() { + registerSiliconTorchServices(this); + // TODO: implement! } + void ServiceManager::registerService(Service* s) { + s->init(); + s->postInit(); + + services[s->getName()] = s; + + ESP_LOGI(TAG, "Registered service[ %s ]", s->getName().c_str()); + + } + + } } diff --git a/CLC-qthing/SiliconTorch/Service/ServiceManager.hpp b/CLC-qthing/SiliconTorch/Service/ServiceManager.hpp index 1675e7688b85c34c4410195d9776d227bf771523..7407949d67784f5595eeb479d1c5d580e8b434af 100644 --- a/CLC-qthing/SiliconTorch/Service/ServiceManager.hpp +++ b/CLC-qthing/SiliconTorch/Service/ServiceManager.hpp @@ -24,7 +24,7 @@ namespace SiliconTorch { extern const str NVSStateKey; - using ServiceMap = std::map<str, Service>; + using ServiceMap = std::map<str, Service*>; class ServiceManager { @@ -32,7 +32,7 @@ namespace SiliconTorch { ServiceManager(); - void registerService(Service s); + void registerService(Service* s); private: diff --git a/CLC-qthing/SiliconTorch/Service/__services__.cpp b/CLC-qthing/SiliconTorch/Service/__services__.cpp index b1ffc11ec4f12f876b8524ebeebaa99c73006a0c..3141a1fe8417241e7e06c7a3fa41c470c33d4d43 100644 --- a/CLC-qthing/SiliconTorch/Service/__services__.cpp +++ b/CLC-qthing/SiliconTorch/Service/__services__.cpp @@ -6,17 +6,18 @@ // #include <functional> // ESP32 specific -#include "esp_log.h" +// #include "esp_log.h" // project specific -#include <Types.hpp> +#include "FxCyanF.hpp" +// #include <Types.hpp> // #include "SiliconTorch/NVSExplorer.hpp" // qthing stuff // #include <qthing> -const char* TAG = "ServiceManager"; +// const char* TAG = "ServiceManager"; namespace SiliconTorch { @@ -24,10 +25,9 @@ namespace SiliconTorch { namespace ServiceManager { - void registerSiliconTorchServices(ServiceManager& mgr) { - - // TODO: implement! + void registerSiliconTorchServices(ServiceManager* mgr) { + mgr->registerService(new SiliconTorch::Service::FxCyanF()); } diff --git a/CLC-qthing/SiliconTorch/Service/__services__.hpp b/CLC-qthing/SiliconTorch/Service/__services__.hpp deleted file mode 100644 index 85ff54b78fc3584beeaa04d1d6a238dd766b6a20..0000000000000000000000000000000000000000 --- a/CLC-qthing/SiliconTorch/Service/__services__.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -// C++ system level -// #include <cstring> // memset, strncmp -// #include <cstdlib> // TODO: is this for memcpy? -// #include <functional> - -// ESP32 specific -#include "esp_log.h" - -// project specific -#include <Types.hpp> -#include "Service.hpp" - -// qthing stuff -// #include <qthing> - - -namespace SiliconTorch { - - namespace ServiceManager { - - extern const str NVSStateKey; - - - - - - } -} diff --git a/CLC-qthing/device_main.cpp b/CLC-qthing/device_main.cpp index 3831830e1a350b71ffd70aeb6fbacb8e6e69a3f1..3167fa685c89363cb2fe47f68b357fab43a28db8 100644 --- a/CLC-qthing/device_main.cpp +++ b/CLC-qthing/device_main.cpp @@ -19,6 +19,7 @@ #include "SiliconTorch/Service/FxCyanF.hpp" #include "SiliconTorch/Service/Service.hpp" +#include "SiliconTorch/Service/ServiceManager.hpp" @@ -28,6 +29,7 @@ CyanLight::CyanLightControl* ctrl = NULL; SiliconTorch::ServiceManager::Service* fxCyan = NULL; +SiliconTorch::ServiceManager::ServiceManager* mgr = NULL; @@ -52,9 +54,13 @@ void device_main() { SiliconTorch::NVSExplorer::NVSExplorer::instance(); - fxCyan = new SiliconTorch::Service::FxCyanF(); + mgr = new SiliconTorch::ServiceManager::ServiceManager(); - fxCyan->start(); + + + // fxCyan = new SiliconTorch::Service::FxCyanF(); + + // fxCyan->start(); xSemaphoreGive(mutex000);