blob: 224e1de88f141b630ea8e53c40e6fe7e2bf37565 [file] [log] [blame]
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +02001#include "dbus_sensor_object.hpp"
2
Szymon Dompke1cdd7e42022-06-08 14:43:13 +02003#include "helpers.hpp"
4
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +02005#include <boost/asio.hpp>
6#include <sdbusplus/asio/connection.hpp>
7#include <sdbusplus/asio/object_server.hpp>
8#include <sdbusplus/bus.hpp>
9
10namespace stubs
11{
12
13DbusSensorObject::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) :
Patrick Williamsf535cad2024-08-16 15:21:20 -040017 ioc(ioc), bus(bus), objServer(objServer)
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +020018{
Patrick Williams3a1c2972023-05-10 07:51:04 -050019 sensorIface = objServer->add_unique_interface(path(), interface(),
20 [this](auto& iface) {
21 iface.register_property_r(property.value(), value,
22 sdbusplus::vtable::property_::emits_change,
23 [this](const auto&) { return value; });
24 });
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +020025}
26
27void DbusSensorObject::setValue(double v)
28{
29 value = v;
30
31 sensorIface->signal_property(property.value());
32}
33
34double DbusSensorObject::getValue() const
35{
36 return value;
37}
38
39const char* DbusSensorObject::path()
40{
41 return "/telemetry/ut/DbusSensorObject";
42}
43
44const char* DbusSensorObject::interface()
45{
46 return "xyz.openbmc_project.Sensor.Value";
47}
48
49const char* DbusSensorObject::Properties::value()
50{
51 return "Value";
52}
53
54} // namespace stubs