Add Host selector button interface
This change includes new button interface
for the host selector switch.
The button handler code is adapted to support
both single host and multiple host power control
dbus events.
design : https://gerrit.openbmc-project.xyz/c/openbmc/docs/+/45544
Signed-off-by: Naveen Moses <naveen.mosess@hcl.com>
Change-Id: Icbfb22baaee057fd255c3ab0cba129693b913a9d
diff --git a/src/main.cpp b/src/main.cpp
index cfa224e..e1efd3e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -22,6 +22,9 @@
#include <phosphor-logging/elog-errors.hpp>
static constexpr auto gpioDefFile = "/etc/default/obmc/gpio/gpio_defs.json";
+using namespace phosphor::logging;
+nlohmann::json gpioDefs;
+
int main(int argc, char* argv[])
{
int ret = 0;
@@ -49,8 +52,8 @@
std::vector<std::unique_ptr<ButtonIface>> buttonInterfaces;
std::ifstream gpios{gpioDefFile};
- auto json = nlohmann::json::parse(gpios, nullptr, true);
- auto gpioDefs = json["gpio_definitions"];
+ auto gpioDefJson = nlohmann::json::parse(gpios, nullptr, true);
+ gpioDefs = gpioDefJson["gpio_definitions"];
// load gpio config from gpio defs json file and create button interface
// objects based on the button form factor type
@@ -60,6 +63,7 @@
std::string formFactorName = gpioConfig["name"];
buttonConfig buttonCfg;
buttonCfg.formFactorName = formFactorName;
+ buttonCfg.extraJsonInfo = gpioConfig;
/* The folloing code checks if the gpio config read
from json file is single gpio config or group gpio config,