Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ff7806c

Browse files
committedMay 2, 2024
stop using attribute storage for TimeSource to make the code more
suitable for unit testing
1 parent 1c0e921 commit ff7806c

File tree

10 files changed

+16
-82
lines changed

10 files changed

+16
-82
lines changed
 

‎examples/all-clusters-app/all-clusters-common/all-clusters-app.matter

+1-1
Original file line numberDiff line numberDiff line change
@@ -7590,7 +7590,7 @@ endpoint 0 {
75907590
emits event MissingTrustedTimeSource;
75917591
callback attribute UTCTime;
75927592
callback attribute granularity;
7593-
ram attribute timeSource default = 0x00;
7593+
callback attribute timeSource;
75947594
callback attribute trustedTimeSource;
75957595
callback attribute defaultNTP;
75967596
callback attribute timeZone;

‎examples/all-clusters-app/all-clusters-common/all-clusters-app.zap

+2-2
Original file line numberDiff line numberDiff line change
@@ -4915,10 +4915,10 @@
49154915
"side": "server",
49164916
"type": "TimeSourceEnum",
49174917
"included": 1,
4918-
"storageOption": "RAM",
4918+
"storageOption": "External",
49194919
"singleton": 0,
49204920
"bounded": 0,
4921-
"defaultValue": "0x00",
4921+
"defaultValue": null,
49224922
"reportable": 1,
49234923
"minInterval": 1,
49244924
"maxInterval": 65534,

‎examples/light-switch-app/light-switch-common/light-switch-app.matter

+1-1
Original file line numberDiff line numberDiff line change
@@ -2778,7 +2778,7 @@ endpoint 0 {
27782778
emits event MissingTrustedTimeSource;
27792779
callback attribute UTCTime;
27802780
callback attribute granularity;
2781-
ram attribute timeSource default = 0x00;
2781+
callback attribute timeSource;
27822782
callback attribute trustedTimeSource;
27832783
callback attribute defaultNTP;
27842784
callback attribute timeZone;

‎examples/light-switch-app/light-switch-common/light-switch-app.zap

+2-2
Original file line numberDiff line numberDiff line change
@@ -3599,10 +3599,10 @@
35993599
"side": "server",
36003600
"type": "TimeSourceEnum",
36013601
"included": 1,
3602-
"storageOption": "RAM",
3602+
"storageOption": "External",
36033603
"singleton": 0,
36043604
"bounded": 0,
3605-
"defaultValue": "0x00",
3605+
"defaultValue": null,
36063606
"reportable": 1,
36073607
"minInterval": 1,
36083608
"maxInterval": 65534,

‎src/app/clusters/time-synchronization-server/time-synchronization-server.cpp

+5-18
Original file line numberDiff line numberDiff line change
@@ -381,12 +381,8 @@ void TimeSynchronizationServer::OnTimeSyncCompletionFn(TimeSourceEnum timeSource
381381
}
382382
return;
383383
}
384-
mGranularity = granularity;
385-
Status status = TimeSource::Set(kRootEndpointId, timeSource);
386-
if (!(status == Status::Success || status == Status::UnsupportedAttribute))
387-
{
388-
ChipLogError(Zcl, "Writing TimeSource failed.");
389-
}
384+
mGranularity = granularity;
385+
mTimeSource = timeSource;
390386
}
391387

392388
void TimeSynchronizationServer::OnFallbackNTPCompletionFn(bool timeSyncSuccessful)
@@ -395,11 +391,7 @@ void TimeSynchronizationServer::OnFallbackNTPCompletionFn(bool timeSyncSuccessfu
395391
{
396392
mGranularity = GranularityEnum::kMillisecondsGranularity;
397393
// Non-matter SNTP because we know it's external and there's only one source
398-
Status status = TimeSource::Set(kRootEndpointId, TimeSourceEnum::kNonMatterSNTP);
399-
if (!(status == Status::Success || status == Status::UnsupportedAttribute))
400-
{
401-
ChipLogError(Zcl, "Writing TimeSource failed.");
402-
}
394+
mTimeSource = TimeSourceEnum::kNonMatterSNTP;
403395
}
404396
else
405397
{
@@ -795,13 +787,8 @@ CHIP_ERROR TimeSynchronizationServer::SetUTCTime(EndpointId ep, uint64_t utcTime
795787
return err;
796788
}
797789
GetDelegate()->UTCTimeAvailabilityChanged(utcTime);
798-
mGranularity = static_cast<GranularityEnum>(to_underlying(granularity) - 1);
799-
Status status = TimeSource::Set(ep, source);
800-
if (!(status == Status::Success || status == Status::UnsupportedAttribute))
801-
{
802-
ChipLogError(Zcl, "Writing TimeSource failed.");
803-
return StatusIB(status).ToChipError();
804-
}
790+
mGranularity = static_cast<GranularityEnum>(to_underlying(granularity) - 1);
791+
mTimeSource = source;
805792
return CHIP_NO_ERROR;
806793
}
807794

‎src/app/clusters/time-synchronization-server/time-synchronization-server.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <app/AppConfig.h>
2828
#include <app/server/Server.h>
2929
#include <app/util/af-types.h>
30-
#include <app/util/config.h>
3130
#include <credentials/FabricTable.h>
3231
#include <lib/core/TLV.h>
3332

@@ -139,6 +138,7 @@ class TimeSynchronizationServer : public FabricTable::Delegate
139138
TimeSyncDataProvider::TimeZoneObj mTimeZoneObj{ Span<TimeSyncDataProvider::TimeZoneStore>(mTz), 0 };
140139
TimeSyncDataProvider::DSTOffsetObj mDstOffsetObj{ DataModel::List<Structs::DSTOffsetStruct::Type>(mDst), 0 };
141140
GranularityEnum mGranularity = GranularityEnum::kNoTimeGranularity;
141+
TimeSourceEnum mTimeSource = TimeSourceEnum::kNone;
142142

143143
TimeSyncDataProvider::TimeZoneStore mTz[CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE];
144144
Structs::DSTOffsetStruct::Type mDst[CHIP_CONFIG_DST_OFFSET_LIST_MAX_SIZE];

‎src/app/zap-templates/zcl/zcl-with-test-extensions.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,8 @@
383383
"LocalTime",
384384
"Granularity",
385385
"TimeZoneListMaxSize",
386-
"DSTOffsetListMaxSize"
386+
"DSTOffsetListMaxSize",
387+
"TimeSource"
387388
],
388389
"Temperature Control": ["SupportedTemperatureLevels"],
389390
"Dishwasher Mode": [

‎src/app/zap-templates/zcl/zcl.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@
381381
"LocalTime",
382382
"Granularity",
383383
"TimeZoneListMaxSize",
384-
"DSTOffsetListMaxSize"
384+
"DSTOffsetListMaxSize",
385+
"TimeSource"
385386
],
386387
"Temperature Control": ["SupportedTemperatureLevels"],
387388
"Dishwasher Mode": [

‎zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp

-47
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h

-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.