Emit the Event.StateSensorEvent signal
When the PLDM daemon receives a state sensor EventMessages, it emits the
StateSensorEvent signal (with TID, sensorID, sensorOffset, eventState,
previousEventState as the signal data).
This commit implements a DBus interface defined at
https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-dbus-interfaces/+/33552
to provide StateSensorEvent signal.
Tested: Tested ok in fp5280g2 system.
1、Using pldmtool to send a sensor event message:
pldmtool raw -d 0x80 0x02 0x0A 0x01 0x01 0x00 0x2 0x00 0x01 0x03 0x04 0x05
2、Using dbus-monitor tool we can see the signal being emitted:
signal time=6467.863313 sender=:1.107 -> destination=(null destination)
serial=37 path=/xyz/openbmc_project/pldm;
interface=xyz.openbmc_project.PLDM.Event; member=StateSensorEvent
byte 1
uint16 2
byte 3
byte 4
byte 5
Signed-off-by: Chicago Duan <duanzhijia01@inspur.com>
Change-Id: Ica22e2b16e334a748b60145c527cd70564751d60
diff --git a/common/utils.cpp b/common/utils.cpp
index f659c07..1dac2e5 100644
--- a/common/utils.cpp
+++ b/common/utils.cpp
@@ -434,5 +434,29 @@
return PLDM_INVALID_EFFECTER_ID;
}
+int emitStateSensorEventSignal(uint8_t tid, uint16_t sensorId,
+ uint8_t sensorOffset, uint8_t eventState,
+ uint8_t previousEventState)
+{
+ try
+ {
+ auto& bus = DBusHandler::getBus();
+ auto msg = bus.new_signal("/xyz/openbmc_project/pldm",
+ "xyz.openbmc_project.PLDM.Event",
+ "StateSensorEvent");
+ msg.append(tid, sensorId, sensorOffset, eventState, previousEventState);
+
+ msg.signal_send();
+ }
+ catch (std::exception& e)
+ {
+ std::cerr << "Error emitting pldm event signal:"
+ << "ERROR=" << e.what() << "\n";
+ return PLDM_ERROR;
+ }
+
+ return PLDM_SUCCESS;
+}
+
} // namespace utils
} // namespace pldm
diff --git a/common/utils.hpp b/common/utils.hpp
index 0eb2b2d..e84ed7b 100644
--- a/common/utils.hpp
+++ b/common/utils.hpp
@@ -297,5 +297,21 @@
uint16_t entityInstance, uint16_t containerId,
uint16_t stateSetId);
+/** @brief Emit the sensor event signal
+ *
+ * @param[in] tid - the terminus id
+ * @param[in] sensorId - sensorID value of the sensor
+ * @param[in] sensorOffset - Identifies which state sensor within a
+ * composite state sensor the event is being returned for
+ * @param[in] eventState - The event state value from the state change that
+ * triggered the event message
+ * @param[in] previousEventState - The event state value for the state from
+ * which the present event state was entered.
+ * @return PLDM completion code
+ */
+int emitStateSensorEventSignal(uint8_t tid, uint16_t sensorId,
+ uint8_t sensorOffset, uint8_t eventState,
+ uint8_t previousEventState);
+
} // namespace utils
} // namespace pldm
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index 17b5095..af89a94 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -328,6 +328,10 @@
return PLDM_ERROR;
}
+ // Emitting state sensor event signal
+ emitStateSensorEventSignal(tid, sensorId, sensorOffset, eventState,
+ previousEventState);
+
// Handle PLDM events for which PDR is not available, setSensorEventData
// will return PLDM_ERROR_INVALID_DATA if the sensorID is not found in
// the hardcoded sensor list.