From 0b8e6dc99f4e99f74c62f41ebe76353a04a96f85 Mon Sep 17 00:00:00 2001 From: fesseha-eve <88329315+fessehaeve@users.noreply.github.com> Date: Thu, 21 Sep 2023 23:53:56 +0200 Subject: [PATCH] TimeSource is optional. Therefore, do not error when it cannot be set. (#29378) --- .../time-synchronization-server.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp b/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp index c7c79f3d1fc499..a20fbac65ade54 100644 --- a/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp +++ b/src/app/clusters/time-synchronization-server/time-synchronization-server.cpp @@ -392,8 +392,9 @@ void TimeSynchronizationServer::OnTimeSyncCompletionFn(TimeSourceEnum timeSource } return; } - mGranularity = granularity; - if (EMBER_ZCL_STATUS_SUCCESS != TimeSource::Set(kRootEndpointId, timeSource)) + mGranularity = granularity; + EmberAfStatus status = TimeSource::Set(kRootEndpointId, timeSource); + if (!(status == EMBER_ZCL_STATUS_SUCCESS || status == EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)) { ChipLogError(Zcl, "Writing TimeSource failed."); } @@ -405,7 +406,8 @@ void TimeSynchronizationServer::OnFallbackNTPCompletionFn(bool timeSyncSuccessfu { mGranularity = GranularityEnum::kMillisecondsGranularity; // Non-matter SNTP because we know it's external and there's only one source - if (EMBER_ZCL_STATUS_SUCCESS != TimeSource::Set(kRootEndpointId, TimeSourceEnum::kNonMatterSNTP)) + EmberAfStatus status = TimeSource::Set(kRootEndpointId, TimeSourceEnum::kNonMatterSNTP); + if (!(status == EMBER_ZCL_STATUS_SUCCESS || status == EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)) { ChipLogError(Zcl, "Writing TimeSource failed."); } @@ -789,8 +791,9 @@ CHIP_ERROR TimeSynchronizationServer::SetUTCTime(EndpointId ep, uint64_t utcTime ChipLogError(Zcl, "Error setting UTC time on the device"); return err; } - mGranularity = granularity; - if (EMBER_ZCL_STATUS_SUCCESS != TimeSource::Set(ep, source)) + mGranularity = granularity; + EmberAfStatus status = TimeSource::Set(ep, source); + if (!(status == EMBER_ZCL_STATUS_SUCCESS || status == EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)) { ChipLogError(Zcl, "Writing TimeSource failed."); return CHIP_IM_GLOBAL_STATUS(Failure);