blob: 60b5c9a35667e3055f610bc5a2bf5bb23dd4d562 [file] [log] [blame]
Patrick Venture3a5071a2018-09-12 13:27:42 -07001#include "sensordatahandler.hpp"
2
3#include "sensorhandler.hpp"
Patrick Venture3a5071a2018-09-12 13:27:42 -07004
Vernon Mauery33250242019-03-12 16:49:26 -07005#include <ipmid/types.hpp>
Vernon Mauery6a98fe72019-03-11 15:57:48 -07006#include <ipmid/utils.hpp>
William A. Kennington III4c008022018-10-12 17:18:14 -07007#include <sdbusplus/message/types.hpp>
Patrick Venture3a5071a2018-09-12 13:27:42 -07008#include <xyz/openbmc_project/Common/error.hpp>
9
Patrick Williamsfbc6c9d2023-05-10 07:50:16 -050010#include <bitset>
11#include <filesystem>
12#include <optional>
13
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050014namespace ipmi
15{
16namespace sensor
17{
18
19using namespace phosphor::logging;
20using InternalFailure =
Willy Tu523e2d12023-09-05 11:36:48 -070021 sdbusplus::error::xyz::openbmc_project::common::InternalFailure;
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050022
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050023AssertionSet getAssertionSet(const SetSensorReadingReq& cmdData)
24{
25 Assertion assertionStates =
26 (static_cast<Assertion>(cmdData.assertOffset8_14)) << 8 |
27 cmdData.assertOffset0_7;
28 Deassertion deassertionStates =
29 (static_cast<Deassertion>(cmdData.deassertOffset8_14)) << 8 |
30 cmdData.deassertOffset0_7;
31 return std::make_pair(assertionStates, deassertionStates);
32}
33
George Liu23c868c2025-07-04 09:31:35 +080034ipmi::Cc updateToDbus(IpmiUpdateData& msg)
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050035{
Patrick Williams5d82f472022-07-22 19:26:53 -050036 sdbusplus::bus_t bus{ipmid_get_sd_bus_connection()};
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050037 try
38 {
39 auto serviceResponseMsg = bus.call(msg);
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050040 }
Patrick Williamsa2ad2da2021-10-06 12:21:46 -050041 catch (const InternalFailure& e)
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050042 {
George Liu9b745a82024-07-19 09:09:36 +080043 lg2::error("Error in D-Bus call: {ERROR}", "ERROR", e);
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050044 commit<InternalFailure>();
George Liu879c1d82025-07-03 09:36:57 +080045 return ipmi::ccUnspecifiedError;
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050046 }
George Liue8a97bd2024-12-05 17:26:46 +080047 return ipmi::ccSuccess;
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050048}
49
Tom Joseph816e92b2017-09-06 19:23:00 +053050namespace get
51{
52
Tom Josephb0adbcd2018-01-24 11:51:29 +053053SensorName nameParentLeaf(const Info& sensorInfo)
54{
55 const auto pos = sensorInfo.sensorPath.find_last_of('/');
56 const auto leaf = sensorInfo.sensorPath.substr(pos + 1);
57
58 const auto remaining = sensorInfo.sensorPath.substr(0, pos);
59
60 const auto parentPos = remaining.find_last_of('/');
61 auto parent = remaining.substr(parentPos + 1);
62
63 parent += "_" + leaf;
64 return parent;
65}
66
Tom Joseph816e92b2017-09-06 19:23:00 +053067GetSensorResponse mapDbusToAssertion(const Info& sensorInfo,
68 const InstancePath& path,
69 const DbusInterface& interface)
70{
Patrick Williams5d82f472022-07-22 19:26:53 -050071 sdbusplus::bus_t bus{ipmid_get_sd_bus_connection()};
Patrick Venture0b02be92018-08-31 11:55:55 -070072 GetSensorResponse response{};
Tom Joseph816e92b2017-09-06 19:23:00 +053073
Jeremy Kerr3dc35582020-05-17 15:47:07 +080074 enableScanning(&response);
75
Tom Joseph816e92b2017-09-06 19:23:00 +053076 auto service = ipmi::getService(bus, interface, path);
77
78 const auto& interfaceList = sensorInfo.propertyInterfaces;
79
George Liu08d3add2024-11-18 15:22:43 +080080 for (const auto& [intf, propertyMap] : interfaceList)
Tom Joseph816e92b2017-09-06 19:23:00 +053081 {
George Liu08d3add2024-11-18 15:22:43 +080082 for (const auto& [property, values] : propertyMap)
Tom Joseph816e92b2017-09-06 19:23:00 +053083 {
George Liu08d3add2024-11-18 15:22:43 +080084 try
Tom Joseph816e92b2017-09-06 19:23:00 +053085 {
George Liu08d3add2024-11-18 15:22:43 +080086 auto propValue =
87 ipmi::getDbusProperty(bus, service, path, intf, property);
88
89 for (const auto& value : std::get<OffsetValueMap>(values))
Tom Joseph816e92b2017-09-06 19:23:00 +053090 {
George Liu08d3add2024-11-18 15:22:43 +080091 if (propValue == value.second.assert)
92 {
93 setOffset(value.first, &response);
94 break;
95 }
Tom Joseph816e92b2017-09-06 19:23:00 +053096 }
Tom Joseph816e92b2017-09-06 19:23:00 +053097 }
George Liu08d3add2024-11-18 15:22:43 +080098 catch (const std::exception& e)
99 {
100 lg2::error(
101 "mapDbusToAssertion: Failed to get property, service: {SERVICE},"
102 " path: {PATH}, interface: {INTERFACE}, property name: {PRONAME}: {ERROR}",
103 "SERVICE", service, "PATH", path, "INTERFACE", intf,
104 "PRONAME", property, "ERROR", e);
105 }
Tom Joseph816e92b2017-09-06 19:23:00 +0530106 }
107 }
108
109 return response;
110}
111
Lei YUa8dc09b2021-10-13 18:06:46 +0800112GetSensorResponse mapDbusToEventdata2(const Info& sensorInfo)
Tom Josephe4014fc2017-09-06 23:57:36 +0530113{
Patrick Williams5d82f472022-07-22 19:26:53 -0500114 sdbusplus::bus_t bus{ipmid_get_sd_bus_connection()};
Patrick Venture0b02be92018-08-31 11:55:55 -0700115 GetSensorResponse response{};
Tom Josephe4014fc2017-09-06 23:57:36 +0530116
Jeremy Kerr3dc35582020-05-17 15:47:07 +0800117 enableScanning(&response);
118
Patrick Venture0b02be92018-08-31 11:55:55 -0700119 auto service = ipmi::getService(bus, sensorInfo.sensorInterface,
Tom Josephe4014fc2017-09-06 23:57:36 +0530120 sensorInfo.sensorPath);
121
122 const auto& interfaceList = sensorInfo.propertyInterfaces;
123
George Liu08d3add2024-11-18 15:22:43 +0800124 for (const auto& [intf, propertyMap] : interfaceList)
Tom Josephe4014fc2017-09-06 23:57:36 +0530125 {
George Liu08d3add2024-11-18 15:22:43 +0800126 for (const auto& [property, values] : propertyMap)
Tom Josephe4014fc2017-09-06 23:57:36 +0530127 {
George Liu08d3add2024-11-18 15:22:43 +0800128 try
Tom Josephe4014fc2017-09-06 23:57:36 +0530129 {
George Liu08d3add2024-11-18 15:22:43 +0800130 auto propValue = ipmi::getDbusProperty(
131 bus, service, sensorInfo.sensorPath, intf, property);
132
133 for (const auto& value : std::get<OffsetValueMap>(values))
Tom Josephe4014fc2017-09-06 23:57:36 +0530134 {
George Liu08d3add2024-11-18 15:22:43 +0800135 if (propValue == value.second.assert)
136 {
137 setReading(value.first, &response);
138 break;
139 }
Tom Josephe4014fc2017-09-06 23:57:36 +0530140 }
141 }
George Liu08d3add2024-11-18 15:22:43 +0800142 catch (const std::exception& e)
143 {
144 lg2::error(
145 "mapDbusToEventdata2: Failed to get property, service: {SERVICE},"
146 " path: {PATH}, interface: {INTERFACE}, property name: {PRONAME}: {ERROR}",
147 "SERVICE", service, "PATH", sensorInfo.sensorPath,
148 "INTERFACE", intf, "PRONAME", property, "ERROR", e);
149 }
Tom Josephe4014fc2017-09-06 23:57:36 +0530150 }
151 }
152
153 return response;
154}
Lei YUa8dc09b2021-10-13 18:06:46 +0800155
156#ifndef FEATURE_SENSORS_CACHE
157GetSensorResponse assertion(const Info& sensorInfo)
158{
159 return mapDbusToAssertion(sensorInfo, sensorInfo.sensorPath,
160 sensorInfo.sensorInterface);
161}
162
163GetSensorResponse eventdata2(const Info& sensorInfo)
164{
165 return mapDbusToEventdata2(sensorInfo);
166}
Lei YU8c2c0482021-09-16 17:28:28 +0800167#else
168std::optional<GetSensorResponse> assertion(uint8_t id, const Info& sensorInfo,
Lei YU8e8152c2021-12-06 20:11:08 +0800169 const PropertyMap& /*properties*/)
Lei YU8c2c0482021-09-16 17:28:28 +0800170{
Lei YUef960c02021-10-13 17:54:59 +0800171 // The assertion may contain multiple properties
172 // So we have to get the properties from DBus anyway
173 auto response = mapDbusToAssertion(sensorInfo, sensorInfo.sensorPath,
174 sensorInfo.sensorInterface);
175
176 if (!sensorCacheMap[id].has_value())
177 {
178 sensorCacheMap[id] = SensorData{};
179 }
180 sensorCacheMap[id]->response = response;
181 return response;
Lei YU8c2c0482021-09-16 17:28:28 +0800182}
183
184std::optional<GetSensorResponse> eventdata2(uint8_t id, const Info& sensorInfo,
Lei YU8e8152c2021-12-06 20:11:08 +0800185 const PropertyMap& /*properties*/)
Lei YU8c2c0482021-09-16 17:28:28 +0800186{
Lei YUa8dc09b2021-10-13 18:06:46 +0800187 // The eventdata2 may contain multiple properties
188 // So we have to get the properties from DBus anyway
189 auto response = mapDbusToEventdata2(sensorInfo);
190
191 if (!sensorCacheMap[id].has_value())
192 {
193 sensorCacheMap[id] = SensorData{};
194 }
195 sensorCacheMap[id]->response = response;
196 return response;
Lei YU8c2c0482021-09-16 17:28:28 +0800197}
198
199#endif // FEATURE_SENSORS_CACHE
Tom Josephe4014fc2017-09-06 23:57:36 +0530200
Patrick Venture0b02be92018-08-31 11:55:55 -0700201} // namespace get
Tom Joseph816e92b2017-09-06 19:23:00 +0530202
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500203namespace set
204{
205
206IpmiUpdateData makeDbusMsg(const std::string& updateInterface,
207 const std::string& sensorPath,
208 const std::string& command,
209 const std::string& sensorInterface)
210{
Patrick Williams5d82f472022-07-22 19:26:53 -0500211 sdbusplus::bus_t bus{ipmid_get_sd_bus_connection()};
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500212 using namespace std::string_literals;
213
Patrick Venture0b02be92018-08-31 11:55:55 -0700214 auto dbusService = getService(bus, sensorInterface, sensorPath);
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500215
Patrick Venture0b02be92018-08-31 11:55:55 -0700216 return bus.new_method_call(dbusService.c_str(), sensorPath.c_str(),
217 updateInterface.c_str(), command.c_str());
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500218}
219
George Liu23c868c2025-07-04 09:31:35 +0800220ipmi::Cc eventdata(const SetSensorReadingReq&, const Info& sensorInfo,
221 uint8_t data)
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500222{
Patrick Williams1318a5e2024-08-16 15:19:54 -0400223 auto msg =
224 makeDbusMsg("org.freedesktop.DBus.Properties", sensorInfo.sensorPath,
225 "Set", sensorInfo.sensorInterface);
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500226
227 const auto& interface = sensorInfo.propertyInterfaces.begin();
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500228 msg.append(interface->first);
229 for (const auto& property : interface->second)
230 {
231 msg.append(property.first);
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500232 const auto& iter = std::get<OffsetValueMap>(property.second).find(data);
233 if (iter == std::get<OffsetValueMap>(property.second).end())
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500234 {
George Liu9b745a82024-07-19 09:09:36 +0800235 lg2::error("Invalid event data");
George Liu879c1d82025-07-03 09:36:57 +0800236 return ipmi::ccParmOutOfRange;
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500237 }
238 msg.append(iter->second.assert);
239 }
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500240 return updateToDbus(msg);
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500241}
242
George Liu23c868c2025-07-04 09:31:35 +0800243ipmi::Cc assertion(const SetSensorReadingReq& cmdData, const Info& sensorInfo)
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500244{
Brad Bishop06a0abf2018-02-26 20:46:00 -0500245 std::bitset<16> assertionSet(getAssertionSet(cmdData).first);
246 std::bitset<16> deassertionSet(getAssertionSet(cmdData).second);
247 auto bothSet = assertionSet ^ deassertionSet;
248
249 const auto& interface = sensorInfo.propertyInterfaces.begin();
250
251 for (const auto& property : interface->second)
252 {
William A. Kennington III4c008022018-10-12 17:18:14 -0700253 std::optional<Value> tmp;
Brad Bishop06a0abf2018-02-26 20:46:00 -0500254 for (const auto& value : std::get<OffsetValueMap>(property.second))
255 {
256 if (bothSet.size() <= value.first || !bothSet.test(value.first))
257 {
258 // A BIOS shouldn't do this but ignore if they do.
259 continue;
260 }
261
262 if (assertionSet.test(value.first))
263 {
264 tmp = value.second.assert;
265 break;
266 }
267 if (deassertionSet.test(value.first))
268 {
269 tmp = value.second.deassert;
270 break;
271 }
272 }
273
William A. Kennington III4c008022018-10-12 17:18:14 -0700274 if (tmp)
Brad Bishop06a0abf2018-02-26 20:46:00 -0500275 {
Patrick Venture0b02be92018-08-31 11:55:55 -0700276 auto msg = makeDbusMsg("org.freedesktop.DBus.Properties",
277 sensorInfo.sensorPath, "Set",
278 sensorInfo.sensorInterface);
Brad Bishop06a0abf2018-02-26 20:46:00 -0500279 msg.append(interface->first);
280 msg.append(property.first);
William A. Kennington III4c008022018-10-12 17:18:14 -0700281 msg.append(*tmp);
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500282
Brad Bishop06a0abf2018-02-26 20:46:00 -0500283 auto rc = updateToDbus(msg);
284 if (rc)
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500285 {
Brad Bishop06a0abf2018-02-26 20:46:00 -0500286 return rc;
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500287 }
288 }
289 }
Brad Bishop06a0abf2018-02-26 20:46:00 -0500290
George Liue8a97bd2024-12-05 17:26:46 +0800291 return ipmi::ccSuccess;
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500292}
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500293
Patrick Venture0b02be92018-08-31 11:55:55 -0700294} // namespace set
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500295
296namespace notify
297{
298
299IpmiUpdateData makeDbusMsg(const std::string& updateInterface,
Willy Tu11d68892022-01-20 10:37:34 -0800300 const std::string&, const std::string& command,
301 const std::string&)
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500302{
Patrick Williams5d82f472022-07-22 19:26:53 -0500303 sdbusplus::bus_t bus{ipmid_get_sd_bus_connection()};
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500304 using namespace std::string_literals;
305
Dhruvaraj Subhashchandranf915f852017-09-14 07:01:48 -0500306 static const auto dbusPath = "/xyz/openbmc_project/inventory"s;
307 std::string dbusService = ipmi::getService(bus, updateInterface, dbusPath);
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500308
Patrick Venture0b02be92018-08-31 11:55:55 -0700309 return bus.new_method_call(dbusService.c_str(), dbusPath.c_str(),
310 updateInterface.c_str(), command.c_str());
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500311}
312
George Liu23c868c2025-07-04 09:31:35 +0800313ipmi::Cc assertion(const SetSensorReadingReq& cmdData, const Info& sensorInfo)
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500314{
Patrick Venture0b02be92018-08-31 11:55:55 -0700315 auto msg = makeDbusMsg(sensorInfo.sensorInterface, sensorInfo.sensorPath,
316 "Notify", sensorInfo.sensorInterface);
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500317
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500318 std::bitset<16> assertionSet(getAssertionSet(cmdData).first);
319 std::bitset<16> deassertionSet(getAssertionSet(cmdData).second);
320 ipmi::sensor::ObjectMap objects;
321 ipmi::sensor::InterfaceMap interfaces;
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500322 for (const auto& interface : sensorInfo.propertyInterfaces)
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500323 {
Santosh Puranikbbf8bd62019-05-01 19:02:52 +0530324 // An interface with no properties - It is possible that the sensor
325 // object on DBUS implements a DBUS interface with no properties.
326 // Make sure we add the interface to the list if interfaces on the
327 // object with an empty property map.
328 if (interface.second.empty())
329 {
330 interfaces.emplace(interface.first, ipmi::sensor::PropertyMap{});
331 continue;
332 }
Patrick Venture0b02be92018-08-31 11:55:55 -0700333 // For a property like functional state the result will be
334 // calculated based on the true value of all conditions.
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500335 for (const auto& property : interface.second)
336 {
337 ipmi::sensor::PropertyMap props;
338 bool valid = false;
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500339 auto result = true;
340 for (const auto& value : std::get<OffsetValueMap>(property.second))
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500341 {
342 if (assertionSet.test(value.first))
343 {
Patrick Venture0b02be92018-08-31 11:55:55 -0700344 // Skip update if skipOn is ASSERT
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500345 if (SkipAssertion::ASSERT == value.second.skip)
346 {
George Liue8a97bd2024-12-05 17:26:46 +0800347 return ipmi::ccSuccess;
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500348 }
Vernon Maueryf442e112019-04-09 11:44:36 -0700349 result = result && std::get<bool>(value.second.assert);
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500350 valid = true;
351 }
352 else if (deassertionSet.test(value.first))
353 {
Patrick Venture0b02be92018-08-31 11:55:55 -0700354 // Skip update if skipOn is DEASSERT
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500355 if (SkipAssertion::DEASSERT == value.second.skip)
356 {
George Liue8a97bd2024-12-05 17:26:46 +0800357 return ipmi::ccSuccess;
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500358 }
Vernon Maueryf442e112019-04-09 11:44:36 -0700359 result = result && std::get<bool>(value.second.deassert);
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500360 valid = true;
361 }
362 }
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500363 for (const auto& value :
Patrick Venture0b02be92018-08-31 11:55:55 -0700364 std::get<PreReqOffsetValueMap>(property.second))
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500365 {
366 if (assertionSet.test(value.first))
367 {
Vernon Maueryf442e112019-04-09 11:44:36 -0700368 result = result && std::get<bool>(value.second.assert);
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500369 }
370 else if (deassertionSet.test(value.first))
371 {
Vernon Maueryf442e112019-04-09 11:44:36 -0700372 result = result && std::get<bool>(value.second.deassert);
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500373 }
374 }
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500375 if (valid)
376 {
Dhruvaraj Subhashchandrane245e4e2017-10-03 03:58:05 -0500377 props.emplace(property.first, result);
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500378 interfaces.emplace(interface.first, std::move(props));
379 }
380 }
381 }
Dhruvaraj Subhashchandrane84841c2017-08-22 07:40:27 -0500382
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500383 objects.emplace(sensorInfo.sensorPath, std::move(interfaces));
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500384 msg.append(std::move(objects));
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -0500385 return updateToDbus(msg);
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -0500386}
Tom Joseph816e92b2017-09-06 19:23:00 +0530387
Patrick Venture0b02be92018-08-31 11:55:55 -0700388} // namespace notify
Tom Joseph816e92b2017-09-06 19:23:00 +0530389
390namespace inventory
391{
392
393namespace get
394{
395
Lei YUff8c9b42021-10-15 14:20:57 +0800396#ifndef FEATURE_SENSORS_CACHE
397
Tom Joseph816e92b2017-09-06 19:23:00 +0530398GetSensorResponse assertion(const Info& sensorInfo)
399{
Vernon Mauery185b9f82018-07-20 10:52:36 -0700400 namespace fs = std::filesystem;
Tom Joseph816e92b2017-09-06 19:23:00 +0530401
402 fs::path path{ipmi::sensor::inventoryRoot};
403 path += sensorInfo.sensorPath;
404
405 return ipmi::sensor::get::mapDbusToAssertion(
Patrick Venture0b02be92018-08-31 11:55:55 -0700406 sensorInfo, path.string(),
407 sensorInfo.propertyInterfaces.begin()->first);
Tom Joseph816e92b2017-09-06 19:23:00 +0530408}
409
Lei YUff8c9b42021-10-15 14:20:57 +0800410#else
411
412std::optional<GetSensorResponse> assertion(uint8_t id, const Info& sensorInfo,
Lei YU8e8152c2021-12-06 20:11:08 +0800413 const PropertyMap& /*properties*/)
Lei YUff8c9b42021-10-15 14:20:57 +0800414{
Lei YUff8c9b42021-10-15 14:20:57 +0800415 // The assertion may contain multiple properties
416 // So we have to get the properties from DBus anyway
417 namespace fs = std::filesystem;
418
419 fs::path path{ipmi::sensor::inventoryRoot};
420 path += sensorInfo.sensorPath;
421
422 auto response = ipmi::sensor::get::mapDbusToAssertion(
423 sensorInfo, path.string(),
424 sensorInfo.propertyInterfaces.begin()->first);
425
426 if (!sensorCacheMap[id].has_value())
427 {
428 sensorCacheMap[id] = SensorData{};
429 }
430 sensorCacheMap[id]->response = response;
431 return response;
432}
433
434#endif
435
Patrick Venture0b02be92018-08-31 11:55:55 -0700436} // namespace get
Tom Joseph816e92b2017-09-06 19:23:00 +0530437
438} // namespace inventory
Patrick Venture0b02be92018-08-31 11:55:55 -0700439} // namespace sensor
440} // namespace ipmi