forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchef-dishwasher-alarm-delegate-impl.cpp
147 lines (132 loc) · 5.25 KB
/
chef-dishwasher-alarm-delegate-impl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <app-common/zap-generated/cluster-objects.h>
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
#ifdef MATTER_DM_PLUGIN_DISHWASHER_ALARM_SERVER
#include <app/clusters/dishwasher-alarm-server/dishwasher-alarm-server.h>
using namespace chip::app::Clusters::DishwasherAlarm;
class DishwasherAlarmDelegate : public Delegate
{
public:
/**
* @brief
* A notification that the Mask attribute will be changed. When this happens, some previously suppressed
* alarms may need to be enabled, and previously enabled alarms may need to be suppressed.
* @param[in] mask The new value of the Mask attribute.
* @return The cluster will do this update if ModifyEnabledAlarmsCallback() returns true.
* The cluster will not do this update if ModifyEnabledAlarmsCallback() returns false.
*/
bool ModifyEnabledAlarmsCallback(const BitMask<AlarmMap> mask) override;
/**
* @brief
* A notification that resets active alarms (if possible)
* @param[in] alarms The value of reset alarms
* @return The cluster will reset active alarms if ResetAlarmsCallback() returns true.
* The cluster will not reset active alarms if ResetAlarmsCallback() returns false.
*/
bool ResetAlarmsCallback(const BitMask<AlarmMap> alarms) override;
~DishwasherAlarmDelegate() = default;
};
bool DishwasherAlarmDelegate::ModifyEnabledAlarmsCallback(const BitMask<AlarmMap> mask)
{
// placeholder implementation
return true;
}
bool DishwasherAlarmDelegate::ResetAlarmsCallback(const BitMask<AlarmMap> alarms)
{
// placeholder implementation
return true;
}
/*
* An example to present device's endpointId
*/
static constexpr EndpointId kDemoEndpointId = 1;
void MatterDishwasherAlarmServerInit()
{
using namespace app::Clusters;
using namespace app::Clusters::DishwasherAlarm;
static DishwasherAlarm::DishwasherAlarmDelegate delegate;
DishwasherAlarm::SetDefaultDelegate(kDemoEndpointId, &delegate);
// Set Supported attribute = 0x3F = 63
// Bit Name Value
// 0 InflowError 1
// 1 DrainError 1
// 2 DoorError 1
// 3 TempTooLow 1
// 4 TempTooHigh 1
// 5 WaterLevelError 1
BitMask<AlarmMap> supported;
supported.SetField(AlarmMap::kInflowError, 1);
supported.SetField(AlarmMap::kDrainError, 1);
supported.SetField(AlarmMap::kDoorError, 1);
supported.SetField(AlarmMap::kTempTooLow, 1);
supported.SetField(AlarmMap::kTempTooHigh, 1);
supported.SetField(AlarmMap::kWaterLevelError, 1);
DishwasherAlarmServer::Instance().SetSupportedValue(kDemoEndpointId, supported);
// Set Mask attribute = 0x0 = 0
// Bit Name Value
// 0 InflowError 0
// 1 DrainError 0
// 2 DoorError 0
// 3 TempTooLow 0
// 4 TempTooHigh 0
// 5 WaterLevelError 0
BitMask<AlarmMap> mask;
mask.SetField(AlarmMap::kInflowError, 0);
mask.SetField(AlarmMap::kDrainError, 0);
mask.SetField(AlarmMap::kDoorError, 0);
mask.SetField(AlarmMap::kTempTooLow, 0);
mask.SetField(AlarmMap::kTempTooHigh, 0);
mask.SetField(AlarmMap::kWaterLevelError, 0);
DishwasherAlarmServer::Instance().SetMaskValue(kDemoEndpointId, mask);
// Set Latch attribute = 0x30
// Bit Name Value
// 0 InflowError 1
// 1 DrainError 1
// 2 DoorError 0
// 3 TempTooLow 0
// 4 TempTooHigh 0
// 5 WaterLevelError 0
BitMask<AlarmMap> latch;
latch.SetField(AlarmMap::kInflowError, 1);
latch.SetField(AlarmMap::kDrainError, 1);
latch.SetField(AlarmMap::kDoorError, 0);
latch.SetField(AlarmMap::kTempTooLow, 0);
latch.SetField(AlarmMap::kTempTooHigh, 0);
latch.SetField(AlarmMap::kWaterLevelError, 0);
DishwasherAlarmServer::Instance().SetLatchValue(kDemoEndpointId, latch);
// Set State attribute = 0x00
// Bit Name Value
// 0 InflowError 0
// 1 DrainError 0
// 2 DoorError 0
// 3 TempTooLow 0
// 4 TempTooHigh 0
// 5 WaterLevelError 0
BitMask<AlarmMap> state;
state.SetField(AlarmMap::kInflowError, 0);
state.SetField(AlarmMap::kDrainError, 0);
state.SetField(AlarmMap::kDoorError, 0);
state.SetField(AlarmMap::kTempTooLow, 0);
state.SetField(AlarmMap::kTempTooHigh, 0);
state.SetField(AlarmMap::kWaterLevelError, 0);
DishwasherAlarmServer::Instance().SetStateValue(kDemoEndpointId, state);
}
#endif // MATTER_DM_PLUGIN_DISHWASHER_ALARM_SERVER