Skip to content

Commit

Permalink
Applying suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesharrow committed Feb 11, 2024
1 parent ebc6243 commit fa7cb67
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerHandler.h>
#include <app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.h>
#include <app/clusters/energy-evse-server/EnergyEvseTestEventTriggerHandler.h>
#include <app/server/Server.h>

using namespace chip;
using namespace chip::app;
Expand Down Expand Up @@ -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<System::Clock::Milliseconds64>(chip::Server::GetInstance().TimeSinceInit());
uint64_t nowMS = static_cast<uint64_t>(system_time_ms.count());

CHIP_ERROR err = GetEpochTS(currentTimestamp);
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "GetEpochTS returned error getting timestamp");
Expand Down Expand Up @@ -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<System::Clock::Milliseconds64>(chip::Server::GetInstance().TimeSinceInit());
uint64_t nowMS = static_cast<uint64_t>(system_time_ms.count());

CHIP_ERROR err = GetEpochTS(currentTimestamp);
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "GetEpochTS returned error getting timestamp");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit fa7cb67

Please sign in to comment.