Skip to content
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

Add OnNetwork pairing command to chip-tool #6309

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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