Add support for Previous State in Sensor events
Previously, the sensor events generated by the PLDM stack only
included the current state of the sensor without any reference
to the previous state.
This commit introduces a new feature to address this limitation
by caching the previous states of all sensors.
The enhancement ensures that platform event messages(sensor events)
now contain the correct previous state information alongside the
current state.
Behavior Model:
1. Upon the initial occurrence of a sensor event, both the current
state and the previous state are identical, adhering to the
specification.
2. Subsequently, when the PLDM stack sends out sensor events, it
retrieves the previous state from its cache and populates it
accordingly.
Testing:
1. Example: Change the value of a sensor, such as dimm8 identify, to
false using busctl.
Tx: 81 02 0a 01 00 00 4d 00 01 00 [ 01 01 ]
- Note: Initially, both the event state and the previous state are 01.
2. Change the value of dimm8 identify to true.
Tx: 81 02 0a 01 00 00 4d 00 01 00 [ 02 01 ]
- Result: Event state: 02, Previous state: 01.
3. Change the value of dimm8 identify back to false.
Tx: 81 02 0a 01 00 00 4d 00 01 00 [ 01 02 ]
- Result: Event state: 01, Previous state: 02.
4. Similar results can be obtained using the getStateSensorReadings
command for the same sensor at respective times.
Change-Id: Ic93a55e61fd5128cecc698b3555a6639876882ed
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
diff --git a/libpldmresponder/pdr_utils.hpp b/libpldmresponder/pdr_utils.hpp
index 4a95ebe..44dfff3 100644
--- a/libpldmresponder/pdr_utils.hpp
+++ b/libpldmresponder/pdr_utils.hpp
@@ -79,6 +79,7 @@
using StatestoDbusVal = std::map<State, pldm::utils::PropertyValue>;
using DbusMappings = std::vector<pldm::utils::DBusMapping>;
using DbusValMaps = std::vector<StatestoDbusVal>;
+using EventStates = std::array<uint8_t, 8>;
/** @brief Parse PDR JSON file and output Json object
*