Skip to content

Commit

Permalink
Darwin: Improve CommissioningType naming (project-chip#35209)
Browse files Browse the repository at this point in the history
* Darwin: Improve CommissioningType naming

* Restore WaitForCommissioneeCommand behavior to always use CASE
  • Loading branch information
ksperling-apple authored and shgutte committed Sep 10, 2024
1 parent a627a8f commit 052eb38
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@

CHIP_ERROR WaitForCommissioneeCommand::RunCommand()
{
auto * base_device = BaseDeviceWithNodeId(mNodeId);
MTRDeviceController * commissioner = CurrentCommissioner();
VerifyOrReturnError(nil != commissioner, CHIP_ERROR_INCORRECT_STATE);

auto * base_device = [MTRBaseDevice deviceWithNodeID:@(mNodeId) controller:commissioner];
VerifyOrReturnError(base_device != nil, CHIP_ERROR_INCORRECT_STATE);

if (mExpireExistingSession.ValueOr(true)) {
Expand Down
16 changes: 8 additions & 8 deletions examples/darwin-framework-tool/commands/pairing/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
class PairCode : public PairingCommandBridge
{
public:
PairCode() : PairingCommandBridge("code", PairingMode::Code, CommissioningType::NoNetwork) {}
PairCode() : PairingCommandBridge("code", PairingMode::Code, CommissioningType::WithoutNetwork) {}
};

class PairCodePASEOnly : public PairingCommandBridge
Expand All @@ -40,32 +40,32 @@ class PairCodePASEOnly : public PairingCommandBridge
class PairCodeWifi : public PairingCommandBridge
{
public:
PairCodeWifi() : PairingCommandBridge("code-wifi", PairingMode::Code, CommissioningType::WiFi) {}
PairCodeWifi() : PairingCommandBridge("code-wifi", PairingMode::Code, CommissioningType::WithWiFi) {}
};

class PairCodeThread : public PairingCommandBridge
{
public:
PairCodeThread() : PairingCommandBridge("code-thread", PairingMode::Code, CommissioningType::Thread) {}
PairCodeThread() : PairingCommandBridge("code-thread", PairingMode::Code, CommissioningType::WithThread) {}
};

class PairBleWiFi : public PairingCommandBridge
{
public:
PairBleWiFi() : PairingCommandBridge("ble-wifi", PairingMode::Ble, CommissioningType::WiFi) {}
PairBleWiFi() : PairingCommandBridge("ble-wifi", PairingMode::Ble, CommissioningType::WithWiFi) {}
};

class PairBleThread : public PairingCommandBridge
{
public:
PairBleThread() : PairingCommandBridge("ble-thread", PairingMode::Ble, CommissioningType::Thread) {}
PairBleThread() : PairingCommandBridge("ble-thread", PairingMode::Ble, CommissioningType::WithThread) {}
};

class PairAlreadyDiscoveredByIndex : public PairingCommandBridge
{
public:
PairAlreadyDiscoveredByIndex() :
PairingCommandBridge("by-index", PairingMode::AlreadyDiscoveredByIndex, CommissioningType::NoNetwork)
PairingCommandBridge("by-index", PairingMode::AlreadyDiscoveredByIndex, CommissioningType::WithoutNetwork)
{}
};

Expand All @@ -81,15 +81,15 @@ class PairAlreadyDiscoveredByIndexWithWiFi : public PairingCommandBridge
{
public:
PairAlreadyDiscoveredByIndexWithWiFi() :
PairingCommandBridge("by-index-with-wifi", PairingMode::AlreadyDiscoveredByIndex, CommissioningType::WiFi)
PairingCommandBridge("by-index-with-wifi", PairingMode::AlreadyDiscoveredByIndex, CommissioningType::WithWiFi)
{}
};

class PairAlreadyDiscoveredByIndexWithThread : public PairingCommandBridge
{
public:
PairAlreadyDiscoveredByIndexWithThread() :
PairingCommandBridge("by-index-with-thread", PairingMode::AlreadyDiscoveredByIndex, CommissioningType::Thread)
PairingCommandBridge("by-index-with-thread", PairingMode::AlreadyDiscoveredByIndex, CommissioningType::WithThread)
{}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ enum class PairingMode

enum class CommissioningType
{
None, // establish PASE only
NoNetwork,
WiFi,
Thread,
Ethernet,
None, // establish PASE only
WithoutNetwork, // commission but don't configure network
WithWiFi, // commission and configure WiFi
WithThread, // commission and configure Thread
};

class PairingCommandBridge : public CHIPCommandBridge
Expand All @@ -47,14 +46,13 @@ class PairingCommandBridge : public CHIPCommandBridge
switch (commissioningType)
{
case CommissioningType::None:
case CommissioningType::NoNetwork:
case CommissioningType::Ethernet:
case CommissioningType::WithoutNetwork:
break;
case CommissioningType::WiFi:
case CommissioningType::WithWiFi:
AddArgument("ssid", &mSSID);
AddArgument("password", &mPassword);
break;
case CommissioningType::Thread:
case CommissioningType::WithThread:
AddArgument("operationalDataset", &mOperationalDataset);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ - (void)deviceAttestationCompletedForController:(MTRDeviceController *)controlle
MTRCommissioningParameters * params = [[MTRCommissioningParameters alloc] init];
switch (mCommissioningType) {
case CommissioningType::None:
case CommissioningType::NoNetwork:
case CommissioningType::Ethernet:
case CommissioningType::WithoutNetwork:
break;
case CommissioningType::WiFi:
case CommissioningType::WithWiFi:
[params setWifiSSID:[NSData dataWithBytes:mSSID.data() length:mSSID.size()]];
[params setWifiCredentials:[NSData dataWithBytes:mPassword.data() length:mPassword.size()]];
break;
case CommissioningType::Thread:
case CommissioningType::WithThread:
[params setThreadOperationalDataset:[NSData dataWithBytes:mOperationalDataset.data() length:mOperationalDataset.size()]];
break;
}
Expand Down

0 comments on commit 052eb38

Please sign in to comment.