Line data Source code
1 : /*
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 :
21 : #include <controller/AbstractDnssdDiscoveryController.h>
22 : #include <lib/support/logging/CHIPLogging.h>
23 : #include <platform/CHIPDeviceConfig.h>
24 :
25 : namespace chip {
26 :
27 : namespace 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 : */
36 : class DLL_EXPORT CommissionableNodeController : public AbstractDnssdDiscoveryController
37 : {
38 : public:
39 : CommissionableNodeController(chip::Dnssd::Resolver * resolver = nullptr) : AbstractDnssdDiscoveryController(resolver) {}
40 : ~CommissionableNodeController() override;
41 :
42 : void RegisterDeviceDiscoveryDelegate(DeviceDiscoveryDelegate * delegate) { mDeviceDiscoveryDelegate = delegate; }
43 : CHIP_ERROR DiscoverCommissioners(Dnssd::DiscoveryFilter discoveryFilter = Dnssd::DiscoveryFilter());
44 :
45 : /**
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 : */
52 : const Dnssd::CommissionNodeData * GetDiscoveredCommissioner(int idx);
53 :
54 : protected:
55 64 : DiscoveredNodeList GetDiscoveredNodes() override { return DiscoveredNodeList(mDiscoveredCommissioners); }
56 :
57 : private:
58 : Dnssd::CommissionNodeData mDiscoveredCommissioners[CHIP_DEVICE_CONFIG_MAX_DISCOVERED_NODES];
59 : };
60 :
61 : } // namespace Controller
62 : } // namespace chip
|