dbus-sdr: Add sensor event type to sensor
The sensor event type only returned threshold sensor(0x01).
Implement the functionality of getSensorEventTypeFromPath to support
sensor event type codes: unspecified(0x00), threshold(0x01), and
sensor-specified(0x6f).
Signed-off-by: Scron Chang <Scron.Chang@quantatw.com>
Change-Id: Ic08bce55422b8d436fb032627a0a8f96fead1d61
diff --git a/include/dbus-sdr/sdrutils.hpp b/include/dbus-sdr/sdrutils.hpp
index 753c0dd..6b54417 100644
--- a/include/dbus-sdr/sdrutils.hpp
+++ b/include/dbus-sdr/sdrutils.hpp
@@ -239,6 +239,9 @@
}
};
+static constexpr size_t sensorTypeCodes = 0;
+static constexpr size_t sensorEventTypeCodes = 1;
+
enum class SensorTypeCodes : uint8_t
{
reserved = 0x0,
@@ -249,13 +252,28 @@
other = 0xB,
};
-const static boost::container::flat_map<const char*, SensorTypeCodes, CmpStr>
- sensorTypes{{{"temperature", SensorTypeCodes::temperature},
- {"voltage", SensorTypeCodes::voltage},
- {"current", SensorTypeCodes::current},
- {"fan_tach", SensorTypeCodes::fan},
- {"fan_pwm", SensorTypeCodes::fan},
- {"power", SensorTypeCodes::other}}};
+enum class SensorEventTypeCodes : uint8_t
+{
+ unspecified = 0x00,
+ threshold = 0x01,
+ sensorSpecified = 0x6f
+};
+
+const static boost::container::flat_map<
+ const char*, std::pair<SensorTypeCodes, SensorEventTypeCodes>, CmpStr>
+ sensorTypes{
+ {{"temperature", std::make_pair(SensorTypeCodes::temperature,
+ SensorEventTypeCodes::threshold)},
+ {"voltage", std::make_pair(SensorTypeCodes::voltage,
+ SensorEventTypeCodes::threshold)},
+ {"current", std::make_pair(SensorTypeCodes::current,
+ SensorEventTypeCodes::threshold)},
+ {"fan_tach", std::make_pair(SensorTypeCodes::fan,
+ SensorEventTypeCodes::threshold)},
+ {"fan_pwm", std::make_pair(SensorTypeCodes::fan,
+ SensorEventTypeCodes::threshold)},
+ {"power", std::make_pair(SensorTypeCodes::other,
+ SensorEventTypeCodes::threshold)}}};
std::string getSensorTypeStringFromPath(const std::string& path);