sensor-cache: Implement assertion()
Implement assertion() for cache's sensor.
Tested: Verify the sensors using `assersion` have valid values in
QEMU, e.g.
OperatingSystemS | 0x0 | discrete | 0x4000| na | na | na | na | na | na
Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: I753c4359a2b6870427dfb4a1999ee6d1c61cd64f
diff --git a/sensordatahandler.cpp b/sensordatahandler.cpp
index 3f3b04b..7b3b57b 100644
--- a/sensordatahandler.cpp
+++ b/sensordatahandler.cpp
@@ -202,8 +202,30 @@
std::optional<GetSensorResponse> assertion(uint8_t id, const Info& sensorInfo,
sdbusplus::message::message& msg)
{
- // TODO
- return {};
+ auto type = msg.get_type();
+ if (type == msgTypeSignal)
+ {
+ // This is signal callback
+ std::string interfaceName;
+ msg.read(interfaceName);
+ if (interfaceName != sensorInfo.sensorInterface)
+ {
+ // Not the interface we need
+ return {};
+ }
+ }
+
+ // The assertion may contain multiple properties
+ // So we have to get the properties from DBus anyway
+ auto response = mapDbusToAssertion(sensorInfo, sensorInfo.sensorPath,
+ sensorInfo.sensorInterface);
+
+ if (!sensorCacheMap[id].has_value())
+ {
+ sensorCacheMap[id] = SensorData{};
+ }
+ sensorCacheMap[id]->response = response;
+ return response;
}
std::optional<GetSensorResponse> eventdata2(uint8_t id, const Info& sensorInfo,