Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[example] Fix CommandList for GeneralCommissioning cluster on all-clusters-app #17833

Merged
merged 6 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/tests/suites/TestCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3778,7 +3778,7 @@ tests:
command: "readAttribute"
attribute: "GeneratedCommandList"
response:
value: [0, 1, 4, 5, 6, 9, 10, 11]
value: [0, 1, 4, 5, 6, 8, 9, 10, 11]

# Struct-typed attribute
- label: "Write struct-typed attribute"
Expand Down
30 changes: 22 additions & 8 deletions src/app/zap-templates/templates/app/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,30 +141,35 @@ function chip_endpoint_generated_functions()

function chip_endpoint_generated_commands_list(options)
{
let ret = [];
let ret = [];
let index = 0;
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
this.clusterList.forEach((c) => {
let acceptedCommands = [];
let generatedCommands = [];

c.commands.forEach((cmd) => {
if (cmd.mask.includes('incoming_server')) {
acceptedCommands.push(`${cmd.commandId} /* ${cmd.name} */`);
}
if (cmd.mask.includes('incoming_client')) {
generatedCommands.push(`${cmd.commandId} /* ${cmd.name} */`);
if (cmd.responseId !== null) {
generatedCommands.push(`${cmd.responseId} /* ${cmd.responseName} */`);
}
}
});

generatedCommands = [...new Set(generatedCommands) ].sort();

if (acceptedCommands.length > 0 || generatedCommands.length > 0) {
ret.push({ text : ` /* ${c.comment} */\\` });
}
if (acceptedCommands.length > 0) {
acceptedCommands.push('chip::kInvalidCommandId /* end of list */')
ret.push({ text : ` /* client_generated */ \\\n ${acceptedCommands.join(', \\\n ')}, \\` });
ret.push({ text : ` /* AcceptedCommandList (index=${index}) */ \\\n ${acceptedCommands.join(', \\\n ')}, \\` });
index += acceptedCommands.length;
}
if (generatedCommands.length > 0) {
generatedCommands.push('chip::kInvalidCommandId /* end of list */')
ret.push({ text : ` /* server_generated */ \\\n ${generatedCommands.join(', \\\n ')}, \\` });
ret.push({ text : ` /* GeneratedCommandList (index=${index})*/ \\\n ${generatedCommands.join(', \\\n ')}, \\` });
index += generatedCommands.length;
}
})
return templateUtil.collectBlocks(ret, options, this);
Expand Down Expand Up @@ -217,8 +222,17 @@ function chip_endpoint_cluster_list()
mask = c.mask.map((m) => `ZAP_CLUSTER_MASK(${m.toUpperCase()})`).join(' | ')
}

let acceptedCommands = c.commands.reduce(((acc, cmd) => (acc + (cmd.mask.includes('incoming_server') ? 1 : 0))), 0);
let generatedCommands = c.commands.reduce(((acc, cmd) => (acc + (cmd.mask.includes('incoming_client') ? 1 : 0))), 0);
let acceptedCommands = 0;
let generatedCommandList = [];
c.commands.forEach((cmd) => {
if (cmd.mask.includes('incoming_server')) {
acceptedCommands++;
if (cmd.responseId !== null) {
generatedCommandList.push(cmd.responseId);
}
}
});
let generatedCommands = new Set(generatedCommandList).size;

let acceptedCommandsListVal = "nullptr";
let generatedCommandsListVal = "nullptr";
Expand Down
Loading