reduce dbus string constants

There are a large number of dbus constants scattered throughout the
code that could/should be obtained from phosphor-dbus-interface values.
Perform minor refactoring to greatly reduce the number of string
constants.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ie8700bc90611d21eee7160f4686bc978fe0a0eb4
diff --git a/utils.cpp b/utils.cpp
index 95760cb..332ddc0 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -7,6 +7,10 @@
 #include <gpiod.h>
 
 #include <phosphor-logging/lg2.hpp>
+#include <xyz/openbmc_project/Dump/Create/client.hpp>
+#include <xyz/openbmc_project/Logging/Create/client.hpp>
+#include <xyz/openbmc_project/ObjectMapper/client.hpp>
+#include <xyz/openbmc_project/State/BMC/client.hpp>
 
 #include <chrono>
 #include <filesystem>
@@ -27,12 +31,10 @@
 constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1";
 constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1";
 constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager";
-
-constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
-constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper";
-constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper";
 constexpr auto PROPERTY_INTERFACE = "org.freedesktop.DBus.Properties";
 
+using ObjectMapper = sdbusplus::client::xyz::openbmc_project::ObjectMapper<>;
+
 void subscribeToSystemdSignals(sdbusplus::bus_t& bus)
 {
     auto method = bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH,
@@ -58,8 +60,9 @@
 std::string getService(sdbusplus::bus_t& bus, std::string path,
                        std::string interface)
 {
-    auto mapper = bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
-                                      MAPPER_INTERFACE, "GetObject");
+    auto mapper = bus.new_method_call(ObjectMapper::default_service,
+                                      ObjectMapper::instance_path,
+                                      ObjectMapper::interface, "GetObject");
 
     mapper.append(path, std::vector<std::string>({interface}));
 
@@ -174,9 +177,12 @@
         // Always add the _PID on for some extra logging debug
         additionalData.emplace("_PID", std::to_string(getpid()));
 
-        auto method = bus.new_method_call(
-            "xyz.openbmc_project.Logging", "/xyz/openbmc_project/logging",
-            "xyz.openbmc_project.Logging.Create", "Create");
+        using LoggingCreate =
+            sdbusplus::client::xyz::openbmc_project::logging::Create<>;
+
+        auto method = bus.new_method_call(LoggingCreate::default_service,
+                                          LoggingCreate::instance_path,
+                                          LoggingCreate::interface, "Create");
 
         method.append(errorMsg, errLevel, additionalData);
         auto resp = bus.call(method);
@@ -199,9 +205,14 @@
 
 void createBmcDump(sdbusplus::bus_t& bus)
 {
-    auto method = bus.new_method_call(
-        "xyz.openbmc_project.Dump.Manager", "/xyz/openbmc_project/dump/bmc",
-        "xyz.openbmc_project.Dump.Create", "CreateDump");
+    using DumpCreate = sdbusplus::client::xyz::openbmc_project::dump::Create<>;
+    auto dumpPath =
+        sdbusplus::message::object_path(DumpCreate::namespace_path::value) /
+        DumpCreate::namespace_path::bmc;
+
+    auto method = bus.new_method_call(DumpCreate::default_service,
+                                      dumpPath.str.c_str(),
+                                      DumpCreate::interface, "CreateDump");
     method.append(
         std::vector<
             std::pair<std::string, std::variant<std::string, uint64_t>>>());
@@ -233,10 +244,15 @@
 
 bool isBmcReady(sdbusplus::bus_t& bus)
 {
-    auto bmcState = getProperty(bus, "/xyz/openbmc_project/state/bmc0",
-                                "xyz.openbmc_project.State.BMC",
+    using BMC = sdbusplus::client::xyz::openbmc_project::state::BMC<>;
+    auto bmcPath = sdbusplus::message::object_path(BMC::namespace_path::value) /
+                   BMC::namespace_path::bmc;
+
+    auto bmcState = getProperty(bus, bmcPath.str.c_str(), BMC::interface,
                                 "CurrentBMCState");
-    if (bmcState != "xyz.openbmc_project.State.BMC.BMCState.Ready")
+
+    if (sdbusplus::message::convert_from_string<BMC::BMCState>(bmcState) !=
+        BMC::BMCState::Ready)
     {
         debug("BMC State is {BMC_STATE}", "BMC_STATE", bmcState);
         return false;