From fa7cb678c1cbbfcdeb89ead155cc41931c690196 Mon Sep 17 00:00:00 2001 From: James Harrow Date: Sun, 11 Feb 2024 20:53:23 +0000 Subject: [PATCH] Applying suggested changes --- .../src/EVSEManufacturerImpl.cpp | 19 +++++++++++++++---- .../ElectricalPowerMeasurementDelegate.cpp | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/examples/energy-management-app/energy-management-common/src/EVSEManufacturerImpl.cpp b/examples/energy-management-app/energy-management-common/src/EVSEManufacturerImpl.cpp index a255e9811492e3..1558b7fda2d28c 100644 --- a/examples/energy-management-app/energy-management-common/src/EVSEManufacturerImpl.cpp +++ b/examples/energy-management-app/energy-management-common/src/EVSEManufacturerImpl.cpp @@ -21,6 +21,7 @@ #include #include #include +#include using namespace chip; using namespace chip::app; @@ -152,8 +153,13 @@ CHIP_ERROR EVSEManufacturer::SendCumulativeEnergyReading(EndpointId aEndpointId, // Get current timestamp uint32_t currentTimestamp = 0; - uint64_t nowMS = System::SystemClock().GetMonotonicMilliseconds64().count(); // In case we can't get real time - CHIP_ERROR err = GetEpochTS(currentTimestamp); + + // In case we can't get real time + System::Clock::Milliseconds64 system_time_ms = + std::chrono::duration_cast(chip::Server::GetInstance().TimeSinceInit()); + uint64_t nowMS = static_cast(system_time_ms.count()); + + CHIP_ERROR err = GetEpochTS(currentTimestamp); if (err != CHIP_NO_ERROR) { ChipLogError(AppServer, "GetEpochTS returned error getting timestamp"); @@ -224,8 +230,13 @@ CHIP_ERROR EVSEManufacturer::SendPeriodicEnergyReading(EndpointId aEndpointId, i // Get current timestamp uint32_t currentTimestamp = 0; - uint64_t nowMS = System::SystemClock().GetMonotonicMilliseconds64().count(); // In case we can't get real time - CHIP_ERROR err = GetEpochTS(currentTimestamp); + + // In case we can't get real time + System::Clock::Milliseconds64 system_time_ms = + std::chrono::duration_cast(chip::Server::GetInstance().TimeSinceInit()); + uint64_t nowMS = static_cast(system_time_ms.count()); + + CHIP_ERROR err = GetEpochTS(currentTimestamp); if (err != CHIP_NO_ERROR) { ChipLogError(AppServer, "GetEpochTS returned error getting timestamp"); diff --git a/examples/energy-management-app/energy-management-common/src/ElectricalPowerMeasurementDelegate.cpp b/examples/energy-management-app/energy-management-common/src/ElectricalPowerMeasurementDelegate.cpp index c986bd88984393..fe712d92ae1667 100644 --- a/examples/energy-management-app/energy-management-common/src/ElectricalPowerMeasurementDelegate.cpp +++ b/examples/energy-management-app/energy-management-common/src/ElectricalPowerMeasurementDelegate.cpp @@ -42,7 +42,7 @@ CHIP_ERROR ElectricalPowerMeasurementDelegate::SetPowerMode(PowerModeEnum newVal { PowerModeEnum oldValue = mPowerMode; - if (newValue >= PowerModeEnum::kUnknownEnumValue) + if (EnsureKnownEnumValue(newValue) == PowerModeEnum::kUnknownEnumValue) { return CHIP_IM_GLOBAL_STATUS(ConstraintError); }