Skip to content

Commit

Permalink
Add support for turning off fabric-filtering to YAML. (#15162)
Browse files Browse the repository at this point in the history
Allows listing "fabricFiltered: false" on a read or subscribe to get a
non-fabric-filtered read/subscribe.

Defaults to fabric-filtered if not otherwise specified.

Supported in chip-tool YAML, not yet in Darwin YAML pending the Darwin
framework growing APIs to support non-fabric-filtered reads.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Nov 1, 2023
1 parent d9670a5 commit 2137058
Show file tree
Hide file tree
Showing 4 changed files with 1,078 additions and 1,068 deletions.
4 changes: 2 additions & 2 deletions examples/chip-tool/templates/partials/test_cluster.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ class {{filename}}: public TestCommand
{{else if isSubscribeEvent}}
ReturnErrorOnFailure(cluster.SubscribeEvent<{{zapTypeToDecodableClusterObjectType event ns=cluster isArgument=true}}>(this, {{>staticSuccessResponse}}, {{>staticFailureResponse}}, minIntervalArgument, maxIntervalArgument, {{>staticSubscriptionEstablished}}));
{{else if isReadAttribute}}
ReturnErrorOnFailure(cluster.ReadAttribute<chip::app::Clusters::{{asUpperCamelCase cluster}}::Attributes::{{asUpperCamelCase attribute}}::TypeInfo>({{#chip_tests_item_parameters}}{{asLowerCamelCase name}}Argument, {{/chip_tests_item_parameters}}this, {{>staticSuccessResponse}}, {{>staticFailureResponse}}));
ReturnErrorOnFailure(cluster.ReadAttribute<chip::app::Clusters::{{asUpperCamelCase cluster}}::Attributes::{{asUpperCamelCase attribute}}::TypeInfo>({{#chip_tests_item_parameters}}{{asLowerCamelCase name}}Argument, {{/chip_tests_item_parameters}}this, {{>staticSuccessResponse}}, {{>staticFailureResponse}}, {{fabricFiltered}}));
{{else if isSubscribeAttribute}}
ReturnErrorOnFailure(cluster.SubscribeAttribute<chip::app::Clusters::{{asUpperCamelCase cluster}}::Attributes::{{asUpperCamelCase attribute}}::TypeInfo>(this, {{>staticSuccessResponse}}, {{>staticFailureResponse}}, minIntervalArgument, maxIntervalArgument, {{>staticSubscriptionEstablished}}));
ReturnErrorOnFailure(cluster.SubscribeAttribute<chip::app::Clusters::{{asUpperCamelCase cluster}}::Attributes::{{asUpperCamelCase attribute}}::TypeInfo>(this, {{>staticSuccessResponse}}, {{>staticFailureResponse}}, minIntervalArgument, maxIntervalArgument, {{>staticSubscriptionEstablished}}, {{fabricFiltered}}));
{{else if isWaitForReport}}
{{> subscribeDataCallback}} = {{> staticSuccessResponse}};
{{else}}
Expand Down
7 changes: 7 additions & 0 deletions src/app/zap-templates/common/ClusterTestGeneration.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const kResponseErrorName = 'error';
const kResponseWrongErrorName = 'errorWrongValue';
const kPICSName = 'PICS';
const kSaveAsName = 'saveAs';
const kFabricFiltered = 'fabricFiltered';

class NullObject {
toString()
Expand Down Expand Up @@ -139,6 +140,9 @@ function setDefaultTypeForCommand(test)
test.commandName = 'Read';
test.isAttribute = true;
test.isReadAttribute = true;
if (!(kFabricFiltered in test)) {
test[kFabricFiltered] = true;
}
break;

case 'writeAttribute':
Expand All @@ -156,6 +160,9 @@ function setDefaultTypeForCommand(test)
test.isAttribute = true;
test.isSubscribe = true;
test.isSubscribeAttribute = true;
if (!(kFabricFiltered in test)) {
test[kFabricFiltered] = true;
}
break;

case 'waitForReport':
Expand Down
20 changes: 11 additions & 9 deletions src/controller/CHIPCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,18 @@ class DLL_EXPORT ClusterBase
*/
template <typename AttributeInfo>
CHIP_ERROR ReadAttribute(void * context, ReadResponseSuccessCallback<typename AttributeInfo::DecodableArgType> successCb,
ReadResponseFailureCallback failureCb, const Optional<DataVersion> & aDataVersion = NullOptional)
ReadResponseFailureCallback failureCb, bool aIsFabricFiltered = true,
const Optional<DataVersion> & aDataVersion = NullOptional)
{
return ReadAttribute<typename AttributeInfo::DecodableType, typename AttributeInfo::DecodableArgType>(
context, AttributeInfo::GetClusterId(), AttributeInfo::GetAttributeId(), successCb, failureCb, aDataVersion);
context, AttributeInfo::GetClusterId(), AttributeInfo::GetAttributeId(), successCb, failureCb, aIsFabricFiltered,
aDataVersion);
}

template <typename DecodableType, typename DecodableArgType>
CHIP_ERROR ReadAttribute(void * context, ClusterId clusterId, AttributeId attributeId,
ReadResponseSuccessCallback<DecodableArgType> successCb, ReadResponseFailureCallback failureCb,
const Optional<DataVersion> & aDataVersion = NullOptional)
bool aIsFabricFiltered = true, const Optional<DataVersion> & aDataVersion = NullOptional)
{
VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);

Expand All @@ -220,8 +222,8 @@ class DLL_EXPORT ClusterBase
};

return Controller::ReadAttribute<DecodableType>(mDevice->GetExchangeManager(), mDevice->GetSecureSession().Value(),
mEndpoint, clusterId, attributeId, onSuccessCb, onFailureCb, true,
aDataVersion);
mEndpoint, clusterId, attributeId, onSuccessCb, onFailureCb,
aIsFabricFiltered, aDataVersion);
}

/**
Expand All @@ -233,19 +235,19 @@ class DLL_EXPORT ClusterBase
ReadResponseFailureCallback failureCb, uint16_t minIntervalFloorSeconds,
uint16_t maxIntervalCeilingSeconds,
SubscriptionEstablishedCallback subscriptionEstablishedCb = nullptr,
const Optional<DataVersion> & aDataVersion = NullOptional)
bool aIsFabricFiltered = true, const Optional<DataVersion> & aDataVersion = NullOptional)
{
return SubscribeAttribute<typename AttributeInfo::DecodableType, typename AttributeInfo::DecodableArgType>(
context, AttributeInfo::GetClusterId(), AttributeInfo::GetAttributeId(), reportCb, failureCb, minIntervalFloorSeconds,
maxIntervalCeilingSeconds, subscriptionEstablishedCb, aDataVersion);
maxIntervalCeilingSeconds, subscriptionEstablishedCb, aIsFabricFiltered, aDataVersion);
}

template <typename DecodableType, typename DecodableArgType>
CHIP_ERROR SubscribeAttribute(void * context, ClusterId clusterId, AttributeId attributeId,
ReadResponseSuccessCallback<DecodableArgType> reportCb, ReadResponseFailureCallback failureCb,
uint16_t minIntervalFloorSeconds, uint16_t maxIntervalCeilingSeconds,
SubscriptionEstablishedCallback subscriptionEstablishedCb = nullptr,
const Optional<DataVersion> & aDataVersion = NullOptional)
bool aIsFabricFiltered = true, const Optional<DataVersion> & aDataVersion = NullOptional)
{
VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);

Expand Down Expand Up @@ -273,7 +275,7 @@ class DLL_EXPORT ClusterBase
return Controller::SubscribeAttribute<DecodableType>(mDevice->GetExchangeManager(), mDevice->GetSecureSession().Value(),
mEndpoint, clusterId, attributeId, onReportCb, onFailureCb,
minIntervalFloorSeconds, maxIntervalCeilingSeconds,
onSubscriptionEstablishedCb, true, false, aDataVersion);
onSubscriptionEstablishedCb, aIsFabricFiltered, false, aDataVersion);
}

/**
Expand Down
Loading

0 comments on commit 2137058

Please sign in to comment.