Skip to content

Commit a075fb5

Browse files
committed
WIP: raise MTRDevice; MTRDevice_Concrete impl
1 parent 2bd9d0b commit a075fb5

File tree

5 files changed

+80
-13
lines changed

5 files changed

+80
-13
lines changed

src/darwin/Framework/CHIP/MTRDevice.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ typedef NS_ENUM(NSUInteger, MTRDeviceState) {
3333

3434
MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
3535
@interface MTRDevice : NSObject
36-
- (instancetype)init NS_UNAVAILABLE;
37-
+ (instancetype)new NS_UNAVAILABLE;
36+
// TODO: implement and error? kmo 2 aug 2024 14h16
37+
//- (instancetype)init NS_UNAVAILABLE;
38+
//+ (instancetype)new NS_UNAVAILABLE;
3839

3940
/**
4041
* TODO: Document usage better
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
*
3+
* Copyright (c) 2022-2023 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#import <Foundation/Foundation.h>
19+
#import <Matter/MTRDevice.h>
20+
21+
NS_ASSUME_NONNULL_BEGIN
22+
23+
@class MTRDeviceController;
24+
25+
MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
26+
@interface MTRDevice_Concrete : MTRDevice
27+
- (instancetype)init NS_UNAVAILABLE;
28+
+ (instancetype)new NS_UNAVAILABLE;
29+
30+
@end
31+
32+
33+
NS_ASSUME_NONNULL_END

src/darwin/Framework/CHIP/MTRDevice.mm src/darwin/Framework/CHIP/MTRDevice_Concrete.mm

+35-7
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@
5454
#import <platform/LockTracker.h>
5555
#import <platform/PlatformManager.h>
5656

57+
58+
// allow readwrite access to superclass properties
59+
@interface MTRDevice_Concrete ()
60+
61+
@property (nonatomic, readwrite, copy) NSNumber * nodeID;
62+
@property (nonatomic, readwrite, nullable) MTRDeviceController * deviceController;
63+
@property (nonatomic, readwrite) MTRAsyncWorkQueue<MTRDevice *> * asyncWorkQueue;
64+
@property (nonatomic, readwrite) MTRDeviceState state;
65+
@property (nonatomic, readwrite, nullable) NSDate * estimatedStartTime;
66+
@property (nonatomic, readwrite, nullable, copy) NSNumber * estimatedSubscriptionLatency;
67+
68+
// forward declaration
69+
- (MTRBaseDevice *)newBaseDevice;
70+
//
71+
72+
@end
73+
74+
5775
typedef void (^MTRDeviceAttributeReportHandler)(NSArray * _Nonnull);
5876

5977
NSString * const MTRPreviousDataKey = @"previousData";
@@ -366,7 +384,7 @@ - (BOOL)isEqual:(id)object
366384
// better behavior.
367385
#define MTRDEVICE_SUBSCRIPTION_LATENCY_NEW_VALUE_WEIGHT (1.0 / 3.0)
368386

369-
@interface MTRDevice ()
387+
@interface MTRDevice_Concrete ()
370388
@property (nonatomic, readonly) os_unfair_lock lock; // protects the caches and device state
371389
// protects against concurrent time updates by guarding timeUpdateScheduled flag which manages time updates scheduling,
372390
// and protects device calls to setUTCTime and setDSTOffset
@@ -436,7 +454,8 @@ - (BOOL)unitTestSuppressTimeBasedReachabilityChanges:(MTRDevice *)device;
436454
@end
437455
#endif
438456

439-
@implementation MTRDevice {
457+
@implementation MTRDevice_Concrete {
458+
440459
#ifdef DEBUG
441460
NSUInteger _unitTestAttributesReportedSinceLastCheck;
442461
#endif
@@ -498,6 +517,15 @@ @implementation MTRDevice {
498517
NSMutableSet<MTRDeviceDelegateInfo *> * _delegates;
499518
}
500519

520+
// synthesize superclass property readwrite accessors
521+
@synthesize nodeID = _nodeID;
522+
@synthesize deviceController = _deviceController;
523+
@synthesize queue = _queue;
524+
@synthesize asyncWorkQueue = _asyncWorkQueue;
525+
@synthesize state = _state;
526+
@synthesize estimatedStartTime = _estimatedStartTime;
527+
@synthesize estimatedSubscriptionLatency = _estimatedSubscriptionLatency;
528+
501529
- (instancetype)initWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller
502530
{
503531
if (self = [super init]) {
@@ -543,13 +571,13 @@ - (void)dealloc
543571
[[NSNotificationCenter defaultCenter] removeObserver:_systemTimeChangeObserverToken];
544572

545573
// TODO: retain cycle and clean up https://github.com/project-chip/connectedhomeip/issues/34267
546-
MTR_LOG("MTRDevice dealloc: %p", self);
574+
MTR_LOG("MTRDevice_Concrete dealloc: %p", self);
547575
}
548576

549577
- (NSString *)description
550578
{
551579
return [NSString
552-
stringWithFormat:@"<MTRDevice: %p>[fabric: %u, nodeID: 0x%016llX]", self, _fabricIndex, _nodeID.unsignedLongLongValue];
580+
stringWithFormat:@"<MTRDevice_Concrete: %p>[fabric: %u, nodeID: 0x%016llX]", self, _fabricIndex, _nodeID.unsignedLongLongValue];
553581
}
554582

555583
+ (MTRDevice *)deviceWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller
@@ -624,7 +652,7 @@ - (void)_scheduleNextUpdate:(UInt64)nextUpdateInSeconds
624652
if (self) {
625653
[self _performScheduledTimeUpdate];
626654
} else {
627-
MTR_LOG_DEBUG("%@ MTRDevice no longer valid. No Timer Scheduled will be scheduled for a Device Time Update.", self);
655+
MTR_LOG_DEBUG("%@ MTRDevice_Concrete no longer valid. No Timer Scheduled will be scheduled for a Device Time Update.", self);
628656
return;
629657
}
630658
});
@@ -4138,7 +4166,7 @@ - (void)_addInformationalAttributesToCurrentMetricScope
41384166

41394167
/* BEGIN DRAGONS: Note methods here cannot be renamed, and are used by private callers, do not rename, remove or modify behavior here */
41404168

4141-
@implementation MTRDevice (MatterPrivateForInternalDragonsDoNotFeed)
4169+
@implementation MTRDevice_Concrete (MatterPrivateForInternalDragonsDoNotFeed)
41424170

41434171
- (BOOL)_deviceHasActiveSubscription
41444172
{
@@ -4162,7 +4190,7 @@ - (void)_deviceMayBeReachable
41624190

41634191
@end
41644192

4165-
@implementation MTRDevice (Deprecated)
4193+
@implementation MTRDevice_Concrete (Deprecated)
41664194

41674195
+ (MTRDevice *)deviceWithNodeID:(uint64_t)nodeID deviceController:(MTRDeviceController *)deviceController
41684196
{

src/darwin/Framework/CHIP/Matter.h

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#import <Matter/MTRCommissioningParameters.h>
3939
#import <Matter/MTRDefines.h>
4040
#import <Matter/MTRDevice.h>
41+
#import <Matter/MTRDevice_Concrete.h>
4142
#import <Matter/MTRDeviceAttestationDelegate.h>
4243
#import <Matter/MTRDeviceAttestationInfo.h>
4344
#import <Matter/MTRDeviceController+XPC.h>

src/darwin/Framework/Matter.xcodeproj/project.pbxproj

+8-4
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@
261261
7560FD1C27FBBD3F005E85B3 /* MTREventTLVValueDecoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7560FD1B27FBBD3F005E85B3 /* MTREventTLVValueDecoder.mm */; };
262262
7596A83E28751220004DAE0E /* MTRBaseClusters_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596A83D28751220004DAE0E /* MTRBaseClusters_Internal.h */; };
263263
7596A84428762729004DAE0E /* MTRDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596A84228762729004DAE0E /* MTRDevice.h */; settings = {ATTRIBUTES = (Public, ); }; };
264-
7596A84528762729004DAE0E /* MTRDevice.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7596A84328762729004DAE0E /* MTRDevice.mm */; };
265264
7596A84828762783004DAE0E /* MTRAsyncCallbackWorkQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596A84628762783004DAE0E /* MTRAsyncCallbackWorkQueue.h */; settings = {ATTRIBUTES = (Public, ); }; };
266265
7596A84928762783004DAE0E /* MTRAsyncCallbackWorkQueue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7596A84728762783004DAE0E /* MTRAsyncCallbackWorkQueue.mm */; };
267266
7596A84B287636C1004DAE0E /* MTRDevice_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596A84A287636C1004DAE0E /* MTRDevice_Internal.h */; };
@@ -302,6 +301,8 @@
302301
99AECC802798A57F00B6355B /* MTRCommissioningParameters.mm in Sources */ = {isa = PBXBuildFile; fileRef = 99AECC7F2798A57E00B6355B /* MTRCommissioningParameters.mm */; };
303302
99C65E10267282F1003402F6 /* MTRControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 99C65E0F267282F1003402F6 /* MTRControllerTests.m */; };
304303
99D466E12798936D0089A18F /* MTRCommissioningParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 99D466E02798936D0089A18F /* MTRCommissioningParameters.h */; settings = {ATTRIBUTES = (Public, ); }; };
304+
9BD33D6D2C5D81EF005A72F1 /* MTRDevice_Concrete.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BD33D6B2C5D81EF005A72F1 /* MTRDevice_Concrete.h */; settings = {ATTRIBUTES = (Public, ); }; };
305+
9BD33D6E2C5D81EF005A72F1 /* MTRDevice_Concrete.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9BD33D6C2C5D81EF005A72F1 /* MTRDevice_Concrete.mm */; };
305306
AF1CB86E2874B03B00865A96 /* MTROTAProviderDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = AF1CB86D2874B03B00865A96 /* MTROTAProviderDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
306307
AF1CB8702874B04C00865A96 /* MTROTAProviderDelegateBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = AF1CB86F2874B04C00865A96 /* MTROTAProviderDelegateBridge.h */; };
307308
AF5F90FF2878D351005503FA /* MTROTAProviderDelegateBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = AF5F90FE2878D351005503FA /* MTROTAProviderDelegateBridge.mm */; };
@@ -687,7 +688,6 @@
687688
7560FD1B27FBBD3F005E85B3 /* MTREventTLVValueDecoder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTREventTLVValueDecoder.mm; sourceTree = "<group>"; };
688689
7596A83D28751220004DAE0E /* MTRBaseClusters_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRBaseClusters_Internal.h; sourceTree = "<group>"; };
689690
7596A84228762729004DAE0E /* MTRDevice.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRDevice.h; sourceTree = "<group>"; };
690-
7596A84328762729004DAE0E /* MTRDevice.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRDevice.mm; sourceTree = "<group>"; };
691691
7596A84628762783004DAE0E /* MTRAsyncCallbackWorkQueue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRAsyncCallbackWorkQueue.h; sourceTree = "<group>"; };
692692
7596A84728762783004DAE0E /* MTRAsyncCallbackWorkQueue.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRAsyncCallbackWorkQueue.mm; sourceTree = "<group>"; };
693693
7596A84A287636C1004DAE0E /* MTRDevice_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRDevice_Internal.h; sourceTree = "<group>"; };
@@ -729,6 +729,8 @@
729729
99AECC7F2798A57E00B6355B /* MTRCommissioningParameters.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRCommissioningParameters.mm; sourceTree = "<group>"; };
730730
99C65E0F267282F1003402F6 /* MTRControllerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MTRControllerTests.m; sourceTree = "<group>"; };
731731
99D466E02798936D0089A18F /* MTRCommissioningParameters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRCommissioningParameters.h; sourceTree = "<group>"; };
732+
9BD33D6B2C5D81EF005A72F1 /* MTRDevice_Concrete.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRDevice_Concrete.h; sourceTree = "<group>"; };
733+
9BD33D6C2C5D81EF005A72F1 /* MTRDevice_Concrete.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRDevice_Concrete.mm; sourceTree = "<group>"; };
732734
AF1CB86D2874B03B00865A96 /* MTROTAProviderDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTROTAProviderDelegate.h; sourceTree = "<group>"; };
733735
AF1CB86F2874B04C00865A96 /* MTROTAProviderDelegateBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTROTAProviderDelegateBridge.h; sourceTree = "<group>"; };
734736
AF5F90FE2878D351005503FA /* MTROTAProviderDelegateBridge.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MTROTAProviderDelegateBridge.mm; sourceTree = "<group>"; };
@@ -1300,7 +1302,8 @@
13001302
3DFCB32A2966827F00332B35 /* MTRDefines_Internal.h */,
13011303
7596A84A287636C1004DAE0E /* MTRDevice_Internal.h */,
13021304
7596A84228762729004DAE0E /* MTRDevice.h */,
1303-
7596A84328762729004DAE0E /* MTRDevice.mm */,
1305+
9BD33D6B2C5D81EF005A72F1 /* MTRDevice_Concrete.h */,
1306+
9BD33D6C2C5D81EF005A72F1 /* MTRDevice_Concrete.mm */,
13041307
88EBF8CB27FABDD500686BC1 /* MTRDeviceAttestationDelegate.h */,
13051308
7534F12728BFF20300390851 /* MTRDeviceAttestationDelegate_Internal.h */,
13061309
7534F12628BFF20300390851 /* MTRDeviceAttestationDelegate.mm */,
@@ -1600,6 +1603,7 @@
16001603
5117DD3929A931AE00FFA1AA /* MTROperationalBrowser.h in Headers */,
16011604
2C1B027B2641DB4E00780EF1 /* MTROperationalCredentialsDelegate.h in Headers */,
16021605
5173A47529C0E2ED00F67F48 /* MTRFabricInfo_Internal.h in Headers */,
1606+
9BD33D6D2C5D81EF005A72F1 /* MTRDevice_Concrete.h in Headers */,
16031607
3D843717294979230070D20A /* MTRClusters_Internal.h in Headers */,
16041608
7596A85728788557004DAE0E /* MTRClusters.h in Headers */,
16051609
99D466E12798936D0089A18F /* MTRCommissioningParameters.h in Headers */,
@@ -1979,6 +1983,7 @@
19791983
511913FB28C100EF009235E9 /* MTRBaseSubscriptionCallback.mm in Sources */,
19801984
510470FB2A2F7DF60053EA7E /* MTRBackwardsCompatShims.mm in Sources */,
19811985
5173A47629C0E2ED00F67F48 /* MTRFabricInfo.mm in Sources */,
1986+
9BD33D6E2C5D81EF005A72F1 /* MTRDevice_Concrete.mm in Sources */,
19821987
5ACDDD7D27CD16D200EFD68A /* MTRClusterStateCacheContainer.mm in Sources */,
19831988
75B3269E2BCDB9EA00E17C4E /* MTRDeviceConnectivityMonitor.mm in Sources */,
19841989
513DDB8A2761F6F900DAA01A /* MTRAttributeTLVValueDecoder.mm in Sources */,
@@ -2008,7 +2013,6 @@
20082013
51D0B1272B617246006E3511 /* MTRServerEndpoint.mm in Sources */,
20092014
3DECCB722934AFE200585AEC /* MTRLogging.mm in Sources */,
20102015
51C659DA2BA3787500C54922 /* MTRTimeUtils.mm in Sources */,
2011-
7596A84528762729004DAE0E /* MTRDevice.mm in Sources */,
20122016
);
20132017
runOnlyForDeploymentPostprocessing = 0;
20142018
};

0 commit comments

Comments
 (0)