send PLDM event msg when state sensor changes
Add the D-Bus to event handler interface to listen all of the state
sensor PDRs and pldm should be able to send up a PLDM event msg when a
D-Bus property changes. the PlatformEventMessage command format is
defined in Table 15 in DSP0248 v1.2.0.
Tested: test with JSON
https://gist.github.com/lxwinspur/6a40abea7330c25e4d49826e890c4be9
The sendEventMsg method is successfully called and the corresponding
message is successfully sent when the D-Bus property value of the sensor
status changes.
print requestMsg Data: 80 02 0a 01 00 00 01 00 01 00 00 00(when calling
sendEventMsg method)
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I9b6d5c1403bfcaa00dbbf478f7d797cc4a40f20d
diff --git a/pldmd/pldmd.cpp b/pldmd/pldmd.cpp
index 192112e..e4a865b 100644
--- a/pldmd/pldmd.cpp
+++ b/pldmd/pldmd.cpp
@@ -6,6 +6,7 @@
#include "common/utils.hpp"
#include "dbus_impl_pdr.hpp"
#include "dbus_impl_requester.hpp"
+#include "host-bmc/dbus_to_event_handler.hpp"
#include "host-bmc/dbus_to_host_effecters.hpp"
#include "host-bmc/host_pdr_handler.hpp"
#include "invoker.hpp"
@@ -49,6 +50,7 @@
using namespace pldm;
using namespace sdeventplus;
using namespace sdeventplus::source;
+using namespace pldm::state_sensor;
static Response processRxMsg(const std::vector<uint8_t>& requestMsg,
Invoker& invoker, dbus_api::Requester& requester)
@@ -174,6 +176,7 @@
std::unique_ptr<HostPDRHandler> hostPDRHandler;
std::unique_ptr<pldm::host_effecters::HostEffecterParser>
hostEffecterParser;
+ std::unique_ptr<DbusToPLDMEvent> dbusToPLDMEventHandler;
auto dbusHandler = std::make_unique<DBusHandler>();
auto hostEID = pldm::utils::readHostEID();
if (hostEID)
@@ -185,6 +188,8 @@
std::make_unique<pldm::host_effecters::HostEffecterParser>(
&dbusImplReq, sockfd, pdrRepo.get(), dbusHandler.get(),
HOST_JSONS_DIR, verbose);
+ dbusToPLDMEventHandler =
+ std::make_unique<DbusToPLDMEvent>(sockfd, hostEID, dbusImplReq);
}
Invoker invoker{};
@@ -195,11 +200,12 @@
// FRU table is built lazily when a FRU command or Get PDR command is
// handled. To enable building FRU table, the FRU handler is passed to the
// Platform handler.
- invoker.registerHandler(PLDM_PLATFORM,
- std::make_unique<platform::Handler>(
- dbusHandler.get(), PDR_JSONS_DIR,
- EVENTS_JSONS_DIR, pdrRepo.get(),
- hostPDRHandler.get(), fruHandler.get(), true));
+ invoker.registerHandler(PLDM_PLATFORM, std::make_unique<platform::Handler>(
+ dbusHandler.get(), PDR_JSONS_DIR,
+ EVENTS_JSONS_DIR, pdrRepo.get(),
+ hostPDRHandler.get(),
+ dbusToPLDMEventHandler.get(),
+ fruHandler.get(), true));
invoker.registerHandler(PLDM_FRU, std::move(fruHandler));
#ifdef OEM_IBM