-
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
Implement User Directed Commissioning - Phase 1 #8034
Changes from all commits
b7318b3
5711479
aa021a6
1e65f1b
2ada1f7
a8c531c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -21,6 +21,7 @@ | |||||
|
||||||
#include <core/Optional.h> | ||||||
#include <mdns/Advertiser.h> | ||||||
#include <mdns/ServiceNaming.h> | ||||||
#include <messaging/ReliableMessageProtocolConfig.h> | ||||||
#if CONFIG_DEVICE_LAYER | ||||||
#include <platform/CHIPDeviceLayer.h> | ||||||
|
@@ -87,6 +88,12 @@ chip::ByteSpan FillMAC(uint8_t (&mac)[8]) | |||||
|
||||||
} // namespace | ||||||
|
||||||
CHIP_ERROR GetCommissionableInstanceName(char * buffer, size_t bufferLen) | ||||||
{ | ||||||
auto & mdnsAdvertiser = chip::Mdns::ServiceAdvertiser::Instance(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is inside
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its actually chip::app::Mdns so I don't think these can be removed |
||||||
return mdnsAdvertiser.GetCommissionableInstanceName(buffer, bufferLen); | ||||||
} | ||||||
|
||||||
/// Set MDNS operational advertisement | ||||||
CHIP_ERROR AdvertiseOperational() | ||||||
{ | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,9 @@ void StartServer(); | |
|
||
CHIP_ERROR GenerateRotatingDeviceId(char rotatingDeviceIdHexBuffer[], size_t rotatingDeviceIdHexBufferSize); | ||
|
||
/// Generates the (random) instance name that a CHIP device is to use for pre-commissioning DNS-SD | ||
CHIP_ERROR GetCommissionableInstanceName(char * buffer, size_t bufferLen); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a followup, we should change this API to take a |
||
|
||
} // namespace Mdns | ||
} // namespace app | ||
} // namespace chip |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -252,7 +252,7 @@ CHIP_ERROR pychip_DeviceController_ConnectIP(chip::Controller::DeviceCommissione | |||||
|
||||||
CHIP_ERROR pychip_DeviceController_DiscoverAllCommissionableNodes(chip::Controller::DeviceCommissioner * devCtrl) | ||||||
{ | ||||||
Mdns::DiscoveryFilter filter(Mdns::DiscoveryFilterType::kNone, 0); | ||||||
Mdns::DiscoveryFilter filter(Mdns::DiscoveryFilterType::kNone, (uint16_t) 0); | ||||||
woody-apple marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return devCtrl->DiscoverCommissionableNodes(filter); | ||||||
} | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -25,6 +25,7 @@ | |||||
#include <core/PeerId.h> | ||||||
#include <inet/InetLayer.h> | ||||||
#include <lib/support/Span.h> | ||||||
#include <support/CHIPMemString.h> | ||||||
|
||||||
namespace chip { | ||||||
namespace Mdns { | ||||||
|
@@ -179,34 +180,55 @@ class CommissionAdvertisingParameters : public BaseAdvertisingParams<CommissionA | |||||
{ | ||||||
if (deviceName.HasValue()) | ||||||
{ | ||||||
strncpy(sDeviceName, deviceName.Value(), min(strlen(deviceName.Value()) + 1, sizeof(sDeviceName))); | ||||||
mDeviceName = Optional<const char *>::Value(static_cast<const char *>(sDeviceName)); | ||||||
chip::Platform::CopyString(mDeviceName, sizeof(mDeviceName), deviceName.Value()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
mDeviceNameHasValue = true; | ||||||
} | ||||||
else | ||||||
{ | ||||||
mDeviceNameHasValue = false; | ||||||
} | ||||||
return *this; | ||||||
} | ||||||
Optional<const char *> GetDeviceName() const { return mDeviceName; } | ||||||
Optional<const char *> GetDeviceName() const | ||||||
{ | ||||||
return mDeviceNameHasValue ? Optional<const char *>::Value(mDeviceName) : Optional<const char *>::Missing(); | ||||||
} | ||||||
|
||||||
CommissionAdvertisingParameters & SetRotatingId(Optional<const char *> rotatingId) | ||||||
{ | ||||||
if (rotatingId.HasValue()) | ||||||
{ | ||||||
strncpy(sRotatingId, rotatingId.Value(), min(strlen(rotatingId.Value()) + 1, sizeof(sRotatingId))); | ||||||
mRotatingId = Optional<const char *>::Value(static_cast<const char *>(sRotatingId)); | ||||||
chip::Platform::CopyString(mRotatingId, sizeof(mRotatingId), rotatingId.Value()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
mRotatingIdHasValue = true; | ||||||
} | ||||||
else | ||||||
{ | ||||||
mRotatingIdHasValue = false; | ||||||
} | ||||||
return *this; | ||||||
} | ||||||
Optional<const char *> GetRotatingId() const { return mRotatingId; } | ||||||
Optional<const char *> GetRotatingId() const | ||||||
{ | ||||||
return mRotatingIdHasValue ? Optional<const char *>::Value(mRotatingId) : Optional<const char *>::Missing(); | ||||||
} | ||||||
|
||||||
CommissionAdvertisingParameters & SetPairingInstr(Optional<const char *> pairingInstr) | ||||||
{ | ||||||
if (pairingInstr.HasValue()) | ||||||
{ | ||||||
strncpy(sPairingInstr, pairingInstr.Value(), min(strlen(pairingInstr.Value()) + 1, sizeof(sPairingInstr))); | ||||||
mPairingInstr = Optional<const char *>::Value(static_cast<const char *>(sPairingInstr)); | ||||||
chip::Platform::CopyString(mPairingInstr, sizeof(mPairingInstr), pairingInstr.Value()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
mPairingInstrHasValue = true; | ||||||
} | ||||||
else | ||||||
{ | ||||||
mPairingInstrHasValue = false; | ||||||
} | ||||||
return *this; | ||||||
} | ||||||
Optional<const char *> GetPairingInstr() const { return mPairingInstr; } | ||||||
Optional<const char *> GetPairingInstr() const | ||||||
{ | ||||||
return mPairingInstrHasValue ? Optional<const char *>::Value(mPairingInstr) : Optional<const char *>::Missing(); | ||||||
} | ||||||
|
||||||
CommissionAdvertisingParameters & SetPairingHint(Optional<uint16_t> pairingHint) | ||||||
{ | ||||||
|
@@ -233,14 +255,14 @@ class CommissionAdvertisingParameters : public BaseAdvertisingParams<CommissionA | |||||
chip::Optional<uint16_t> mDeviceType; | ||||||
chip::Optional<uint16_t> mPairingHint; | ||||||
|
||||||
char sDeviceName[kKeyDeviceNameMaxLength + 1]; | ||||||
chip::Optional<const char *> mDeviceName; | ||||||
char mDeviceName[kKeyDeviceNameMaxLength + 1]; | ||||||
bool mDeviceNameHasValue = false; | ||||||
|
||||||
char sRotatingId[kKeyRotatingIdMaxLength + 1]; | ||||||
chip::Optional<const char *> mRotatingId; | ||||||
char mRotatingId[kKeyRotatingIdMaxLength + 1]; | ||||||
bool mRotatingIdHasValue = false; | ||||||
|
||||||
char sPairingInstr[kKeyPairingInstructionMaxLength + 1]; | ||||||
chip::Optional<const char *> mPairingInstr; | ||||||
char mPairingInstr[kKeyPairingInstructionMaxLength + 1]; | ||||||
bool mPairingInstrHasValue = false; | ||||||
}; | ||||||
|
||||||
/// Handles advertising of CHIP nodes | ||||||
|
@@ -264,6 +286,9 @@ class ServiceAdvertiser | |||||
|
||||||
/// Provides the system-wide implementation of the service advertiser | ||||||
static ServiceAdvertiser & Instance(); | ||||||
|
||||||
/// Returns DNS-SD instance name formatted as hex string | ||||||
virtual CHIP_ERROR GetCommissionableInstanceName(char * instanceName, size_t maxLength) = 0; | ||||||
}; | ||||||
|
||||||
} // namespace Mdns | ||||||
|
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.
This whole file is
using namespace chip
, so I'd think you don't need thechip::
prefix on all of these...