Sharad Binjola | f78d60e | 2021-06-17 05:50:45 -0700 | [diff] [blame] | 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/AbstractMdnsDiscoveryController.h> |
| 22 | #include <mdns/Resolver.h> |
Michael Spang | 28977db | 2021-07-05 15:20:40 -0400 | [diff] [blame^] | 23 | #include <platform/CHIPDeviceConfig.h> |
Sharad Binjola | f78d60e | 2021-06-17 05:50:45 -0700 | [diff] [blame] | 24 | #include <support/logging/CHIPLogging.h> |
| 25 | |
| 26 | namespace chip { |
| 27 | |
| 28 | namespace 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 | */ |
| 37 | class DLL_EXPORT CommissionableNodeController : public AbstractMdnsDiscoveryController |
| 38 | { |
| 39 | public: |
| 40 | CommissionableNodeController(){}; |
| 41 | virtual ~CommissionableNodeController() {} |
| 42 | |
C Freeman | 8a53528 | 2021-06-22 22:54:19 -0400 | [diff] [blame] | 43 | CHIP_ERROR DiscoverCommissioners(Mdns::DiscoveryFilter discoveryFilter = Mdns::DiscoveryFilter()); |
Sharad Binjola | f78d60e | 2021-06-17 05:50:45 -0700 | [diff] [blame] | 44 | |
| 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 Binjola | f78d60e | 2021-06-17 05:50:45 -0700 | [diff] [blame] | 57 | protected: |
| 58 | Mdns::DiscoveredNodeData * GetDiscoveredNodes() override { return mDiscoveredCommissioners; } |
| 59 | |
| 60 | private: |
| 61 | Mdns::DiscoveredNodeData mDiscoveredCommissioners[CHIP_DEVICE_CONFIG_MAX_DISCOVERED_NODES]; |
| 62 | }; |
| 63 | |
| 64 | } // namespace Controller |
| 65 | } // namespace chip |