Fixed issue with wrong timestamp
Telemetry service used steady_clock for generating timestamps, but it
produced incorrect time. This change makes telemetry service use
steady_clock for intervals and system_clock for timestamps.
Changed readings timestamp to display current timestamp instead of a
time when reading was received.
Tested:
- correct timestamp is visible on dbus
- other telemetry service features are still working
Change-Id: Ic49f45640532cfffaeff5e0bd5591e6d99e5def5
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
diff --git a/src/utils/clock.hpp b/src/utils/clock.hpp
index 00fd8d0..4e17952 100644
--- a/src/utils/clock.hpp
+++ b/src/utils/clock.hpp
@@ -1,22 +1,24 @@
#pragma once
#include "interfaces/clock.hpp"
-#include "types/duration_type.hpp"
+#include "types/duration_types.hpp"
#include <chrono>
class Clock : public interfaces::Clock
{
public:
- time_point now() const noexcept override
+ Milliseconds steadyTimestamp() const noexcept override
{
- return std::chrono::steady_clock::now();
+ return std::chrono::time_point_cast<Milliseconds>(
+ std::chrono::steady_clock::now())
+ .time_since_epoch();
}
- uint64_t timestamp() const noexcept override
+ Milliseconds systemTimestamp() const noexcept override
{
- return std::chrono::time_point_cast<Milliseconds>(now())
- .time_since_epoch()
- .count();
+ return std::chrono::time_point_cast<Milliseconds>(
+ std::chrono::system_clock::now())
+ .time_since_epoch();
}
};