Skip to content

Commit

Permalink
updated time-synchronization cluster definition based on PR project-c…
Browse files Browse the repository at this point in the history
…hip#6352

add Time Synchronization cluster in all-clusters-app, controller-app and light-switch-app zap and regenerate all

remove constraint from a single element attribute

first code commit

initialize timezone and trustedtimesource to 0 and null

added statuscode and changed to fabricIndex

regenerate zap

use time sync server code

set default zap setting to external for complex time sync attributes

add endpoint to trustedtimesourcestruct and set command for it

regenerate

using updated trustedtimesourcestruct

update time sync xml definition

update zap files

regenerate

added persistent data provider for time sync cluster

added new commands based on PR project-chip#6353

added test template for TimeSyncDataProvider

changed command arguments to list type

regenerate

update SetTrustedTimeSource definition

regenerate

use consistent data types of attributes

user CHIP_CONFIG to set size of lists

clean up read handler

adde TSC feature and change attribute ids

include time sync related resource for build

regenerate after changing attribute ids and adding time sync client feature

reorganize code and implement defaultNTP handlers

handle span data the right way
improved overall implementation

change default time zone list size to 1

made settrustedtimesource command to be fabric scoped

update time sync cluster definition based on latest PR merges

regenerate and changes related to attribute names and access

setdefaultntp parameter is nullable

implemented setdefaultntp

changed the id of settimezoneresponse command to the current in spec

removed curly brace that sneaked in to previous commits

ValidUntil of DSTOffsetStruct is nullable

added basic rules of operation in comment/psuedo-code

added DSTOffsetActive predicate for DSTStatus event

fixed clang compiler errors

added skeleton delegate implementation for time sync

use delegate placeholder and implemented events

clean up usage of namespaces

seems like unused code

skleton verifiers for NTP address

moved init from header

removed conflicting generated files

regenerate all

enum now starts at 0, name field is optional in timezonestatus event

force external storage for UTCTime and LocalTime attributes

moved time sync cluster code to cpp file
added mechanism to track real size of list data
removed custom encoder for TimeZone attribute
changed TimeZone list size to 2 for better testing behavior
addressed multiple PR comments

improved defaultNTP implementation and storage usage
cleaned up return usage

changed time logic to be able to set older time but not old than default LastKnownTime

ignore attribute storage values for sizes with F quality

resolve rebase conflicts

some random generated code that needs to be there

use consistent data types

changes based on CI failures

TrustedTimeSource is not a list

fixed response behavior of setttimezone command

missed generated code
  • Loading branch information
fessehaeve committed May 5, 2023
1 parent 844783e commit 1367a2f
Show file tree
Hide file tree
Showing 43 changed files with 6,306 additions and 13 deletions.
164 changes: 164 additions & 0 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1909,6 +1909,145 @@ server cluster EthernetNetworkDiagnostics = 55 {
command ResetCounts(): DefaultSuccess = 0;
}

/** Accurate time is required for a number of reasons, including scheduling, display and validating security materials. */
server cluster TimeSynchronization = 56 {
enum GranularityEnum : ENUM8 {
kNoTimeGranularity = 0;
kMinutesGranularity = 1;
kSecondsGranularity = 2;
kMillisecondsGranularity = 3;
kMicrosecondsGranularity = 4;
}

enum StatusCode : ENUM8 {
kTimeNotAccepted = 2;
}

enum TimeSourceEnum : ENUM8 {
kNone = 0;
kUnknown = 1;
kAdmin = 2;
kNodeTimeCluster = 3;
kNonMatterSNTP = 4;
kNonMatterNTP = 5;
kMatterSNTP = 6;
kMatterNTP = 7;
kMixedNTP = 8;
kNonMatterSNTPNTS = 9;
kNonMatterNTPNTS = 10;
kMatterSNTPNTS = 11;
kMatterNTPNTS = 12;
kMixedNTPNTS = 13;
kCloudSource = 14;
kPtp = 15;
kGnss = 16;
}

enum TimeZoneDatabaseEnum : ENUM8 {
kFull = 0;
kPartial = 1;
kNone = 2;
}

bitmap TimeSynchronizationFeature : BITMAP32 {
kTimeZone = 0x1;
kNTPClient = 0x2;
kNTPServer = 0x4;
kTimeSyncClient = 0x8;
}

struct DSTOffsetStruct {
int32s offset = 0;
epoch_us validStarting = 1;
nullable epoch_us validUntil = 2;
}

struct FabricScopedTrustedTimeSourceStruct {
node_id nodeID = 0;
endpoint_no endpoint = 1;
}

struct TimeZoneStruct {
int32s offset = 0;
epoch_us validAt = 1;
optional char_string<64> name = 2;
}

struct TrustedTimeSourceStruct {
fabric_idx fabricIndex = 0;
node_id nodeID = 1;
endpoint_no endpoint = 2;
}

info event DSTTableEmpty = 0 {
}

info event DSTStatus = 1 {
boolean DSTOffsetActive = 0;
}

info event TimeZoneStatus = 2 {
INT32S offset = 0;
optional CHAR_STRING name = 1;
}

info event TimeFailure = 3 {
}

info event MissingTrustedTimeSource = 4 {
}

readonly attribute nullable epoch_us UTCTime = 0;
readonly attribute GranularityEnum granularity = 1;
readonly attribute TimeSourceEnum timeSource = 2;
readonly attribute nullable TrustedTimeSourceStruct trustedTimeSource = 3;
readonly attribute nullable char_string<128> defaultNTP = 4;
readonly attribute TimeZoneStruct timeZone[] = 5;
readonly attribute DSTOffsetStruct DSTOffset[] = 6;
readonly attribute nullable epoch_us localTime = 7;
readonly attribute TimeZoneDatabaseEnum timeZoneDatabase = 8;
readonly attribute int8u timeZoneListMaxSize = 10;
readonly attribute int8u DSTOffsetListMaxSize = 11;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;

request struct SetUTCTimeRequest {
epoch_us UTCTime = 0;
GranularityEnum granularity = 1;
optional TimeSourceEnum timeSource = 2;
}

request struct SetTrustedTimeSourceRequest {
nullable FabricScopedTrustedTimeSourceStruct trustedTimeSource = 0;
}

request struct SetTimeZoneRequest {
TimeZoneStruct timeZone[] = 0;
}

request struct SetDSTOffsetRequest {
DSTOffsetStruct DSTOffset[] = 0;
}

request struct SetDefaultNTPRequest {
nullable CHAR_STRING<128> defaultNTP = 0;
}

response struct SetTimeZoneResponse = 3 {
boolean DSTOffsetRequired = 0;
}

command access(invoke: administer) SetUTCTime(SetUTCTimeRequest): DefaultSuccess = 0;
fabric command access(invoke: administer) SetTrustedTimeSource(SetTrustedTimeSourceRequest): DefaultSuccess = 1;
command access(invoke: manage) SetTimeZone(SetTimeZoneRequest): SetTimeZoneResponse = 2;
command access(invoke: manage) SetDSTOffset(SetDSTOffsetRequest): DefaultSuccess = 4;
command access(invoke: administer) SetDefaultNTP(SetDefaultNTPRequest): DefaultSuccess = 5;
}

/** This cluster exposes interactions with a switch device, for the purpose of using those interactions by other devices.
Two types of switch devices are supported: latching switch (e.g. rocker switch) and momentary switch (e.g. push button), distinguished with their feature flags.
Interactions with the switch device are exposed as attributes (for the latching switch) and as events (for both types of switches). An interested party MAY subscribe to these attributes/events and thus be informed of the interactions, and can perform actions based on this, for example by sending commands to perform an action such as controlling a light or a window shade. */
Expand Down Expand Up @@ -4870,6 +5009,31 @@ endpoint 0 {
ram attribute clusterRevision default = 1;
}

server cluster TimeSynchronization {
emits event DSTTableEmpty;
emits event DSTStatus;
emits event TimeZoneStatus;
emits event TimeFailure;
emits event MissingTrustedTimeSource;
callback attribute UTCTime;
ram attribute granularity default = 0x00;
ram attribute timeSource default = 0x00;
callback attribute trustedTimeSource;
callback attribute defaultNTP;
callback attribute timeZone default = 1;
callback attribute DSTOffset;
callback attribute localTime default = 1;
ram attribute timeZoneDatabase default = 0;
ram attribute timeZoneListMaxSize default = 3;
ram attribute DSTOffsetListMaxSize;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
ram attribute featureMap default = 1;
ram attribute clusterRevision default = 1;
}

server cluster AdministratorCommissioning {
callback attribute windowStatus default = 0;
callback attribute adminFabricIndex default = 1;
Expand Down
Loading

0 comments on commit 1367a2f

Please sign in to comment.