-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make CHIP devices advertise as operational devices via mDNS (#4132)
* Initial definition of an mDNS advertiser * Make chip app server listen on mdns by default * Replace DiscoveryManager with advertiser * Fix compilation, ensure we shutdown before we listen for mDNS server, to make sure multiple start calls work * Always advertise as operational, add some more logging * Register delegates, add some logging, fix PTR records * Remove errand space * Fix crash in ESP code on broadcast * Fix return value: ref return does not work well * Update logging verbosity on ESP32: chip already configures its logging, so mark esp verbosity to verbose * hex format server name * Better logging, fix server discovery * Update registration of names * Restyle fixes * Make ipv4 in minmdns optional * Fix logic error in interface lister * Move Clone into SystemPacketBuffer. Clean up a bit of handle usage in mdns * Make stringbuilder a support class * Restyle fixes * Fix build after merge with master * Rename Clone to CloneData * Replace minimal-mdns with minimal * Clariy update for interface iteration
- Loading branch information
Showing
21 changed files
with
778 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
#include <core/CHIPError.h> | ||
#include <inet/InetLayer.h> | ||
|
||
namespace chip { | ||
namespace Mdns { | ||
|
||
static constexpr uint16_t kMdnsPort = 5353; | ||
|
||
/// Defines parameters required for advertising a CHIP node | ||
/// over mDNS as an 'operationally ready' node. | ||
class OperationalAdvertisingParameters | ||
{ | ||
public: | ||
OperationalAdvertisingParameters & SetFabricId(uint64_t fabricId) | ||
{ | ||
mFabricId = fabricId; | ||
return *this; | ||
} | ||
uint64_t GetFabricId() const { return mFabricId; } | ||
|
||
OperationalAdvertisingParameters & SetNodeId(uint64_t nodeId) | ||
{ | ||
mNodeId = nodeId; | ||
return *this; | ||
} | ||
uint64_t GetNodeId() const { return mNodeId; } | ||
|
||
OperationalAdvertisingParameters & SetPort(uint16_t port) | ||
{ | ||
mPort = port; | ||
return *this; | ||
} | ||
uint64_t GetPort() const { return mPort; } | ||
|
||
OperationalAdvertisingParameters & EnableIpV4(bool enable) | ||
{ | ||
mEnableIPv4 = enable; | ||
return *this; | ||
} | ||
bool IsIPv4Enabled() const { return mEnableIPv4; } | ||
|
||
private: | ||
uint64_t mFabricId = 0; | ||
uint64_t mNodeId = 0; | ||
uint16_t mPort = CHIP_PORT; | ||
bool mEnableIPv4 = true; | ||
}; | ||
|
||
/// Handles advertising of CHIP nodes | ||
class ServiceAdvertiser | ||
{ | ||
public: | ||
virtual ~ServiceAdvertiser() {} | ||
|
||
/// Starts the advertiser. Items 'Advertised' will become visible. | ||
/// May be called before OR after Advertise() calls. | ||
virtual CHIP_ERROR Start(chip::Inet::InetLayer * inetLayer, uint16_t port) = 0; | ||
|
||
/// Advertises the CHIP node as an operational node | ||
virtual CHIP_ERROR Advertise(const OperationalAdvertisingParameters & params) = 0; | ||
|
||
/// Provides the system-wide implementation of the service advertiser | ||
static ServiceAdvertiser & Instance(); | ||
}; | ||
|
||
} // namespace Mdns | ||
} // namespace chip |
Oops, something went wrong.