host-bmc: Split processing for string type
According to PLDM SPEC (DSP_0249_1.1.0 Table 1, SetID=17),
when the `Identify Stat` value is equal to 2, the `chassis identify`
and `chassis fault` may have two states ("xxx.On" and "xxx.Blink"),
So need to merge them into one string in 4.json file like this:
("xxx.On || yy.Blink"), and the value of string type needs to be
split and verified when processing D-Bus signals.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I9fdbcbf232455d6cf94aeca6c1316a424d666f58
diff --git a/host-bmc/dbus_to_event_handler.cpp b/host-bmc/dbus_to_event_handler.cpp
index d65ce14..5d4d857 100644
--- a/host-bmc/dbus_to_event_handler.cpp
+++ b/host-bmc/dbus_to_event_handler.cpp
@@ -123,7 +123,32 @@
}
for (const auto& itr : dbusValueMapping)
{
- if (itr.second == props.at(dbusMapping.propertyName))
+ bool findValue = false;
+ if (dbusMapping.propertyType == "string")
+ {
+ std::string src = std::get<std::string>(itr.second);
+ std::string dst = std::get<std::string>(
+ props.at(dbusMapping.propertyName));
+
+ auto values = pldm::utils::split(src, "||", " ");
+ for (auto& value : values)
+ {
+ if (value == dst)
+ {
+ findValue = true;
+ break;
+ }
+ }
+ }
+ else
+ {
+ findValue =
+ itr.second == props.at(dbusMapping.propertyName)
+ ? true
+ : false;
+ }
+
+ if (findValue)
{
auto eventData =
reinterpret_cast<struct pldm_sensor_event_data*>(
@@ -132,6 +157,7 @@
eventData->event_class[2] = itr.first;
this->sendEventMsg(PLDM_SENSOR_EVENT,
sensorEventDataVec);
+ break;
}
}
});