blob: 5c9f57919a289764fd06ed9de04d79ca567908b5 [file] [log] [blame]
Sharad Binjolaf78d60e2021-06-17 05:50:45 -07001/*
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#pragma once
20
Kamil Kasperczykd9e02a02021-10-12 09:19:23 +020021#include <controller/AbstractDnssdDiscoveryController.h>
Zang MingJie53dd5832021-09-03 03:05:16 +080022#include <lib/support/logging/CHIPLogging.h>
Michael Spang28977db2021-07-05 15:20:40 -040023#include <platform/CHIPDeviceConfig.h>
Sharad Binjolaf78d60e2021-06-17 05:50:45 -070024
25namespace chip {
26
27namespace Controller {
28
29/**
30 * @brief
31 * CHIPCommissionableNodeController is a Controller class that
32 * centralizes (acts as facade) discovery of commissioners, sending User
33 * Directed Commissioning requests, Commissionable Node advertisement and
34 * Commissioning of the node
35 */
Kamil Kasperczykd9e02a02021-10-12 09:19:23 +020036class DLL_EXPORT CommissionableNodeController : public AbstractDnssdDiscoveryController
Sharad Binjolaf78d60e2021-06-17 05:50:45 -070037{
38public:
Damian Królik1d37eb02023-11-23 21:07:00 +010039 CommissionableNodeController(chip::Dnssd::Resolver * resolver = nullptr) : AbstractDnssdDiscoveryController(resolver) {}
Andrei Litvin489b0162022-05-17 20:58:08 -040040 ~CommissionableNodeController() override;
Sharad Binjolaf78d60e2021-06-17 05:50:45 -070041
Sharad Binjolabcdf9dd2023-02-08 19:56:20 -080042 void RegisterDeviceDiscoveryDelegate(DeviceDiscoveryDelegate * delegate) { mDeviceDiscoveryDelegate = delegate; }
Kamil Kasperczykd9e02a02021-10-12 09:19:23 +020043 CHIP_ERROR DiscoverCommissioners(Dnssd::DiscoveryFilter discoveryFilter = Dnssd::DiscoveryFilter());
Sharad Binjolaf78d60e2021-06-17 05:50:45 -070044
Sharad Binjola2937f1a2021-08-24 14:25:16 -070045 /**
46 * @return
47 * Pointer to DiscoveredNodeData at index idx in the list of commissioners discovered
48 * by the CHIPCommissionableNodeController, if the node is a valid node.
49 * Otherwise, returns nullptr
50 * See Resolver.h IsValid()
51 */
Kamil Kasperczykd9e02a02021-10-12 09:19:23 +020052 const Dnssd::DiscoveredNodeData * GetDiscoveredCommissioner(int idx);
Sharad Binjolaf78d60e2021-06-17 05:50:45 -070053
Sharad Binjolaf78d60e2021-06-17 05:50:45 -070054protected:
Boris Zbarsky5081bbe2021-07-12 11:53:06 -040055 DiscoveredNodeList GetDiscoveredNodes() override { return DiscoveredNodeList(mDiscoveredCommissioners); }
Sharad Binjolaf78d60e2021-06-17 05:50:45 -070056
57private:
Kamil Kasperczykd9e02a02021-10-12 09:19:23 +020058 Dnssd::DiscoveredNodeData mDiscoveredCommissioners[CHIP_DEVICE_CONFIG_MAX_DISCOVERED_NODES];
Sharad Binjolaf78d60e2021-06-17 05:50:45 -070059};
60
61} // namespace Controller
62} // namespace chip