From 2031036259fff94569331e5007e91e4f7afcd0a8 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 9 May 2023 00:41:10 -0400 Subject: [PATCH] Adjust Darwin availability annotations for Time Synchronization updates. (#26436) This aims to as much as possible undo the changes from #26332 to Darwin generated code, by listing the set of renames and then marking almost all the new names provisional. The two exceptions are: 1) The attributes that got renamed, for which the codegen sets the old id constants equal to the new id constants, so we have to generate the new id constants. 2) The nullability change for validUntil in DSTOffsetStruct, which we have no way to make conditional based on availability. --- .../CHIP/templates/MTRClusterConstants.zapt | 9 +++ .../CHIP/templates/availability.yaml | 68 +++++++++++++++++++ .../CHIP/zap-generated/MTRBaseClusters.h | 24 +++---- .../CHIP/zap-generated/MTRClusterConstants.h | 42 ++++++++---- .../zap-generated/MTRCommandPayloadsObjc.h | 34 ++++++++++ .../zap-generated/MTRCommandPayloadsObjc.mm | 37 ++++++++++ 6 files changed, 187 insertions(+), 27 deletions(-) diff --git a/src/darwin/Framework/CHIP/templates/MTRClusterConstants.zapt b/src/darwin/Framework/CHIP/templates/MTRClusterConstants.zapt index 04111e11cfbf2c..4432bde2cf240d 100644 --- a/src/darwin/Framework/CHIP/templates/MTRClusterConstants.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRClusterConstants.zapt @@ -157,6 +157,15 @@ MTRCommandIDTypeCluster{{cluster}}Command{{command}}ID {{availability cluster co {{/inline}} {{> commandIdDecl cluster=(asUpperCamelCase ../clusterName preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true)}} +{{! Anything which has an old name, and the new name was introduced in the "First after major API revamp" release or later + (or just after the "First major API revamp" release, but we don't have a good way to test for that), + we need to generate the new-form id for the old name too, as long as it was not removed. }} +{{#if (and (hasOldName (asUpperCamelCase ../clusterName preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true) isForIds=true) + (not (wasIntroducedBeforeRelease "First after major API revamp" (asUpperCamelCase ../clusterName preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true) isForIds=true)) + (isSupported (compatClusterNameRemapping ../clusterName) command=(compatCommandNameRemapping ../clusterName name) isForIds=true))}} +{{> commandIdDecl cluster=(compatClusterNameRemapping ../clusterName) + command=(compatCommandNameRemapping ../clusterName name)}} +{{/if}} {{#last}} {{/last}} diff --git a/src/darwin/Framework/CHIP/templates/availability.yaml b/src/darwin/Framework/CHIP/templates/availability.yaml index 33e51e15d8e722..5814f5a94460bd 100644 --- a/src/darwin/Framework/CHIP/templates/availability.yaml +++ b/src/darwin/Framework/CHIP/templates/availability.yaml @@ -7139,6 +7139,12 @@ Scenes: ScenesFeature: - SceneNames + ids: + attributes: + TimeSynchronization: + - TrustedTimeSource + - DefaultNTP + - NTPServerAvailable deprecated: bitmaps: Groups: @@ -7172,6 +7178,29 @@ - ProductFinishEnum - ColorEnum renames: + attributes: + TimeSynchronization: + TrustedTimeSource: TrustedTimeNodeId + DefaultNTP: DefaultNtp + NTPServerAvailable: NtpServerPort + commands: + TimeSynchronization: + SetUTCTime: SetUtcTime + enum values: + TimeSynchronization: + TimeSourceEnum: + NonMatterSNTP: NonFabricSntp + NonMatterNTP: NonFabricNtp + MatterSNTP: FabricSntp + MatterNTP: FabricNtp + MixedNTP: MixedNtp + NonMatterSNTPNTS: NonFabricSntpNts + NonMatterNTPNTS: NonFabricNtpNts + MatterSNTPNTS: FabricSntpNts + MatterNTPNTS: FabricNtpNts + MixedNTPNTS: MixedNtpNts + PTP: Ptp + GNSS: Gnss bitmaps: Groups: GroupsFeature: GroupClusterFeature @@ -7179,3 +7208,42 @@ PressureMeasurementFeature: PressureFeature PumpConfigurationAndControl: PumpConfigurationAndControlFeature: PumpFeature + provisional: + # Once we actually unmark TimeSynchronization as provisional, all these bits should go away too, and we should instead + # mark things as introduced/deprecated as needed. The "ids" entries should go away, in particular. + ids: + attributes: + TimeSynchronization: + - TimeZoneListMaxSize + - DSTOffsetListMaxSize + - SupportsDNSResolve + commands: + TimeSynchronization: + - SetUTCTime + - SetTrustedTimeSource + - SetTimeZone + - SetTimeZoneResponse + - SetDSTOffset + - SetDefaultNTP + events: + TimeSynchronization: + - DSTTableEmpty + - DSTStatus + - TimeZoneStatus + - TimeFailure + - MissingTrustedTimeSource + enum values: + TimeSynchronization: + TimeSourceEnum: + - NonMatterSNTP + - NonMatterNTP + - MatterSNTP + - MatterNTP + - MixedNTP + - NonMatterSNTPNTS + - NonMatterNTPNTS + - MatterSNTPNTS + - MatterNTPNTS + - MixedNTPNTS + - PTP + - GNSS diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index c7b3edf744c299..f55d7231050d42 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -19975,19 +19975,19 @@ typedef NS_ENUM(uint8_t, MTRTimeSynchronizationTimeSource) { MTRTimeSynchronizationTimeSourceUnknown API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x01, MTRTimeSynchronizationTimeSourceAdmin API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x02, MTRTimeSynchronizationTimeSourceNodeTimeCluster API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x03, - MTRTimeSynchronizationTimeSourceNonMatterSNTP MTR_NEWLY_AVAILABLE = 0x04, - MTRTimeSynchronizationTimeSourceNonMatterNTP MTR_NEWLY_AVAILABLE = 0x05, - MTRTimeSynchronizationTimeSourceMatterSNTP MTR_NEWLY_AVAILABLE = 0x06, - MTRTimeSynchronizationTimeSourceMatterNTP MTR_NEWLY_AVAILABLE = 0x07, - MTRTimeSynchronizationTimeSourceMixedNTP MTR_NEWLY_AVAILABLE = 0x08, - MTRTimeSynchronizationTimeSourceNonMatterSNTPNTS MTR_NEWLY_AVAILABLE = 0x09, - MTRTimeSynchronizationTimeSourceNonMatterNTPNTS MTR_NEWLY_AVAILABLE = 0x0A, - MTRTimeSynchronizationTimeSourceMatterSNTPNTS MTR_NEWLY_AVAILABLE = 0x0B, - MTRTimeSynchronizationTimeSourceMatterNTPNTS MTR_NEWLY_AVAILABLE = 0x0C, - MTRTimeSynchronizationTimeSourceMixedNTPNTS MTR_NEWLY_AVAILABLE = 0x0D, + MTRTimeSynchronizationTimeSourceNonFabricSntp API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x04, + MTRTimeSynchronizationTimeSourceNonFabricNtp API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x05, + MTRTimeSynchronizationTimeSourceFabricSntp API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x06, + MTRTimeSynchronizationTimeSourceFabricNtp API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x07, + MTRTimeSynchronizationTimeSourceMixedNtp API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x08, + MTRTimeSynchronizationTimeSourceNonFabricSntpNts API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x09, + MTRTimeSynchronizationTimeSourceNonFabricNtpNts API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x0A, + MTRTimeSynchronizationTimeSourceFabricSntpNts API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x0B, + MTRTimeSynchronizationTimeSourceFabricNtpNts API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x0C, + MTRTimeSynchronizationTimeSourceMixedNtpNts API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x0D, MTRTimeSynchronizationTimeSourceCloudSource API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x0E, - MTRTimeSynchronizationTimeSourcePTP MTR_NEWLY_AVAILABLE = 0x0F, - MTRTimeSynchronizationTimeSourceGNSS MTR_NEWLY_AVAILABLE = 0x10, + MTRTimeSynchronizationTimeSourcePtp API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x0F, + MTRTimeSynchronizationTimeSourceGnss API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x10, } API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); typedef NS_ENUM(uint8_t, MTRBridgedDeviceBasicInformationColor) { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h index c035318ae60a5d..28ee1109035ef2 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h @@ -2849,6 +2849,14 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { "Please use MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeSourceID", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)) = 0x00000002, + MTRClusterTimeSynchronizationAttributeTrustedTimeNodeIdID MTR_DEPRECATED( + "Please use MTRAttributeIDTypeClusterTimeSynchronizationAttributeTrustedTimeSourceID", ios(16.1, 16.4), macos(13.0, 13.3), + watchos(9.1, 9.4), tvos(16.1, 16.4)) + = 0x00000003, + MTRClusterTimeSynchronizationAttributeDefaultNtpID MTR_DEPRECATED( + "Please use MTRAttributeIDTypeClusterTimeSynchronizationAttributeDefaultNTPID", ios(16.1, 16.4), macos(13.0, 13.3), + watchos(9.1, 9.4), tvos(16.1, 16.4)) + = 0x00000004, MTRClusterTimeSynchronizationAttributeTimeZoneID MTR_DEPRECATED( "Please use MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeZoneID", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)) @@ -2865,6 +2873,10 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { "Please use MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeZoneDatabaseID", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)) = 0x00000008, + MTRClusterTimeSynchronizationAttributeNtpServerPortID MTR_DEPRECATED( + "Please use MTRAttributeIDTypeClusterTimeSynchronizationAttributeNTPServerAvailableID", ios(16.1, 16.4), macos(13.0, 13.3), + watchos(9.1, 9.4), tvos(16.1, 16.4)) + = 0x00000009, MTRClusterTimeSynchronizationAttributeGeneratedCommandListID MTR_DEPRECATED( "Please use MTRAttributeIDTypeClusterTimeSynchronizationAttributeGeneratedCommandListID", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)) @@ -2896,7 +2908,13 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000002, MTRAttributeIDTypeClusterTimeSynchronizationAttributeTrustedTimeSourceID MTR_NEWLY_AVAILABLE = 0x00000003, + MTRAttributeIDTypeClusterTimeSynchronizationAttributeTrustedTimeNodeIdID API_AVAILABLE( + ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) + = MTRAttributeIDTypeClusterTimeSynchronizationAttributeTrustedTimeSourceID, MTRAttributeIDTypeClusterTimeSynchronizationAttributeDefaultNTPID MTR_NEWLY_AVAILABLE = 0x00000004, + MTRAttributeIDTypeClusterTimeSynchronizationAttributeDefaultNtpID API_AVAILABLE( + ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) + = MTRAttributeIDTypeClusterTimeSynchronizationAttributeDefaultNTPID, MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeZoneID API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000005, MTRAttributeIDTypeClusterTimeSynchronizationAttributeDSTOffsetID API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)) @@ -2911,9 +2929,9 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000008, MTRAttributeIDTypeClusterTimeSynchronizationAttributeNTPServerAvailableID MTR_NEWLY_AVAILABLE = 0x00000009, - MTRAttributeIDTypeClusterTimeSynchronizationAttributeTimeZoneListMaxSizeID MTR_NEWLY_AVAILABLE = 0x0000000A, - MTRAttributeIDTypeClusterTimeSynchronizationAttributeDSTOffsetListMaxSizeID MTR_NEWLY_AVAILABLE = 0x0000000B, - MTRAttributeIDTypeClusterTimeSynchronizationAttributeSupportsDNSResolveID MTR_NEWLY_AVAILABLE = 0x0000000C, + MTRAttributeIDTypeClusterTimeSynchronizationAttributeNtpServerPortID API_AVAILABLE( + ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) + = MTRAttributeIDTypeClusterTimeSynchronizationAttributeNTPServerAvailableID, MTRAttributeIDTypeClusterTimeSynchronizationAttributeGeneratedCommandListID API_AVAILABLE( ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID, @@ -8545,14 +8563,14 @@ typedef NS_ENUM(uint32_t, MTRCommandIDType) { = 0x00000000, // Cluster TimeSynchronization deprecated command id names + MTRClusterTimeSynchronizationCommandSetUtcTimeID MTR_DEPRECATED( + "Please use MTRCommandIDTypeClusterTimeSynchronizationCommandSetUTCTimeID", ios(16.1, 16.4), macos(13.0, 13.3), + watchos(9.1, 9.4), tvos(16.1, 16.4)) + = 0x00000000, // Cluster TimeSynchronization commands - MTRCommandIDTypeClusterTimeSynchronizationCommandSetUTCTimeID MTR_NEWLY_AVAILABLE = 0x00000000, - MTRCommandIDTypeClusterTimeSynchronizationCommandSetTrustedTimeSourceID MTR_NEWLY_AVAILABLE = 0x00000001, - MTRCommandIDTypeClusterTimeSynchronizationCommandSetTimeZoneID MTR_NEWLY_AVAILABLE = 0x00000002, - MTRCommandIDTypeClusterTimeSynchronizationCommandSetTimeZoneResponseID MTR_NEWLY_AVAILABLE = 0x00000003, - MTRCommandIDTypeClusterTimeSynchronizationCommandSetDSTOffsetID MTR_NEWLY_AVAILABLE = 0x00000004, - MTRCommandIDTypeClusterTimeSynchronizationCommandSetDefaultNTPID MTR_NEWLY_AVAILABLE = 0x00000005, + MTRCommandIDTypeClusterTimeSynchronizationCommandSetUtcTimeID API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) + = 0x00000000, // Cluster AdministratorCommissioning deprecated command id names MTRClusterAdministratorCommissioningCommandOpenCommissioningWindowID MTR_DEPRECATED( @@ -9760,12 +9778,6 @@ typedef NS_ENUM(uint32_t, MTREventIDType) { ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000002, - MTREventIDTypeClusterTimeSynchronizationEventDSTTableEmptyID MTR_NEWLY_AVAILABLE = 0x00000000, - MTREventIDTypeClusterTimeSynchronizationEventDSTStatusID MTR_NEWLY_AVAILABLE = 0x00000001, - MTREventIDTypeClusterTimeSynchronizationEventTimeZoneStatusID MTR_NEWLY_AVAILABLE = 0x00000002, - MTREventIDTypeClusterTimeSynchronizationEventTimeFailureID MTR_NEWLY_AVAILABLE = 0x00000003, - MTREventIDTypeClusterTimeSynchronizationEventMissingTrustedTimeSourceID MTR_NEWLY_AVAILABLE = 0x00000004, - // Cluster BridgedDeviceBasic deprecated event names MTRClusterBridgedDeviceBasicEventStartUpID MTR_DEPRECATED( "Please use MTREventIDTypeClusterBridgedDeviceBasicInformationEventStartUpID", ios(16.1, 16.4), macos(13.0, 13.3), diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h index a96f234508cf3c..2e257f43660372 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h @@ -3012,6 +3012,40 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout; @end +API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) +@interface MTRTimeSynchronizationClusterSetUtcTimeParams : NSObject + +@property (nonatomic, copy) NSNumber * _Nonnull utcTime API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); + +@property (nonatomic, copy) NSNumber * _Nonnull granularity API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); + +@property (nonatomic, copy) NSNumber * _Nullable timeSource API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); +/** + * Controls whether the command is a timed command (using Timed Invoke). + * + * If nil (the default value), a regular invoke is done for commands that do + * not require a timed invoke and a timed invoke with some default timed request + * timeout is done for commands that require a timed invoke. + * + * If not nil, a timed invoke is done, with the provided value used as the timed + * request timeout. The value should be chosen small enough to provide the + * desired security properties but large enough that it will allow a round-trip + * from the sever to the client (for the status response and actual invoke + * request) within the timeout window. + * + */ +@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; + +/** + * Controls how much time, in seconds, we will allow for the server to process the command. + * + * The command will then time out if that much time, plus an allowance for retransmits due to network failures, passes. + * + * If nil, the framework will try to select an appropriate timeout value itself. + */ +@property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout; +@end + API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @interface MTRAdministratorCommissioningClusterOpenCommissioningWindowParams : NSObject diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm index c12cfb5bc60d2d..b0a66d4e6484ee 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm @@ -3678,6 +3678,43 @@ - (NSString *)description return descriptionString; } +@end +@implementation MTRTimeSynchronizationClusterSetUtcTimeParams +- (instancetype)init +{ + if (self = [super init]) { + + _utcTime = @(0); + + _granularity = @(0); + + _timeSource = nil; + _timedInvokeTimeoutMs = nil; + _serverSideProcessingTimeout = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone; +{ + auto other = [[MTRTimeSynchronizationClusterSetUtcTimeParams alloc] init]; + + other.utcTime = self.utcTime; + other.granularity = self.granularity; + other.timeSource = self.timeSource; + other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; + other.serverSideProcessingTimeout = self.serverSideProcessingTimeout; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: utcTime:%@; granularity:%@; timeSource:%@; >", + NSStringFromClass([self class]), _utcTime, _granularity, _timeSource]; + return descriptionString; +} + @end @implementation MTRAdministratorCommissioningClusterOpenCommissioningWindowParams - (instancetype)init