Skip to content

Commit 085f57f

Browse files
crlonxprestyled-commitsbzbarsky-appleksperling-apple
authored
Add --wifipaf commission in chip-tool and apps of Linux platform (#33977)
* [NXP] Add --wifi-paf commission in chip-tool and apps of Linux platform * Need to enable the function by adding "chip_device_config_enable_wifipaf=true" * chip-tool: Add wifi-paf option for pairing. Example: $ chip-tool pairing wifi-paf 1 ap_ssid ap_pwd [setup-pin-code] [discriminator] * apps: Add --wifi-paf. Example: $ chip-all-clusters-app --wifi --wifi-paf Note: Need the usd functions of wpa_supplicant to run this option Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com> * Restyled by clang-format * Restyled by gn * * Add the missing compile macro * Restyled by clang-format * Update src/controller/CHIPDeviceController.cpp Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Update src/include/platform/ConnectivityManager.h Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Update examples/platform/linux/Options.cpp Co-authored-by: Karsten Sperling <113487422+ksperling-apple@users.noreply.github.com> * Change by following the review's comment: * Change the name of option to [pair_mode]-[network] * Remove redundant compile flags * Move to start the Wi-Fi Manager in initialization stage * Unconditional the defintion * Add the cancel-publish / cancel-subscribe dbus interface * Fix bugs: - Redundant callback function registration - Remove the incorrect StackLock Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com> * Restyled by clang-format * Change by following the review's comment: - Unconditional functions in SetUpCodePairer - Change the description of the comment Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com> * * Add the identifier to distinguish connections * Unconditional the SetupCode verification Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com> * Restyled by clang-format * Add RendezvousInformationFlag::kWiFiPAF to tests of TestQRCode Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com> * Restyled by clang-format * * Add code-wifi to do WiFiPAF by using code. example: - Linux DUT: sudo ./chip-all-clusters-app --wifi --wifipaf - Controller: sudo ./chip-tool pairing code-wifi 1 ap_ssid ap_pwd MT:-24J0SGJ10KA0648G00 Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com> * Restyled by clang-format * Update src/transport/raw/PeerAddress.h Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Update examples/chip-tool/commands/payload/SetupPayloadParseCommand.cpp Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Update src/include/platform/CHIPDeviceConfig.h Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Change by following the review's comment: * Add to end of the queue in OnDiscoveredDeviceOverWifiPAF() * Factor out the long expression into local Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com> * Remove the redundant LogErrorOnFailure() Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com> * Restyled by clang-format * Use the smart pointer to detect if the caller is still valid in the callback function Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com> * Fix the building error after rebase to TOT of master branch Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com> * Change the dbus interface usage by following the new api update in wpa_supplicant Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com> * Restyled by clang-format * * Add freq_list option to support multiple channels * Add more tests in QRCode test Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com> * Restyled by clang-format * * Change to have the consistent naming of the new added variables * Fix the problem to add tests in TestQRCode.cpp * Use a list to track the validation of the caller object. Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com> * Restyled by clang-format * Cancel the subscription in destructor to avoid the use-after-free issue Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com> * Restyled by clang-format --------- Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com> Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> Co-authored-by: Karsten Sperling <113487422+ksperling-apple@users.noreply.github.com>
1 parent 7b488ed commit 085f57f

34 files changed

+1078
-14
lines changed

examples/chip-tool/commands/pairing/Commands.h

+13
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,16 @@ class PairSoftAP : public PairingCommand
181181
{}
182182
};
183183

184+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
185+
class PairWiFiPAF : public PairingCommand
186+
{
187+
public:
188+
PairWiFiPAF(CredentialIssuerCommands * credsIssuerConfig) :
189+
PairingCommand("wifipaf-wifi", PairingMode::WiFiPAF, PairingNetworkType::WiFi, credsIssuerConfig)
190+
{}
191+
};
192+
#endif
193+
184194
class PairAlreadyDiscovered : public PairingCommand
185195
{
186196
public:
@@ -243,6 +253,9 @@ void registerCommandsPairing(Commands & commands, CredentialIssuerCommands * cre
243253
make_unique<PairBleWiFi>(credsIssuerConfig),
244254
make_unique<PairBleThread>(credsIssuerConfig),
245255
make_unique<PairSoftAP>(credsIssuerConfig),
256+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
257+
make_unique<PairWiFiPAF>(credsIssuerConfig),
258+
#endif
246259
make_unique<PairAlreadyDiscovered>(credsIssuerConfig),
247260
make_unique<PairAlreadyDiscoveredByIndex>(credsIssuerConfig),
248261
make_unique<PairAlreadyDiscoveredByIndexWithWiFi>(credsIssuerConfig),

examples/chip-tool/commands/pairing/PairingCommand.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ CHIP_ERROR PairingCommand::RunInternal(NodeId remoteId)
8080
case PairingMode::SoftAP:
8181
err = Pair(remoteId, PeerAddress::UDP(mRemoteAddr.address, mRemotePort, mRemoteAddr.interfaceId));
8282
break;
83+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
84+
case PairingMode::WiFiPAF:
85+
err = Pair(remoteId, PeerAddress::WiFiPAF(remoteId));
86+
break;
87+
#endif
8388
case PairingMode::AlreadyDiscovered:
8489
err = Pair(remoteId, PeerAddress::UDP(mRemoteAddr.address, mRemotePort, mRemoteAddr.interfaceId));
8590
break;

examples/chip-tool/commands/pairing/PairingCommand.h

+10
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ enum class PairingMode
3535
CodePaseOnly,
3636
Ble,
3737
SoftAP,
38+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
39+
WiFiPAF,
40+
#endif
3841
AlreadyDiscovered,
3942
AlreadyDiscoveredByIndex,
4043
AlreadyDiscoveredByIndexWithCode,
@@ -127,6 +130,13 @@ class PairingCommand : public CHIPCommand,
127130
AddArgument("device-remote-port", 0, UINT16_MAX, &mRemotePort);
128131
AddArgument("pase-only", 0, 1, &mPaseOnly);
129132
break;
133+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
134+
case PairingMode::WiFiPAF:
135+
AddArgument("skip-commissioning-complete", 0, 1, &mSkipCommissioningComplete);
136+
AddArgument("setup-pin-code", 0, 134217727, &mSetupPINCode.emplace());
137+
AddArgument("discriminator", 0, 4096, &mDiscriminator.emplace());
138+
break;
139+
#endif
130140
case PairingMode::AlreadyDiscovered:
131141
AddArgument("skip-commissioning-complete", 0, 1, &mSkipCommissioningComplete);
132142
AddArgument("setup-pin-code", 0, 134217727, &mSetupPINCode.emplace());

examples/chip-tool/commands/payload/SetupPayloadParseCommand.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ CHIP_ERROR SetupPayloadParseCommand::Print(chip::SetupPayload payload)
108108
}
109109
humanFlags.Add("On IP network");
110110
}
111+
if (payload.rendezvousInformation.Value().Has(RendezvousInformationFlag::kWiFiPAF))
112+
{
113+
if (!humanFlags.Empty())
114+
{
115+
humanFlags.Add(", ");
116+
}
117+
humanFlags.Add("Wi-Fi PAF");
118+
}
111119
}
112120
else
113121
{

examples/platform/linux/AppMain.cpp

+18-1
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,15 @@ int ChipLinuxAppInit(int argc, char * const argv[], OptionSet * customOptions,
367367
#if CONFIG_NETWORK_LAYER_BLE
368368
RendezvousInformationFlags rendezvousFlags = RendezvousInformationFlag::kBLE;
369369
#else // CONFIG_NETWORK_LAYER_BLE
370-
RendezvousInformationFlag rendezvousFlags = RendezvousInformationFlag::kOnNetwork;
370+
RendezvousInformationFlags rendezvousFlags = RendezvousInformationFlag::kOnNetwork;
371371
#endif // CONFIG_NETWORK_LAYER_BLE
372372

373373
#ifdef CONFIG_RENDEZVOUS_MODE
374374
rendezvousFlags = static_cast<RendezvousInformationFlags>(CONFIG_RENDEZVOUS_MODE);
375375
#endif
376+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
377+
rendezvousFlags.Set(RendezvousInformationFlag::kWiFiPAF);
378+
#endif
376379

377380
err = Platform::MemoryInit();
378381
SuccessOrExit(err);
@@ -471,6 +474,20 @@ int ChipLinuxAppInit(int argc, char * const argv[], OptionSet * customOptions,
471474
}
472475
}
473476
#endif // CHIP_DEVICE_CONFIG_ENABLE_WPA
477+
#if CHIP_DEVICE_CONFIG_ENABLE_WPA && CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
478+
ChipLogProgress(NotSpecified, "WiFi-PAF: initialzing");
479+
if (LinuxDeviceOptions::GetInstance().mWiFi)
480+
{
481+
if (EnsureWiFiIsStarted())
482+
{
483+
ChipLogProgress(NotSpecified, "Wi-Fi Management started");
484+
DeviceLayer::ConnectivityManager::WiFiPAFAdvertiseParam args;
485+
args.enable = LinuxDeviceOptions::GetInstance().mWiFiPAF;
486+
args.ExtCmds = LinuxDeviceOptions::GetInstance().mWiFiPAFExtCmds;
487+
DeviceLayer::ConnectivityMgr().SetWiFiPAFAdvertisingEnabled(args);
488+
}
489+
}
490+
#endif
474491

475492
#if CHIP_ENABLE_OPENTHREAD
476493
if (LinuxDeviceOptions::GetInstance().mThread)

examples/platform/linux/Options.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ enum
106106
#if CHIP_WITH_NLFAULTINJECTION
107107
kDeviceOption_FaultInjection,
108108
#endif
109+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
110+
kDeviceOption_WiFi_PAF,
111+
#endif
109112
};
110113

111114
constexpr unsigned kAppUsageLength = 64;
@@ -117,6 +120,9 @@ OptionDef sDeviceOptionDefs[] = {
117120
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
118121
{ "wifi", kNoArgument, kDeviceOption_WiFi },
119122
{ "wifi-supports-5g", kNoArgument, kDeviceOption_WiFiSupports5g },
123+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
124+
{ "wifipaf", kArgumentRequired, kDeviceOption_WiFi_PAF },
125+
#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
120126
#endif // CHIP_DEVICE_CONFIG_ENABLE_WPA
121127
#if CHIP_ENABLE_OPENTHREAD
122128
{ "thread", kNoArgument, kDeviceOption_Thread },
@@ -189,6 +195,12 @@ const char * sDeviceOptionHelp =
189195
" --wifi-supports-5g\n"
190196
" Indicate that local Wi-Fi hardware should report 5GHz support.\n"
191197
#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI
198+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
199+
"\n"
200+
" --wifipaf freq_list=<freq_1>,<freq_2>... \n"
201+
" Enable Wi-Fi PAF via wpa_supplicant.\n"
202+
" Give an empty string if not setting freq_list: \"\"\n"
203+
#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFIPAFs
192204
#if CHIP_ENABLE_OPENTHREAD
193205
"\n"
194206
" --thread\n"
@@ -588,6 +600,13 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier,
588600
}
589601
break;
590602
}
603+
#endif
604+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
605+
case kDeviceOption_WiFi_PAF: {
606+
LinuxDeviceOptions::GetInstance().mWiFiPAF = true;
607+
LinuxDeviceOptions::GetInstance().mWiFiPAFExtCmds = aValue;
608+
break;
609+
}
591610
#endif
592611
default:
593612
PrintArgError("%s: INTERNAL ERROR: Unhandled option: %s\n", aProgram, aName);

examples/platform/linux/Options.h

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ struct LinuxDeviceOptions
4949
bool wifiSupports5g = false;
5050
bool mWiFi = false;
5151
bool mThread = false;
52+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
53+
bool mWiFiPAF = false;
54+
const char * mWiFiPAFExtCmds = nullptr;
55+
#endif
5256
#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE || CHIP_DEVICE_ENABLE_PORT_PARAMS
5357
uint16_t securedDevicePort = CHIP_PORT;
5458
uint16_t unsecuredCommissionerPort = CHIP_UDC_PORT;

src/app/server/CommissioningWindowManager.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ void CommissioningWindowManager::OnPlatformEvent(const DeviceLayer::ChipDeviceEv
7171
#if CONFIG_NETWORK_LAYER_BLE && CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION
7272
// If in NonConcurrentConnection, this will already have been completed
7373
mServer->GetBleLayerObject()->CloseAllBleConnections();
74+
#endif
75+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
76+
DeviceLayer::ConnectivityManager::WiFiPAFAdvertiseParam args;
77+
args.enable = false;
78+
args.ExtCmds = nullptr;
79+
DeviceLayer::ConnectivityMgr().SetWiFiPAFAdvertisingEnabled(args);
7480
#endif
7581
}
7682
else if (event->Type == DeviceLayer::DeviceEventType::kFailSafeTimerExpired)

src/app/server/Server.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
#include <system/TLVPacketBufferBackingStore.h>
5757
#include <transport/SessionManager.h>
5858

59+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
60+
#include <transport/raw/WiFiPAF.h>
61+
#endif
62+
5963
#if defined(CHIP_SUPPORT_ENABLE_STORAGE_API_AUDIT) || defined(CHIP_SUPPORT_ENABLE_STORAGE_LOAD_TEST_AUDIT)
6064
#include <lib/support/PersistentStorageAudit.h>
6165
#endif // defined(CHIP_SUPPORT_ENABLE_STORAGE_API_AUDIT) || defined(CHIP_SUPPORT_ENABLE_STORAGE_LOAD_TEST_AUDIT)
@@ -214,6 +218,10 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
214218
TcpListenParameters(DeviceLayer::TCPEndPointManager())
215219
.SetAddressType(IPAddressType::kIPv6)
216220
.SetListenPort(mOperationalServicePort)
221+
#endif
222+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
223+
,
224+
Transport::WiFiPAFListenParameters(DeviceLayer::ConnectivityMgr().GetWiFiPAF())
217225
#endif
218226
);
219227

src/app/server/Server.h

+7
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
#if CONFIG_NETWORK_LAYER_BLE
6666
#include <transport/raw/BLE.h>
6767
#endif
68+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
69+
#include <transport/raw/WiFiPAF.h>
70+
#endif
6871
#include <app/TimerDelegates.h>
6972
#include <app/reporting/ReportSchedulerImpl.h>
7073
#include <transport/raw/UDP.h>
@@ -104,6 +107,10 @@ using ServerTransportMgr = chip::TransportMgr<chip::Transport::UDP
104107
#if INET_CONFIG_ENABLE_TCP_ENDPOINT
105108
,
106109
chip::Transport::TCP<kMaxTcpActiveConnectionCount, kMaxTcpPendingPackets>
110+
#endif
111+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
112+
,
113+
chip::Transport::WiFiPAFBase
107114
#endif
108115
>;
109116

src/controller/AutoCommissioner.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -590,11 +590,16 @@ CHIP_ERROR AutoCommissioner::StartCommissioning(DeviceCommissioner * commissione
590590
mStopCommissioning = false;
591591
mCommissioner = commissioner;
592592
mCommissioneeDeviceProxy = proxy;
593-
mNeedsNetworkSetup =
594-
mCommissioneeDeviceProxy->GetSecureSession().Value()->AsSecureSession()->GetPeerAddress().GetTransportType() ==
595-
Transport::Type::kBle;
593+
594+
auto transportType =
595+
mCommissioneeDeviceProxy->GetSecureSession().Value()->AsSecureSession()->GetPeerAddress().GetTransportType();
596+
mNeedsNetworkSetup = (transportType == Transport::Type::kBle);
597+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
598+
mNeedsNetworkSetup = mNeedsNetworkSetup || (transportType == Transport::Type::kWiFiPAF);
599+
#endif
596600
CHIP_ERROR err = CHIP_NO_ERROR;
597601
CommissioningStage nextStage = GetNextCommissioningStage(CommissioningStage::kSecurePairing, err);
602+
598603
mCommissioner->PerformCommissioningStep(mCommissioneeDeviceProxy, nextStage, mParams, this, GetEndpoint(nextStage),
599604
GetCommandTimeout(mCommissioneeDeviceProxy, nextStage));
600605
return CHIP_NO_ERROR;

src/controller/CHIPDeviceController.cpp

+71
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
#include <ble/Ble.h>
6767
#include <transport/raw/BLE.h>
6868
#endif
69+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
70+
#include <transport/raw/WiFiPAF.h>
71+
#endif
6972

7073
#include <errno.h>
7174
#include <inttypes.h>
@@ -466,6 +469,13 @@ DeviceCommissioner::DeviceCommissioner() :
466469
mDeviceNOCChainCallback(OnDeviceNOCChainGeneration, this), mSetUpCodePairer(this)
467470
{}
468471

472+
DeviceCommissioner::~DeviceCommissioner()
473+
{
474+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
475+
DeviceLayer::ConnectivityMgr().WiFiPAFCancelConnect();
476+
#endif
477+
}
478+
469479
CHIP_ERROR DeviceCommissioner::Init(CommissionerInitParams params)
470480
{
471481
VerifyOrReturnError(params.operationalCredentialsDelegate != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
@@ -730,6 +740,12 @@ CHIP_ERROR DeviceCommissioner::EstablishPASEConnection(NodeId remoteDeviceId, Re
730740
peerAddress = Transport::PeerAddress::UDP(params.GetPeerAddress().GetIPAddress(), params.GetPeerAddress().GetPort(),
731741
params.GetPeerAddress().GetInterface());
732742
}
743+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
744+
else if (params.GetPeerAddress().GetTransportType() == Transport::Type::kWiFiPAF)
745+
{
746+
peerAddress = Transport::PeerAddress::WiFiPAF(remoteDeviceId);
747+
}
748+
#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
733749

734750
current = FindCommissioneeDevice(peerAddress);
735751
if (current != nullptr)
@@ -804,6 +820,24 @@ CHIP_ERROR DeviceCommissioner::EstablishPASEConnection(NodeId remoteDeviceId, Re
804820
ExitNow(err = CHIP_ERROR_INVALID_ARGUMENT);
805821
}
806822
}
823+
#endif
824+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
825+
if (params.GetPeerAddress().GetTransportType() == Transport::Type::kWiFiPAF)
826+
{
827+
if (DeviceLayer::ConnectivityMgr().GetWiFiPAF()->GetWiFiPAFState() != Transport::WiFiPAFBase::State::kConnected)
828+
{
829+
ChipLogProgress(Controller, "WiFi-PAF: Subscribing the NAN-USD devices");
830+
if (!DeviceLayer::ConnectivityMgrImpl().IsWiFiManagementStarted())
831+
{
832+
ChipLogError(Controller, "Wi-Fi Management should have be started now.");
833+
ExitNow(CHIP_ERROR_INTERNAL);
834+
}
835+
mRendezvousParametersForDeviceDiscoveredOverWiFiPAF = params;
836+
DeviceLayer::ConnectivityMgr().WiFiPAFConnect(params.GetSetupDiscriminator().value(), (void *) this,
837+
OnWiFiPAFSubscribeComplete, OnWiFiPAFSubscribeError);
838+
ExitNow(CHIP_NO_ERROR);
839+
}
840+
}
807841
#endif
808842
session = mSystemState->SessionMgr()->CreateUnauthenticatedSession(params.GetPeerAddress(), params.GetMRPConfig());
809843
VerifyOrExit(session.HasValue(), err = CHIP_ERROR_NO_MEMORY);
@@ -872,6 +906,43 @@ void DeviceCommissioner::OnDiscoveredDeviceOverBleError(void * appState, CHIP_ER
872906
}
873907
#endif // CONFIG_NETWORK_LAYER_BLE
874908

909+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
910+
void DeviceCommissioner::OnWiFiPAFSubscribeComplete(void * appState)
911+
{
912+
auto self = (DeviceCommissioner *) appState;
913+
auto device = self->mDeviceInPASEEstablishment;
914+
915+
if (nullptr != device && device->GetDeviceTransportType() == Transport::Type::kWiFiPAF)
916+
{
917+
ChipLogProgress(Controller, "WiFi-PAF: Subscription Completed, dev_id = %lu", device->GetDeviceId());
918+
auto remoteId = device->GetDeviceId();
919+
auto params = self->mRendezvousParametersForDeviceDiscoveredOverWiFiPAF;
920+
921+
self->mRendezvousParametersForDeviceDiscoveredOverWiFiPAF = RendezvousParameters();
922+
self->ReleaseCommissioneeDevice(device);
923+
LogErrorOnFailure(self->EstablishPASEConnection(remoteId, params));
924+
}
925+
}
926+
927+
void DeviceCommissioner::OnWiFiPAFSubscribeError(void * appState, CHIP_ERROR err)
928+
{
929+
auto self = (DeviceCommissioner *) appState;
930+
auto device = self->mDeviceInPASEEstablishment;
931+
932+
if (nullptr != device && device->GetDeviceTransportType() == Transport::Type::kWiFiPAF)
933+
{
934+
ChipLogError(Controller, "WiFi-PAF: Subscription Error, id = %lu, err = %" CHIP_ERROR_FORMAT, device->GetDeviceId(),
935+
err.Format());
936+
self->ReleaseCommissioneeDevice(device);
937+
self->mRendezvousParametersForDeviceDiscoveredOverWiFiPAF = RendezvousParameters();
938+
if (self->mPairingDelegate != nullptr)
939+
{
940+
self->mPairingDelegate->OnPairingComplete(err);
941+
}
942+
}
943+
}
944+
#endif
945+
875946
CHIP_ERROR DeviceCommissioner::Commission(NodeId remoteDeviceId, CommissioningParameters & params)
876947
{
877948
if (mDefaultCommissioner == nullptr)

src/controller/CHIPDeviceController.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ class DLL_EXPORT DeviceCommissioner : public DeviceController,
468468
{
469469
public:
470470
DeviceCommissioner();
471-
~DeviceCommissioner() override {}
471+
~DeviceCommissioner() override;
472472

473473
#if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY // make this commissioner discoverable
474474
/**
@@ -847,6 +847,11 @@ class DLL_EXPORT DeviceCommissioner : public DeviceController,
847847
static void OnDiscoveredDeviceOverBleError(void * appState, CHIP_ERROR err);
848848
RendezvousParameters mRendezvousParametersForDeviceDiscoveredOverBle;
849849
#endif
850+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
851+
static void OnWiFiPAFSubscribeComplete(void * appState);
852+
static void OnWiFiPAFSubscribeError(void * appState, CHIP_ERROR err);
853+
RendezvousParameters mRendezvousParametersForDeviceDiscoveredOverWiFiPAF;
854+
#endif
850855

851856
static void OnBasicFailure(void * context, CHIP_ERROR err);
852857
static void OnBasicSuccess(void * context, const chip::app::DataModel::NullObjectType &);

src/controller/CHIPDeviceControllerFactory.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params)
141141
#else
142142
stateParams.bleLayer = params.bleLayer;
143143
#endif // CONFIG_DEVICE_LAYER
144+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
145+
stateParams.wifipaf_layer = params.wifipaf_layer;
146+
#endif
144147
VerifyOrReturnError(stateParams.bleLayer != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
145148
#endif
146149

@@ -167,6 +170,10 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params)
167170
Transport::TcpListenParameters(stateParams.tcpEndPointManager)
168171
.SetAddressType(IPAddressType::kIPv6)
169172
.SetListenPort(params.listenPort)
173+
#endif
174+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
175+
,
176+
Transport::WiFiPAFListenParameters()
170177
#endif
171178
));
172179

0 commit comments

Comments
 (0)