#pragma once #include #include #include #include #include #include namespace utils { using SensorPath = std::string; using ServiceName = std::string; using Ifaces = std::vector; using SensorIfaces = std::vector>; using SensorTree = std::pair; constexpr std::array sensorInterfaces = { "xyz.openbmc_project.Sensor.Value"}; inline std::vector getSubTreeSensors(boost::asio::yield_context& yield, const std::shared_ptr& bus) { boost::system::error_code ec; auto tree = bus->yield_method_call>( yield, ec, "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/xyz/openbmc_project/sensors", 2, sensorInterfaces); if (ec) { throw std::runtime_error("Failed to query ObjectMapper!"); } return tree; } inline std::vector getSubTreeSensors(const std::shared_ptr& bus) { auto method_call = bus->new_method_call("xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", "xyz.openbmc_project.ObjectMapper", "GetSubTree"); method_call.append("/xyz/openbmc_project/sensors/", 2, sensorInterfaces); auto reply = bus->call(method_call); std::vector tree; reply.read(tree); return tree; } } // namespace utils