/src/connectedhomeip/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerHandler.h
Line | Count | Source |
1 | | /* |
2 | | * |
3 | | * Copyright (c) 2023 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 <app-common/zap-generated/cluster-objects.h> |
21 | | #include <app/TestEventTriggerDelegate.h> |
22 | | |
23 | | /** |
24 | | * @brief User handler for handling the test event trigger |
25 | | * |
26 | | * @note If TestEventTrigger is enabled, it needs to be implemented in the app |
27 | | * |
28 | | * @param eventTrigger Event trigger to handle |
29 | | * |
30 | | * @retval true on success |
31 | | * @retval false if error happened |
32 | | */ |
33 | | bool HandleSmokeCOTestEventTrigger(uint64_t eventTrigger); |
34 | | |
35 | | namespace chip { |
36 | | |
37 | | enum class SmokeCOTrigger : uint64_t |
38 | | { |
39 | | // Force alarm commands |
40 | | kForceSmokeWarning = 0x005c'0000'00000090, |
41 | | kForceCOWarning = 0x005c'0000'00000091, |
42 | | kForceSmokeInterconnect = 0x005c'0000'00000092, |
43 | | kForceMalfunction = 0x005c'0000'00000093, |
44 | | kForceCOInterconnect = 0x005c'0000'00000094, |
45 | | kForceLowBatteryWarning = 0x005c'0000'00000095, |
46 | | kForceSmokeContaminationHigh = 0x005c'0000'00000096, |
47 | | kForceSmokeContaminationLow = 0x005c'0000'00000097, |
48 | | kForceSmokeSensitivityHigh = 0x005c'0000'00000098, |
49 | | kForceSmokeSensitivityLow = 0x005c'0000'00000099, |
50 | | kForceEndOfLife = 0x005c'0000'0000009a, |
51 | | kForceSilence = 0x005c'0000'0000009b, |
52 | | kForceSmokeCritical = 0x005c'0000'0000009c, |
53 | | kForceCOCritical = 0x005c'0000'0000009d, |
54 | | kForceLowBatteryCritical = 0x005c'0000'0000009e, |
55 | | // Clear alarm commands |
56 | | kClearSmoke = 0x005c'0000'000000a0, |
57 | | kClearCO = 0x005c'0000'000000a1, |
58 | | kClearSmokeInterconnect = 0x005c'0000'000000a2, |
59 | | kClearMalfunction = 0x005c'0000'000000a3, |
60 | | kClearCOInterconnect = 0x005c'0000'000000a4, |
61 | | kClearBatteryLevelLow = 0x005c'0000'000000a5, |
62 | | kClearContamination = 0x005c'0000'000000a6, |
63 | | kClearSensitivity = 0x005c'0000'000000a8, |
64 | | kClearEndOfLife = 0x005c'0000'000000aa, |
65 | | kClearSilence = 0x005c'0000'000000ab |
66 | | }; |
67 | | |
68 | | class SmokeCOTestEventTriggerHandler : public TestEventTriggerHandler |
69 | | { |
70 | | public: |
71 | | SmokeCOTestEventTriggerHandler() = default; |
72 | | CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override |
73 | 0 | { |
74 | 0 | eventTrigger = clearEndpointInEventTrigger(eventTrigger); |
75 | 0 | return HandleSmokeCOTestEventTrigger(eventTrigger) ? CHIP_NO_ERROR : CHIP_ERROR_INVALID_ARGUMENT; |
76 | 0 | } |
77 | | }; |
78 | | |
79 | | } // namespace chip |