1 #include "dbus_sensor_object.hpp" 2 3 #include "helpers.hpp" 4 5 #include <boost/asio.hpp> 6 #include <sdbusplus/asio/connection.hpp> 7 #include <sdbusplus/asio/object_server.hpp> 8 #include <sdbusplus/bus.hpp> 9 10 namespace stubs 11 { 12 13 DbusSensorObject::DbusSensorObject( 14 boost::asio::io_context& ioc, 15 const std::shared_ptr<sdbusplus::asio::connection>& bus, 16 const std::shared_ptr<sdbusplus::asio::object_server>& objServer) : 17 ioc(ioc), 18 bus(bus), objServer(objServer) 19 { 20 sensorIface = objServer->add_unique_interface( 21 path(), interface(), [this](auto& iface) { 22 iface.register_property_r( 23 property.value(), value, 24 sdbusplus::vtable::property_::emits_change, 25 [this](const auto&) { return value; }); 26 }); 27 } 28 29 void DbusSensorObject::setValue(double v) 30 { 31 value = v; 32 33 sensorIface->signal_property(property.value()); 34 } 35 36 double DbusSensorObject::getValue() const 37 { 38 return value; 39 } 40 41 const char* DbusSensorObject::path() 42 { 43 return "/telemetry/ut/DbusSensorObject"; 44 } 45 46 const char* DbusSensorObject::interface() 47 { 48 return "xyz.openbmc_project.Sensor.Value"; 49 } 50 51 const char* DbusSensorObject::Properties::value() 52 { 53 return "Value"; 54 } 55 56 } // namespace stubs 57