Skip to content

Commit

Permalink
Make Group Id follow the SPEC (#25995)
Browse files Browse the repository at this point in the history
  • Loading branch information
wqx6 authored and pull[bot] committed Sep 15, 2023
1 parent ba5d8ab commit 2180053
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/app/clusters/groups-server/groups-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static bool KeyExists(FabricIndex fabricIndex, GroupId groupId)

static Status GroupAdd(FabricIndex fabricIndex, EndpointId endpointId, GroupId groupId, const CharSpan & groupName)
{
VerifyOrReturnError(IsFabricGroupId(groupId), Status::ConstraintError);
VerifyOrReturnError(IsValidGroupId(groupId), Status::ConstraintError);

GroupDataProvider * provider = GetGroupDataProvider();
VerifyOrReturnError(nullptr != provider, Status::NotFound);
Expand All @@ -99,7 +99,7 @@ static Status GroupAdd(FabricIndex fabricIndex, EndpointId endpointId, GroupId g

static EmberAfStatus GroupRemove(FabricIndex fabricIndex, EndpointId endpointId, GroupId groupId)
{
VerifyOrReturnError(IsFabricGroupId(groupId), EMBER_ZCL_STATUS_CONSTRAINT_ERROR);
VerifyOrReturnError(IsValidGroupId(groupId), EMBER_ZCL_STATUS_CONSTRAINT_ERROR);
VerifyOrReturnError(GroupExists(fabricIndex, endpointId, groupId), EMBER_ZCL_STATUS_NOT_FOUND);

GroupDataProvider * provider = GetGroupDataProvider();
Expand Down Expand Up @@ -159,7 +159,7 @@ bool emberAfGroupsClusterViewGroupCallback(app::CommandHandler * commandObj, con
CHIP_ERROR err = CHIP_NO_ERROR;
EmberAfStatus status = EMBER_ZCL_STATUS_NOT_FOUND;

VerifyOrExit(IsFabricGroupId(groupId), status = EMBER_ZCL_STATUS_CONSTRAINT_ERROR);
VerifyOrExit(IsValidGroupId(groupId), status = EMBER_ZCL_STATUS_CONSTRAINT_ERROR);
VerifyOrExit(nullptr != provider, status = EMBER_ZCL_STATUS_FAILURE);
VerifyOrExit(provider->HasEndpoint(fabricIndex, groupId, commandPath.mEndpointId), status = EMBER_ZCL_STATUS_NOT_FOUND);

Expand Down
4 changes: 2 additions & 2 deletions src/credentials/tests/TestGroupDataProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ constexpr ByteSpan kCompressedFabricId1(kCompressedFabricIdBuffer1);
static const uint8_t kCompressedFabricIdBuffer2[] = { 0x3f, 0xaa, 0xe2, 0x90, 0x93, 0xd5, 0xaf, 0x45 };
constexpr ByteSpan kCompressedFabricId2(kCompressedFabricIdBuffer2);

constexpr chip::GroupId kGroup1 = kMinFabricGroupId;
constexpr chip::GroupId kGroup1 = kMinApplicationGroupId;
constexpr chip::GroupId kGroup2 = 0x2222;
constexpr chip::GroupId kGroup3 = kMaxFabricGroupId;
constexpr chip::GroupId kGroup3 = kMaxApplicationGroupId;
constexpr chip::GroupId kGroup4 = 0x4444;
constexpr chip::GroupId kGroup5 = 0x5555;

Expand Down
12 changes: 6 additions & 6 deletions src/lib/core/GroupId.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ using GroupId = uint16_t;

constexpr GroupId kUndefinedGroupId = 0;

constexpr GroupId kMinUniversalGroupId = 0x8000;
constexpr GroupId kMinUniversalGroupId = 0xFF00;
constexpr GroupId kMaxUniversalGroupId = 0xFFFF;

constexpr GroupId kMinFabricGroupId = 0x0001;
constexpr GroupId kMaxFabricGroupId = 0x7FFF;
constexpr GroupId kMinApplicationGroupId = 0x0001;
constexpr GroupId kMaxApplicationGroupId = 0xFEFF;

constexpr GroupId kAllNodes = 0xFFFF;
constexpr GroupId kAllNonSleepy = 0xFFFE;
constexpr GroupId kAllProxies = 0xFFFD;

constexpr GroupId kMinUniversalGroupIdReserved = 0x8000;
constexpr GroupId kMinUniversalGroupIdReserved = 0xFF00;
constexpr GroupId kMaxUniversalGroupIdReserved = 0xFFFC;

constexpr bool IsOperationalGroupId(GroupId aGroupId)
Expand All @@ -44,9 +44,9 @@ constexpr bool IsOperationalGroupId(GroupId aGroupId)
((aGroupId < kMinUniversalGroupIdReserved) || (aGroupId > kMaxUniversalGroupIdReserved));
}

constexpr bool IsFabricGroupId(GroupId aGroupId)
constexpr bool IsApplicationGroupId(GroupId aGroupId)
{
return (aGroupId >= kMinFabricGroupId) && (aGroupId <= kMaxFabricGroupId);
return (aGroupId >= kMinApplicationGroupId) && (aGroupId <= kMaxApplicationGroupId);
}

constexpr bool IsUniversalGroupId(GroupId aGroupId)
Expand Down

0 comments on commit 2180053

Please sign in to comment.