Initial implementation of Telemetry service

Implemented main application of Telemetry service.
Added ReportManager interface. Added MaxReports and
PollRateResolution properties to ReportManager interface.
Implemented simple logger.

Tested:
 - Built without Yocto and ran on x86 platform with success
 - Added telemetry to romulus image using
   recipe-phosphor/telemetry from meta-phosphor repository
 - Started as service in romulus image in QEMU with success
 - Verified that all added properties are present in dbus

Change-Id: I26af7a19b1f9cac32e9e9da65523d72a36e13855
Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..bea8a13
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,37 @@
+#include "telemetry.hpp"
+
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/signal_set.hpp>
+#include <phosphor-logging/log.hpp>
+#include <sdbusplus/asio/connection.hpp>
+
+#include <memory>
+#include <stdexcept>
+
+int main()
+{
+    boost::asio::io_context ioc;
+    boost::asio::signal_set signals(ioc, SIGINT, SIGTERM);
+
+    auto bus = std::make_shared<sdbusplus::asio::connection>(ioc);
+
+    constexpr const char* serviceName = "xyz.openbmc_project.Telemetry";
+    bus->request_name(serviceName);
+
+    signals.async_wait(
+        [&ioc](const boost::system::error_code ec, const int& sig) {
+            if (ec)
+            {
+                throw std::runtime_error("Signal should not be canceled");
+            }
+
+            ioc.stop();
+        });
+
+    phosphor::logging::log<phosphor::logging::level::INFO>(
+        "Telemetry starting");
+    Telemetry app(bus);
+    ioc.run();
+
+    return 0;
+}
diff --git a/src/report_manager.cpp b/src/report_manager.cpp
new file mode 100644
index 0000000..9735abd
--- /dev/null
+++ b/src/report_manager.cpp
@@ -0,0 +1,30 @@
+#include "report_manager.hpp"
+
+#include <system_error>
+
+constexpr const char* reportManagerIfaceName =
+    "xyz.openbmc_project.Telemetry.ReportManager";
+constexpr const char* reportManagerPath =
+    "/xyz/openbmc_project/Telemetry/Reports";
+
+ReportManager::ReportManager(
+    const std::shared_ptr<sdbusplus::asio::object_server>& objServer) :
+    objServer(objServer)
+{
+    reportManagerIntf =
+        objServer->add_interface(reportManagerPath, reportManagerIfaceName);
+
+    reportManagerIntf->register_property_r(
+        "MaxReports", uint32_t{}, sdbusplus::vtable::property_::const_,
+        [](const auto&) { return maxReports; });
+    reportManagerIntf->register_property_r(
+        "MinInterval", uint64_t{}, sdbusplus::vtable::property_::const_,
+        [](const auto&) -> uint64_t { return minInterval.count(); });
+
+    reportManagerIntf->initialize();
+}
+
+ReportManager::~ReportManager()
+{
+    objServer->remove_interface(reportManagerIntf);
+}
diff --git a/src/report_manager.hpp b/src/report_manager.hpp
new file mode 100644
index 0000000..c01c34a
--- /dev/null
+++ b/src/report_manager.hpp
@@ -0,0 +1,25 @@
+#pragma once
+
+#include <sdbusplus/asio/object_server.hpp>
+
+#include <chrono>
+#include <memory>
+#include <vector>
+
+class ReportManager
+{
+  public:
+    ReportManager(
+        const std::shared_ptr<sdbusplus::asio::object_server>& objServer);
+    ~ReportManager();
+
+    ReportManager(const ReportManager&) = delete;
+    ReportManager& operator=(const ReportManager&) = delete;
+
+  private:
+    std::shared_ptr<sdbusplus::asio::object_server> objServer;
+    std::shared_ptr<sdbusplus::asio::dbus_interface> reportManagerIntf;
+
+    static constexpr uint32_t maxReports{20};
+    static constexpr std::chrono::milliseconds minInterval{1000};
+};
diff --git a/src/telemetry.hpp b/src/telemetry.hpp
new file mode 100644
index 0000000..0edcd2d
--- /dev/null
+++ b/src/telemetry.hpp
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "report_manager.hpp"
+
+#include <sdbusplus/asio/connection.hpp>
+#include <sdbusplus/asio/object_server.hpp>
+
+#include <memory>
+
+class Telemetry
+{
+  public:
+    Telemetry(std::shared_ptr<sdbusplus::asio::connection> bus) :
+        objServer(std::make_shared<sdbusplus::asio::object_server>(bus)),
+        reportManager(objServer)
+    {}
+
+  private:
+    std::shared_ptr<sdbusplus::asio::object_server> objServer;
+    ReportManager reportManager;
+};