Skip to content

Commit

Permalink
Add OnNetwork pairing command to chip-tool (#6309)
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple authored and pull[bot] committed Jun 7, 2021
1 parent 6a7cc4d commit 2eeb8b8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
10 changes: 8 additions & 2 deletions examples/chip-tool/commands/pairing/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ class PairBypass : public PairingCommand
PairBypass() : PairingCommand("bypass", PairingMode::Bypass, PairingNetworkType::None) {}
};

class PairOnNetwork : public PairingCommand
{
public:
PairOnNetwork() : PairingCommand("onnetwork", PairingMode::OnNetwork, PairingNetworkType::None) {}
};

class PairBleWiFi : public PairingCommand
{
public:
Expand Down Expand Up @@ -61,8 +67,8 @@ void registerCommandsPairing(Commands & commands)
const char * clusterName = "Pairing";

commands_list clusterCommands = {
make_unique<Unpair>(), make_unique<PairBypass>(), make_unique<PairBleWiFi>(),
make_unique<PairBleThread>(), make_unique<PairSoftAP>(), make_unique<Ethernet>(),
make_unique<Unpair>(), make_unique<PairBypass>(), make_unique<PairBleWiFi>(), make_unique<PairBleThread>(),
make_unique<PairSoftAP>(), make_unique<Ethernet>(), make_unique<PairOnNetwork>(),
};

commands.Register(clusterName, clusterCommands);
Expand Down
4 changes: 4 additions & 0 deletions examples/chip-tool/commands/pairing/PairingCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ CHIP_ERROR PairingCommand::Run(PersistentStorage & storage, NodeId localId, Node
.mDeviceAddressUpdateDelegate = this,
};

err = mCommissioner.SetUdpListenPort(storage.GetListenPort());
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init failure! Commissioner: %s", ErrorStr(err)));

err = mCommissioner.Init(localId, params, this);
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init failure! Commissioner: %s", ErrorStr(err)));

Expand Down Expand Up @@ -70,6 +73,7 @@ CHIP_ERROR PairingCommand::RunInternal(NodeId remoteId)
case PairingMode::Ble:
err = Pair(remoteId, PeerAddress::BLE());
break;
case PairingMode::OnNetwork:
case PairingMode::SoftAP:
err = Pair(remoteId, PeerAddress::UDP(mRemoteAddr.address, mRemotePort));
break;
Expand Down
2 changes: 2 additions & 0 deletions examples/chip-tool/commands/pairing/PairingCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum class PairingMode
Ble,
SoftAP,
Ethernet,
OnNetwork,
};

enum class PairingNetworkType
Expand Down Expand Up @@ -75,6 +76,7 @@ class PairingCommand : public Command,
AddArgument("setup-pin-code", 0, 134217727, &mSetupPINCode);
AddArgument("discriminator", 0, 4096, &mDiscriminator);
break;
case PairingMode::OnNetwork:
case PairingMode::SoftAP:
AddArgument("fabric-id", 0, UINT64_MAX, &mFabricId);
AddArgument("setup-pin-code", 0, 134217727, &mSetupPINCode);
Expand Down
5 changes: 5 additions & 0 deletions src/app/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,11 @@ void InitServer(AppDelegate * delegate)
InitDataModelHandler();
gCallbacks.SetDelegate(delegate);

#if CHIP_DEVICE_LAYER_TARGET_DARWIN
err = PersistedStorage::KeyValueStoreMgrImpl().Init("chip.store");
SuccessOrExit(err);
#endif

err = gRendezvousServer.Init(delegate, &gServerStorage);
SuccessOrExit(err);

Expand Down

0 comments on commit 2eeb8b8

Please sign in to comment.