Add associations for pwm
Pwm doesn't inheirt from Sensor as it is special, so
it needs it to be added seperate.
Tested: Saw associations on dbus
Change-Id: I2178e9346dcae845b47a013a2cc15f62e9ed9b31
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/include/PwmSensor.hpp b/include/PwmSensor.hpp
index 0a712fb..67aff56 100644
--- a/include/PwmSensor.hpp
+++ b/include/PwmSensor.hpp
@@ -6,7 +6,8 @@
{
public:
PwmSensor(const std::string& sysPath,
- sdbusplus::asio::object_server& objectServer);
+ sdbusplus::asio::object_server& objectServer,
+ const std::string& sensorConfiguration);
~PwmSensor();
private:
@@ -15,6 +16,7 @@
std::string name;
std::shared_ptr<sdbusplus::asio::dbus_interface> sensorInterface;
std::shared_ptr<sdbusplus::asio::dbus_interface> controlInterface;
+ std::shared_ptr<sdbusplus::asio::dbus_interface> association;
void setValue(uint32_t value);
uint32_t getValue(bool errThrow = true);
};
diff --git a/include/Utils.hpp b/include/Utils.hpp
index a1c9d37..edaccc0 100644
--- a/include/Utils.hpp
+++ b/include/Utils.hpp
@@ -6,6 +6,7 @@
#include <iostream>
#include <regex>
#include <sdbusplus/asio/connection.hpp>
+#include <sdbusplus/asio/object_server.hpp>
#include <sdbusplus/message/types.hpp>
const constexpr char* jsonStore = "/var/configuration/flattened.json";
@@ -41,6 +42,10 @@
const std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
ManagedObjectType& resp, bool useCache = false);
+void createAssociation(
+ std::shared_ptr<sdbusplus::asio::dbus_interface>& association,
+ const std::string& path);
+
// replaces limits if MinReading and MaxReading are found.
void findLimits(std::pair<double, double>& limits,
const SensorBaseConfiguration* data);
diff --git a/include/sensor.hpp b/include/sensor.hpp
index a6bf2b1..607eb3d 100644
--- a/include/sensor.hpp
+++ b/include/sensor.hpp
@@ -50,16 +50,7 @@
void
setInitialProperties(std::shared_ptr<sdbusplus::asio::connection>& conn)
{
- if (association)
- {
- using Association =
- std::tuple<std::string, std::string, std::string>;
- std::vector<Association> associations;
- associations.push_back(
- Association("inventory", "sensors", configurationPath));
- association->register_property("associations", associations);
- association->initialize();
- }
+ createAssociation(association, configurationPath);
sensorInterface->register_property("MaxValue", maxValue);
sensorInterface->register_property("MinValue", minValue);