presence: Don't start until JSON config is found
Make use of the JsonConfig class's callback functionality to not
actually start fan presence checking until the config file is available.
If the config file name is known right away, then monitoring will start
right away, but if it has to wait for the IBMCompatible interface to
show up on D-bus first, it will wait for that.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ic00bbf56a092983f93968b08bcbcaa848e4d085a
diff --git a/presence/tach_detect.cpp b/presence/tach_detect.cpp
index 41af199..3527105 100644
--- a/presence/tach_detect.cpp
+++ b/presence/tach_detect.cpp
@@ -15,6 +15,7 @@
*/
#include "config.h"
#ifdef PRESENCE_USE_JSON
+#include "json_config.hpp"
#include "json_parser.hpp"
#else
#include "generated.hpp"
@@ -34,12 +35,15 @@
bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
#ifdef PRESENCE_USE_JSON
- // Use json file for presence config
+
presence::JsonConfig config(bus);
- for (auto& p : presence::JsonConfig::get())
- {
- p->monitor();
- }
+
+ // jsonConfig will call config::start when
+ // the conf file is available.
+ phosphor::fan::JsonConfig jsonConfig{
+ bus, presence::confAppName, presence::confFileName,
+ std::bind(&presence::JsonConfig::start, &config,
+ std::placeholders::_1)};
stdplus::signal::block(SIGHUP);
sdeventplus::source::Signal signal(