sensorhandler: Get sensor type and event type from yaml-generated
Get the sensor type and event type from the yaml-generated cpp
Tested:
```
<1>. Verify the voltage sensor, the return value should
be "02 01"
ipmitool raw 0x04 0x2f 0xa0
02 01
<2>. Verfity the temp sensor, the return value should
be "01 01"
ipmitool raw 0x04 0x2f 0x01
01 01
<3>. Verify the power sensor, the return value should
be "0b 01"
ipmitool raw 0x04 0x2f 0xe6
0b 01
<4>. verify the SYS_FAN_Status sensor, the return value
should be "04 07"
ipmitool raw 0x04 0x2f 0xda
04 07
```
Signed-off-by: Wang Xiaohua <wangxiaohua.1217@bytedance.com>
Change-Id: I24771d0f7ff2b6cd0f3d91521a640125d5d0ff0a
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index a819100..5afa730 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -433,14 +433,17 @@
>
ipmiGetSensorType(uint8_t sensorNumber)
{
- uint8_t sensorType = find_type_for_sensor_number(sensorNumber);
-
- if (sensorType == 0)
+ const auto it = ipmi::sensor::sensors.find(sensorNumber);
+ if (it == ipmi::sensor::sensors.end())
{
+ // The sensor map does not contain the sensor requested
return ipmi::responseSensorInvalid();
}
- constexpr uint8_t eventType = 0x6F;
+ const auto& info = it->second;
+ uint8_t sensorType = info.sensorType;
+ uint8_t eventType = info.sensorReadingType;
+
return ipmi::responseSuccess(sensorType, eventType);
}