blob: 9a4397710267360fb8cd53098a77fe4602524163 [file] [log] [blame]
Boris Zbarsky583ac0d2022-05-28 13:08:33 -04001/*
2 *
3 * Copyright (c) 2021 Project CHIP Authors
4 * Copyright 2021, Cypress Semiconductor Corporation (an Infineon company)
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/**
20 * @file
21 * This file implements the handler for data model messages.
22 */
23
24#include "AppConfig.h"
25#include <lib/support/logging/CHIPLogging.h>
26
27#include "ClusterManager.h"
28
Boris Zbarsky583ac0d2022-05-28 13:08:33 -040029#include <app-common/zap-generated/ids/Attributes.h>
30#include <app-common/zap-generated/ids/Clusters.h>
31#include <app/util/af-types.h>
32
33using namespace ::chip;
34using namespace ::chip::app::Clusters;
35
36void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size,
37 uint8_t * value)
38{
39 EndpointId endpoint = attributePath.mEndpointId;
40 ClusterId clusterId = attributePath.mClusterId;
41 AttributeId attributeId = attributePath.mAttributeId;
42 P6_LOG("MatterPostAttributeChangeCallback - Cluster ID: " ChipLogFormatMEI
43 ", EndPoint ID: '0x%02x', Attribute ID: " ChipLogFormatMEI,
44 ChipLogValueMEI(clusterId), endpoint, ChipLogValueMEI(attributeId));
45
46 switch (clusterId)
47 {
48 case OnOff::Id:
49 ClusterMgr().OnOnOffPostAttributeChangeCallback(endpoint, attributeId, value);
50 break;
51
52 case Identify::Id:
53 ClusterMgr().OnIdentifyPostAttributeChangeCallback(endpoint, attributeId, value);
54 break;
55
56 case LevelControl::Id:
57 ClusterMgr().OnLevelControlAttributeChangeCallback(endpoint, attributeId, value);
58 break;
59
60 case ColorControl::Id:
61 ClusterMgr().OnColorControlAttributeChangeCallback(endpoint, attributeId, value);
62 break;
63 default:
64 P6_LOG("Unhandled cluster ID: " ChipLogFormatMEI, ChipLogValueMEI(clusterId));
65 break;
66 }
67}
68/** @brief OnOff Cluster Init
69 *
70 * This function is called when a specific cluster is initialized. It gives the
71 * application an opportunity to take care of cluster initialization procedures.
72 * It is called exactly once for each endpoint where cluster is present.
73 *
74 * @param endpoint Ver.: always
75 *
76 * TODO Issue #3841
77 * emberAfOnOffClusterInitCallback happens before the stack initialize the cluster
78 * attributes to the default value.
79 * The logic here expects something similar to the deprecated Plugins callback
80 * emberAfPluginOnOffClusterServerPostInitCallback.
81 *
82 */
83void emberAfOnOffClusterInitCallback(EndpointId endpoint)
84{
85 // TODO: implement any additional Cluster Server init actions
86}