Line data Source code
1 : /*
2 : *
3 : * Copyright (c) 2024 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 : #include "reporting.h"
18 :
19 : #include <app/AttributePathParams.h>
20 : #include <app/InteractionModelEngine.h>
21 : #include <app/data-model-provider/Provider.h>
22 : #include <lib/support/CodeUtils.h>
23 : #include <platform/LockTracker.h>
24 :
25 : using namespace chip;
26 : using namespace chip::app;
27 :
28 12 : void MatterReportingAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId)
29 : {
30 : // Attribute writes have asserted this already, but this assert should catch
31 : // applications notifying about changes from their end.
32 12 : assertChipStackLockedByCurrentThread();
33 :
34 12 : DataModel::Provider * provider = InteractionModelEngine::GetInstance()->GetDataModelProvider();
35 12 : VerifyOrReturn(provider != nullptr);
36 :
37 12 : provider->Temporary_ReportAttributeChanged(AttributePathParams(endpoint, clusterId, attributeId));
38 : }
39 :
40 0 : void MatterReportingAttributeChangeCallback(const ConcreteAttributePath & aPath)
41 : {
42 : // Attribute writes have asserted this already, but this assert should catch
43 : // applications notifying about changes from their end.
44 0 : assertChipStackLockedByCurrentThread();
45 :
46 0 : DataModel::Provider * provider = InteractionModelEngine::GetInstance()->GetDataModelProvider();
47 0 : VerifyOrReturn(provider != nullptr);
48 :
49 0 : provider->Temporary_ReportAttributeChanged(AttributePathParams(aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId));
50 : }
51 :
52 0 : void MatterReportingAttributeChangeCallback(EndpointId endpoint)
53 : {
54 : // Attribute writes have asserted this already, but this assert should catch
55 : // applications notifying about changes from their end.
56 0 : assertChipStackLockedByCurrentThread();
57 :
58 0 : DataModel::Provider * provider = InteractionModelEngine::GetInstance()->GetDataModelProvider();
59 0 : VerifyOrReturn(provider != nullptr);
60 :
61 0 : provider->Temporary_ReportAttributeChanged(AttributePathParams(endpoint));
62 : }
|