Handle FRU records from host
- Get FRU record table from host and traverse the entity structure
from the FRU record set PDR, and create D-Bus object.
- When the FRU field type is a PLDM_OEM_FRU_FIELD_TYPE_LOCATION_CODE
, the location code is used to populate the
xyz.openbmc_project.Inventory.Decorator.LocationCode D-Bus
interface for the corresponding FRU.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I482c4d371f76b4881109ef420dfd9543e1aa810b
diff --git a/host-bmc/custom_dbus.cpp b/host-bmc/custom_dbus.cpp
new file mode 100644
index 0000000..6427a93
--- /dev/null
+++ b/host-bmc/custom_dbus.cpp
@@ -0,0 +1,31 @@
+#include "custom_dbus.hpp"
+
+namespace pldm
+{
+namespace dbus
+{
+void CustomDBus::setLocationCode(const std::string& path, std::string value)
+{
+ if (!location.contains(path))
+ {
+ location.emplace(path,
+ std::make_unique<LocationIntf>(
+ pldm::utils::DBusHandler::getBus(), path.c_str()));
+ }
+
+ location.at(path)->locationCode(value);
+}
+
+std::optional<std::string>
+ CustomDBus::getLocationCode(const std::string& path) const
+{
+ if (location.contains(path))
+ {
+ return location.at(path)->locationCode();
+ }
+
+ return std::nullopt;
+}
+
+} // namespace dbus
+} // namespace pldm