Add meson options to modify Telemetry consts

Added 'min-interval', 'max-reading-parameters' and 'max-reports'
to meson_options to allow user to control Telemetry constant
values. Now user is able to adjust those values to platform.
Fixed checking maximal number of ReadingParameters in Report.
Synced type of properties with interface defined in
phosphor-dbus-interface.

Tested:
 - Unit tests passes

Change-Id: Ie8c009931d9e5e22b30d7df82c81aaac8d68dd3e
Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
diff --git a/meson.build b/meson.build
index 22e0cc3..160946f 100644
--- a/meson.build
+++ b/meson.build
@@ -68,6 +68,13 @@
     )
 endif
 
+add_project_arguments(
+    '-DTELEMETRY_MAX_REPORTS=' + get_option('max-reports').to_string(),
+    '-DTELEMETRY_MAX_READING_PARAMS=' + get_option('max-reading-parameters').to_string(),
+    '-DTELEMETRY_MIN_INTERVAL=' + get_option('min-interval').to_string(),
+    language: 'cpp'
+)
+
 executable(
     'telemetry',
     [
diff --git a/meson_options.txt b/meson_options.txt
index 05fc7c1..5021eb6 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1 +1,7 @@
 option('buildtest', type: 'boolean', value: true, description: 'Build tests')
+option('max-reports', type: 'integer', min: 1, value: 10,
+       description: 'Max number of Reports')
+option('max-reading-parameters', type: 'integer', min: 1, value: 200,
+       description: 'Max number of reading parameters in single report')
+option('min-interval', type: 'integer', min: 1, value: 1000,
+       description: 'Minimal value of interval in milliseconds')
diff --git a/src/report_manager.cpp b/src/report_manager.cpp
index 21f0ac1..13ca6db 100644
--- a/src/report_manager.cpp
+++ b/src/report_manager.cpp
@@ -24,7 +24,7 @@
     reportManagerIface = objServer->add_unique_interface(
         reportManagerPath, reportManagerIfaceName, [this](auto& dbusIface) {
             dbusIface.register_property_r(
-                "MaxReports", uint32_t{}, sdbusplus::vtable::property_::const_,
+                "MaxReports", size_t{}, sdbusplus::vtable::property_::const_,
                 [](const auto&) { return maxReports; });
             dbusIface.register_property_r(
                 "MinInterval", uint64_t{}, sdbusplus::vtable::property_::const_,
@@ -102,7 +102,7 @@
                 "Only single sensor per metric is allowed");
         }
     }
-    if (readingParams.size() >= maxReadingParams)
+    if (readingParams.size() > maxReadingParams)
     {
         throw sdbusplus::exception::SdBusError(
             static_cast<int>(std::errc::argument_list_too_long),
diff --git a/src/report_manager.hpp b/src/report_manager.hpp
index 85358cc..2180d52 100644
--- a/src/report_manager.hpp
+++ b/src/report_manager.hpp
@@ -55,9 +55,10 @@
     void loadFromPersistent();
 
   public:
-    static constexpr uint32_t maxReports{20};
-    static constexpr uint32_t maxReadingParams{200};
-    static constexpr std::chrono::milliseconds minInterval{1000};
+    static constexpr size_t maxReports{TELEMETRY_MAX_REPORTS};
+    static constexpr size_t maxReadingParams{TELEMETRY_MAX_READING_PARAMS};
+    static constexpr std::chrono::milliseconds minInterval{
+        TELEMETRY_MIN_INTERVAL};
     static constexpr const char* reportManagerIfaceName =
         "xyz.openbmc_project.Telemetry.ReportManager";
     static constexpr const char* reportManagerPath =
diff --git a/tests/src/test_report_manager.cpp b/tests/src/test_report_manager.cpp
index 1a81844..ac947c4 100644
--- a/tests/src/test_report_manager.cpp
+++ b/tests/src/test_report_manager.cpp
@@ -87,7 +87,7 @@
 
 TEST_F(TestReportManager, maxReports)
 {
-    EXPECT_THAT(getProperty<uint32_t>("MaxReports"),
+    EXPECT_THAT(getProperty<size_t>("MaxReports"),
                 Eq(ReportManager::maxReports));
 }