platform-mc: Add sensor manager
Added sensor_manager class. The sensor_manager class manages the timing
of sensor polling.
tested: Verified on ast2600 EVB which is connected to a PLDM device
over I2C. bmcweb can display the state of numeric sensor.
Signed-off-by: Gilbert Chen <gilbert.chen@arm.com>
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Change-Id: I4257f823ea26d7fdb322cc82d847e94db056258c
diff --git a/platform-mc/terminus_manager.cpp b/platform-mc/terminus_manager.cpp
index 7567d89..cbf56c5 100644
--- a/platform-mc/terminus_manager.cpp
+++ b/platform-mc/terminus_manager.cpp
@@ -162,6 +162,7 @@
exec::task<int> TerminusManager::discoverMctpTerminusTask()
{
+ std::vector<pldm_tid_t> addedTids;
while (!queuedMctpInfos.empty())
{
if (manager)
@@ -177,11 +178,23 @@
{
co_await initMctpTerminus(mctpInfo);
}
+
+ /* Get TID of initialized terminus */
+ auto tid = toTid(mctpInfo);
+ if (!tid)
+ {
+ co_return PLDM_ERROR;
+ }
+ addedTids.push_back(tid.value());
}
if (manager)
{
co_await manager->afterDiscoverTerminus();
+ for (const auto& tid : addedTids)
+ {
+ manager->startSensorPolling(tid);
+ }
}
queuedMctpInfos.pop();
@@ -201,6 +214,11 @@
continue;
}
+ if (manager)
+ {
+ manager->stopSensorPolling(it->second->getTid());
+ }
+
unmapTid(it->first);
termini.erase(it);
}