Line data Source code
1 : /*
2 : * Copyright (c) 2025 Project CHIP Authors
3 : * All rights reserved.
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 : #include "AutoCommissioner.h"
19 :
20 : #include <app-common/zap-generated/ids/Attributes.h>
21 : #include <app-common/zap-generated/ids/Clusters.h>
22 : #include <app/InteractionModelEngine.h>
23 : #include <controller/CommissioningDelegate.h>
24 : #include <credentials/CHIPCert.h>
25 : #include <lib/core/CHIPCore.h>
26 : #include <lib/core/CHIPError.h>
27 :
28 : using namespace ::chip;
29 : using namespace ::chip::app;
30 : using namespace chip::app::Clusters;
31 :
32 : namespace chip {
33 : namespace Controller {
34 : namespace JCM {
35 :
36 : /*
37 : * AutoCommissioner override implementation
38 : */
39 7 : CHIP_ERROR AutoCommissioner::SetCommissioningParameters(const CommissioningParameters & params)
40 : {
41 7 : ReturnErrorOnFailure(chip::Controller::AutoCommissioner::SetCommissioningParameters(params));
42 :
43 : #if CHIP_DEVICE_CONFIG_ENABLE_JOINT_FABRIC
44 : if (params.GetUseJCM().ValueOr(false))
45 : {
46 : auto extraReadPaths = params.GetExtraReadPaths();
47 :
48 : mTempReadPaths.clear();
49 : mTempReadPaths.reserve(extraReadPaths.size() + mExtraReadPaths.size());
50 : mTempReadPaths.insert(mTempReadPaths.end(), extraReadPaths.begin(), extraReadPaths.end());
51 : mTempReadPaths.insert(mTempReadPaths.end(), mExtraReadPaths.begin(), mExtraReadPaths.end());
52 :
53 : // Set the extra read paths for JCM
54 : mParams.SetExtraReadPaths(Span<app::AttributePathParams>(mTempReadPaths.data(), mTempReadPaths.size()));
55 : }
56 : #endif // CHIP_DEVICE_CONFIG_ENABLE_JOINT_FABRIC
57 :
58 7 : return CHIP_NO_ERROR;
59 : }
60 :
61 0 : void AutoCommissioner::CleanupCommissioning()
62 : {
63 0 : mTempReadPaths.clear();
64 :
65 0 : chip::Controller::AutoCommissioner::CleanupCommissioning();
66 0 : }
67 :
68 : } // namespace JCM
69 : } // namespace Controller
70 : } // namespace chip
|