Skip to content

Commit 85b8e13

Browse files
committed
stop using attribute storage for TimeSource to make the code more
suitable for unit testing
1 parent 6ff3e0a commit 85b8e13

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
@@ -378,12 +378,8 @@ void TimeSynchronizationServer::OnTimeSyncCompletionFn(TimeSourceEnum timeSource
378378
}
379379
return;
380380
}
381-
mGranularity = granularity;
382-
Status status = TimeSource::Set(kRootEndpointId, timeSource);
383-
if (!(status == Status::Success || status == Status::UnsupportedAttribute))
384-
{
385-
ChipLogError(Zcl, "Writing TimeSource failed.");
386-
}
381+
mGranularity = granularity;
382+
mTimeSource = timeSource;
387383
}
388384

389385
void TimeSynchronizationServer::OnFallbackNTPCompletionFn(bool timeSyncSuccessful)
@@ -392,11 +388,7 @@ void TimeSynchronizationServer::OnFallbackNTPCompletionFn(bool timeSyncSuccessfu
392388
{
393389
mGranularity = GranularityEnum::kMillisecondsGranularity;
394390
// Non-matter SNTP because we know it's external and there's only one source
395-
Status status = TimeSource::Set(kRootEndpointId, TimeSourceEnum::kNonMatterSNTP);
396-
if (!(status == Status::Success || status == Status::UnsupportedAttribute))
397-
{
398-
ChipLogError(Zcl, "Writing TimeSource failed.");
399-
}
391+
mTimeSource = TimeSourceEnum::kNonMatterSNTP;
400392
}
401393
else
402394
{
@@ -791,13 +783,8 @@ CHIP_ERROR TimeSynchronizationServer::SetUTCTime(EndpointId ep, uint64_t utcTime
791783
return err;
792784
}
793785
GetDelegate()->UTCTimeAvailabilityChanged(utcTime);
794-
mGranularity = static_cast<GranularityEnum>(to_underlying(granularity) - 1);
795-
Status status = TimeSource::Set(ep, source);
796-
if (!(status == Status::Success || status == Status::UnsupportedAttribute))
797-
{
798-
ChipLogError(Zcl, "Writing TimeSource failed.");
799-
return StatusIB(status).ToChipError();
800-
}
786+
mGranularity = static_cast<GranularityEnum>(to_underlying(granularity) - 1);
787+
mTimeSource = source;
801788
return CHIP_NO_ERROR;
802789
}
803790

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

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

141141
TimeSyncDataProvider::TimeZoneStore mTz[CHIP_CONFIG_TIME_ZONE_LIST_MAX_SIZE];
142142
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
@@ -382,7 +382,8 @@
382382
"LocalTime",
383383
"Granularity",
384384
"TimeZoneListMaxSize",
385-
"DSTOffsetListMaxSize"
385+
"DSTOffsetListMaxSize",
386+
"TimeSource"
386387
],
387388
"Temperature Control": ["SupportedTemperatureLevels"],
388389
"Dishwasher Mode": [

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@
380380
"LocalTime",
381381
"Granularity",
382382
"TimeZoneListMaxSize",
383-
"DSTOffsetListMaxSize"
383+
"DSTOffsetListMaxSize",
384+
"TimeSource"
384385
],
385386
"Temperature Control": ["SupportedTemperatureLevels"],
386387
"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)