James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 1 | #pragma once |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 2 | #include <VariantVisitors.hpp> |
Zhikui Ren | da98f09 | 2021-11-01 09:41:08 -0700 | [diff] [blame] | 3 | #include <boost/algorithm/string/replace.hpp> |
James Feist | 8086aba | 2020-08-25 16:00:59 -0700 | [diff] [blame] | 4 | #include <boost/asio/steady_timer.hpp> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 5 | #include <boost/container/flat_map.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 6 | #include <sdbusplus/asio/connection.hpp> |
| 7 | #include <sdbusplus/asio/object_server.hpp> |
| 8 | #include <sdbusplus/message/types.hpp> |
| 9 | |
James Feist | 24f02f2 | 2019-04-15 11:05:39 -0700 | [diff] [blame] | 10 | #include <filesystem> |
Patrick Venture | fd6ba73 | 2019-10-31 14:27:39 -0700 | [diff] [blame] | 11 | #include <functional> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 12 | #include <iostream> |
Patrick Venture | fd6ba73 | 2019-10-31 14:27:39 -0700 | [diff] [blame] | 13 | #include <memory> |
Bruce Mitchell | 544e7dc | 2021-07-29 18:05:49 -0500 | [diff] [blame] | 14 | #include <optional> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 15 | #include <regex> |
Zev Weiss | 214d971 | 2022-08-12 12:54:31 -0700 | [diff] [blame] | 16 | #include <span> |
Patrick Venture | fd6ba73 | 2019-10-31 14:27:39 -0700 | [diff] [blame] | 17 | #include <string> |
| 18 | #include <tuple> |
| 19 | #include <utility> |
| 20 | #include <variant> |
| 21 | #include <vector> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 22 | |
Jae Hyun Yoo | 9ced0a3 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 23 | const constexpr char* jsonStore = "/var/configuration/flattened.json"; |
| 24 | const constexpr char* inventoryPath = "/xyz/openbmc_project/inventory"; |
| 25 | const constexpr char* entityManagerName = "xyz.openbmc_project.EntityManager"; |
James Feist | 58295ad | 2019-05-30 15:01:41 -0700 | [diff] [blame] | 26 | |
| 27 | constexpr const char* cpuInventoryPath = |
| 28 | "/xyz/openbmc_project/inventory/system/chassis/motherboard"; |
Jae Hyun Yoo | 9ced0a3 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 29 | const std::regex illegalDbusRegex("[^A-Za-z0-9_]"); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 30 | |
| 31 | using BasicVariantType = |
James Feist | 3eb8262 | 2019-02-08 13:10:22 -0800 | [diff] [blame] | 32 | std::variant<std::vector<std::string>, std::string, int64_t, uint64_t, |
| 33 | double, int32_t, uint32_t, int16_t, uint16_t, uint8_t, bool>; |
Alex Qiu | 8b3f7d4 | 2020-01-06 13:54:42 -0800 | [diff] [blame] | 34 | using SensorBaseConfigMap = |
| 35 | boost::container::flat_map<std::string, BasicVariantType>; |
| 36 | using SensorBaseConfiguration = std::pair<std::string, SensorBaseConfigMap>; |
| 37 | using SensorData = boost::container::flat_map<std::string, SensorBaseConfigMap>; |
| 38 | using ManagedObjectType = |
| 39 | boost::container::flat_map<sdbusplus::message::object_path, SensorData>; |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 40 | |
James Feist | a5e5872 | 2019-04-22 14:43:11 -0700 | [diff] [blame] | 41 | using GetSubTreeType = std::vector< |
| 42 | std::pair<std::string, |
| 43 | std::vector<std::pair<std::string, std::vector<std::string>>>>>; |
James Feist | d8bd562 | 2019-06-26 12:09:05 -0700 | [diff] [blame] | 44 | using Association = std::tuple<std::string, std::string, std::string>; |
| 45 | |
Zhikui Ren | da98f09 | 2021-11-01 09:41:08 -0700 | [diff] [blame] | 46 | inline std::string escapeName(const std::string& sensorName) |
| 47 | { |
| 48 | return boost::replace_all_copy(sensorName, " ", "_"); |
| 49 | } |
| 50 | |
Zev Weiss | 88cb29d | 2022-05-09 03:46:15 +0000 | [diff] [blame] | 51 | enum class PowerState |
| 52 | { |
| 53 | on, |
| 54 | biosPost, |
| 55 | always |
| 56 | }; |
| 57 | |
Jason Ling | 100c20b | 2020-08-11 14:50:33 -0700 | [diff] [blame] | 58 | std::optional<std::string> openAndRead(const std::string& hwmonFile); |
| 59 | std::optional<std::string> |
| 60 | getFullHwmonFilePath(const std::string& directory, |
| 61 | const std::string& hwmonBaseName, |
| 62 | const std::set<std::string>& permitSet); |
| 63 | std::set<std::string> getPermitSet(const SensorBaseConfigMap& config); |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 64 | bool findFiles(const std::filesystem::path& dirPath, |
Lei YU | 6a4e973 | 2021-10-20 13:27:34 +0800 | [diff] [blame] | 65 | std::string_view matchString, |
James Feist | cf3bce6 | 2019-01-08 10:07:19 -0800 | [diff] [blame] | 66 | std::vector<std::filesystem::path>& foundPaths, |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 67 | int symlinkDepth = 1); |
James Feist | 71d31b2 | 2019-01-02 16:57:54 -0800 | [diff] [blame] | 68 | bool isPowerOn(void); |
James Feist | fc94b21 | 2019-02-06 16:14:51 -0800 | [diff] [blame] | 69 | bool hasBiosPost(void); |
Zev Weiss | 88cb29d | 2022-05-09 03:46:15 +0000 | [diff] [blame] | 70 | void setupPowerMatchCallback( |
| 71 | const std::shared_ptr<sdbusplus::asio::connection>& conn, |
| 72 | std::function<void(PowerState type, bool state)>&& callback); |
James Feist | 71d31b2 | 2019-01-02 16:57:54 -0800 | [diff] [blame] | 73 | void setupPowerMatch(const std::shared_ptr<sdbusplus::asio::connection>& conn); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 74 | bool getSensorConfiguration( |
| 75 | const std::string& type, |
| 76 | const std::shared_ptr<sdbusplus::asio::connection>& dbusConnection, |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 77 | ManagedObjectType& resp, bool useCache); |
| 78 | |
| 79 | bool getSensorConfiguration( |
| 80 | const std::string& type, |
| 81 | const std::shared_ptr<sdbusplus::asio::connection>& dbusConnection, |
| 82 | ManagedObjectType& resp); |
James Feist | 87d713a | 2018-12-06 16:06:24 -0800 | [diff] [blame] | 83 | |
James Feist | 82bac4c | 2019-03-11 11:16:53 -0700 | [diff] [blame] | 84 | void createAssociation( |
| 85 | std::shared_ptr<sdbusplus::asio::dbus_interface>& association, |
| 86 | const std::string& path); |
| 87 | |
James Feist | 87d713a | 2018-12-06 16:06:24 -0800 | [diff] [blame] | 88 | // replaces limits if MinReading and MaxReading are found. |
| 89 | void findLimits(std::pair<double, double>& limits, |
James Feist | 40a7214 | 2018-12-21 10:09:53 -0800 | [diff] [blame] | 90 | const SensorBaseConfiguration* data); |
| 91 | |
Konstantin Aladyshev | c7a1ae6 | 2021-04-30 08:50:43 +0000 | [diff] [blame] | 92 | bool readingStateGood(const PowerState& powerState); |
| 93 | |
Zev Weiss | 054aad8 | 2022-08-18 01:37:34 -0700 | [diff] [blame] | 94 | constexpr const char* configInterfacePrefix = |
| 95 | "xyz.openbmc_project.Configuration."; |
| 96 | |
| 97 | inline std::string configInterfaceName(const std::string& type) |
| 98 | { |
| 99 | return std::string(configInterfacePrefix) + type; |
| 100 | } |
| 101 | |
James Feist | a5e5872 | 2019-04-22 14:43:11 -0700 | [diff] [blame] | 102 | namespace mapper |
| 103 | { |
| 104 | constexpr const char* busName = "xyz.openbmc_project.ObjectMapper"; |
| 105 | constexpr const char* path = "/xyz/openbmc_project/object_mapper"; |
| 106 | constexpr const char* interface = "xyz.openbmc_project.ObjectMapper"; |
| 107 | constexpr const char* subtree = "GetSubTree"; |
| 108 | } // namespace mapper |
| 109 | |
| 110 | namespace properties |
| 111 | { |
| 112 | constexpr const char* interface = "org.freedesktop.DBus.Properties"; |
| 113 | constexpr const char* get = "Get"; |
James Feist | 49a8ccd | 2020-09-16 16:09:52 -0700 | [diff] [blame] | 114 | constexpr const char* set = "Set"; |
James Feist | a5e5872 | 2019-04-22 14:43:11 -0700 | [diff] [blame] | 115 | } // namespace properties |
| 116 | |
James Feist | 52497fd | 2019-06-07 13:01:33 -0700 | [diff] [blame] | 117 | namespace power |
| 118 | { |
| 119 | const static constexpr char* busname = "xyz.openbmc_project.State.Host"; |
| 120 | const static constexpr char* interface = "xyz.openbmc_project.State.Host"; |
| 121 | const static constexpr char* path = "/xyz/openbmc_project/state/host0"; |
| 122 | const static constexpr char* property = "CurrentHostState"; |
| 123 | } // namespace power |
| 124 | namespace post |
| 125 | { |
| 126 | const static constexpr char* busname = |
| 127 | "xyz.openbmc_project.State.OperatingSystem"; |
| 128 | const static constexpr char* interface = |
| 129 | "xyz.openbmc_project.State.OperatingSystem.Status"; |
| 130 | const static constexpr char* path = "/xyz/openbmc_project/state/os"; |
| 131 | const static constexpr char* property = "OperatingSystemState"; |
| 132 | } // namespace post |
| 133 | |
James Feist | 2adc95c | 2019-09-30 14:55:28 -0700 | [diff] [blame] | 134 | namespace association |
| 135 | { |
| 136 | const static constexpr char* interface = |
| 137 | "xyz.openbmc_project.Association.Definitions"; |
| 138 | } // namespace association |
| 139 | |
James Feist | 40a7214 | 2018-12-21 10:09:53 -0800 | [diff] [blame] | 140 | template <typename T> |
Zev Weiss | afd1504 | 2022-07-18 12:28:40 -0700 | [diff] [blame] | 141 | inline T loadVariant(const SensorBaseConfigMap& data, const std::string& key) |
James Feist | 40a7214 | 2018-12-21 10:09:53 -0800 | [diff] [blame] | 142 | { |
| 143 | auto it = data.find(key); |
| 144 | if (it == data.end()) |
| 145 | { |
| 146 | std::cerr << "Configuration missing " << key << "\n"; |
| 147 | throw std::invalid_argument("Key Missing"); |
| 148 | } |
| 149 | if constexpr (std::is_same_v<T, double>) |
| 150 | { |
James Feist | 3eb8262 | 2019-02-08 13:10:22 -0800 | [diff] [blame] | 151 | return std::visit(VariantToDoubleVisitor(), it->second); |
James Feist | 40a7214 | 2018-12-21 10:09:53 -0800 | [diff] [blame] | 152 | } |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 153 | else if constexpr (std::is_unsigned_v<T>) |
| 154 | { |
James Feist | 3eb8262 | 2019-02-08 13:10:22 -0800 | [diff] [blame] | 155 | return std::visit(VariantToUnsignedIntVisitor(), it->second); |
James Feist | 6ef2040 | 2019-01-07 16:45:08 -0800 | [diff] [blame] | 156 | } |
James Feist | 40a7214 | 2018-12-21 10:09:53 -0800 | [diff] [blame] | 157 | else if constexpr (std::is_same_v<T, std::string>) |
| 158 | { |
James Feist | 3eb8262 | 2019-02-08 13:10:22 -0800 | [diff] [blame] | 159 | return std::visit(VariantToStringVisitor(), it->second); |
James Feist | 40a7214 | 2018-12-21 10:09:53 -0800 | [diff] [blame] | 160 | } |
| 161 | else |
| 162 | { |
James Feist | 52497fd | 2019-06-07 13:01:33 -0700 | [diff] [blame] | 163 | static_assert(!std::is_same_v<T, T>, "Type Not Implemented"); |
James Feist | 40a7214 | 2018-12-21 10:09:53 -0800 | [diff] [blame] | 164 | } |
| 165 | } |
James Feist | fc94b21 | 2019-02-06 16:14:51 -0800 | [diff] [blame] | 166 | |
| 167 | inline void setReadState(const std::string& str, PowerState& val) |
| 168 | { |
| 169 | |
| 170 | if (str == "On") |
| 171 | { |
| 172 | val = PowerState::on; |
| 173 | } |
| 174 | else if (str == "BiosPost") |
| 175 | { |
| 176 | val = PowerState::biosPost; |
| 177 | } |
| 178 | else if (str == "Always") |
| 179 | { |
| 180 | val = PowerState::always; |
| 181 | } |
| 182 | } |
Cheng C Yang | 5580f2f | 2019-09-19 09:01:47 +0800 | [diff] [blame] | 183 | |
Zev Weiss | a4d2768 | 2022-07-19 15:30:36 -0700 | [diff] [blame] | 184 | inline PowerState getPowerState(const SensorBaseConfigMap& cfg) |
| 185 | { |
| 186 | PowerState state = PowerState::always; |
| 187 | auto findPowerState = cfg.find("PowerState"); |
| 188 | if (findPowerState != cfg.end()) |
| 189 | { |
| 190 | std::string powerState = |
| 191 | std::visit(VariantToStringVisitor(), findPowerState->second); |
| 192 | setReadState(powerState, state); |
| 193 | } |
| 194 | return state; |
| 195 | } |
| 196 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 197 | inline void setLed(const std::shared_ptr<sdbusplus::asio::connection>& conn, |
James Feist | 49a8ccd | 2020-09-16 16:09:52 -0700 | [diff] [blame] | 198 | const std::string& name, bool on) |
| 199 | { |
| 200 | conn->async_method_call( |
| 201 | [name](const boost::system::error_code ec) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 202 | if (ec) |
| 203 | { |
| 204 | std::cerr << "Failed to set LED " << name << "\n"; |
| 205 | } |
James Feist | 49a8ccd | 2020-09-16 16:09:52 -0700 | [diff] [blame] | 206 | }, |
| 207 | "xyz.openbmc_project.LED.GroupManager", |
| 208 | "/xyz/openbmc_project/led/groups/" + name, properties::interface, |
| 209 | properties::set, "xyz.openbmc_project.Led.Group", "Asserted", |
| 210 | std::variant<bool>(on)); |
| 211 | } |
| 212 | |
Cheng C Yang | 5580f2f | 2019-09-19 09:01:47 +0800 | [diff] [blame] | 213 | void createInventoryAssoc( |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 214 | const std::shared_ptr<sdbusplus::asio::connection>& conn, |
| 215 | const std::shared_ptr<sdbusplus::asio::dbus_interface>& association, |
Cheng C Yang | 5580f2f | 2019-09-19 09:01:47 +0800 | [diff] [blame] | 216 | const std::string& path); |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 217 | |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 218 | struct GetSensorConfiguration : |
| 219 | std::enable_shared_from_this<GetSensorConfiguration> |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 220 | { |
| 221 | GetSensorConfiguration( |
| 222 | std::shared_ptr<sdbusplus::asio::connection> connection, |
| 223 | std::function<void(ManagedObjectType& resp)>&& callbackFunc) : |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 224 | dbusConnection(std::move(connection)), |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 225 | callback(std::move(callbackFunc)) |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 226 | {} |
James Feist | f27a55c | 2020-08-04 14:27:30 -0700 | [diff] [blame] | 227 | |
| 228 | void getPath(const std::string& path, const std::string& interface, |
| 229 | const std::string& owner, size_t retries = 5) |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 230 | { |
James Feist | f27a55c | 2020-08-04 14:27:30 -0700 | [diff] [blame] | 231 | if (retries > 5) |
| 232 | { |
| 233 | retries = 5; |
| 234 | } |
| 235 | std::shared_ptr<GetSensorConfiguration> self = shared_from_this(); |
| 236 | |
| 237 | self->dbusConnection->async_method_call( |
Zev Weiss | afd1504 | 2022-07-18 12:28:40 -0700 | [diff] [blame] | 238 | [self, path, interface, owner, retries]( |
| 239 | const boost::system::error_code ec, SensorBaseConfigMap& data) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 240 | if (ec) |
| 241 | { |
| 242 | std::cerr << "Error getting " << path << ": retries left" |
| 243 | << retries - 1 << "\n"; |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 244 | if (retries == 0U) |
James Feist | f27a55c | 2020-08-04 14:27:30 -0700 | [diff] [blame] | 245 | { |
James Feist | f27a55c | 2020-08-04 14:27:30 -0700 | [diff] [blame] | 246 | return; |
| 247 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 248 | auto timer = std::make_shared<boost::asio::steady_timer>( |
| 249 | self->dbusConnection->get_io_context()); |
| 250 | timer->expires_after(std::chrono::seconds(10)); |
| 251 | timer->async_wait([self, timer, path, interface, owner, |
| 252 | retries](boost::system::error_code ec) { |
| 253 | if (ec) |
| 254 | { |
| 255 | std::cerr << "Timer error!\n"; |
| 256 | return; |
| 257 | } |
| 258 | self->getPath(path, interface, owner, retries - 1); |
| 259 | }); |
| 260 | return; |
| 261 | } |
James Feist | f27a55c | 2020-08-04 14:27:30 -0700 | [diff] [blame] | 262 | |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 263 | self->respData[path][interface] = std::move(data); |
James Feist | f27a55c | 2020-08-04 14:27:30 -0700 | [diff] [blame] | 264 | }, |
| 265 | owner, path, "org.freedesktop.DBus.Properties", "GetAll", |
| 266 | interface); |
| 267 | } |
| 268 | |
Zev Weiss | 054aad8 | 2022-08-18 01:37:34 -0700 | [diff] [blame] | 269 | void getConfiguration(const std::vector<std::string>& types, |
James Feist | f27a55c | 2020-08-04 14:27:30 -0700 | [diff] [blame] | 270 | size_t retries = 0) |
| 271 | { |
| 272 | if (retries > 5) |
| 273 | { |
| 274 | retries = 5; |
| 275 | } |
| 276 | |
Zev Weiss | 054aad8 | 2022-08-18 01:37:34 -0700 | [diff] [blame] | 277 | std::vector<std::string> interfaces(types.size()); |
| 278 | for (const auto& type : types) |
| 279 | { |
| 280 | interfaces.push_back(configInterfaceName(type)); |
| 281 | } |
| 282 | |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 283 | std::shared_ptr<GetSensorConfiguration> self = shared_from_this(); |
| 284 | dbusConnection->async_method_call( |
James Feist | f27a55c | 2020-08-04 14:27:30 -0700 | [diff] [blame] | 285 | [self, interfaces, retries](const boost::system::error_code ec, |
| 286 | const GetSubTreeType& ret) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 287 | if (ec) |
| 288 | { |
| 289 | std::cerr << "Error calling mapper\n"; |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 290 | if (retries == 0U) |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 291 | { |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 292 | return; |
| 293 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 294 | auto timer = std::make_shared<boost::asio::steady_timer>( |
| 295 | self->dbusConnection->get_io_context()); |
| 296 | timer->expires_after(std::chrono::seconds(10)); |
| 297 | timer->async_wait([self, timer, interfaces, |
| 298 | retries](boost::system::error_code ec) { |
| 299 | if (ec) |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 300 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 301 | std::cerr << "Timer error!\n"; |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 302 | return; |
| 303 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 304 | self->getConfiguration(interfaces, retries - 1); |
| 305 | }); |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 306 | |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 307 | return; |
| 308 | } |
| 309 | for (const auto& [path, objDict] : ret) |
| 310 | { |
| 311 | if (objDict.empty()) |
| 312 | { |
| 313 | return; |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 314 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 315 | const std::string& owner = objDict.begin()->first; |
| 316 | |
| 317 | for (const std::string& interface : objDict.begin()->second) |
| 318 | { |
| 319 | // anything that starts with a requested configuration |
| 320 | // is good |
| 321 | if (std::find_if(interfaces.begin(), interfaces.end(), |
| 322 | [interface](const std::string& possible) { |
Zev Weiss | 6c106d6 | 2022-08-17 20:50:00 -0700 | [diff] [blame] | 323 | return interface.starts_with(possible); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 324 | }) == interfaces.end()) |
| 325 | { |
| 326 | continue; |
| 327 | } |
| 328 | self->getPath(path, interface, owner); |
| 329 | } |
| 330 | } |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 331 | }, |
| 332 | mapper::busName, mapper::path, mapper::interface, mapper::subtree, |
| 333 | "/", 0, interfaces); |
| 334 | } |
| 335 | |
| 336 | ~GetSensorConfiguration() |
| 337 | { |
| 338 | callback(respData); |
| 339 | } |
| 340 | |
| 341 | std::shared_ptr<sdbusplus::asio::connection> dbusConnection; |
| 342 | std::function<void(ManagedObjectType& resp)> callback; |
| 343 | ManagedObjectType respData; |
| 344 | }; |
Zbigniew Kurzynski | 63f3866 | 2020-06-09 13:02:11 +0200 | [diff] [blame] | 345 | |
| 346 | // The common scheme for sysfs files naming is: <type><number>_<item>. |
| 347 | // This function returns optionally these 3 elements as a tuple. |
| 348 | std::optional<std::tuple<std::string, std::string, std::string>> |
| 349 | splitFileName(const std::filesystem::path& filePath); |
| 350 | std::optional<double> readFile(const std::string& thresholdFile, |
James Feist | 8086aba | 2020-08-25 16:00:59 -0700 | [diff] [blame] | 351 | const double& scaleFactor); |
Bruce Lee | 1263c3d | 2021-06-04 15:16:33 +0800 | [diff] [blame] | 352 | void setupManufacturingModeMatch(sdbusplus::asio::connection& conn); |
| 353 | bool getManufacturingMode(); |
Zev Weiss | 214d971 | 2022-08-12 12:54:31 -0700 | [diff] [blame] | 354 | std::vector<std::unique_ptr<sdbusplus::bus::match_t>> |
| 355 | setupPropertiesChangedMatches( |
| 356 | sdbusplus::asio::connection& bus, std::span<const char* const> types, |
| 357 | const std::function<void(sdbusplus::message_t&)>& handler); |