Add labels
Labels are descriptive names for sensor channels. For
example a label for temp1 might be "motherboard". Labels
will be used as the final path element when creating
DBus objects so they are bound by the same restrictions
as DBus object paths.
Discover labels from the environment when scanning sysfs.
Ignore inputs that don't have a label.
Change-Id: I2aa5684447f106d99361a9834eaad43d21037d5c
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/mainloop.cpp b/mainloop.cpp
index c1b3fe3..5f2b33d 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -58,7 +58,24 @@
for (auto& i : *sensors)
{
- auto value = std::make_tuple(std::move(i.second));
+ // Ignore inputs without a label.
+ std::string envKey = "LABEL_" + i.first.first + i.first.second;
+ std::string label;
+
+ auto env = getenv(envKey.c_str());
+
+ if (env)
+ {
+ label.assign(env);
+ }
+
+ if (label.empty())
+ {
+ continue;
+ }
+
+ auto value = std::make_tuple(std::move(i.second), std::move(label));
+
state[std::move(i.first)] = std::move(value);
}