Pass discrete type/ID values into addThreshold
The ID has to be looked up separately in some cases
so can't always be the ID specified in the key_type object.
Change-Id: I7f5b395ec3db2182fe84df24047bfae64fcee479
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/mainloop.cpp b/mainloop.cpp
index 3205ad8..1190d85 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -342,8 +342,8 @@
#endif
}
auto sensorValue = valueInterface->value();
- addThreshold<WarningObject>(i.first, sensorValue, info);
- addThreshold<CriticalObject>(i.first, sensorValue, info);
+ addThreshold<WarningObject>(i.first.first, id, sensorValue, info);
+ addThreshold<CriticalObject>(i.first.first, id, sensorValue, info);
auto target = addTarget<hwmon::FanSpeed>(
i.first, ioAccess.path(), _devPath, info);
diff --git a/thresholds.hpp b/thresholds.hpp
index 5639615..3bb3f7a 100644
--- a/thresholds.hpp
+++ b/thresholds.hpp
@@ -72,13 +72,16 @@
*
* @tparam T - The threshold type.
*
- * @param[in] sensor - A sensor type and name.
+ * @param[in] sensorType - sensor type, like 'temp'
+ * @param[in] sensorID - sensor ID, like '5'
* @param[in] value - The sensor reading.
* @param[in] info - The sdbusplus server connection and interfaces.
*/
template <typename T>
-auto addThreshold(const SensorSet::key_type& sensor,
- int64_t value, ObjectInfo& info)
+auto addThreshold(const std::string& sensorType,
+ const std::string& sensorID,
+ int64_t value,
+ ObjectInfo& info)
{
static constexpr bool deferSignals = true;
@@ -86,8 +89,9 @@
auto& objPath = std::get<std::string>(info);
auto& obj = std::get<Object>(info);
std::shared_ptr<T> iface;
- auto tLo = getEnv(Thresholds<T>::envLo, sensor);
- auto tHi = getEnv(Thresholds<T>::envHi, sensor);
+
+ auto tLo = getEnv(Thresholds<T>::envLo, sensorType, sensorID);
+ auto tHi = getEnv(Thresholds<T>::envHi, sensorType, sensorID);
if (!tLo.empty() && !tHi.empty())
{
iface = std::make_shared<T>(bus, objPath.c_str(), deferSignals);