Skip to content

Commit

Permalink
Replace "Id" with "ID" in Darwin APIs. (project-chip#22558)
Browse files Browse the repository at this point in the history
Fixes project-chip#22528

Addresses part of project-chip#22420
  • Loading branch information
bzbarsky-apple authored and isiu-apple committed Sep 16, 2022
1 parent 9f4478b commit b515ce6
Show file tree
Hide file tree
Showing 35 changed files with 924 additions and 922 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ class ClusterCommand : public ModelCommand {
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);

while (repeatCount--) {
[device invokeCommandWithEndpointId:[NSNumber numberWithUnsignedShort:endpointId]
clusterId:[NSNumber numberWithUnsignedInteger:clusterId]
commandId:[NSNumber numberWithUnsignedInteger:commandId]
[device invokeCommandWithEndpointID:[NSNumber numberWithUnsignedShort:endpointId]
clusterID:[NSNumber numberWithUnsignedInteger:clusterId]
commandID:[NSNumber numberWithUnsignedInteger:commandId]
commandFields:commandFields
timedInvokeTimeout:mTimedInteractionTimeoutMs.HasValue()
? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class ReadAttribute : public ModelCommand {
MTRReadParams * params = [[MTRReadParams alloc] init];
params.fabricFiltered = mFabricFiltered.HasValue() ? [NSNumber numberWithBool:mFabricFiltered.Value()] : nil;
[device
readAttributeWithEndpointId:[NSNumber numberWithUnsignedShort:endpointId]
clusterId:[NSNumber numberWithUnsignedInteger:mClusterId]
attributeId:[NSNumber numberWithUnsignedInteger:mAttributeId]
readAttributeWithEndpointID:[NSNumber numberWithUnsignedShort:endpointId]
clusterID:[NSNumber numberWithUnsignedInteger:mClusterId]
attributeID:[NSNumber numberWithUnsignedInteger:mAttributeId]
params:params
clientQueue:callbackQueue
completion:^(NSArray<NSDictionary<NSString *, id> *> * _Nullable values, NSError * _Nullable error) {
Expand Down Expand Up @@ -129,9 +129,9 @@ class SubscribeAttribute : public ModelCommand {
= mKeepSubscriptions.HasValue() ? [NSNumber numberWithBool:mKeepSubscriptions.Value()] : nil;
params.autoResubscribe = mAutoResubscribe.HasValue() ? [NSNumber numberWithBool:mAutoResubscribe.Value()] : nil;

[device subscribeAttributeWithEndpointId:[NSNumber numberWithUnsignedShort:endpointId]
clusterId:[NSNumber numberWithUnsignedInteger:mClusterId]
attributeId:[NSNumber numberWithUnsignedInteger:mAttributeId]
[device subscribeAttributeWithEndpointID:[NSNumber numberWithUnsignedShort:endpointId]
clusterID:[NSNumber numberWithUnsignedInteger:mClusterId]
attributeID:[NSNumber numberWithUnsignedInteger:mAttributeId]
minInterval:[NSNumber numberWithUnsignedInteger:mMinInterval]
maxInterval:[NSNumber numberWithUnsignedInteger:mMaxInterval]
params:params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ class WriteAttribute : public ModelCommand {
{
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
[device
writeAttributeWithEndpointId:[NSNumber numberWithUnsignedShort:endpointId]
clusterId:[NSNumber numberWithUnsignedInteger:clusterId]
attributeId:[NSNumber numberWithUnsignedInteger:attributeId]
writeAttributeWithEndpointID:[NSNumber numberWithUnsignedShort:endpointId]
clusterID:[NSNumber numberWithUnsignedInteger:clusterId]
attributeID:[NSNumber numberWithUnsignedInteger:attributeId]
value:value
timedWriteTimeout:mTimedInteractionTimeoutMs.HasValue()
? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@
constexpr const char * identities[] = { kIdentityAlpha, kIdentityBeta, kIdentityGamma };
for (size_t i = 0; i < ArraySize(identities); ++i) {
auto controllerParams = [[MTRDeviceControllerStartupParams alloc] initWithSigningKeypair:gNocSigner
fabricId:@(i + 1)
fabricID:@(i + 1)
ipk:ipk];

// We're not sure whether we're creating a new fabric or using an
// existing one, so just try both.
auto controller = [factory startControllerOnExistingFabric:controllerParams];
if (controller == nil) {
// Maybe we didn't have this fabric yet.
controllerParams.vendorId = @(chip::VendorId::TestVendor1);
controllerParams.vendorID = @(chip::VendorId::TestVendor1);
controller = [factory startControllerOnNewFabric:controllerParams];
}
if (controller == nil) {
Expand Down Expand Up @@ -201,7 +201,7 @@
constexpr const char * identities[] = { kIdentityAlpha, kIdentityBeta, kIdentityGamma };
for (size_t i = 0; i < ArraySize(identities); ++i) {
auto controllerParams = [[MTRDeviceControllerStartupParams alloc] initWithSigningKeypair:gNocSigner
fabricId:@(i + 1)
fabricID:@(i + 1)
ipk:ipk];

auto controller = [factory startControllerOnExistingFabric:controllerParams];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ void MTRSetNextAvailableDeviceID(uint64_t id)
return;
}

__auto_type * params = [[MTRDeviceControllerStartupParams alloc] initWithSigningKeypair:keys fabricId:@(1) ipk:keys.ipk];
params.vendorId = @(kTestVendorId);
__auto_type * params = [[MTRDeviceControllerStartupParams alloc] initWithSigningKeypair:keys fabricID:@(1) ipk:keys.ipk];
params.vendorID = @(kTestVendorId);

// We're not sure whether we have a fabric configured already; try as if
// we did, and if not fall back to creating a new one.
Expand All @@ -113,7 +113,7 @@ void MTRSetNextAvailableDeviceID(uint64_t id)
[controller shutdown];

NSLog(@"Starting up the stack");
__auto_type * params = [[MTRDeviceControllerStartupParams alloc] initWithSigningKeypair:keys fabricId:@(1) ipk:keys.ipk];
__auto_type * params = [[MTRDeviceControllerStartupParams alloc] initWithSigningKeypair:keys fabricID:@(1) ipk:keys.ipk];

sController = [[MTRControllerFactory sharedInstance] startControllerOnExistingFabric:params];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ - (void)setupUI
- (void)_clearTextFields
{
MTRDeviceController * chipController = InitializeMTR();
_nodeIDTextField.text = [NSString stringWithFormat:@"%@", chipController.controllerNodeId];
_nodeIDTextField.text = [NSString stringWithFormat:@"%@", chipController.controllerNodeID];
_endpointIDTextField.text = @"1";
_groupIDTextField.text = @"0";
_clusterIDTextField.text = @"";
Expand Down
4 changes: 2 additions & 2 deletions src/darwin/Framework/CHIP/MTRAttributeCacheContainer+XPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ NS_ASSUME_NONNULL_BEGIN

@interface MTRAttributeCacheContainer (XPC)
- (void)setXPCConnection:(MTRDeviceControllerXPCConnection *)xpcConnection
controllerId:(id<NSCopying>)controllerId
deviceId:(NSNumber *)deviceId;
controllerID:(id<NSCopying>)controllerID
deviceID:(NSNumber *)deviceID;
@end

NS_ASSUME_NONNULL_END
14 changes: 7 additions & 7 deletions src/darwin/Framework/CHIP/MTRAttributeCacheContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Reads an attribute with specific attribute path
*
* @param endpointId endpoint ID of the attribute
* @param clusterId cluster ID of the attribute
* @param attributeId attribute ID of the attribute
* @param endpointID endpoint ID of the attribute
* @param clusterID cluster ID of the attribute
* @param attributeID attribute ID of the attribute
* @param clientQueue client queue to dispatch the completion handler through
* @param completion block to receive the result.
* "values" received by the block will have the same format of object as the one received by completion block
* of CHIPDevice readAttributeWithEndpointId:clusterId:attributeId:clientQueue:completion method.
* of CHIPDevice readAttributeWithEndpointID:clusterID:attributeID:clientQueue:completion method.
*/
- (void)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId
clusterId:(NSNumber * _Nullable)clusterId
attributeId:(NSNumber * _Nullable)attributeId
- (void)readAttributeWithEndpointID:(NSNumber * _Nullable)endpointID
clusterID:(NSNumber * _Nullable)clusterID
attributeID:(NSNumber * _Nullable)attributeID
clientQueue:(dispatch_queue_t)clientQueue
completion:(MTRDeviceResponseHandler)completion;

Expand Down
58 changes: 29 additions & 29 deletions src/darwin/Framework/CHIP/MTRAttributeCacheContainer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ - (instancetype)init
}

- (void)setXPCConnection:(MTRDeviceControllerXPCConnection *)xpcConnection
controllerId:(id<NSCopying>)controllerId
deviceId:(NSNumber *)deviceId
controllerID:(id<NSCopying>)controllerID
deviceID:(NSNumber *)deviceID
{
self.xpcConnection = xpcConnection;
self.xpcControllerId = controllerId;
self.deviceId = deviceId;
self.xpcControllerID = controllerID;
self.deviceID = deviceID;
self.shouldUseXPC = YES;
}

Expand Down Expand Up @@ -78,9 +78,9 @@ static CHIP_ERROR AppendAttibuteValueToArray(
return err;
}

- (void)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId
clusterId:(NSNumber * _Nullable)clusterId
attributeId:(NSNumber * _Nullable)attributeId
- (void)readAttributeWithEndpointID:(NSNumber * _Nullable)endpointID
clusterID:(NSNumber * _Nullable)clusterID
attributeID:(NSNumber * _Nullable)attributeID
clientQueue:(dispatch_queue_t)clientQueue
completion:(MTRDeviceResponseHandler)completion
{
Expand All @@ -97,16 +97,16 @@ - (void)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId
completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]);
return;
}
__auto_type controllerId = self.xpcControllerId;
NSNumber * nodeId = self.deviceId;
__auto_type controllerId = self.xpcControllerID;
NSNumber * nodeId = self.deviceID;
[xpcConnection
getProxyHandleWithCompletion:^(dispatch_queue_t _Nonnull queue, MTRDeviceControllerXPCProxyHandle * _Nullable handle) {
if (handle) {
[handle.proxy readAttributeCacheWithController:controllerId
nodeId:nodeId
endpointId:endpointId
clusterId:clusterId
attributeId:attributeId
nodeID:nodeId
endpointID:endpointID
clusterID:clusterID
attributeID:attributeID
completion:^(id _Nullable values, NSError * _Nullable error) {
completion([MTRDeviceController decodeXPCResponseValues:values], error);
__auto_type handleRetainer = handle;
Expand All @@ -121,7 +121,7 @@ - (void)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId
}

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

NSMutableArray * result = [[NSMutableArray alloc] init];
CHIP_ERROR err = CHIP_NO_ERROR;
if (endpointId == nil) {
if (endpointID == nil) {
err = self.cppAttributeCache->ForEachAttribute(
static_cast<chip::ClusterId>([clusterId unsignedLongValue]), [&](const app::ConcreteAttributePath & path) {
if (attributeId == nil
|| static_cast<chip::AttributeId>([attributeId unsignedLongValue]) == path.mAttributeId) {
static_cast<chip::ClusterId>([clusterID unsignedLongValue]), [&](const app::ConcreteAttributePath & path) {
if (attributeID == nil
|| static_cast<chip::AttributeId>([attributeID unsignedLongValue]) == path.mAttributeId) {
(void) AppendAttibuteValueToArray(path, self.cppAttributeCache, result);
}
return CHIP_NO_ERROR;
});
} else if (clusterId == nil) {
} else if (clusterID == nil) {
err = self.cppAttributeCache->ForEachCluster(
static_cast<chip::EndpointId>([endpointId unsignedShortValue]), [&](chip::ClusterId enumeratedClusterId) {
(void) self.cppAttributeCache->ForEachAttribute(static_cast<chip::EndpointId>([endpointId unsignedShortValue]),
static_cast<chip::EndpointId>([endpointID unsignedShortValue]), [&](chip::ClusterId enumeratedClusterId) {
(void) self.cppAttributeCache->ForEachAttribute(static_cast<chip::EndpointId>([endpointID unsignedShortValue]),
enumeratedClusterId, [&](const app::ConcreteAttributePath & path) {
if (attributeId == nil
|| static_cast<chip::AttributeId>([attributeId unsignedLongValue]) == path.mAttributeId) {
if (attributeID == nil
|| static_cast<chip::AttributeId>([attributeID unsignedLongValue]) == path.mAttributeId) {
(void) AppendAttibuteValueToArray(path, self.cppAttributeCache, result);
}
return CHIP_NO_ERROR;
});
return CHIP_NO_ERROR;
});
} else if (attributeId == nil) {
err = self.cppAttributeCache->ForEachAttribute(static_cast<chip::EndpointId>([endpointId unsignedShortValue]),
static_cast<chip::ClusterId>([clusterId unsignedLongValue]), [&](const app::ConcreteAttributePath & path) {
} else if (attributeID == nil) {
err = self.cppAttributeCache->ForEachAttribute(static_cast<chip::EndpointId>([endpointID unsignedShortValue]),
static_cast<chip::ClusterId>([clusterID unsignedLongValue]), [&](const app::ConcreteAttributePath & path) {
(void) AppendAttibuteValueToArray(path, self.cppAttributeCache, result);
return CHIP_NO_ERROR;
});
} else {
app::ConcreteAttributePath path;
path.mEndpointId = static_cast<chip::EndpointId>([endpointId unsignedShortValue]);
path.mClusterId = static_cast<chip::ClusterId>([clusterId unsignedLongValue]);
path.mAttributeId = static_cast<chip::AttributeId>([attributeId unsignedLongValue]);
path.mEndpointId = static_cast<chip::EndpointId>([endpointID unsignedShortValue]);
path.mClusterId = static_cast<chip::ClusterId>([clusterID unsignedLongValue]);
path.mAttributeId = static_cast<chip::AttributeId>([attributeID unsignedLongValue]);
err = AppendAttibuteValueToArray(path, self.cppAttributeCache, result);
}
if (err == CHIP_NO_ERROR) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ NS_ASSUME_NONNULL_BEGIN
@interface MTRAttributeCacheContainer ()

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

@end
Expand Down
Loading

0 comments on commit b515ce6

Please sign in to comment.