sensor: Implement sensor "PRIORITY"
This commit introduces the `xyz.openbmc_project.Common.Priority`
interface to define the priority of sensors. If a sensor's priority
attribute is specified, this interface is created with the 'priority'
attribute. However, if the priority attribute is not specified, this
interface is not created.
The `xyz.openbmc_project.Common.Priority` interface is used to indicate
the priority level of fan sensors. It provides information about
primary and secondary RPM sensors for dual rotor fans, allowing for a
more specific description of the sensor's priority.
phosphor-dbus-interfaces commit:
https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/66779
Tested: Build phosphor-hwmon successfully
'''
1. Retrieve the priority level of the secondary sensor
busctl introspect xyz.openbmc_project.Hwmon-xxx .Hwmon1 \
/xyz/openbmc_project/sensors/fan_tach/fan1_1 xyz.openbmc_project.Common.Priority
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.Priority property u 1 emits-change writable
2. If the "PRIORITY" is not specified in the sensor's configuration file
busctl introspect xyz.openbmc_project.Hwmon-xxx .Hwmon1 \
/xyz/openbmc_project/sensors/fan_tach/fan1_0 xyz.openbmc_project.Common.Priority
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
3. Change the sensor priority
busctl set-property xyz.openbmc_project.Hwmon-xxx.Hwmon1 \
/xyz/openbmc_project/sensors/fan_tach/fan1_1 xyz.openbmc_project.Common.Priority \
Priority u 0
busctl introspect xyz.openbmc_project.Hwmon-xxx .Hwmon1 \
/xyz/openbmc_project/sensors/fan_tach/fan1_1 xyz.openbmc_project.Common.Priority
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.Priority property u 0 emits-change writable
'''
Change-Id: I7a226cf105756bc32e04f6724428d93e84dfb72a
Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
diff --git a/sensor.cpp b/sensor.cpp
index e53b01c..0b3ca66 100644
--- a/sensor.cpp
+++ b/sensor.cpp
@@ -280,6 +280,22 @@
return iface;
}
+std::shared_ptr<PriorityObject> Sensor::addPriority(ObjectInfo& info,
+ size_t priority)
+{
+ auto& objPath = std::get<std::string>(info);
+ auto& obj = std::get<InterfaceMap>(info);
+
+ auto& bus = *std::get<sdbusplus::bus_t*>(info);
+ auto iface = std::make_shared<PriorityObject>(
+ bus, objPath.c_str(), PriorityObject::action::emit_no_signals);
+
+ iface->priority(priority);
+ obj[InterfaceType::PRIORITY] = iface;
+
+ return iface;
+}
+
void gpioLock(const gpioplus::HandleInterface*&& handle)
{
handle->setValues({0});