James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2017 Intel Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | */ |
| 16 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 17 | #include <HwmonTempSensor.hpp> |
| 18 | #include <Utils.hpp> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 19 | #include <boost/algorithm/string/predicate.hpp> |
| 20 | #include <boost/algorithm/string/replace.hpp> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 21 | #include <boost/container/flat_map.hpp> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 22 | #include <boost/container/flat_set.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 23 | #include <sdbusplus/asio/connection.hpp> |
| 24 | #include <sdbusplus/asio/object_server.hpp> |
| 25 | #include <sdbusplus/bus/match.hpp> |
| 26 | |
| 27 | #include <array> |
James Feist | 24f02f2 | 2019-04-15 11:05:39 -0700 | [diff] [blame] | 28 | #include <filesystem> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 29 | #include <fstream> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 30 | #include <functional> |
| 31 | #include <memory> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 32 | #include <regex> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 33 | #include <stdexcept> |
| 34 | #include <string> |
| 35 | #include <utility> |
| 36 | #include <variant> |
| 37 | #include <vector> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 38 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 39 | static constexpr bool debug = false; |
Jeff Lin | 87bc67f | 2020-12-04 20:58:01 +0800 | [diff] [blame] | 40 | static constexpr float pollRateDefault = 0.5; |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 41 | |
James Feist | cf3bce6 | 2019-01-08 10:07:19 -0800 | [diff] [blame] | 42 | namespace fs = std::filesystem; |
Zev Weiss | 7ea918f | 2021-03-24 22:46:02 +0000 | [diff] [blame] | 43 | static constexpr std::array<const char*, 16> sensorTypes = { |
Gilbert Chen | 381636e | 2020-11-03 01:39:56 +0800 | [diff] [blame] | 44 | "xyz.openbmc_project.Configuration.EMC1412", |
Alex Qiu | 8b3f7d4 | 2020-01-06 13:54:42 -0800 | [diff] [blame] | 45 | "xyz.openbmc_project.Configuration.EMC1413", |
Gilbert Chen | 381636e | 2020-11-03 01:39:56 +0800 | [diff] [blame] | 46 | "xyz.openbmc_project.Configuration.EMC1414", |
Alex Qiu | 8b3f7d4 | 2020-01-06 13:54:42 -0800 | [diff] [blame] | 47 | "xyz.openbmc_project.Configuration.MAX31725", |
| 48 | "xyz.openbmc_project.Configuration.MAX31730", |
Jason Ling | 16e7af1 | 2020-06-05 17:41:01 -0700 | [diff] [blame] | 49 | "xyz.openbmc_project.Configuration.MAX6581", |
Josh Lehan | 3840d0a | 2020-05-13 16:13:45 -0700 | [diff] [blame] | 50 | "xyz.openbmc_project.Configuration.MAX6654", |
Josh Lehan | 8fb0a01 | 2020-06-26 19:28:16 -0700 | [diff] [blame] | 51 | "xyz.openbmc_project.Configuration.SBTSI", |
Konstantin Aladyshev | 5a3b3f8 | 2021-04-01 17:27:48 +0300 | [diff] [blame] | 52 | "xyz.openbmc_project.Configuration.LM95234", |
John Wang | 55ab2af | 2019-04-18 14:22:31 +0800 | [diff] [blame] | 53 | "xyz.openbmc_project.Configuration.TMP112", |
Patrick Venture | 3546adb | 2019-08-14 18:35:29 -0700 | [diff] [blame] | 54 | "xyz.openbmc_project.Configuration.TMP175", |
Alex Qiu | 8b3f7d4 | 2020-01-06 13:54:42 -0800 | [diff] [blame] | 55 | "xyz.openbmc_project.Configuration.TMP421", |
| 56 | "xyz.openbmc_project.Configuration.TMP441", |
Konstantin Aladyshev | 34fc75a | 2021-04-01 17:19:17 +0300 | [diff] [blame] | 57 | "xyz.openbmc_project.Configuration.LM75A", |
Zev Weiss | 7ea918f | 2021-03-24 22:46:02 +0000 | [diff] [blame] | 58 | "xyz.openbmc_project.Configuration.TMP75", |
| 59 | "xyz.openbmc_project.Configuration.W83773G"}; |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 60 | |
| 61 | void createSensors( |
| 62 | boost::asio::io_service& io, sdbusplus::asio::object_server& objectServer, |
Yong Li | f3fd191 | 2020-03-25 21:35:23 +0800 | [diff] [blame] | 63 | boost::container::flat_map<std::string, std::shared_ptr<HwmonTempSensor>>& |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 64 | sensors, |
| 65 | std::shared_ptr<sdbusplus::asio::connection>& dbusConnection, |
James Feist | 5591cf08 | 2020-07-15 16:44:54 -0700 | [diff] [blame] | 66 | const std::shared_ptr<boost::container::flat_set<std::string>>& |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 67 | sensorsChanged) |
| 68 | { |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 69 | auto getter = std::make_shared<GetSensorConfiguration>( |
| 70 | dbusConnection, |
| 71 | std::move([&io, &objectServer, &sensors, &dbusConnection, |
James Feist | 5591cf08 | 2020-07-15 16:44:54 -0700 | [diff] [blame] | 72 | sensorsChanged]( |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 73 | const ManagedObjectType& sensorConfigurations) { |
| 74 | bool firstScan = sensorsChanged == nullptr; |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 75 | |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 76 | std::vector<fs::path> paths; |
| 77 | if (!findFiles(fs::path("/sys/class/hwmon"), R"(temp\d+_input)", |
| 78 | paths)) |
James Feist | 37266ca | 2018-10-15 15:56:28 -0700 | [diff] [blame] | 79 | { |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 80 | std::cerr << "No temperature sensors in system\n"; |
| 81 | return; |
| 82 | } |
| 83 | |
| 84 | boost::container::flat_set<std::string> directories; |
| 85 | |
| 86 | // iterate through all found temp sensors, and try to match them |
| 87 | // with configuration |
| 88 | for (auto& path : paths) |
| 89 | { |
| 90 | std::smatch match; |
| 91 | const std::string& pathStr = path.string(); |
| 92 | auto directory = path.parent_path(); |
| 93 | |
| 94 | auto ret = directories.insert(directory.string()); |
| 95 | if (!ret.second) |
James Feist | 37266ca | 2018-10-15 15:56:28 -0700 | [diff] [blame] | 96 | { |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 97 | continue; // already searched this path |
| 98 | } |
| 99 | |
| 100 | fs::path device = directory / "device"; |
| 101 | std::string deviceName = fs::canonical(device).stem(); |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 102 | auto findHyphen = deviceName.find('-'); |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 103 | if (findHyphen == std::string::npos) |
| 104 | { |
| 105 | std::cerr << "found bad device " << deviceName << "\n"; |
| 106 | continue; |
| 107 | } |
| 108 | std::string busStr = deviceName.substr(0, findHyphen); |
| 109 | std::string addrStr = deviceName.substr(findHyphen + 1); |
| 110 | |
| 111 | size_t bus = 0; |
| 112 | size_t addr = 0; |
| 113 | try |
| 114 | { |
| 115 | bus = std::stoi(busStr); |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 116 | addr = std::stoi(addrStr, nullptr, 16); |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 117 | } |
| 118 | catch (std::invalid_argument&) |
| 119 | { |
| 120 | continue; |
| 121 | } |
| 122 | const SensorData* sensorData = nullptr; |
| 123 | const std::string* interfacePath = nullptr; |
| 124 | const char* sensorType = nullptr; |
Alex Qiu | 8b3f7d4 | 2020-01-06 13:54:42 -0800 | [diff] [blame] | 125 | const SensorBaseConfiguration* baseConfiguration = nullptr; |
| 126 | const SensorBaseConfigMap* baseConfigMap = nullptr; |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 127 | |
| 128 | for (const std::pair<sdbusplus::message::object_path, |
| 129 | SensorData>& sensor : sensorConfigurations) |
| 130 | { |
| 131 | sensorData = &(sensor.second); |
| 132 | for (const char* type : sensorTypes) |
| 133 | { |
| 134 | auto sensorBase = sensorData->find(type); |
| 135 | if (sensorBase != sensorData->end()) |
| 136 | { |
| 137 | baseConfiguration = &(*sensorBase); |
| 138 | sensorType = type; |
| 139 | break; |
| 140 | } |
| 141 | } |
| 142 | if (baseConfiguration == nullptr) |
| 143 | { |
| 144 | std::cerr << "error finding base configuration for " |
| 145 | << deviceName << "\n"; |
| 146 | continue; |
| 147 | } |
Alex Qiu | 8b3f7d4 | 2020-01-06 13:54:42 -0800 | [diff] [blame] | 148 | baseConfigMap = &baseConfiguration->second; |
| 149 | auto configurationBus = baseConfigMap->find("Bus"); |
| 150 | auto configurationAddress = baseConfigMap->find("Address"); |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 151 | |
Alex Qiu | 8b3f7d4 | 2020-01-06 13:54:42 -0800 | [diff] [blame] | 152 | if (configurationBus == baseConfigMap->end() || |
| 153 | configurationAddress == baseConfigMap->end()) |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 154 | { |
Alex Qiu | 8b3f7d4 | 2020-01-06 13:54:42 -0800 | [diff] [blame] | 155 | std::cerr << "error finding bus or address in " |
| 156 | "configuration\n"; |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 157 | continue; |
| 158 | } |
| 159 | |
| 160 | if (std::get<uint64_t>(configurationBus->second) != bus || |
| 161 | std::get<uint64_t>(configurationAddress->second) != |
| 162 | addr) |
| 163 | { |
| 164 | continue; |
| 165 | } |
| 166 | |
| 167 | interfacePath = &(sensor.first.str); |
James Feist | 37266ca | 2018-10-15 15:56:28 -0700 | [diff] [blame] | 168 | break; |
| 169 | } |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 170 | if (interfacePath == nullptr) |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 171 | { |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 172 | std::cerr << "failed to find match for " << deviceName |
| 173 | << "\n"; |
| 174 | continue; |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 175 | } |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 176 | |
Alex Qiu | 8b3f7d4 | 2020-01-06 13:54:42 -0800 | [diff] [blame] | 177 | auto findSensorName = baseConfigMap->find("Name"); |
| 178 | if (findSensorName == baseConfigMap->end()) |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 179 | { |
| 180 | std::cerr << "could not determine configuration name for " |
| 181 | << deviceName << "\n"; |
| 182 | continue; |
| 183 | } |
| 184 | std::string sensorName = |
| 185 | std::get<std::string>(findSensorName->second); |
| 186 | // on rescans, only update sensors we were signaled by |
| 187 | auto findSensor = sensors.find(sensorName); |
| 188 | if (!firstScan && findSensor != sensors.end()) |
| 189 | { |
| 190 | bool found = false; |
| 191 | for (auto it = sensorsChanged->begin(); |
| 192 | it != sensorsChanged->end(); it++) |
| 193 | { |
| 194 | if (boost::ends_with(*it, findSensor->second->name)) |
| 195 | { |
| 196 | sensorsChanged->erase(it); |
| 197 | findSensor->second = nullptr; |
| 198 | found = true; |
| 199 | break; |
| 200 | } |
| 201 | } |
| 202 | if (!found) |
| 203 | { |
| 204 | continue; |
| 205 | } |
| 206 | } |
Matt Spinler | 5636d52 | 2021-03-17 14:52:18 -0500 | [diff] [blame] | 207 | |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 208 | std::vector<thresholds::Threshold> sensorThresholds; |
Matt Spinler | 5636d52 | 2021-03-17 14:52:18 -0500 | [diff] [blame] | 209 | int index = 1; |
| 210 | |
| 211 | if (!parseThresholdsFromConfig(*sensorData, sensorThresholds, |
| 212 | nullptr, &index)) |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 213 | { |
| 214 | std::cerr << "error populating thresholds for " |
Matt Spinler | 5636d52 | 2021-03-17 14:52:18 -0500 | [diff] [blame] | 215 | << sensorName << " index 1\n"; |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 216 | } |
Jeff Lin | 87bc67f | 2020-12-04 20:58:01 +0800 | [diff] [blame] | 217 | |
| 218 | auto findPollRate = baseConfiguration->second.find("PollRate"); |
| 219 | float pollRate = pollRateDefault; |
| 220 | if (findPollRate != baseConfiguration->second.end()) |
| 221 | { |
| 222 | pollRate = std::visit(VariantToFloatVisitor(), |
| 223 | findPollRate->second); |
| 224 | if (pollRate <= 0.0f) |
| 225 | { |
| 226 | pollRate = pollRateDefault; // polling time too short |
| 227 | } |
| 228 | } |
| 229 | |
James Feist | f9b01b6 | 2020-01-29 15:21:58 -0800 | [diff] [blame] | 230 | auto findPowerOn = baseConfiguration->second.find("PowerState"); |
| 231 | PowerState readState = PowerState::always; |
| 232 | if (findPowerOn != baseConfiguration->second.end()) |
| 233 | { |
| 234 | std::string powerState = std::visit( |
| 235 | VariantToStringVisitor(), findPowerOn->second); |
| 236 | setReadState(powerState, readState); |
| 237 | } |
Jason Ling | 100c20b | 2020-08-11 14:50:33 -0700 | [diff] [blame] | 238 | |
| 239 | auto permitSet = getPermitSet(*baseConfigMap); |
Alex Qiu | 8b3f7d4 | 2020-01-06 13:54:42 -0800 | [diff] [blame] | 240 | auto& sensor = sensors[sensorName]; |
| 241 | sensor = nullptr; |
Jason Ling | 100c20b | 2020-08-11 14:50:33 -0700 | [diff] [blame] | 242 | auto hwmonFile = getFullHwmonFilePath(directory.string(), |
| 243 | "temp1", permitSet); |
| 244 | if (hwmonFile) |
| 245 | { |
| 246 | sensor = std::make_shared<HwmonTempSensor>( |
| 247 | *hwmonFile, sensorType, objectServer, dbusConnection, |
Jeff Lin | 87bc67f | 2020-12-04 20:58:01 +0800 | [diff] [blame] | 248 | io, sensorName, std::move(sensorThresholds), pollRate, |
Jason Ling | 100c20b | 2020-08-11 14:50:33 -0700 | [diff] [blame] | 249 | *interfacePath, readState); |
| 250 | sensor->setupRead(); |
| 251 | } |
Alex Qiu | 8b3f7d4 | 2020-01-06 13:54:42 -0800 | [diff] [blame] | 252 | // Looking for keys like "Name1" for temp2_input, |
| 253 | // "Name2" for temp3_input, etc. |
| 254 | int i = 0; |
| 255 | while (true) |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 256 | { |
Alex Qiu | 8b3f7d4 | 2020-01-06 13:54:42 -0800 | [diff] [blame] | 257 | ++i; |
| 258 | auto findKey = |
Jason Ling | 8b8bcc8 | 2020-08-04 19:33:22 -0700 | [diff] [blame] | 259 | baseConfigMap->find("Name" + std::to_string(i)); |
Alex Qiu | 8b3f7d4 | 2020-01-06 13:54:42 -0800 | [diff] [blame] | 260 | if (findKey == baseConfigMap->end()) |
| 261 | { |
| 262 | break; |
| 263 | } |
Alex Qiu | 8b3f7d4 | 2020-01-06 13:54:42 -0800 | [diff] [blame] | 264 | std::string sensorName = |
| 265 | std::get<std::string>(findKey->second); |
Jason Ling | 100c20b | 2020-08-11 14:50:33 -0700 | [diff] [blame] | 266 | hwmonFile = getFullHwmonFilePath( |
| 267 | directory.string(), "temp" + std::to_string(i + 1), |
| 268 | permitSet); |
| 269 | if (hwmonFile) |
| 270 | { |
Matt Spinler | 5636d52 | 2021-03-17 14:52:18 -0500 | [diff] [blame] | 271 | // To look up thresholds for these additional sensors, |
| 272 | // match on the Index property in the threshold data |
| 273 | // where the index comes from the sysfs file we're on, |
| 274 | // i.e. index = 2 for temp2_input. |
| 275 | int index = i + 1; |
| 276 | std::vector<thresholds::Threshold> thresholds; |
| 277 | |
| 278 | if (!parseThresholdsFromConfig(*sensorData, thresholds, |
| 279 | nullptr, &index)) |
| 280 | { |
| 281 | std::cerr << "error populating thresholds for " |
| 282 | << sensorName << " index " << index |
| 283 | << "\n"; |
| 284 | } |
| 285 | |
Jason Ling | 100c20b | 2020-08-11 14:50:33 -0700 | [diff] [blame] | 286 | auto& sensor = sensors[sensorName]; |
| 287 | sensor = nullptr; |
| 288 | sensor = std::make_shared<HwmonTempSensor>( |
| 289 | *hwmonFile, sensorType, objectServer, |
| 290 | dbusConnection, io, sensorName, |
Matt Spinler | 5636d52 | 2021-03-17 14:52:18 -0500 | [diff] [blame] | 291 | std::move(thresholds), pollRate, *interfacePath, |
| 292 | readState); |
Jason Ling | 100c20b | 2020-08-11 14:50:33 -0700 | [diff] [blame] | 293 | sensor->setupRead(); |
| 294 | } |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 295 | } |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 296 | } |
| 297 | })); |
| 298 | getter->getConfiguration( |
| 299 | std::vector<std::string>(sensorTypes.begin(), sensorTypes.end())); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 300 | } |
| 301 | |
James Feist | b6c0b91 | 2019-07-09 12:21:44 -0700 | [diff] [blame] | 302 | int main() |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 303 | { |
| 304 | boost::asio::io_service io; |
| 305 | auto systemBus = std::make_shared<sdbusplus::asio::connection>(io); |
| 306 | systemBus->request_name("xyz.openbmc_project.HwmonTempSensor"); |
| 307 | sdbusplus::asio::object_server objectServer(systemBus); |
Yong Li | f3fd191 | 2020-03-25 21:35:23 +0800 | [diff] [blame] | 308 | boost::container::flat_map<std::string, std::shared_ptr<HwmonTempSensor>> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 309 | sensors; |
| 310 | std::vector<std::unique_ptr<sdbusplus::bus::match::match>> matches; |
James Feist | 5591cf08 | 2020-07-15 16:44:54 -0700 | [diff] [blame] | 311 | auto sensorsChanged = |
| 312 | std::make_shared<boost::container::flat_set<std::string>>(); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 313 | |
| 314 | io.post([&]() { |
| 315 | createSensors(io, objectServer, sensors, systemBus, nullptr); |
| 316 | }); |
| 317 | |
| 318 | boost::asio::deadline_timer filterTimer(io); |
| 319 | std::function<void(sdbusplus::message::message&)> eventHandler = |
| 320 | [&](sdbusplus::message::message& message) { |
| 321 | if (message.is_method_error()) |
| 322 | { |
| 323 | std::cerr << "callback method error\n"; |
| 324 | return; |
| 325 | } |
| 326 | sensorsChanged->insert(message.get_path()); |
| 327 | // this implicitly cancels the timer |
| 328 | filterTimer.expires_from_now(boost::posix_time::seconds(1)); |
| 329 | |
| 330 | filterTimer.async_wait([&](const boost::system::error_code& ec) { |
| 331 | if (ec == boost::asio::error::operation_aborted) |
| 332 | { |
| 333 | /* we were canceled*/ |
| 334 | return; |
| 335 | } |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 336 | if (ec) |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 337 | { |
| 338 | std::cerr << "timer error\n"; |
| 339 | return; |
| 340 | } |
| 341 | createSensors(io, objectServer, sensors, systemBus, |
| 342 | sensorsChanged); |
| 343 | }); |
| 344 | }; |
| 345 | |
Jae Hyun Yoo | 9ced0a3 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 346 | for (const char* type : sensorTypes) |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 347 | { |
| 348 | auto match = std::make_unique<sdbusplus::bus::match::match>( |
| 349 | static_cast<sdbusplus::bus::bus&>(*systemBus), |
| 350 | "type='signal',member='PropertiesChanged',path_namespace='" + |
Jae Hyun Yoo | 9ced0a3 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 351 | std::string(inventoryPath) + "',arg0namespace='" + type + "'", |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 352 | eventHandler); |
| 353 | matches.emplace_back(std::move(match)); |
| 354 | } |
| 355 | |
| 356 | io.run(); |
| 357 | } |