Line data Source code
1 : /*
2 : *
3 : * Copyright (c) 2021 Project CHIP Authors
4 : *
5 : * Licensed under the Apache License, Version 2.0 (the "License");
6 : * you may not use this file except in compliance with the License.
7 : * You may obtain a copy of the License at
8 : *
9 : * http://www.apache.org/licenses/LICENSE-2.0
10 : *
11 : * Unless required by applicable law or agreed to in writing, software
12 : * distributed under the License is distributed on an "AS IS" BASIS,
13 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 : * See the License for the specific language governing permissions and
15 : * limitations under the License.
16 : */
17 :
18 : #pragma once
19 :
20 : #include <cstdint>
21 :
22 : namespace chip {
23 :
24 : using GroupId = uint16_t;
25 :
26 : inline constexpr GroupId kUndefinedGroupId = 0;
27 :
28 : inline constexpr GroupId kMinUniversalGroupId = 0xFF00;
29 : inline constexpr GroupId kMaxUniversalGroupId = 0xFFFF;
30 :
31 : inline constexpr GroupId kMinApplicationGroupId = 0x0001;
32 : inline constexpr GroupId kMaxApplicationGroupId = 0xFEFF;
33 :
34 : inline constexpr GroupId kAllNodes = 0xFFFF;
35 : inline constexpr GroupId kAllNonSleepy = 0xFFFE;
36 : inline constexpr GroupId kAllProxies = 0xFFFD;
37 :
38 : inline constexpr GroupId kMinUniversalGroupIdReserved = 0xFF00;
39 : inline constexpr GroupId kMaxUniversalGroupIdReserved = 0xFFFC;
40 :
41 : constexpr bool IsOperationalGroupId(GroupId aGroupId)
42 : {
43 : return (aGroupId != kUndefinedGroupId) &&
44 : ((aGroupId < kMinUniversalGroupIdReserved) || (aGroupId > kMaxUniversalGroupIdReserved));
45 : }
46 :
47 : constexpr bool IsApplicationGroupId(GroupId aGroupId)
48 : {
49 : return (aGroupId >= kMinApplicationGroupId) && (aGroupId <= kMaxApplicationGroupId);
50 : }
51 :
52 : constexpr bool IsUniversalGroupId(GroupId aGroupId)
53 : {
54 : return (aGroupId >= kMinUniversalGroupId);
55 : }
56 :
57 90 : constexpr bool IsValidGroupId(GroupId aGroupId)
58 : {
59 90 : return aGroupId != kUndefinedGroupId;
60 : }
61 :
62 : } // namespace chip
|