1 #include "dbusUtils.hpp" 2 3 #include <sdbusplus/bus.hpp> 4 5 const char* sensorIntf = "xyz.openbmc_project.Sensor.Value"; 6 7 class DbusSensor 8 { 9 public: 10 DbusSensor() = delete; 11 virtual ~DbusSensor() = default; 12 13 /** @brief Constructs DbusSensor 14 * 15 * @param[in] bus - Handle to system dbus 16 * @param[in] path - The Dbus path of sensor 17 */ 18 DbusSensor(sdbusplus::bus::bus& bus, const std::string& path) : 19 bus(bus), path(path) 20 { 21 servName = getService(bus, path, sensorIntf); 22 } 23 24 /** @brief Get sensor value property from D-bus interface */ 25 double getSensorValue() 26 { 27 return getDbusProperty<double>(bus, servName, path, sensorIntf, 28 "Value"); 29 } 30 31 private: 32 /** @brief sdbusplus bus client connection. */ 33 sdbusplus::bus::bus& bus; 34 /** @brief complete path for sensor */ 35 std::string path; 36 /** @brief service name for the sensor daemon */ 37 std::string servName; 38 }; 39