presence: Add JSON config class
Add a JSON config class that will be used to parse a given JSON config
file and generate the fan presence policies from that config.
Tested:
N/A
Change-Id: Iac1703ea8d9e1e1d0d40e15a58145181d4f1a0f9
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/presence/tach_detect.cpp b/presence/tach_detect.cpp
index 9b23571..c0bee2b 100644
--- a/presence/tach_detect.cpp
+++ b/presence/tach_detect.cpp
@@ -13,7 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "config.h"
+#ifdef PRESENCE_JSON_FILE
+#include "json_config.hpp"
+#else
#include "generated.hpp"
+#endif
#include "sdbusplus.hpp"
#include <sdeventplus/event.hpp>
@@ -25,10 +30,19 @@
util::SDBusPlus::getBus().attach_event(
event.get(), SD_EVENT_PRIORITY_NORMAL);
+#ifdef PRESENCE_JSON_FILE
+ // Use json file for presence config
+ presence::JsonConfig config(PRESENCE_JSON_FILE);
+ for (auto& p: presence::JsonConfig::get())
+ {
+ p->monitor();
+ }
+#else
for (auto& p: presence::ConfigPolicy::get())
{
p->monitor();
}
+#endif
return event.loop();
}