-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make CHIP devices advertise as operational devices via mDNS #4132
Merged
andy31415
merged 26 commits into
project-chip:master
from
andy31415:01_chip_mdns_operational
Dec 11, 2020
Merged
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
ca26e5d
Initial definition of an mDNS advertiser
andy31415 97a79c2
Make chip app server listen on mdns by default
andy31415 38b611f
Replace DiscoveryManager with advertiser
andy31415 fce86db
Fix compilation, ensure we shutdown before we listen for mDNS server,…
andy31415 ac60dc8
Always advertise as operational, add some more logging
andy31415 cb54ed0
Register delegates, add some logging, fix PTR records
andy31415 ab9472d
Remove errand space
andy31415 22123ae
Fix crash in ESP code on broadcast
andy31415 6996da8
Fix return value: ref return does not work well
andy31415 91b6dca
Update logging verbosity on ESP32: chip already configures its loggin…
andy31415 b4d0811
hex format server name
andy31415 1568e4d
Better logging, fix server discovery
andy31415 89d7583
Update registration of names
andy31415 6a09a52
Restyle fixes
andy31415 dd48fe5
Make ipv4 in minmdns optional
andy31415 cd68341
Fix logic error in interface lister
andy31415 43b6bc8
Move Clone into SystemPacketBuffer. Clean up a bit of handle usage in…
andy31415 0f08552
Make stringbuilder a support class
andy31415 a3a14e3
Restyle fixes
andy31415 5d454f0
Merge branch 'master' into 01_chip_mdns_operational
andy31415 15abce0
Fix build after merge with master
andy31415 d44085b
Rename Clone to CloneData
andy31415 785c4cd
Merge branch 'master' into 01_chip_mdns_operational
andy31415 40a11c1
Replace minimal-mdns with minimal
andy31415 1446836
Clariy update for interface iteration
andy31415 bde31eb
Merge branch 'master' into 01_chip_mdns_operational
andy31415 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can still guard with
IsFullyProvisioned
to support advertising_chipc._udp
for IP rendezvous.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. The reason I made it advertise fully here is to always have functional mDNS to test with.
My next PRs (maybe pending some cleanup in usage) would be to add _chipc._udp vs operational advertisiement.