Skip to content

Commit

Permalink
ZAP-generated Matter TV Casting Cluster Commands part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
pgregorr-amazon committed Mar 18, 2024
1 parent 766248d commit 64a11d2
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 207 deletions.
25 changes: 17 additions & 8 deletions examples/tv-casting-app/APIs.md
Original file line number Diff line number Diff line change
Expand Up @@ -822,18 +822,27 @@ Once the Casting Client has selected an `Endpoint`, it is ready to
[issue commands](#issuing-commands) to it, [read](#read-operations) current
playback state, and [subscribe](#subscriptions) to playback events.
Refer to the following platform specific files for a list of clusters, command
and attributes supported by the Matter TV Casting library:
On Linux refer to the following platform specific files:
1. Linux:
1. For list of clusters, command and attributes supported by the Matter TV
Casting library:
[tv-casting-common/clusters/Clusters.h](tv-casting-common/clusters/Clusters.h)
Refer to the following platform specific files for the IDs and request /
response types to use with these APIs:
1. Linux:
2. For the IDs and request / response types to use with these APIs:
[/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h](/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h)
On iOS refer to the following platform specific files:
1. For list of clusters, command and attributes supported by the Matter TV
Casting library:
[/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCClusterObjects.h](/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCClusterObjects.h)
2. For the IDs and request / response types to use with these APIs:
[/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandObjects.h](/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandObjects.h)
and
[/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandPayloads.h](/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandPayloads.h)
3. For attribute [read operations](#read-operations) and
[subscriptions](#subscriptions):
[/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCAttributeObjects.h](/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCAttributeObjects.h)
### Issuing Commands
_{Complete Command invocation examples: [Linux](linux/simple-app-helper.cpp) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@
{{>command_response_type command=.}} * objCResponse = nil;
CHIP_ERROR err = CHIP_NO_ERROR;
if (cppResponse.type() == typeid(std::shared_ptr<const chip::app::Clusters::{{asUpperCamelCase ../name}}::Commands::{{asUpperCamelCase name}}::Type::ResponseType>)) {
std::shared_ptr<const chip::app::Clusters::{{asUpperCamelCase ../name}}::Commands::{{asUpperCamelCase name}}::Type::ResponseType> responseSharedPtr = std::any_cast<std::shared_ptr<const chip::app::Clusters::{{asUpperCamelCase ../name}}::Commands::{{asUpperCamelCase name}}::Type::ResponseType>>(cppResponse);
objCResponse = [[{{>command_response_type command=.}} alloc] init];
// Set the ObjC response fields using the given cpp Response
err = [objCResponse setObjCResponseFromCppResponse:*responseSharedPtr];
err = [objCResponse setObjCResponseFromCppResponse:cppResponse];
VerifyOrReturnValue(err == CHIP_NO_ERROR, nil, ChipLogError(AppServer, "MC{{asUpperCamelCase ../name}}Cluster{{asUpperCamelCase name}}Command getObjCResponseFromCpp() failed"));
}
return objCResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,11 @@ NS_ASSUME_NONNULL_BEGIN
{{/if}}
{{#if (isStrEqual source "server")}}

- (CHIP_ERROR)setObjCResponseFromCppResponse:(const chip::app::Clusters::{{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase name}}::DecodableType &)cppDecodableStruct
- (CHIP_ERROR)setObjCResponseFromCppResponse:(std::any)cppResponse
{
std::shared_ptr<const chip::app::Clusters::{{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase name}}::DecodableType> responseSharedPtr = std::any_cast<std::shared_ptr<const chip::app::Clusters::{{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase name}}::DecodableType>>(cppResponse);
const chip::app::Clusters::{{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase name}}::DecodableType cppDecodableStruct = *responseSharedPtr;

{{#zcl_command_arguments}}
{
{{>decode_value target=(concat "self." (asStructPropertyName label)) source=(concat "cppDecodableStruct." (asLowerCamelCase label)) cluster=parent.parent.name errorCode="return err;" depth=0}}
Expand Down
Loading

0 comments on commit 64a11d2

Please sign in to comment.