From 17991843c0aadea0e8cdd592a799aa0436b4931b Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Wed, 8 Feb 2023 21:16:40 -0800 Subject: [PATCH] [chip-tool] Add pairing already-discovered command (#24917) * [chip-tool] Add pairing already-discovered command * Address review comments * Use PairingNetworkType::None instead of PairingNetworkType::Network --- examples/chip-tool/commands/pairing/Commands.h | 9 +++++++++ examples/chip-tool/commands/pairing/PairingCommand.cpp | 3 +++ examples/chip-tool/commands/pairing/PairingCommand.h | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/examples/chip-tool/commands/pairing/Commands.h b/examples/chip-tool/commands/pairing/Commands.h index 25ddf5dd5a2593..4ac57177bf806f 100644 --- a/examples/chip-tool/commands/pairing/Commands.h +++ b/examples/chip-tool/commands/pairing/Commands.h @@ -173,6 +173,14 @@ class PairSoftAP : public PairingCommand {} }; +class PairAlreadyDiscovered : public PairingCommand +{ +public: + PairAlreadyDiscovered(CredentialIssuerCommands * credsIssuerConfig) : + PairingCommand("already-discovered", PairingMode::AlreadyDiscovered, PairingNetworkType::None, credsIssuerConfig) + {} +}; + class StartUdcServerCommand : public CHIPCommand { public: @@ -199,6 +207,7 @@ void registerCommandsPairing(Commands & commands, CredentialIssuerCommands * cre make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), diff --git a/examples/chip-tool/commands/pairing/PairingCommand.cpp b/examples/chip-tool/commands/pairing/PairingCommand.cpp index 1c64a872371c26..c0cefcd3420af3 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.cpp +++ b/examples/chip-tool/commands/pairing/PairingCommand.cpp @@ -75,6 +75,9 @@ CHIP_ERROR PairingCommand::RunInternal(NodeId remoteId) case PairingMode::SoftAP: err = Pair(remoteId, PeerAddress::UDP(mRemoteAddr.address, mRemotePort, mRemoteAddr.interfaceId)); break; + case PairingMode::AlreadyDiscovered: + err = Pair(remoteId, PeerAddress::UDP(mRemoteAddr.address, mRemotePort, mRemoteAddr.interfaceId)); + break; } return err; diff --git a/examples/chip-tool/commands/pairing/PairingCommand.h b/examples/chip-tool/commands/pairing/PairingCommand.h index 0f8dbf4ad5fa71..516d5f68b56110 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.h +++ b/examples/chip-tool/commands/pairing/PairingCommand.h @@ -34,6 +34,7 @@ enum class PairingMode CodePaseOnly, Ble, SoftAP, + AlreadyDiscovered, OnNetwork, }; @@ -106,6 +107,13 @@ class PairingCommand : public CHIPCommand, AddArgument("device-remote-port", 0, UINT16_MAX, &mRemotePort); AddArgument("pase-only", 0, 1, &mPaseOnly); break; + case PairingMode::AlreadyDiscovered: + AddArgument("skip-commissioning-complete", 0, 1, &mSkipCommissioningComplete); + AddArgument("setup-pin-code", 0, 134217727, &mSetupPINCode); + AddArgument("device-remote-ip", &mRemoteAddr); + AddArgument("device-remote-port", 0, UINT16_MAX, &mRemotePort); + AddArgument("pase-only", 0, 1, &mPaseOnly); + break; } switch (filterType)