From a9ea1c0d1cfda13b5ea086ca9ac94191d0bcd704 Mon Sep 17 00:00:00 2001 From: "Richie Gomez (he/him)" Date: Mon, 21 Sep 2026 15:36:40 -0700 Subject: [PATCH] Add BLE network credential provisioning Add ABI-compatible Wi-Fi and Thread credential types and a network commissioning runtime class so factory-reset devices can receive operational network configuration after BLE PASE. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8ecac9d9-7be8-4ea3-a69c-5ae32e36fd23 --- .github/workflows/windows.yml | 4 +- README.md | 2 +- .../ControllerApp/ApiSurfaceCompileChecks.cs | 22 ++ .../Dialogs/AddDeviceDialog.xaml | 48 ++-- .../ControllerApp/MatterControllerApp.csproj | 2 +- .../Services/ControllerSession.cs | 10 +- .../ViewModels/AddDeviceDialogViewModel.cs | 26 ++- tools/build.ps1 | 2 +- winrt/BleNetworkCommissioningParameters.h | 2 + winrt/Matter.Windows.Controller.idl | 30 +++ winrt/Matter.Windows.Controller.xml | 52 +++++ winrt/MatterControllerNetworkCommissioning.h | 2 + winrt/Projection.cpp | 210 +++++++++++++++++- winrt/ProjectionTypes.h | 74 ++++++ winrt/ThreadNetworkCredentials.h | 2 + winrt/WiFiNetworkCredentials.h | 2 + 16 files changed, 462 insertions(+), 28 deletions(-) create mode 100644 winrt/BleNetworkCommissioningParameters.h create mode 100644 winrt/MatterControllerNetworkCommissioning.h create mode 100644 winrt/ThreadNetworkCredentials.h create mode 100644 winrt/WiFiNetworkCredentials.h diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 3deb586..a981f0e 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -58,9 +58,9 @@ jobs: $archive = Join-Path $env:RUNNER_TEMP 'baseline.zip' $destination = Join-Path $env:RUNNER_TEMP 'baseline' Invoke-WebRequest ` - -Uri 'https://github.com/dotMorten/matter.winrt/releases/download/v0.1.0-preview.6/Matter.Windows.Controller.0.1.0-preview.6.nupkg' ` + -Uri 'https://github.com/dotMorten/matter.winrt/releases/download/v0.1.0-preview.8/Matter.Windows.Controller.0.1.0-preview.8.nupkg' ` -OutFile $package - $expectedHash = '8DC16FB9707BADB8BAAF4CDCA4FB590FDDB12D55FA3796B7FE8EC4F4C4B02334' + $expectedHash = '82C970ECE9B76209F80EE694523A57F52E3106F03947A0E78D4D5BB376D40199' $actualHash = (Get-FileHash $package -Algorithm SHA256).Hash if ($actualHash -ne $expectedHash) { throw "Compatibility baseline hash mismatch. Expected $expectedHash; got $actualHash." diff --git a/README.md b/README.md index 484f77f..41c5043 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ repository is not a GN source tree and does not create directory junctions to the SDK. The build produces -`artifacts\Matter.Windows.Controller.0.1.0-preview.8.nupkg`. The package +`artifacts\Matter.Windows.Controller.0.1.0-preview.9.nupkg`. The package contains a WinMD plus architecture-specific native DLLs for `win-x64` and `win-arm64`. diff --git a/samples/ControllerApp/ApiSurfaceCompileChecks.cs b/samples/ControllerApp/ApiSurfaceCompileChecks.cs index d6cf99f..0c17e9e 100644 --- a/samples/ControllerApp/ApiSurfaceCompileChecks.cs +++ b/samples/ControllerApp/ApiSurfaceCompileChecks.cs @@ -30,4 +30,26 @@ internal static async Task ExerciseGenericInteractionsAsync(MatterController con await controller.SubscribeEventAsync(nodeId, eventPath, 0, 1, 60); await eventSubscription.CloseAsync(); } + + internal static async Task ExerciseNetworkCommissioningAsync(MatterController controller) + { + var wiFi = new BleNetworkCommissioningParameters + { + NodeId = 1, + SetupPinCode = 20202021, + LongDiscriminator = 3840, + WiFi = new WiFiNetworkCredentials("network", "passphrase") + }; + await new MatterControllerNetworkCommissioning(controller).CommissionBleAsync(wiFi); + + var dataset = new Windows.Storage.Streams.Buffer(16) { Length = 16 }; + var thread = new BleNetworkCommissioningParameters + { + NodeId = 2, + SetupPinCode = 20202021, + LongDiscriminator = 3840, + Thread = new ThreadNetworkCredentials(dataset) + }; + await new MatterControllerNetworkCommissioning(controller).CommissionBleAsync(thread); + } } diff --git a/samples/ControllerApp/Dialogs/AddDeviceDialog.xaml b/samples/ControllerApp/Dialogs/AddDeviceDialog.xaml index ce4f024..4da9855 100644 --- a/samples/ControllerApp/Dialogs/AddDeviceDialog.xaml +++ b/samples/ControllerApp/Dialogs/AddDeviceDialog.xaml @@ -68,27 +68,39 @@ AutomationProperties.AutomationId="AddDeviceSharingCode" /> - - - - - - + + + + + + + + - + - + Password="{x:Bind ViewModel.WiFiPassphrase, Mode=TwoWay}" + AutomationProperties.AutomationId="AddDeviceWiFiPassphrase" /> + diff --git a/samples/ControllerApp/MatterControllerApp.csproj b/samples/ControllerApp/MatterControllerApp.csproj index b179acf..107e571 100644 --- a/samples/ControllerApp/MatterControllerApp.csproj +++ b/samples/ControllerApp/MatterControllerApp.csproj @@ -62,7 +62,7 @@ - + diff --git a/samples/ControllerApp/Services/ControllerSession.cs b/samples/ControllerApp/Services/ControllerSession.cs index ee828ac..65324be 100644 --- a/samples/ControllerApp/Services/ControllerSession.cs +++ b/samples/ControllerApp/Services/ControllerSession.cs @@ -96,18 +96,22 @@ public async Task CommissionOnNetworkAsync( public async Task CommissionBleAsync( uint setupPinCode, - ushort longDiscriminator) + ushort longDiscriminator, + string wiFiSsid, + string wiFiPassphrase) { MatterController controller = RequireController(); ulong nodeId = AllocateNodeId(controller); CommissionedNode node; try { - node = await controller.CommissionBleAsync(new BleCommissioningParameters + node = await new MatterControllerNetworkCommissioning(controller).CommissionBleAsync( + new BleNetworkCommissioningParameters { NodeId = nodeId, SetupPinCode = setupPinCode, - LongDiscriminator = longDiscriminator + LongDiscriminator = longDiscriminator, + WiFi = new WiFiNetworkCredentials(wiFiSsid, wiFiPassphrase) }); } catch (Exception exception) when ( diff --git a/samples/ControllerApp/ViewModels/AddDeviceDialogViewModel.cs b/samples/ControllerApp/ViewModels/AddDeviceDialogViewModel.cs index e781c8f..e509e41 100644 --- a/samples/ControllerApp/ViewModels/AddDeviceDialogViewModel.cs +++ b/samples/ControllerApp/ViewModels/AddDeviceDialogViewModel.cs @@ -62,6 +62,20 @@ public ushort LongDiscriminator set => SetProperty(ref longDiscriminator, value); } + private string wiFiSsid = string.Empty; + public string WiFiSsid + { + get => wiFiSsid; + set => SetProperty(ref wiFiSsid, value); + } + + private string wiFiPassphrase = string.Empty; + public string WiFiPassphrase + { + get => wiFiPassphrase; + set => SetProperty(ref wiFiPassphrase, value); + } + private string status = "Ready to connect."; public string Status { @@ -154,6 +168,10 @@ public async Task ConnectAsync() throw new InvalidOperationException("Enter the device's sharing code."); } } + else if (string.IsNullOrWhiteSpace(WiFiSsid)) + { + throw new InvalidOperationException("Enter the Wi-Fi network name."); + } IsBusy = true; Status = UsesSharingCode ? "Connecting with the sharing code…" @@ -168,7 +186,9 @@ public async Task ConnectAsync() LongDiscriminator) : await session.CommissionBleAsync( SetupPinCode, - LongDiscriminator); + LongDiscriminator, + WiFiSsid, + WiFiPassphrase); DeviceName = connectedDevice.Device.DisplayName; OnPropertyChanged(nameof(IsConnecting)); OnPropertyChanged(nameof(IsNaming)); @@ -182,6 +202,10 @@ public async Task ConnectAsync() } finally { + if (UsesBluetooth) + { + WiFiPassphrase = string.Empty; + } IsBusy = false; } } diff --git a/tools/build.ps1 b/tools/build.ps1 index bc82ba9..49b585b 100644 --- a/tools/build.ps1 +++ b/tools/build.ps1 @@ -2,7 +2,7 @@ param( [ValidateSet("x64", "arm64", "all")] [string] $Architecture = "all", - [string] $Version = "0.1.0-preview.8", + [string] $Version = "0.1.0-preview.9", [string] $OutputDirectory = "artifacts", [switch] $SkipBuild ) diff --git a/winrt/BleNetworkCommissioningParameters.h b/winrt/BleNetworkCommissioningParameters.h new file mode 100644 index 0000000..5b5ae34 --- /dev/null +++ b/winrt/BleNetworkCommissioningParameters.h @@ -0,0 +1,2 @@ +#pragma once +#include "ProjectionTypes.h" diff --git a/winrt/Matter.Windows.Controller.idl b/winrt/Matter.Windows.Controller.idl index 6fd2be6..f2ddc7a 100644 --- a/winrt/Matter.Windows.Controller.idl +++ b/winrt/Matter.Windows.Controller.idl @@ -1,4 +1,5 @@ import "windows.foundation.idl"; +import "windows.storage.streams.idl"; namespace Matter.Windows.Controller { @@ -40,6 +41,29 @@ namespace Matter.Windows.Controller UInt16 LongDiscriminator { get; set; }; }; + runtimeclass WiFiNetworkCredentials + { + WiFiNetworkCredentials(String ssid, String passphrase); + UInt32 SsidLength { get; }; + UInt32 PassphraseLength { get; }; + }; + + runtimeclass ThreadNetworkCredentials + { + ThreadNetworkCredentials(Windows.Storage.Streams.IBuffer operationalDataset); + UInt32 DatasetLength { get; }; + }; + + runtimeclass BleNetworkCommissioningParameters + { + BleNetworkCommissioningParameters(); + UInt64 NodeId { get; set; }; + UInt32 SetupPinCode { get; set; }; + UInt16 LongDiscriminator { get; set; }; + WiFiNetworkCredentials WiFi { get; set; }; + ThreadNetworkCredentials Thread { get; set; }; + }; + runtimeclass CommissioningProgressEventArgs { CommissioningStage Stage { get; }; @@ -185,4 +209,10 @@ namespace Matter.Windows.Controller MatterControllerRecovery(MatterController controller); Windows.Foundation.IAsyncOperation RecoverNodeAsync(UInt64 nodeId); }; + + runtimeclass MatterControllerNetworkCommissioning + { + MatterControllerNetworkCommissioning(MatterController controller); + Windows.Foundation.IAsyncOperation CommissionBleAsync(BleNetworkCommissioningParameters parameters); + }; } diff --git a/winrt/Matter.Windows.Controller.xml b/winrt/Matter.Windows.Controller.xml index ce5d078..347b0aa 100644 --- a/winrt/Matter.Windows.Controller.xml +++ b/winrt/Matter.Windows.Controller.xml @@ -86,6 +86,49 @@ Gets or sets the device's 12-bit discriminator. + + Holds transient Wi-Fi credentials for one commissioning operation. + + + Copies a Wi-Fi SSID and passphrase into bounded native buffers. The native copies are cleared when this object is released.The nonempty Wi-Fi SSID, limited to 32 UTF-8 bytes.The Wi-Fi passphrase, or an empty string for an open network, limited to 64 UTF-8 bytes. + + + Gets the SSID length in UTF-8 bytes without exposing its value. + + + Gets the passphrase length in UTF-8 bytes without exposing its value. + + + Holds a transient Thread operational dataset for one commissioning operation. + + + Copies a Thread operational dataset into a bounded native buffer. The native copy is cleared when this object is released.A complete Thread operational dataset containing between 1 and 254 bytes. The caller may release or clear the source buffer after construction. + + + Gets the operational dataset length without exposing its contents. + + + Describes Bluetooth LE commissioning of a factory-reset Wi-Fi or Thread device. + + + Creates Bluetooth LE network commissioning parameters. + + + Gets or sets the nonzero operational node identifier to assign to the device. + + + Gets or sets the device setup PIN. + + + Gets or sets the device's 12-bit discriminator. + + + Gets or sets Wi-Fi credentials. Set exactly one of WiFi or Thread. + + + Gets or sets Thread credentials. Set exactly one of WiFi or Thread. + + Provides commissioning stage and status text. @@ -257,6 +300,15 @@ Commissions a device over Bluetooth LE.BLE commissioning parameters.The persisted commissioned node. + + Adds factory-reset Wi-Fi or Thread devices through Bluetooth LE without changing the MatterController ABI. + + + Creates network commissioning operations for a controller.The controller that will own the commissioned node. + + + Commissions a factory-reset device over Bluetooth LE and supplies its Wi-Fi or Thread credentials during network configuration.BLE and network commissioning parameters containing exactly one credential type.The persisted commissioned node. + Gets a snapshot of nodes persisted by this controller. Creates node recovery operations for a controller.The controller whose fabric contains the node. Verifies an existing operational node on the current fabric and restores it to the persisted node index.The node identifier previously assigned on this fabric.The recovered commissioned node. diff --git a/winrt/MatterControllerNetworkCommissioning.h b/winrt/MatterControllerNetworkCommissioning.h new file mode 100644 index 0000000..5b5ae34 --- /dev/null +++ b/winrt/MatterControllerNetworkCommissioning.h @@ -0,0 +1,2 @@ +#pragma once +#include "ProjectionTypes.h" diff --git a/winrt/Projection.cpp b/winrt/Projection.cpp index c6ebafb..576a21c 100644 --- a/winrt/Projection.cpp +++ b/winrt/Projection.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,17 @@ constexpr char kCommissionedNodesKey[] = "winrt/nodes"; constexpr size_t kGenericTlvBufferSize = 64 * 1024; constexpr size_t kMaximumPendingReports = 256; +std::vector Utf8Bytes(hstring const & value) +{ + std::string encoded = to_string(value); + std::vector bytes(encoded.begin(), encoded.end()); + if (!encoded.empty()) + { + Crypto::ClearSecretData(reinterpret_cast(encoded.data()), encoded.size()); + } + return bytes; +} + std::chrono::milliseconds InteractionWaitTimeout(std::optional timedInteractionTimeout) { auto timeout = std::chrono::duration_cast(kInteractionTimeout); @@ -1182,7 +1194,9 @@ class ControllerRuntime : public std::enable_shared_from_this } Controller::CommissionedNode Commission(uint64_t nodeId, uint32_t pinCode, uint16_t discriminator, bool useBle, - std::string const & providedSetupCode = {}) + std::string const & providedSetupCode = {}, + std::optional const & wiFiCredentials = std::nullopt, + ByteSpan threadOperationalDataset = {}) { std::scoped_lock operationLock(mOperationMutex); EnsureOpen(); @@ -1191,6 +1205,14 @@ class ControllerRuntime : public std::enable_shared_from_this CommissioningParameters parameters; parameters.SetDeviceAttestationDelegate(&mPairingDelegate); + if (wiFiCredentials.has_value()) + { + parameters.SetWiFiCredentials(*wiFiCredentials); + } + if (!threadOperationalDataset.empty()) + { + parameters.SetThreadOperationalDataset(threadOperationalDataset); + } PlatformMgr().LockChipStack(); CHIP_ERROR error = mCommissioner.PairDevice( nodeId, setupCode.c_str(), parameters, useBle ? DiscoveryType::kDiscoveryBleOnly : DiscoveryType::kDiscoveryNetworkOnly); @@ -1892,6 +1914,146 @@ void BleCommissioningParameters::LongDiscriminator(uint16_t value) mLongDiscriminator = value; } +WiFiNetworkCredentials::WiFiNetworkCredentials(hstring const & ssid, hstring const & passphrase) +{ + std::vector encodedSsid = Utf8Bytes(ssid); + std::vector encodedPassphrase = Utf8Bytes(passphrase); + if (encodedSsid.empty() || encodedSsid.size() > CommissioningParameters::kMaxSsidLen || + encodedPassphrase.size() > CommissioningParameters::kMaxCredentialsLen) + { + Crypto::ClearSecretData(encodedSsid.data(), encodedSsid.size()); + Crypto::ClearSecretData(encodedPassphrase.data(), encodedPassphrase.size()); + throw hresult_invalid_argument( + L"ssid must contain 1 to 32 UTF-8 bytes and passphrase must not exceed 64 UTF-8 bytes."); + } + mSsid = std::move(encodedSsid); + mPassphrase = std::move(encodedPassphrase); +} + +WiFiNetworkCredentials::~WiFiNetworkCredentials() +{ + if (!mSsid.empty()) + { + Crypto::ClearSecretData(mSsid.data(), mSsid.size()); + } + if (!mPassphrase.empty()) + { + Crypto::ClearSecretData(mPassphrase.data(), mPassphrase.size()); + } +} + +uint32_t WiFiNetworkCredentials::SsidLength() const +{ + return static_cast(mSsid.size()); +} + +uint32_t WiFiNetworkCredentials::PassphraseLength() const +{ + return static_cast(mPassphrase.size()); +} + +std::vector const & WiFiNetworkCredentials::Ssid() const +{ + return mSsid; +} + +std::vector const & WiFiNetworkCredentials::Passphrase() const +{ + return mPassphrase; +} + +ThreadNetworkCredentials::ThreadNetworkCredentials(Windows::Storage::Streams::IBuffer const & operationalDataset) +{ + if (!operationalDataset) + { + throw hresult_invalid_argument(L"operationalDataset cannot be null."); + } + if (operationalDataset.Length() == 0 || + operationalDataset.Length() > CommissioningParameters::kMaxThreadDatasetLen) + { + throw hresult_invalid_argument(L"operationalDataset must contain between 1 and 254 bytes."); + } + std::vector dataset(operationalDataset.Length()); + try + { + Windows::Storage::Streams::DataReader::FromBuffer(operationalDataset).ReadBytes(dataset); + } + catch (...) + { + Crypto::ClearSecretData(dataset.data(), dataset.size()); + throw; + } + mOperationalDataset = std::move(dataset); +} + +ThreadNetworkCredentials::~ThreadNetworkCredentials() +{ + if (!mOperationalDataset.empty()) + { + Crypto::ClearSecretData(mOperationalDataset.data(), mOperationalDataset.size()); + } +} + +uint32_t ThreadNetworkCredentials::DatasetLength() const +{ + return static_cast(mOperationalDataset.size()); +} + +std::vector const & ThreadNetworkCredentials::OperationalDataset() const +{ + return mOperationalDataset; +} + +uint64_t BleNetworkCommissioningParameters::NodeId() const +{ + return mNodeId; +} + +void BleNetworkCommissioningParameters::NodeId(uint64_t value) +{ + mNodeId = value; +} + +uint32_t BleNetworkCommissioningParameters::SetupPinCode() const +{ + return mSetupPinCode; +} + +void BleNetworkCommissioningParameters::SetupPinCode(uint32_t value) +{ + mSetupPinCode = value; +} + +uint16_t BleNetworkCommissioningParameters::LongDiscriminator() const +{ + return mLongDiscriminator; +} + +void BleNetworkCommissioningParameters::LongDiscriminator(uint16_t value) +{ + mLongDiscriminator = value; +} + +Controller::WiFiNetworkCredentials BleNetworkCommissioningParameters::WiFi() const +{ + return mWiFi; +} + +void BleNetworkCommissioningParameters::WiFi(Controller::WiFiNetworkCredentials const & value) +{ + mWiFi = value; +} + +Controller::ThreadNetworkCredentials BleNetworkCommissioningParameters::Thread() const +{ + return mThread; +} + +void BleNetworkCommissioningParameters::Thread(Controller::ThreadNetworkCredentials const & value) +{ + mThread = value; +} + AttributePath::AttributePath(uint16_t endpointId, uint32_t clusterId, uint32_t attributeId) : mEndpointId(endpointId), mClusterId(clusterId), mAttributeId(attributeId) {} @@ -2634,6 +2796,52 @@ MatterControllerRecovery::MatterControllerRecovery(Controller::MatterController mRuntime = get_self(controller)->Runtime(); } +MatterControllerNetworkCommissioning::MatterControllerNetworkCommissioning(Controller::MatterController controller) +{ + if (!controller) + { + throw hresult_invalid_argument(L"controller cannot be null."); + } + mRuntime = get_self(controller)->Runtime(); +} + +Windows::Foundation::IAsyncOperation +MatterControllerNetworkCommissioning::CommissionBleAsync(Controller::BleNetworkCommissioningParameters parameters) +{ + if (!parameters) + { + throw hresult_invalid_argument(L"parameters cannot be null."); + } + + auto wiFi = parameters.WiFi(); + auto thread = parameters.Thread(); + if (static_cast(wiFi) == static_cast(thread)) + { + throw hresult_invalid_argument(L"Provide exactly one Wi-Fi or Thread credential set."); + } + + std::optional nativeWiFi; + ByteSpan threadDataset; + if (wiFi) + { + auto implementation = get_self(wiFi); + auto const & ssid = implementation->Ssid(); + auto const & passphrase = implementation->Passphrase(); + nativeWiFi.emplace(ByteSpan(ssid.data(), ssid.size()), ByteSpan(passphrase.data(), passphrase.size())); + } + else + { + auto const & dataset = get_self(thread)->OperationalDataset(); + threadDataset = ByteSpan(dataset.data(), dataset.size()); + } + + uint64_t nodeId = parameters.NodeId(); + uint32_t setupPinCode = parameters.SetupPinCode(); + uint16_t discriminator = parameters.LongDiscriminator(); + co_await resume_background(); + co_return mRuntime->Commission(nodeId, setupPinCode, discriminator, true, {}, nativeWiFi, threadDataset); +} + Windows::Foundation::IAsyncAction MatterController::CloseAsync() { std::shared_ptr runtime; diff --git a/winrt/ProjectionTypes.h b/winrt/ProjectionTypes.h index 53401af..6e179a1 100644 --- a/winrt/ProjectionTypes.h +++ b/winrt/ProjectionTypes.h @@ -2,6 +2,7 @@ #include #include +#include #include "AttributePath.g.h" #include "AttributeReportEventArgs.g.h" @@ -10,6 +11,7 @@ #include "BasicInformation.g.h" #include "BasicInformationCluster.g.h" #include "BleCommissioningParameters.g.h" +#include "BleNetworkCommissioningParameters.g.h" #include "CommandPath.g.h" #include "CommandResult.g.h" #include "CommissionedNode.g.h" @@ -22,9 +24,12 @@ #include "LevelControlCluster.g.h" #include "MatterController.g.h" #include "MatterControllerRecovery.g.h" +#include "MatterControllerNetworkCommissioning.g.h" #include "OnNetworkCommissioningParameters.g.h" #include "OnOffCluster.g.h" #include "TimedInteractionOptions.g.h" +#include "ThreadNetworkCredentials.g.h" +#include "WiFiNetworkCredentials.g.h" #include #include @@ -91,6 +96,52 @@ struct BleCommissioningParameters : BleCommissioningParametersT +{ + WiFiNetworkCredentials(hstring const & ssid, hstring const & passphrase); + ~WiFiNetworkCredentials(); + uint32_t SsidLength() const; + uint32_t PassphraseLength() const; + std::vector const & Ssid() const; + std::vector const & Passphrase() const; + +private: + std::vector mSsid; + std::vector mPassphrase; +}; + +struct ThreadNetworkCredentials : ThreadNetworkCredentialsT +{ + explicit ThreadNetworkCredentials(Windows::Storage::Streams::IBuffer const & operationalDataset); + ~ThreadNetworkCredentials(); + uint32_t DatasetLength() const; + std::vector const & OperationalDataset() const; + +private: + std::vector mOperationalDataset; +}; + +struct BleNetworkCommissioningParameters : BleNetworkCommissioningParametersT +{ + uint64_t NodeId() const; + void NodeId(uint64_t value); + uint32_t SetupPinCode() const; + void SetupPinCode(uint32_t value); + uint16_t LongDiscriminator() const; + void LongDiscriminator(uint16_t value); + Controller::WiFiNetworkCredentials WiFi() const; + void WiFi(Controller::WiFiNetworkCredentials const & value); + Controller::ThreadNetworkCredentials Thread() const; + void Thread(Controller::ThreadNetworkCredentials const & value); + +private: + uint64_t mNodeId = 1; + uint32_t mSetupPinCode = 20202021; + uint16_t mLongDiscriminator = 3840; + Controller::WiFiNetworkCredentials mWiFi{ nullptr }; + Controller::ThreadNetworkCredentials mThread{ nullptr }; +}; + struct AttributePath : AttributePathT { AttributePath(uint16_t endpointId, uint32_t clusterId, uint32_t attributeId); @@ -378,6 +429,16 @@ struct MatterControllerRecovery : MatterControllerRecoveryT mRuntime; }; +struct MatterControllerNetworkCommissioning : MatterControllerNetworkCommissioningT +{ + explicit MatterControllerNetworkCommissioning(Controller::MatterController controller); + Windows::Foundation::IAsyncOperation + CommissionBleAsync(Controller::BleNetworkCommissioningParameters parameters); + +private: + std::shared_ptr mRuntime; +}; + } // namespace winrt::Matter::Windows::Controller::implementation namespace winrt::Matter::Windows::Controller::factory_implementation { @@ -390,6 +451,15 @@ struct OnNetworkCommissioningParameters : struct BleCommissioningParameters : BleCommissioningParametersT {}; +struct BleNetworkCommissioningParameters : + BleNetworkCommissioningParametersT +{}; +struct WiFiNetworkCredentials : + WiFiNetworkCredentialsT +{}; +struct ThreadNetworkCredentials : + ThreadNetworkCredentialsT +{}; struct AttributePath : AttributePathT {}; struct CommandPath : CommandPathT @@ -402,5 +472,9 @@ struct MatterController : MatterControllerT {}; +struct MatterControllerNetworkCommissioning : + MatterControllerNetworkCommissioningT +{}; } // namespace winrt::Matter::Windows::Controller::factory_implementation diff --git a/winrt/ThreadNetworkCredentials.h b/winrt/ThreadNetworkCredentials.h new file mode 100644 index 0000000..5b5ae34 --- /dev/null +++ b/winrt/ThreadNetworkCredentials.h @@ -0,0 +1,2 @@ +#pragma once +#include "ProjectionTypes.h" diff --git a/winrt/WiFiNetworkCredentials.h b/winrt/WiFiNetworkCredentials.h new file mode 100644 index 0000000..5b5ae34 --- /dev/null +++ b/winrt/WiFiNetworkCredentials.h @@ -0,0 +1,2 @@ +#pragma once +#include "ProjectionTypes.h"