sensor yaml: allow custom sensor names
Currently, we can only name sensors based on data from the dbus object
implementing a sensor's interface. While this mostly works, there may
not be a sensible name to extract in all cases.
This change introduces an optional sensorName property to the sensor
YAML description, which allows a custom name to be used.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Change-Id: I3f3b8ef581c70fbde94db122d4f3c0ca181c6ff7
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index d2fac66..e23ea48 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -715,7 +715,12 @@
}
/* ID string */
- auto id_string = info->sensorNameFunc(*info);
+ auto id_string = info->sensorName;
+
+ if (id_string.empty())
+ {
+ id_string = info->sensorNameFunc(*info);
+ }
if (id_string.length() > FULL_RECORD_ID_STR_MAX_LENGTH)
{