Skip to content

Commit

Permalink
[controller] Update codegen for Chip Device Controller after project-…
Browse files Browse the repository at this point in the history
  • Loading branch information
erjiaqing committed Apr 19, 2021
1 parent 88780da commit 2ef65d4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
"gcc_release") GN_ARGS='is_debug=false';;
"clang") GN_ARGS='is_clang=true';;
"mbedtls") GN_ARGS='chip_crypto="mbedtls"';;
"clang_experimental") GN_ARGS='is_clang=true chip_enable_interaction_model=true';;
*) ;;
esac
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC
ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx16 " Command=%" PRIx8 " Endpoint=%" PRIx8, aClusterId,
aCommandId, aEndPointId);
Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId);
TLV::TLVType dataTlvType;
SuccessOrExit(aReader.EnterContainer(dataTlvType));
switch (aClusterId)
{
{{#all_user_clusters}}
Expand All @@ -88,7 +90,9 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC
ChipLogError(Zcl, "Unknown cluster %" PRIx16, aClusterId);
break;
}
exit:
Compatibility::ResetEmberAfObjects();
aReader.ExitContainer(dataTlvType);
}

} // namespace app
Expand Down
14 changes: 5 additions & 9 deletions src/app/zap-templates/templates/chip/CHIPClusters-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,26 @@ CHIP_ERROR {{asCamelCased clusterName false}}Cluster::{{asCamelCased name false}
#if CHIP_ENABLE_INTERACTION_MODEL
VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
(void) onSuccessCallback;
(void) onFailureCallback;
(void) onFailureCallback;

app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, k{{asCamelCased name false}}CommandId,
(chip::app::Command::CommandPathFlags::kEndpointIdValid) };
app::Command * ZCLcommand = mDevice->GetCommandSender();

TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter();

TLV::TLVType dummyType = TLV::kTLVType_NotSpecified;
ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType));
ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams));

{{#chip_server_cluster_command_arguments}}
{{#first}}
TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter();
uint8_t argSeqNumber = 0;
{{/first}}
// {{asCamelCased label}}: {{asCamelCased type}}
ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), {{asCamelCased label}}));
ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), {{asCamelCased label}}));
{{else}}
// Command takes no arguments.
{{/chip_server_cluster_command_arguments}}

ReturnErrorOnFailure(writer.EndContainer(dummyType));
ReturnErrorOnFailure(writer.Finalize());
ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams));
ReturnErrorOnFailure(ZCLcommand->FinishCommand());

return mDevice->SendCommands();
#else
Expand Down

0 comments on commit 2ef65d4

Please sign in to comment.