c377517375bc04b0c8876fa9199ab7363d1404f5
[platform/upstream/connectedhomeip.git] / src / controller / OnOffCluster.cpp
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *    All rights reserved.
5  *
6  *    Licensed under the Apache License, Version 2.0 (the "License");
7  *    you may not use this file except in compliance with the License.
8  *    You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *    Unless required by applicable law or agreed to in writing, software
13  *    distributed under the License is distributed on an "AS IS" BASIS,
14  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *    See the License for the specific language governing permissions and
16  *    limitations under the License.
17  */
18
19 #include <app/chip-zcl-zpro-codec-api.h>
20 #include <controller/OnOffCluster.h>
21
22 namespace chip {
23 namespace Controller {
24
25 // TODO: Find a way to calculate maximum message length for clusters
26 //       https://github.com/project-chip/connectedhomeip/issues/965
27 constexpr uint16_t kMaxOnOffMessageLength = 64;
28
29 CHIP_ERROR OnOffCluster::On(Callback::Callback<> * onCompletion)
30 {
31     return SendCommand(encodeOnOffClusterOnCommand, kMaxOnOffMessageLength, onCompletion);
32 }
33
34 CHIP_ERROR OnOffCluster::Off(Callback::Callback<> * onCompletion)
35 {
36     return SendCommand(encodeOnOffClusterOffCommand, kMaxOnOffMessageLength, onCompletion);
37 }
38
39 CHIP_ERROR OnOffCluster::Toggle(Callback::Callback<> * onCompletion)
40 {
41     return SendCommand(encodeOnOffClusterToggleCommand, kMaxOnOffMessageLength, onCompletion);
42 }
43
44 CHIP_ERROR OnOffCluster::ReadAttributeOnOff(Callback::Callback<> * onCompletion)
45 {
46     return SendCommand(encodeOnOffClusterReadOnOffAttribute, kMaxOnOffMessageLength, onCompletion);
47 }
48
49 CHIP_ERROR OnOffCluster::ReportAttributeOnOff(Callback::Callback<> * onChange, uint16_t minInterval, uint16_t maxInterval)
50 {
51     return RequestAttributeReporting(encodeOnOffClusterReportOnOffAttribute, kMaxOnOffMessageLength, minInterval, maxInterval,
52                                      onChange);
53 }
54
55 CHIP_ERROR OnOffCluster::ReadAttributeClusterRevision(Callback::Callback<> * onCompletion)
56 {
57     return CHIP_NO_ERROR;
58 }
59
60 } // namespace Controller
61 } // namespace chip