Skip to content

Commit

Permalink
Groups cluster: GroupInfo is now removed from the GroupTable whenever…
Browse files Browse the repository at this point in the history
… the last endpoint is removed from the group. (#19221)
  • Loading branch information
rcasallas-silabs authored and pull[bot] committed Jul 5, 2022
1 parent c5477e4 commit e3a3f65
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 18 deletions.
29 changes: 29 additions & 0 deletions src/app/tests/suites/TestGroupKeyManagementCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,35 @@ tests:
EpochStartTime2: 2110002,
}

- label: "Remove Group 1"
cluster: "Groups"
endpoint: 1
command: "RemoveGroup"
arguments:
values:
- name: "groupId"
value: 0x0101
response:
values:
- name: "status"
value: 0
- name: "groupId"
value: 0x0101

- label: "Read GroupTable 2"
command: "readAttribute"
attribute: "GroupTable"
response:
value:
[
{
FabricIndex: 1,
GroupId: 0x0102,
endpoints: [1],
GroupName: "Group #2",
},
]

- label: "Remove All"
cluster: "Groups"
endpoint: 1
Expand Down
8 changes: 6 additions & 2 deletions src/credentials/GroupDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1187,11 +1187,15 @@ CHIP_ERROR GroupDataProviderImpl::RemoveEndpoint(chip::FabricIndex fabric_index,
prev.next = endpoint.next;
ReturnErrorOnFailure(prev.Save(mStorage));
}
if (group.endpoint_count > 0)

if (group.endpoint_count > 1)
{
group.endpoint_count--;
return group.Save(mStorage);
}
return group.Save(mStorage);

// No more endpoints, remove the group
return RemoveGroupInfoAt(fabric_index, group.index);
}

CHIP_ERROR GroupDataProviderImpl::RemoveEndpoint(chip::FabricIndex fabric_index, chip::EndpointId endpoint_id)
Expand Down
56 changes: 50 additions & 6 deletions zzz_generated/chip-tool/zap-generated/test/Commands.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 88 additions & 10 deletions zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e3a3f65

Please sign in to comment.