blob: ef2c56685afa342351cb92c189816cd1fb8f62cd [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
21#include <controller/AbstractMdnsDiscoveryController.h>
22#include <mdns/Resolver.h>
Michael Spang28977db2021-07-05 15:20:40 -040023#include <platform/CHIPDeviceConfig.h>
Sharad Binjolaf78d60e2021-06-17 05:50:45 -070024#include <support/logging/CHIPLogging.h>
25
26namespace chip {
27
28namespace Controller {
29
30/**
31 * @brief
32 * CHIPCommissionableNodeController is a Controller class that
33 * centralizes (acts as facade) discovery of commissioners, sending User
34 * Directed Commissioning requests, Commissionable Node advertisement and
35 * Commissioning of the node
36 */
37class DLL_EXPORT CommissionableNodeController : public AbstractMdnsDiscoveryController
38{
39public:
40 CommissionableNodeController(){};
41 virtual ~CommissionableNodeController() {}
42
C Freeman8a535282021-06-22 22:54:19 -040043 CHIP_ERROR DiscoverCommissioners(Mdns::DiscoveryFilter discoveryFilter = Mdns::DiscoveryFilter());
Sharad Binjolaf78d60e2021-06-17 05:50:45 -070044
45 const Mdns::DiscoveredNodeData * GetDiscoveredCommissioner(int idx);
46
47 void OnNodeIdResolved(const chip::Mdns::ResolvedNodeData & nodeData) override
48 {
49 ChipLogError(Controller, "Unsupported operation CommissionableNodeController::OnNodeIdResolved");
50 }
51
52 void OnNodeIdResolutionFailed(const chip::PeerId & peerId, CHIP_ERROR error) override
53 {
54 ChipLogError(Controller, "Unsupported operation CommissionableNodeController::OnNodeIdResolutionFailed");
55 }
56
Sharad Binjolaf78d60e2021-06-17 05:50:45 -070057protected:
58 Mdns::DiscoveredNodeData * GetDiscoveredNodes() override { return mDiscoveredCommissioners; }
59
60private:
61 Mdns::DiscoveredNodeData mDiscoveredCommissioners[CHIP_DEVICE_CONFIG_MAX_DISCOVERED_NODES];
62};
63
64} // namespace Controller
65} // namespace chip