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/platform.cpp b/libpldmresponder/platform.cpp
index 0e5455c..72f2977 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -788,9 +788,9 @@
else
{
rc = platform_state_sensor::getStateSensorReadingsHandler<
- pldm::utils::DBusHandler, Handler>(dBusIntf, *this, sensorId,
- sensorRearmCount, comSensorCnt,
- stateField);
+ pldm::utils::DBusHandler, Handler>(
+ dBusIntf, *this, sensorId, sensorRearmCount, comSensorCnt,
+ stateField, dbusToPLDMEventHandler->getSensorCache());
}
if (rc != PLDM_SUCCESS)