Skip to content

Commit e05527e

Browse files
Replace "Id" with "ID" in Darwin APIs.
This is a re-landing of PR project-chip#22558 but modified to preserve the old APIs. The header changes not accompanied by backwards-compat shims are OK for the following reasons: * MTRAttributeCacheContainer+XPC.h is not public API. * MTRAttributeCacheContainer_Internal.h is not public API. * MTRDeviceOverXPC.h is not public API. * MTRDeviceControllerXPCConnection.h is not public API. * MTRDeviceControllerOverXPC.h is not public API. * MTRDeviceControllerOverXPC_Internal.h is not public API.
1 parent 09acc29 commit e05527e

32 files changed

+1072
-740
lines changed

examples/darwin-framework-tool/commands/clusters/ClusterCommandBridge.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ class ClusterCommand : public ModelCommand {
7474
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
7575

7676
while (repeatCount--) {
77-
[device invokeCommandWithEndpointId:[NSNumber numberWithUnsignedShort:endpointId]
78-
clusterId:[NSNumber numberWithUnsignedInteger:clusterId]
79-
commandId:[NSNumber numberWithUnsignedInteger:commandId]
77+
[device invokeCommandWithEndpointID:[NSNumber numberWithUnsignedShort:endpointId]
78+
clusterID:[NSNumber numberWithUnsignedInteger:clusterId]
79+
commandID:[NSNumber numberWithUnsignedInteger:commandId]
8080
commandFields:commandFields
8181
timedInvokeTimeout:mTimedInteractionTimeoutMs.HasValue()
8282
? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()]

examples/darwin-framework-tool/commands/clusters/ReportCommandBridge.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ class ReadAttribute : public ModelCommand {
5656
MTRReadParams * params = [[MTRReadParams alloc] init];
5757
params.fabricFiltered = mFabricFiltered.HasValue() ? [NSNumber numberWithBool:mFabricFiltered.Value()] : nil;
5858
[device
59-
readAttributeWithEndpointId:[NSNumber numberWithUnsignedShort:endpointId]
60-
clusterId:[NSNumber numberWithUnsignedInteger:mClusterId]
61-
attributeId:[NSNumber numberWithUnsignedInteger:mAttributeId]
59+
readAttributeWithEndpointID:[NSNumber numberWithUnsignedShort:endpointId]
60+
clusterID:[NSNumber numberWithUnsignedInteger:mClusterId]
61+
attributeID:[NSNumber numberWithUnsignedInteger:mAttributeId]
6262
params:params
6363
clientQueue:callbackQueue
6464
completion:^(NSArray<NSDictionary<NSString *, id> *> * _Nullable values, NSError * _Nullable error) {
@@ -129,9 +129,9 @@ class SubscribeAttribute : public ModelCommand {
129129
= mKeepSubscriptions.HasValue() ? [NSNumber numberWithBool:mKeepSubscriptions.Value()] : nil;
130130
params.autoResubscribe = mAutoResubscribe.HasValue() ? [NSNumber numberWithBool:mAutoResubscribe.Value()] : nil;
131131

132-
[device subscribeAttributeWithEndpointId:[NSNumber numberWithUnsignedShort:endpointId]
133-
clusterId:[NSNumber numberWithUnsignedInteger:mClusterId]
134-
attributeId:[NSNumber numberWithUnsignedInteger:mAttributeId]
132+
[device subscribeAttributeWithEndpointID:[NSNumber numberWithUnsignedShort:endpointId]
133+
clusterID:[NSNumber numberWithUnsignedInteger:mClusterId]
134+
attributeID:[NSNumber numberWithUnsignedInteger:mAttributeId]
135135
minInterval:[NSNumber numberWithUnsignedInteger:mMinInterval]
136136
maxInterval:[NSNumber numberWithUnsignedInteger:mMaxInterval]
137137
params:params

examples/darwin-framework-tool/commands/clusters/WriteAttributeCommandBridge.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ class WriteAttribute : public ModelCommand {
7474
{
7575
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
7676
[device
77-
writeAttributeWithEndpointId:[NSNumber numberWithUnsignedShort:endpointId]
78-
clusterId:[NSNumber numberWithUnsignedInteger:clusterId]
79-
attributeId:[NSNumber numberWithUnsignedInteger:attributeId]
77+
writeAttributeWithEndpointID:[NSNumber numberWithUnsignedShort:endpointId]
78+
clusterID:[NSNumber numberWithUnsignedInteger:clusterId]
79+
attributeID:[NSNumber numberWithUnsignedInteger:attributeId]
8080
value:value
8181
timedWriteTimeout:mTimedInteractionTimeoutMs.HasValue()
8282
? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()]

examples/darwin-framework-tool/commands/common/CHIPCommandBridge.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
auto controller = [factory startControllerOnExistingFabric:controllerParams];
148148
if (controller == nil) {
149149
// Maybe we didn't have this fabric yet.
150-
controllerParams.vendorId = @(chip::VendorId::TestVendor1);
150+
controllerParams.vendorID = @(chip::VendorId::TestVendor1);
151151
controller = [factory startControllerOnNewFabric:controllerParams];
152152
}
153153
if (controller == nil) {

src/darwin/Framework/CHIP/MTRAttributeCacheContainer+XPC.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ NS_ASSUME_NONNULL_BEGIN
2323

2424
@interface MTRAttributeCacheContainer (XPC)
2525
- (void)setXPCConnection:(MTRDeviceControllerXPCConnection *)xpcConnection
26-
controllerId:(id<NSCopying>)controllerId
27-
deviceId:(NSNumber *)deviceId;
26+
controllerID:(id<NSCopying>)controllerID
27+
deviceID:(NSNumber *)deviceID;
2828
@end
2929

3030
NS_ASSUME_NONNULL_END

src/darwin/Framework/CHIP/MTRAttributeCacheContainer.h

+16-5
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,30 @@ NS_ASSUME_NONNULL_BEGIN
2929
/**
3030
* Reads an attribute with specific attribute path
3131
*
32-
* @param endpointId endpoint ID of the attribute
33-
* @param clusterId cluster ID of the attribute
34-
* @param attributeId attribute ID of the attribute
32+
* @param endpointID endpoint ID of the attribute
33+
* @param clusterID cluster ID of the attribute
34+
* @param attributeID attribute ID of the attribute
3535
* @param clientQueue client queue to dispatch the completion handler through
3636
* @param completion block to receive the result.
3737
* "values" received by the block will have the same format of object as the one received by completion block
38-
* of CHIPDevice readAttributeWithEndpointId:clusterId:attributeId:clientQueue:completion method.
38+
* of MTRBaseDevice readAttributeWithEndpointID:clusterID:attributeID:clientQueue:completion method.
3939
*/
40+
- (void)readAttributeWithEndpointID:(NSNumber * _Nullable)endpointID
41+
clusterID:(NSNumber * _Nullable)clusterID
42+
attributeID:(NSNumber * _Nullable)attributeID
43+
clientQueue:(dispatch_queue_t)clientQueue
44+
completion:(MTRDeviceResponseHandler)completion MTR_NEWLY_AVAILABLE;
45+
46+
@end
47+
48+
@interface MTRAttributeCacheContainer (Deprecated)
49+
4050
- (void)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId
4151
clusterId:(NSNumber * _Nullable)clusterId
4252
attributeId:(NSNumber * _Nullable)attributeId
4353
clientQueue:(dispatch_queue_t)clientQueue
44-
completion:(MTRDeviceResponseHandler)completion;
54+
completion:(MTRDeviceResponseHandler)completion
55+
MTR_NEWLY_DEPRECATED("Please use readAttributeWithEndpointID:clusterID:attributeID:clientQueue:completion:");
4556

4657
@end
4758

src/darwin/Framework/CHIP/MTRAttributeCacheContainer.mm

+45-28
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ - (instancetype)init
4343
}
4444

4545
- (void)setXPCConnection:(MTRDeviceControllerXPCConnection *)xpcConnection
46-
controllerId:(id<NSCopying>)controllerId
47-
deviceId:(NSNumber *)deviceId
46+
controllerID:(id<NSCopying>)controllerID
47+
deviceID:(NSNumber *)deviceID
4848
{
4949
self.xpcConnection = xpcConnection;
50-
self.xpcControllerId = controllerId;
51-
self.deviceId = deviceId;
50+
self.xpcControllerID = controllerID;
51+
self.deviceID = deviceID;
5252
self.shouldUseXPC = YES;
5353
}
5454

@@ -78,9 +78,9 @@ static CHIP_ERROR AppendAttibuteValueToArray(
7878
return err;
7979
}
8080

81-
- (void)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId
82-
clusterId:(NSNumber * _Nullable)clusterId
83-
attributeId:(NSNumber * _Nullable)attributeId
81+
- (void)readAttributeWithEndpointID:(NSNumber * _Nullable)endpointID
82+
clusterID:(NSNumber * _Nullable)clusterID
83+
attributeID:(NSNumber * _Nullable)attributeID
8484
clientQueue:(dispatch_queue_t)clientQueue
8585
completion:(MTRDeviceResponseHandler)completion
8686
{
@@ -97,16 +97,16 @@ - (void)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId
9797
completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]);
9898
return;
9999
}
100-
__auto_type controllerId = self.xpcControllerId;
101-
NSNumber * nodeId = self.deviceId;
100+
__auto_type controllerId = self.xpcControllerID;
101+
NSNumber * nodeId = self.deviceID;
102102
[xpcConnection
103103
getProxyHandleWithCompletion:^(dispatch_queue_t _Nonnull queue, MTRDeviceControllerXPCProxyHandle * _Nullable handle) {
104104
if (handle) {
105105
[handle.proxy readAttributeCacheWithController:controllerId
106106
nodeId:nodeId.unsignedLongLongValue
107-
endpointId:endpointId
108-
clusterId:clusterId
109-
attributeId:attributeId
107+
endpointId:endpointID
108+
clusterId:clusterID
109+
attributeId:attributeID
110110
completion:^(id _Nullable values, NSError * _Nullable error) {
111111
completion([MTRDeviceController decodeXPCResponseValues:values], error);
112112
__auto_type handleRetainer = handle;
@@ -121,7 +121,7 @@ - (void)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId
121121
}
122122

123123
dispatch_async(DeviceLayer::PlatformMgrImpl().GetWorkQueue(), ^{
124-
if (endpointId == nil && clusterId == nil) {
124+
if (endpointID == nil && clusterID == nil) {
125125
MTR_LOG_ERROR("Error: currently read from attribute cache does not support wildcards for both endpoint and cluster");
126126
completionHandler(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeInvalidArgument userInfo:nil]);
127127
return;
@@ -135,39 +135,39 @@ - (void)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId
135135

136136
NSMutableArray * result = [[NSMutableArray alloc] init];
137137
CHIP_ERROR err = CHIP_NO_ERROR;
138-
if (endpointId == nil) {
138+
if (endpointID == nil) {
139139
err = self.cppAttributeCache->ForEachAttribute(
140-
static_cast<chip::ClusterId>([clusterId unsignedLongValue]), [&](const app::ConcreteAttributePath & path) {
141-
if (attributeId == nil
142-
|| static_cast<chip::AttributeId>([attributeId unsignedLongValue]) == path.mAttributeId) {
140+
static_cast<chip::ClusterId>([clusterID unsignedLongValue]), [&](const app::ConcreteAttributePath & path) {
141+
if (attributeID == nil
142+
|| static_cast<chip::AttributeId>([attributeID unsignedLongValue]) == path.mAttributeId) {
143143
(void) AppendAttibuteValueToArray(path, self.cppAttributeCache, result);
144144
}
145145
return CHIP_NO_ERROR;
146146
});
147-
} else if (clusterId == nil) {
147+
} else if (clusterID == nil) {
148148
err = self.cppAttributeCache->ForEachCluster(
149-
static_cast<chip::EndpointId>([endpointId unsignedShortValue]), [&](chip::ClusterId enumeratedClusterId) {
150-
(void) self.cppAttributeCache->ForEachAttribute(static_cast<chip::EndpointId>([endpointId unsignedShortValue]),
149+
static_cast<chip::EndpointId>([endpointID unsignedShortValue]), [&](chip::ClusterId enumeratedClusterId) {
150+
(void) self.cppAttributeCache->ForEachAttribute(static_cast<chip::EndpointId>([endpointID unsignedShortValue]),
151151
enumeratedClusterId, [&](const app::ConcreteAttributePath & path) {
152-
if (attributeId == nil
153-
|| static_cast<chip::AttributeId>([attributeId unsignedLongValue]) == path.mAttributeId) {
152+
if (attributeID == nil
153+
|| static_cast<chip::AttributeId>([attributeID unsignedLongValue]) == path.mAttributeId) {
154154
(void) AppendAttibuteValueToArray(path, self.cppAttributeCache, result);
155155
}
156156
return CHIP_NO_ERROR;
157157
});
158158
return CHIP_NO_ERROR;
159159
});
160-
} else if (attributeId == nil) {
161-
err = self.cppAttributeCache->ForEachAttribute(static_cast<chip::EndpointId>([endpointId unsignedShortValue]),
162-
static_cast<chip::ClusterId>([clusterId unsignedLongValue]), [&](const app::ConcreteAttributePath & path) {
160+
} else if (attributeID == nil) {
161+
err = self.cppAttributeCache->ForEachAttribute(static_cast<chip::EndpointId>([endpointID unsignedShortValue]),
162+
static_cast<chip::ClusterId>([clusterID unsignedLongValue]), [&](const app::ConcreteAttributePath & path) {
163163
(void) AppendAttibuteValueToArray(path, self.cppAttributeCache, result);
164164
return CHIP_NO_ERROR;
165165
});
166166
} else {
167167
app::ConcreteAttributePath path;
168-
path.mEndpointId = static_cast<chip::EndpointId>([endpointId unsignedShortValue]);
169-
path.mClusterId = static_cast<chip::ClusterId>([clusterId unsignedLongValue]);
170-
path.mAttributeId = static_cast<chip::AttributeId>([attributeId unsignedLongValue]);
168+
path.mEndpointId = static_cast<chip::EndpointId>([endpointID unsignedShortValue]);
169+
path.mClusterId = static_cast<chip::ClusterId>([clusterID unsignedLongValue]);
170+
path.mAttributeId = static_cast<chip::AttributeId>([attributeID unsignedLongValue]);
171171
err = AppendAttibuteValueToArray(path, self.cppAttributeCache, result);
172172
}
173173
if (err == CHIP_NO_ERROR) {
@@ -179,3 +179,20 @@ - (void)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId
179179
}
180180

181181
@end
182+
183+
@implementation MTRAttributeCacheContainer (Deprecated)
184+
185+
- (void)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId
186+
clusterId:(NSNumber * _Nullable)clusterId
187+
attributeId:(NSNumber * _Nullable)attributeId
188+
clientQueue:(dispatch_queue_t)clientQueue
189+
completion:(MTRDeviceResponseHandler)completion
190+
{
191+
[self readAttributeWithEndpointID:endpointId
192+
clusterID:clusterId
193+
attributeID:attributeId
194+
clientQueue:clientQueue
195+
completion:completion];
196+
}
197+
198+
@end

src/darwin/Framework/CHIP/MTRAttributeCacheContainer_Internal.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ NS_ASSUME_NONNULL_BEGIN
2727
@interface MTRAttributeCacheContainer ()
2828

2929
@property (atomic, readwrite, nullable) chip::app::ClusterStateCache * cppAttributeCache;
30-
@property (nonatomic, readwrite, copy) NSNumber * deviceId;
30+
@property (nonatomic, readwrite, copy) NSNumber * deviceID;
3131
@property (nonatomic, readwrite, weak, nullable) MTRDeviceControllerXPCConnection * xpcConnection;
32-
@property (nonatomic, readwrite, strong, nullable) id<NSCopying> xpcControllerId;
32+
@property (nonatomic, readwrite, strong, nullable) id<NSCopying> xpcControllerID;
3333
@property (atomic, readwrite) BOOL shouldUseXPC;
3434

3535
@end

0 commit comments

Comments
 (0)