-
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 2 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 |
---|---|---|
|
@@ -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 | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,13 +52,16 @@ struct ResolvedNodeData | |
constexpr size_t kMaxDeviceNameLen = 32; | ||
constexpr size_t kMaxRotatingIdLen = 50; | ||
constexpr size_t kMaxPairingInstructionLen = 128; | ||
|
||
// Largest host name is 64-bits in hex. | ||
static constexpr int kMaxHostNameSize = 16; | ||
static constexpr int kMaxInstanceNameSize = 16; | ||
struct DiscoveredNodeData | ||
{ | ||
// TODO(cecille): is 4 OK? IPv6 LL, GUA, ULA, IPv4? | ||
static constexpr int kMaxIPAddresses = 5; | ||
// Largest host name is 64-bits in hex. | ||
static constexpr int kHostNameSize = 16; | ||
char hostName[kHostNameSize + 1]; | ||
char hostName[kMaxHostNameSize + 1]; | ||
char instanceName[kMaxInstanceNameSize + 1]; | ||
uint16_t longDiscriminator; | ||
uint16_t vendorId; | ||
uint16_t productId; | ||
|
@@ -76,6 +79,7 @@ struct DiscoveredNodeData | |
void Reset() | ||
{ | ||
memset(hostName, 0, sizeof(hostName)); | ||
memset(instanceName, 0, sizeof(instanceName)); | ||
longDiscriminator = 0; | ||
vendorId = 0; | ||
productId = 0; | ||
|
@@ -107,14 +111,17 @@ enum class DiscoveryFilterType : uint8_t | |
kDeviceType, | ||
kCommissioningMode, | ||
kCommissioningModeFromCommand, | ||
kInstanceName, | ||
kCommissioner | ||
}; | ||
struct DiscoveryFilter | ||
{ | ||
DiscoveryFilterType type; | ||
uint16_t code; | ||
char * instanceName; | ||
DiscoveryFilter() : type(DiscoveryFilterType::kNone), code(0) {} | ||
DiscoveryFilter(DiscoveryFilterType newType, uint16_t newCode) : type(newType), code(newCode) {} | ||
DiscoveryFilter(DiscoveryFilterType newType, char * newInstanceName) : type(newType), instanceName(newInstanceName) {} | ||
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. Oh, one more question. Should |
||
}; | ||
enum class DiscoveryType | ||
{ | ||
|
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 is inside
namespace Mdns {
, so you shouldn't need all the prefixing.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.
its actually chip::app::Mdns so I don't think these can be removed