Skip to content

Commit

Permalink
Allow Darwin frawework to commission onto a password-less WiFi networ…
Browse files Browse the repository at this point in the history
…k. (#21363)

We were requiring a WiFi password in order to provide the WiFi SSID to
the underlying SDK.  But not all networks have a password.
  • Loading branch information
bzbarsky-apple authored Jul 29, 2022
1 parent 0d24af5 commit 78fc5ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
7 changes: 4 additions & 3 deletions src/darwin/Framework/CHIP/MTRCommissioningParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, copy, nullable) NSData * attestationNonce;
/**
* The Wi-Fi SSID
* The Wi-Fi SSID, if available.
*/
@property (nonatomic, copy, nullable) NSData * wifiSSID;
/**
* The Wi-Fi Credentials
* The Wi-Fi Credentials. Allowed to be nil or 0-length data for an open
* network, as long as wifiSSID is not nil.
*/
@property (nonatomic, copy, nullable) NSData * wifiCredentials;
/**
* The Thread operational dataset
* The Thread operational dataset, if available.
*/
@property (nonatomic, copy, nullable) NSData * threadOperationalDataset;
/**
Expand Down
18 changes: 9 additions & 9 deletions src/darwin/Framework/CHIP/MTRDeviceController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -405,20 +405,20 @@ - (BOOL)commissionDevice:(uint64_t)deviceId

chip::Controller::CommissioningParameters params;
if (commissioningParams.CSRNonce) {
params.SetCSRNonce(chip::ByteSpan((uint8_t *) commissioningParams.CSRNonce.bytes, commissioningParams.CSRNonce.length));
params.SetCSRNonce(AsByteSpan(commissioningParams.CSRNonce));
}
if (commissioningParams.attestationNonce) {
params.SetAttestationNonce(chip::ByteSpan(
(uint8_t *) commissioningParams.attestationNonce.bytes, commissioningParams.attestationNonce.length));
params.SetAttestationNonce(AsByteSpan(commissioningParams.attestationNonce));
}
if (commissioningParams.threadOperationalDataset) {
params.SetThreadOperationalDataset(chip::ByteSpan((uint8_t *) commissioningParams.threadOperationalDataset.bytes,
commissioningParams.threadOperationalDataset.length));
params.SetThreadOperationalDataset(AsByteSpan(commissioningParams.threadOperationalDataset));
}
if (commissioningParams.wifiSSID && commissioningParams.wifiCredentials) {
chip::ByteSpan ssid((uint8_t *) commissioningParams.wifiSSID.bytes, commissioningParams.wifiSSID.length);
chip::ByteSpan credentials(
(uint8_t *) commissioningParams.wifiCredentials.bytes, commissioningParams.wifiCredentials.length);
if (commissioningParams.wifiSSID) {
chip::ByteSpan ssid = AsByteSpan(commissioningParams.wifiSSID);
chip::ByteSpan credentials;
if (commissioningParams.wifiCredentials != nil) {
credentials = AsByteSpan(commissioningParams.wifiCredentials);
}
chip::Controller::WiFiCredentials wifiCreds(ssid, credentials);
params.SetWiFiCredentials(wifiCreds);
}
Expand Down

0 comments on commit 78fc5ca

Please sign in to comment.