Add parsing JSON for State Sensor PDR
According to spec DSP0248_1.2.0: 28.6 and sensor_pdr.json, parse JSON
and generate PDR structure.
Tested with JSON file:
https://gist.github.com/lxwinspur/6a40abea7330c25e4d49826e890c4be9
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I654913b6fa07f34f405f7dd41a5f1ac0ae2706fb
diff --git a/libpldmresponder/platform.hpp b/libpldmresponder/platform.hpp
index 5cf2534..06496dc 100644
--- a/libpldmresponder/platform.hpp
+++ b/libpldmresponder/platform.hpp
@@ -137,33 +137,42 @@
}
/** @brief Add D-Bus mapping and value mapping(stateId to D-Bus) for the
- * effecterId. If the same id is added, the previous dbusObjs will
+ * Id. If the same id is added, the previous dbusObjs will
* be "over-written".
*
- * @param[in] effecterId - effecter id
+ * @param[in] Id - effecter/sensor id
* @param[in] dbusObj - list of D-Bus object structure and list of D-Bus
* property value to attribute value
+ * @param[in] typeId - the type id of enum
*/
void addDbusObjMaps(
- uint16_t effecterId,
- std::tuple<pdr_utils::DbusMappings, pdr_utils::DbusValMaps> dbusObj);
+ uint16_t id,
+ std::tuple<pdr_utils::DbusMappings, pdr_utils::DbusValMaps> dbusObj,
+ TypeId typeId = TypeId::PLDM_EFFECTER_ID);
- /** @brief Retrieve an effecter id -> D-Bus objects mapping
+ /** @brief Retrieve an id -> D-Bus objects mapping
*
- * @param[in] effecterId - effecter id
+ * @param[in] Id - id
+ * @param[in] typeId - the type id of enum
*
* @return std::tuple<pdr_utils::DbusMappings, pdr_utils::DbusValMaps> -
* list of D-Bus object structure and list of D-Bus property value
* to attribute value
*/
const std::tuple<pdr_utils::DbusMappings, pdr_utils::DbusValMaps>&
- getDbusObjMaps(uint16_t effecterId) const;
+ getDbusObjMaps(uint16_t id,
+ TypeId typeId = TypeId::PLDM_EFFECTER_ID) const;
uint16_t getNextEffecterId()
{
return ++nextEffecterId;
}
+ uint16_t getNextSensorId()
+ {
+ return ++nextSensorId;
+ }
+
/** @brief Parse PDR JSONs and build PDR repository
*
* @param[in] dBusIntf - The interface object
@@ -340,7 +349,7 @@
try
{
const auto& [dbusMappings, dbusValMaps] =
- dbusObjMaps.at(effecterId);
+ effecterDbusObjMaps.at(effecterId);
for (uint8_t currState = 0; currState < compEffecterCnt;
++currState)
{
@@ -412,7 +421,9 @@
private:
pdr_utils::Repo pdrRepo;
uint16_t nextEffecterId{};
- DbusObjMaps dbusObjMaps{};
+ uint16_t nextSensorId{};
+ DbusObjMaps effecterDbusObjMaps{};
+ DbusObjMaps sensorDbusObjMaps{};
HostPDRHandler* hostPDRHandler;
events::StateSensorHandler stateSensorHandler;
fru::Handler* fruHandler;