From 0a9e9b22bb8e11f70cf03b29742b2362fca091bc Mon Sep 17 00:00:00 2001 From: Sharad Binjola <31142146+sharadb-amazon@users.noreply.github.com> Date: Thu, 17 Nov 2022 07:03:12 -0800 Subject: [PATCH 1/8] tv-casting-app: Adding new app params (#23624) * Adding new app params * Using only nodeId to check two VideoPlayers for equality * Checking for null data on the targetNavigation_navigateTarget command in JNI --- .../jni/com/chip/casting/AppParameters.java | 27 +++ .../jni/com/chip/casting/TvCastingApp.java | 10 +- .../app/src/main/jni/cpp/TvCastingApp-JNI.cpp | 10 +- .../project.pbxproj | 10 +- .../MatterTvCastingBridge/AppParameters.h | 10 +- .../{AppParameters.m => AppParameters.mm} | 11 +- .../CastingServerBridge.mm | 122 +++++++----- .../CommissionableDataProviderImpl.hpp | 180 ++++++++++++++++++ .../include/TargetVideoPlayerInfo.h | 5 +- 9 files changed, 322 insertions(+), 63 deletions(-) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{AppParameters.m => AppParameters.mm} (77%) create mode 100644 examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CommissionableDataProviderImpl.hpp diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/AppParameters.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/AppParameters.java index a98f9d8bbd4f86..78cbad859fc961 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/AppParameters.java +++ b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/AppParameters.java @@ -25,6 +25,9 @@ public class AppParameters { private byte[] rotatingDeviceIdUniqueId; private DACProvider dacProvider = TEST_DAC_PROVIDER; + private String spake2pVerifierBase64; + private String Spake2pSaltBase64; + private int spake2pIterationCount; private int setupPasscode = TEST_SETUP_PASSCODE; private int discriminator = TEST_DISCRIMINATOR; @@ -44,6 +47,30 @@ public void setDacProvider(DACProvider dacProvider) { this.dacProvider = dacProvider; } + public String getSpake2pVerifierBase64() { + return spake2pVerifierBase64; + } + + public void setSpake2pVerifierBase64(String spake2pVerifierBase64) { + this.spake2pVerifierBase64 = spake2pVerifierBase64; + } + + public String getSpake2pSaltBase64() { + return Spake2pSaltBase64; + } + + public void setSpake2pSaltBase64(String spake2pSaltBase64) { + Spake2pSaltBase64 = spake2pSaltBase64; + } + + public int getSpake2pIterationCount() { + return spake2pIterationCount; + } + + public void setSpake2pIterationCount(int spake2pIterationCount) { + this.spake2pIterationCount = spake2pIterationCount; + } + public int getSetupPasscode() { return setupPasscode; } diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java index b099483a8f2856..d483844a79c26b 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java +++ b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java @@ -46,6 +46,10 @@ public class TvCastingApp { private NsdManagerServiceResolver.NsdManagerResolverAvailState nsdManagerResolverAvailState; public boolean initApp(Context applicationContext, AppParameters appParameters) { + if (applicationContext == null || appParameters == null) { + return false; + } + this.applicationContext = applicationContext; nsdManagerResolverAvailState = new NsdManagerServiceResolver.NsdManagerResolverAvailState(); NsdManagerServiceResolver nsdManagerServiceResolver = @@ -62,7 +66,11 @@ public boolean initApp(Context applicationContext, AppParameters appParameters) new DiagnosticDataProviderImpl(applicationContext)); chipPlatform.updateCommissionableDataProviderData( - null, null, 0, appParameters.getSetupPasscode(), appParameters.getDiscriminator()); + appParameters.getSpake2pVerifierBase64(), + appParameters.getSpake2pSaltBase64(), + appParameters.getSpake2pIterationCount(), + appParameters.getSetupPasscode(), + appParameters.getDiscriminator()); chipAppServer = new ChipAppServer(); chipAppServer.startApp(); diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp index c58df8f2cc4f91..7ac67e67f4f7d6 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp @@ -1358,7 +1358,7 @@ JNI_METHOD(jboolean, targetNavigator_1navigateTarget) ChipLogProgress(AppServer, "JNI_METHOD targetNavigator_navigateTarget called"); - const char * nativeData = env->GetStringUTFChars(data, 0); + const char * nativeData = (data != nullptr ? env->GetStringUTFChars(data, 0) : nullptr); TargetEndpointInfo endpoint; CHIP_ERROR err = convertJContentAppToTargetEndpointInfo(contentApp, endpoint); @@ -1371,12 +1371,16 @@ JNI_METHOD(jboolean, targetNavigator_1navigateTarget) ChipLogError(AppServer, "MatterCallbackHandlerJNI.SetUp failed %" CHIP_ERROR_FORMAT, err.Format())); err = CastingServer::GetInstance()->TargetNavigator_NavigateTarget( - &endpoint, static_cast(target), chip::MakeOptional(CharSpan::fromCharString(nativeData)), + &endpoint, static_cast(target), + (nativeData != nullptr ? chip::MakeOptional(CharSpan::fromCharString(nativeData)) : chip::NullOptional), [](CHIP_ERROR err) { TvCastingAppJNIMgr().getMediaCommandResponseHandler(TargetNavigator_NavigateTarget).Handle(err); }); VerifyOrExit(CHIP_NO_ERROR == err, ChipLogError(AppServer, "CastingServer.TargetNavigator_NavigateTarget failed %" CHIP_ERROR_FORMAT, err.Format())); - env->ReleaseStringUTFChars(data, nativeData); + if (nativeData != nullptr) + { + env->ReleaseStringUTFChars(data, nativeData); + } exit: if (err != CHIP_NO_ERROR) { diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge.xcodeproj/project.pbxproj b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge.xcodeproj/project.pbxproj index 45f5d8a68741c9..7736fef3f15030 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge.xcodeproj/project.pbxproj +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge.xcodeproj/project.pbxproj @@ -11,7 +11,7 @@ 3C4E53B028E4F28100F293E8 /* MediaPlaybackTypes.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3C4E53AF28E4F28100F293E8 /* MediaPlaybackTypes.mm */; }; 3C4E53B228E5184C00F293E8 /* TargetNavigatorTypes.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3C4E53B128E5184C00F293E8 /* TargetNavigatorTypes.mm */; }; 3C4E53B628E5595A00F293E8 /* ContentLauncherTypes.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3C4E53B528E5595A00F293E8 /* ContentLauncherTypes.mm */; }; - 3C66FBFC290327BB00B63FE7 /* AppParameters.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C66FBFB290327BB00B63FE7 /* AppParameters.m */; }; + 3C66FBFC290327BB00B63FE7 /* AppParameters.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3C66FBFB290327BB00B63FE7 /* AppParameters.mm */; }; 3C81C74C28F7A777001CB9D1 /* ContentApp.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3C81C74B28F7A777001CB9D1 /* ContentApp.mm */; }; 3C81C75028F7A7D3001CB9D1 /* VideoPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C81C74F28F7A7D3001CB9D1 /* VideoPlayer.m */; }; 3CCB87212869085400771BAD /* MatterTvCastingBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 3CCB87202869085400771BAD /* MatterTvCastingBridge.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -27,6 +27,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 3C0D9CDF2920A30C00D3332B /* CommissionableDataProviderImpl.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CommissionableDataProviderImpl.hpp; sourceTree = ""; }; 3C4AE64E286A7D40005B52A4 /* OnboardingPayload.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OnboardingPayload.h; sourceTree = ""; }; 3C4AE64F286A7D4D005B52A4 /* OnboardingPayload.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OnboardingPayload.m; sourceTree = ""; }; 3C4E53AF28E4F28100F293E8 /* MediaPlaybackTypes.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaPlaybackTypes.mm; sourceTree = ""; }; @@ -35,7 +36,7 @@ 3C4E53B428E5593700F293E8 /* ContentLauncherTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContentLauncherTypes.h; sourceTree = ""; }; 3C4E53B528E5595A00F293E8 /* ContentLauncherTypes.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ContentLauncherTypes.mm; sourceTree = ""; }; 3C66FBFA2903279A00B63FE7 /* AppParameters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppParameters.h; sourceTree = ""; }; - 3C66FBFB290327BB00B63FE7 /* AppParameters.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppParameters.m; sourceTree = ""; }; + 3C66FBFB290327BB00B63FE7 /* AppParameters.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AppParameters.mm; sourceTree = ""; }; 3C81C74B28F7A777001CB9D1 /* ContentApp.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ContentApp.mm; sourceTree = ""; }; 3C81C74E28F7A7AE001CB9D1 /* ContentApp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContentApp.h; sourceTree = ""; }; 3C81C74F28F7A7D3001CB9D1 /* VideoPlayer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VideoPlayer.m; sourceTree = ""; }; @@ -93,7 +94,7 @@ 3CCB873A286A593700771BAD /* CastingServerBridge.h */, 3CCB873D286A593700771BAD /* CastingServerBridge.mm */, 3C66FBFA2903279A00B63FE7 /* AppParameters.h */, - 3C66FBFB290327BB00B63FE7 /* AppParameters.m */, + 3C66FBFB290327BB00B63FE7 /* AppParameters.mm */, 3CCB873B286A593700771BAD /* DiscoveredNodeData.h */, 3CCB8739286A593700771BAD /* DiscoveredNodeData.mm */, 3CCB873C286A593700771BAD /* ConversionUtils.hpp */, @@ -112,6 +113,7 @@ 3C4E53AF28E4F28100F293E8 /* MediaPlaybackTypes.mm */, 3C4E53B328E5185F00F293E8 /* TargetNavigatorTypes.h */, 3C4E53B128E5184C00F293E8 /* TargetNavigatorTypes.mm */, + 3C0D9CDF2920A30C00D3332B /* CommissionableDataProviderImpl.hpp */, ); path = MatterTvCastingBridge; sourceTree = ""; @@ -226,7 +228,7 @@ 3C81C75028F7A7D3001CB9D1 /* VideoPlayer.m in Sources */, 3CCB8744286A593700771BAD /* ConversionUtils.mm in Sources */, 3C4E53B028E4F28100F293E8 /* MediaPlaybackTypes.mm in Sources */, - 3C66FBFC290327BB00B63FE7 /* AppParameters.m in Sources */, + 3C66FBFC290327BB00B63FE7 /* AppParameters.mm in Sources */, 3CCB873F286A593700771BAD /* DiscoveredNodeData.mm in Sources */, 3C81C74C28F7A777001CB9D1 /* ContentApp.mm in Sources */, 3C4AE650286A7D4D005B52A4 /* OnboardingPayload.m in Sources */, diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/AppParameters.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/AppParameters.h index b34590303db00a..e1da8ce04cddfb 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/AppParameters.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/AppParameters.h @@ -17,6 +17,8 @@ #import +#import "OnboardingPayload.h" + #ifndef AppParameters_h #define AppParameters_h @@ -24,7 +26,13 @@ @property NSData * rotatingDeviceIdUniqueId; -- (AppParameters *)initWithRotatingDeviceIdUniqueId:(NSData *)rotatingDeviceIdUniqueId; +@property OnboardingPayload * onboardingPayload; + +@property uint32_t spake2pIterationCount; + +@property NSData * spake2pSalt; + +@property NSData * spake2pVerifier; @end diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/AppParameters.m b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/AppParameters.mm similarity index 77% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/AppParameters.m rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/AppParameters.mm index 287d4ab40fd57c..906888dbbeddc5 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/AppParameters.m +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/AppParameters.mm @@ -21,13 +21,12 @@ @implementation AppParameters -- (AppParameters *)initWithRotatingDeviceIdUniqueId:(NSData *)rotatingDeviceIdUniqueId +/** + * Initialize with default values + */ +- (AppParameters *)init { - self = [super init]; - if (self) { - _rotatingDeviceIdUniqueId = rotatingDeviceIdUniqueId; - } - return self; + return [super init]; } @end diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm index 9ba421b54723ce..86ed73bde4e874 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm @@ -18,6 +18,7 @@ #import "CastingServerBridge.h" #import "CastingServer.h" +#import "CommissionableDataProviderImpl.hpp" #import "ConversionUtils.hpp" #import "MatterCallbacks.h" #import "OnboardingPayload.h" @@ -29,15 +30,18 @@ #include #include #include -#include @interface CastingServerBridge () -// queue used to serialize all work performed by the CastingServerBridge -@property (atomic, readonly) dispatch_queue_t chipWorkQueue; +@property AppParameters * appParameters; @property OnboardingPayload * _Nonnull onboardingPayload; +@property chip::DeviceLayer::CommissionableDataProviderImpl * commissionableDataProvider; + +// queue used to serialize all work performed by the CastingServerBridge +@property (atomic) dispatch_queue_t chipWorkQueue; + @property void (^_Nonnull commissioningCompleteCallback)(bool); @property void (^_Nonnull onConnectionSuccessCallback)(VideoPlayer *); @@ -87,47 +91,12 @@ - (instancetype)init return nil; } - chip::DeviceLayer::TestOnlyCommissionableDataProvider TestOnlyCommissionableDataProvider; - uint32_t defaultTestPasscode = 0; - VerifyOrDie(TestOnlyCommissionableDataProvider.GetSetupPasscode(defaultTestPasscode) == CHIP_NO_ERROR); - uint16_t defaultTestSetupDiscriminator = 0; - VerifyOrDie(TestOnlyCommissionableDataProvider.GetSetupDiscriminator(defaultTestSetupDiscriminator) == CHIP_NO_ERROR); - _onboardingPayload = [[OnboardingPayload alloc] initWithSetupPasscode:defaultTestPasscode - setupDiscriminator:defaultTestSetupDiscriminator]; - - // Initialize device attestation config - SetDeviceAttestationCredentialsProvider(chip::Credentials::Examples::GetExampleDACProvider()); - - // Initialize device attestation verifier from a constant version - { - // TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available - const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore(); - SetDeviceAttestationVerifier(GetDefaultDACVerifier(testingRootStore)); - } - - // init app Server - static chip::CommonCaseDeviceServerInitParams initParams; - err = initParams.InitializeStaticResourcesBeforeServerInit(); - if (err != CHIP_NO_ERROR) { - ChipLogError(AppServer, "InitializeStaticResourcesBeforeServerInit failed: %s", ErrorStr(err)); - return nil; - } - err = chip::Server::GetInstance().Init(initParams); - if (err != CHIP_NO_ERROR) { - ChipLogError(AppServer, "chip::Server init failed: %s", ErrorStr(err)); - return nil; - } - - _chipWorkQueue = chip::DeviceLayer::PlatformMgrImpl().GetWorkQueue(); - _commandResponseCallbacks = [NSMutableDictionary dictionary]; _subscriptionEstablishedCallbacks = [NSMutableDictionary dictionary]; _subscriptionReadSuccessCallbacks = [NSMutableDictionary dictionary]; _subscriptionReadFailureCallbacks = [NSMutableDictionary dictionary]; _readSuccessCallbacks = [NSMutableDictionary dictionary]; _readFailureCallbacks = [NSMutableDictionary dictionary]; - - chip::DeviceLayer::PlatformMgrImpl().StartEventLoopTask(); } return self; } @@ -138,17 +107,82 @@ - (void)initApp:(AppParameters * _Nullable)appParameters { ChipLogProgress(AppServer, "CastingServerBridge().initApp() called"); - dispatch_async(_chipWorkQueue, ^{ - bool initAppStatus = true; + CHIP_ERROR err = CHIP_NO_ERROR; + _commissionableDataProvider = new chip::DeviceLayer::CommissionableDataProviderImpl(); + _appParameters = appParameters; + AppParams cppAppParams; + if (_appParameters != nil) { + err = [ConversionUtils convertToCppAppParamsInfoFrom:_appParameters outAppParams:cppAppParams]; + if (err != CHIP_NO_ERROR) { + ChipLogError(AppServer, "AppParameters conversion failed: %s", ErrorStr(err)); + return; + } + // set fields in commissionableDataProvider + _commissionableDataProvider->SetSpake2pIterationCount(_appParameters.spake2pIterationCount); + if (_appParameters.spake2pSalt != nil) { + chip::ByteSpan spake2pSaltSpan + = chip::ByteSpan(static_cast(_appParameters.spake2pSalt.bytes), _appParameters.spake2pSalt.length); + _commissionableDataProvider->SetSpake2pSalt(spake2pSaltSpan); + } + + if (_appParameters.spake2pVerifier != nil) { + chip::ByteSpan spake2pVerifierSpan = chip::ByteSpan( + static_cast(_appParameters.spake2pVerifier.bytes), _appParameters.spake2pVerifier.length); + _commissionableDataProvider->SetSpake2pSalt(spake2pVerifierSpan); + } + + if (_appParameters.onboardingPayload != nil) { + _commissionableDataProvider->SetSetupPasscode(_appParameters.onboardingPayload.setupPasscode); + _commissionableDataProvider->SetSetupDiscriminator(_appParameters.onboardingPayload.setupDiscriminator); + } + + uint32_t setupPasscode = 0; + uint16_t setupDiscriminator = 0; + _commissionableDataProvider->GetSetupPasscode(setupPasscode); + _commissionableDataProvider->GetSetupDiscriminator(setupDiscriminator); + _onboardingPayload = [[OnboardingPayload alloc] initWithSetupPasscode:setupPasscode setupDiscriminator:setupDiscriminator]; + } + chip::DeviceLayer::SetCommissionableDataProvider(_commissionableDataProvider); + + // Initialize device attestation config + SetDeviceAttestationCredentialsProvider(chip::Credentials::Examples::GetExampleDACProvider()); + + // Initialize device attestation verifier from a constant version + { + // TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available + const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore(); + SetDeviceAttestationVerifier(GetDefaultDACVerifier(testingRootStore)); + } + + // init app Server + static chip::CommonCaseDeviceServerInitParams initParams; + err = initParams.InitializeStaticResourcesBeforeServerInit(); + if (err != CHIP_NO_ERROR) { + ChipLogError(AppServer, "InitializeStaticResourcesBeforeServerInit failed: %s", ErrorStr(err)); + return; + } + + err = chip::Server::GetInstance().Init(initParams); + if (err != CHIP_NO_ERROR) { + ChipLogError(AppServer, "chip::Server init failed: %s", ErrorStr(err)); + return; + } + + _chipWorkQueue = chip::DeviceLayer::PlatformMgrImpl().GetWorkQueue(); + + chip::DeviceLayer::PlatformMgrImpl().StartEventLoopTask(); + + dispatch_async(_chipWorkQueue, ^{ CHIP_ERROR err = CHIP_NO_ERROR; - AppParams appParams; - if (appParameters == nil) { + AppParams appParam; + if (appParameters != nil) { err = CastingServer::GetInstance()->Init(); - } else if ((err = [ConversionUtils convertToCppAppParamsInfoFrom:appParameters outAppParams:appParams]) == CHIP_NO_ERROR) { - err = CastingServer::GetInstance()->Init(&appParams); + } else if ((err = [ConversionUtils convertToCppAppParamsInfoFrom:appParameters outAppParams:appParam]) == CHIP_NO_ERROR) { + err = CastingServer::GetInstance()->Init(&appParam); } + Boolean initAppStatus = true; if (err != CHIP_NO_ERROR) { ChipLogError(AppServer, "CastingServerBridge().initApp() failed: %" CHIP_ERROR_FORMAT, err.Format()); initAppStatus = false; diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CommissionableDataProviderImpl.hpp b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CommissionableDataProviderImpl.hpp new file mode 100644 index 00000000000000..872feb587837d3 --- /dev/null +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CommissionableDataProviderImpl.hpp @@ -0,0 +1,180 @@ +/** + * + * Copyright (c) 2020-2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CommissionableDataProviderImpl_h +#define CommissionableDataProviderImpl_h + +#pragma once + +#include +#include +#include + +namespace chip { +namespace DeviceLayer { + +class CommissionableDataProviderImpl : public CommissionableDataProvider +{ +public: + CommissionableDataProviderImpl() {} + + CHIP_ERROR GetSetupPasscode(uint32_t & setupPasscode) override + { + if (mSetupPasscode > 0) + { + setupPasscode = mSetupPasscode; + } + else + { + setupPasscode = kDefaultTestPasscode; + } + + return CHIP_NO_ERROR; + } + + CHIP_ERROR SetSetupPasscode(uint32_t setupPasscode) override + { + mSetupPasscode = setupPasscode; + return CHIP_NO_ERROR; + } + + CHIP_ERROR GetSetupDiscriminator(uint16_t & setupDiscriminator) override + { + if (mSetupDiscriminator > 0) + { + setupDiscriminator = mSetupDiscriminator; + } + else + { + setupDiscriminator = kDefaultTestDiscriminator; + } + + return CHIP_NO_ERROR; + } + + CHIP_ERROR SetSetupDiscriminator(uint16_t setupDiscriminator) override + { + mSetupDiscriminator = setupDiscriminator; + return CHIP_NO_ERROR; + } + + CHIP_ERROR GetSpake2pIterationCount(uint32_t & iterationCount) override + { + if (mSetupDiscriminator > 0) + { + iterationCount = mSpake2pIterationCount; + } + else + { + iterationCount = kDefaultTestVerifierIterationCount; + } + + return CHIP_NO_ERROR; + } + + CHIP_ERROR SetSpake2pIterationCount(uint32_t iterationCount) + { + mSpake2pIterationCount = iterationCount; + return CHIP_NO_ERROR; + } + + CHIP_ERROR GetSpake2pSalt(MutableByteSpan & saltBuf) override + { + size_t saltLen = mSpake2pSalt.data() == nullptr ? sizeof(kDefaultTestVerifierSalt) : mSpake2pSalt.size(); + if (saltBuf.size() < saltLen) + { + return CHIP_ERROR_BUFFER_TOO_SMALL; + } + + memcpy(saltBuf.data(), mSpake2pSalt.data() == nullptr ? kDefaultTestVerifierSalt : mSpake2pSalt.data(), saltLen); + saltBuf.reduce_size(saltLen); + return CHIP_NO_ERROR; + } + + CHIP_ERROR SetSpake2pSalt(ByteSpan saltBuf) + { + size_t saltLen = saltBuf.size(); + if (chip::Crypto::kSpake2p_Max_PBKDF_Salt_Length < saltLen) + { + return CHIP_ERROR_BUFFER_TOO_SMALL; + } + + mSpake2pSalt = MutableByteSpan(mSpake2pSaltBuf, chip::Crypto::kSpake2p_Max_PBKDF_Salt_Length); + + memcpy(mSpake2pSalt.data(), saltBuf.data(), saltLen); + mSpake2pSalt.reduce_size(saltLen); + return CHIP_NO_ERROR; + } + + CHIP_ERROR GetSpake2pVerifier(MutableByteSpan & verifierBuf, size_t & outVerifierLen) override + { + outVerifierLen = mSpake2pVerifier.data() == nullptr ? sizeof(kDefaultTestVerifier) : mSpake2pVerifier.size(); + if (verifierBuf.size() < outVerifierLen) + { + return CHIP_ERROR_BUFFER_TOO_SMALL; + } + memcpy(verifierBuf.data(), mSpake2pVerifier.data() == nullptr ? kDefaultTestVerifier : mSpake2pVerifier.data(), + outVerifierLen); + verifierBuf.reduce_size(outVerifierLen); + return CHIP_NO_ERROR; + } + + CHIP_ERROR SetSpake2pVerifier(MutableByteSpan verifierBuf) + { + size_t inVerifierBufLen = verifierBuf.size(); + if (chip::Crypto::kSpake2p_VerifierSerialized_Length < inVerifierBufLen) + { + return CHIP_ERROR_BUFFER_TOO_SMALL; + } + + mSpake2pVerifier = MutableByteSpan(mSpake2pSaltBuf, chip::Crypto::kSpake2p_VerifierSerialized_Length); + + memcpy(mSpake2pVerifier.data(), verifierBuf.data(), inVerifierBufLen); + mSpake2pVerifier.reduce_size(inVerifierBufLen); + return CHIP_NO_ERROR; + } + +private: + static constexpr uint32_t kDefaultTestPasscode = 20202021; + static constexpr uint16_t kDefaultTestDiscriminator = 3840; + static constexpr uint32_t kDefaultTestVerifierIterationCount = 1000; + static constexpr uint8_t kDefaultTestVerifierSalt[16] = { + 0x53, 0x50, 0x41, 0x4b, 0x45, 0x32, 0x50, 0x20, 0x4b, 0x65, 0x79, 0x20, 0x53, 0x61, 0x6c, 0x74, + }; + static constexpr uint8_t kDefaultTestVerifier[97] = { + 0xb9, 0x61, 0x70, 0xaa, 0xe8, 0x03, 0x34, 0x68, 0x84, 0x72, 0x4f, 0xe9, 0xa3, 0xb2, 0x87, 0xc3, 0x03, 0x30, 0xc2, 0xa6, + 0x60, 0x37, 0x5d, 0x17, 0xbb, 0x20, 0x5a, 0x8c, 0xf1, 0xae, 0xcb, 0x35, 0x04, 0x57, 0xf8, 0xab, 0x79, 0xee, 0x25, 0x3a, + 0xb6, 0xa8, 0xe4, 0x6b, 0xb0, 0x9e, 0x54, 0x3a, 0xe4, 0x22, 0x73, 0x6d, 0xe5, 0x01, 0xe3, 0xdb, 0x37, 0xd4, 0x41, 0xfe, + 0x34, 0x49, 0x20, 0xd0, 0x95, 0x48, 0xe4, 0xc1, 0x82, 0x40, 0x63, 0x0c, 0x4f, 0xf4, 0x91, 0x3c, 0x53, 0x51, 0x38, 0x39, + 0xb7, 0xc0, 0x7f, 0xcc, 0x06, 0x27, 0xa1, 0xb8, 0x57, 0x3a, 0x14, 0x9f, 0xcd, 0x1f, 0xa4, 0x66, 0xcf, + }; + + uint32_t mSetupPasscode = 0; + uint16_t mSetupDiscriminator = 0; + uint32_t mSpake2pIterationCount = 0; + + uint8_t mSpake2pSaltBuf[chip::Crypto::kSpake2p_Max_PBKDF_Salt_Length]; + MutableByteSpan mSpake2pSalt; + + MutableByteSpan mSpake2pVerifier; + uint8_t mSpake2pVerifierBuf[chip::Crypto::kSpake2p_VerifierSerialized_Length]; +}; + +} // namespace DeviceLayer +} // namespace chip + +#endif /* CommissionableDataProviderImpl_h */ diff --git a/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h b/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h index 0f423e2aeb459a..c362ec95c99a24 100644 --- a/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h +++ b/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h @@ -31,10 +31,7 @@ class TargetVideoPlayerInfo mOnConnectedCallback(HandleDeviceConnected, this), mOnConnectionFailureCallback(HandleDeviceConnectionFailure, this) {} - bool operator==(const TargetVideoPlayerInfo & other) - { - return this->mNodeId == other.mNodeId && this->mFabricIndex == other.mFabricIndex; - } + bool operator==(const TargetVideoPlayerInfo & other) { return this->mNodeId == other.mNodeId; } bool IsInitialized() { return mInitialized; } uint16_t GetVendorId() const { return mVendorId; } From 48d6dbc77e6f9eea5eae2e5258061ad33d09e722 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 17 Nov 2022 16:11:32 +0100 Subject: [PATCH 2/8] Install zap v2022.11.16 in Docker images. (#23643) * Install zap v2022.11.16 in Docker images. Installing from a zip file since deb installation seems to add an entire XWindows dependency and based on feedback from zap folks the zip file is the one more tested. * Fix moved line * Only keep zap-cli in the image. zap is a UI tool, not used and quite large * Remove node install: zap should be a stand-alone tool * Remove chip-build-zap because this image is not compatible anymore with missing node.js installation from the base image * Remove chip-build-zap from chip-build-vscode * Remove zap image build attempts from CI --- .github/workflows/docker_img.yaml | 1 - .../images/chip-build-vscode/Dockerfile | 3 -- .../docker/images/chip-build-zap/Dockerfile | 12 ------- .../docker/images/chip-build-zap/README.md | 8 ----- .../docker/images/chip-build-zap/build.sh | 1 - .../docker/images/chip-build-zap/run.sh | 1 - .../docker/images/chip-build-zap/version | 1 - .../docker/images/chip-build/Dockerfile | 34 +++++++++---------- integrations/docker/images/chip-build/version | 2 +- 9 files changed, 18 insertions(+), 45 deletions(-) delete mode 100644 integrations/docker/images/chip-build-zap/Dockerfile delete mode 100644 integrations/docker/images/chip-build-zap/README.md delete mode 120000 integrations/docker/images/chip-build-zap/build.sh delete mode 120000 integrations/docker/images/chip-build-zap/run.sh delete mode 120000 integrations/docker/images/chip-build-zap/version diff --git a/.github/workflows/docker_img.yaml b/.github/workflows/docker_img.yaml index bd3fb575b2957e..a0fc677dfc06d4 100644 --- a/.github/workflows/docker_img.yaml +++ b/.github/workflows/docker_img.yaml @@ -57,7 +57,6 @@ jobs: - "-openiotsdk" # NOTE: vscode image consumes ~52 GB disk space but GitHub-hosted runners provide ~10 GB free disk space(https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources) #- "-vscode" - - "-zap" steps: - uses: Wandalen/wretry.action@v1.0.36 name: Checkout diff --git a/integrations/docker/images/chip-build-vscode/Dockerfile b/integrations/docker/images/chip-build-vscode/Dockerfile index d3c4dc78efe992..ded2dcab943228 100644 --- a/integrations/docker/images/chip-build-vscode/Dockerfile +++ b/integrations/docker/images/chip-build-vscode/Dockerfile @@ -13,7 +13,6 @@ FROM connectedhomeip/chip-build-k32w:${VERSION} AS k32w FROM connectedhomeip/chip-build-imx:${VERSION} AS imx FROM connectedhomeip/chip-build-ti:${VERSION} AS ti FROM connectedhomeip/chip-build-openiotsdk:${VERSION} AS openiotsdk -FROM connectedhomeip/chip-build-zap:${VERSION} AS zap FROM connectedhomeip/chip-build:${VERSION} # qemu-src copied over because qemu directory contains symlinks to the src @@ -51,8 +50,6 @@ COPY --from=ti /opt/ti/sysconfig_1.13.0 /opt/ti/sysconfig_1.13.0 COPY --from=openiotsdk /opt/gcc-arm-none-eabi-10.3-2021.10/ /opt/gcc-arm-none-eabi-10.3-2021.10/ COPY --from=openiotsdk /opt/FVP_Corstone_SSE-300/ /opt/FVP_Corstone_SSE-300/ -COPY --from=zap /opt/zap /opt/zap - # Android license file "acceping" is done by writing license hashes # into the 'licenses' subfolder. This allows any user (in particular # 'vscode' to accept licenses) diff --git a/integrations/docker/images/chip-build-zap/Dockerfile b/integrations/docker/images/chip-build-zap/Dockerfile deleted file mode 100644 index 73b199fa665483..00000000000000 --- a/integrations/docker/images/chip-build-zap/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -ARG VERSION=latest -FROM connectedhomeip/chip-build:${VERSION} - -ENV ZAP_COMMIT=7ab717d08dfe9b0ba9de907fc7c6eb6549c86bf7 - -ENV ZAP_ORIGIN=https://github.com/project-chip/zap.git - -WORKDIR /opt -RUN git clone $ZAP_ORIGIN -WORKDIR ./zap -RUN git checkout $ZAP_COMMIT -RUN npm ci diff --git a/integrations/docker/images/chip-build-zap/README.md b/integrations/docker/images/chip-build-zap/README.md deleted file mode 100644 index e4d6f1477c198e..00000000000000 --- a/integrations/docker/images/chip-build-zap/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# ZAP - -- This Dockerfile builds https://github.com/project-chip/zap.git, which gets - copied into `chip-build-vscode` -- ZAP is also a submodule in `third_party/zap/repo`. You can check the commit - of ZAP used in the submodule by running - `git ls-tree master third_party/zap/repo | awk '{print $3}'` from the - repository root. diff --git a/integrations/docker/images/chip-build-zap/build.sh b/integrations/docker/images/chip-build-zap/build.sh deleted file mode 120000 index fcb4d4ee75d531..00000000000000 --- a/integrations/docker/images/chip-build-zap/build.sh +++ /dev/null @@ -1 +0,0 @@ -../../build.sh \ No newline at end of file diff --git a/integrations/docker/images/chip-build-zap/run.sh b/integrations/docker/images/chip-build-zap/run.sh deleted file mode 120000 index ccbd3501b330d9..00000000000000 --- a/integrations/docker/images/chip-build-zap/run.sh +++ /dev/null @@ -1 +0,0 @@ -../../run.sh \ No newline at end of file diff --git a/integrations/docker/images/chip-build-zap/version b/integrations/docker/images/chip-build-zap/version deleted file mode 120000 index a4280acd348e7f..00000000000000 --- a/integrations/docker/images/chip-build-zap/version +++ /dev/null @@ -1 +0,0 @@ -../chip-build/version \ No newline at end of file diff --git a/integrations/docker/images/chip-build/Dockerfile b/integrations/docker/images/chip-build/Dockerfile index d53978c727c8f3..ea1360ab586a97 100644 --- a/integrations/docker/images/chip-build/Dockerfile +++ b/integrations/docker/images/chip-build/Dockerfile @@ -6,7 +6,7 @@ VOLUME "/var/source" # base build and check tools and libraries layer RUN set -x \ && apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -fy \ + && DEBIAN_FRONTEND=noninteractive apt-get install -fy --fix-missing \ autoconf \ automake \ bison \ @@ -19,12 +19,14 @@ RUN set -x \ flex \ g++ \ git \ + git-lfs \ gperf \ iproute2 \ jq \ lcov \ libavahi-client-dev \ libavahi-common-dev \ + libcairo-dev \ libcairo2-dev \ libdbus-1-dev \ libdbus-glib-1-dev \ @@ -42,6 +44,7 @@ RUN set -x \ libpango1.0-dev \ libpixman-1-dev \ libreadline-dev \ + libsdl-pango-dev \ libssl-dev \ libtool \ libudev-dev \ @@ -64,7 +67,6 @@ RUN set -x \ udev \ unzip \ wget \ - git-lfs \ zlib1g-dev \ && rm -rf /var/lib/apt/lists/ \ && git lfs install \ @@ -118,21 +120,6 @@ RUN set -x \ && rm -rf bloaty \ && : # last line -# NodeJS: install a newer version than what apt-get would read -# This installs the latest LTS version of nodejs -ENV CHIP_NODE_VERSION=v16.13.2 -RUN set -x \ - && mkdir node_js \ - && cd node_js \ - && wget https://nodejs.org/dist/$CHIP_NODE_VERSION/node-$CHIP_NODE_VERSION-linux-x64.tar.xz \ - && tar xfvJ node-$CHIP_NODE_VERSION-linux-x64.tar.xz \ - && mv node-$CHIP_NODE_VERSION-linux-x64 /opt/ \ - && ln -s /opt/node-$CHIP_NODE_VERSION-linux-x64 /opt/node \ - && ln -s /opt/node/bin/* /usr/bin \ - && cd .. \ - && rm -rf node_js \ - && : # last line - # Build glib-2.0 from source with enabled thread sanitizer. This is needed for # running CHIP tests with TSAN enabled. When running applications with TSAN # all shared libraries should be built with TSAN enabled, otherwise TSAN might @@ -148,3 +135,16 @@ RUN set -x \ && mv glib/build-image/usr/local/lib/x86_64-linux-gnu/lib* $LD_LIBRARY_PATH_TSAN \ && rm -rf glib \ && : # last line + +# Install a known ZAP release +# Only keep the cli version, since `zap` is 143MB and not usable (UI) +ENV ZAP_VERSION=v2022.11.16 +RUN set -x \ + && mkdir -p /opt/zap-${ZAP_VERSION} \ + && cd /opt/zap-${ZAP_VERSION} \ + && wget https://github.com/project-chip/zap/releases/download/${ZAP_VERSION}/zap-linux.zip \ + && unzip zap-linux.zip \ + && rm zap-linux.zip \ + && rm zap \ + && ln -s /opt/zap-${ZAP_VERSION}/zap /usr/bin/ \ + && : # last line diff --git a/integrations/docker/images/chip-build/version b/integrations/docker/images/chip-build/version index 20f61fad306b4e..70fadae772ee59 100644 --- a/integrations/docker/images/chip-build/version +++ b/integrations/docker/images/chip-build/version @@ -1 +1 @@ -0.6.08 Version bump reason: Update ESP-IDF to v4.4.3 release +0.6.09 Version bump reason: Install zap v2022.11.16 in docker images. From b1f48e281aeb561f80b2c7cdd457f403c1e16731 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 17 Nov 2022 16:39:20 +0100 Subject: [PATCH 3/8] Hotfix: correct zap cli symlink for chip build dockerfile (#23662) --- integrations/docker/images/chip-build/Dockerfile | 2 +- integrations/docker/images/chip-build/version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integrations/docker/images/chip-build/Dockerfile b/integrations/docker/images/chip-build/Dockerfile index ea1360ab586a97..6ecb84359ff118 100644 --- a/integrations/docker/images/chip-build/Dockerfile +++ b/integrations/docker/images/chip-build/Dockerfile @@ -146,5 +146,5 @@ RUN set -x \ && unzip zap-linux.zip \ && rm zap-linux.zip \ && rm zap \ - && ln -s /opt/zap-${ZAP_VERSION}/zap /usr/bin/ \ + && ln -s /opt/zap-${ZAP_VERSION}/zap-cli /usr/bin/ \ && : # last line diff --git a/integrations/docker/images/chip-build/version b/integrations/docker/images/chip-build/version index 70fadae772ee59..7ab8f4209d3d23 100644 --- a/integrations/docker/images/chip-build/version +++ b/integrations/docker/images/chip-build/version @@ -1 +1 @@ -0.6.09 Version bump reason: Install zap v2022.11.16 in docker images. +0.6.10 Version bump reason: Fix zap link (link zap-cli into /usr/bin instead of zap) From bdfc185692381cff13d781710ca801a9c4bc2abb Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 17 Nov 2022 10:46:58 -0500 Subject: [PATCH 4/8] Remove all mention of "pairing" from non-deprecated Darwin public APIs. (#23647) This is a re-landing of PR #22676, but with backwards-compat shims in place. The change to MTRDeviceControllerDelegate is OK because this is a newly-introduced protocol. --- .../pairing/DeviceControllerDelegateBridge.h | 3 +-- .../pairing/DeviceControllerDelegateBridge.mm | 7 +------ .../commands/tests/TestCommandBridge.h | 12 ++--------- .../Framework/CHIP/MTRDeviceController.h | 8 ++++---- .../Framework/CHIP/MTRDeviceController.mm | 8 ++------ .../CHIP/MTRDeviceControllerDelegate.h | 20 ++++++------------- .../CHIP/MTRDeviceControllerDelegateBridge.mm | 14 +++---------- src/darwin/Framework/CHIP/MTRSetupPayload.h | 12 ++++++----- .../Framework/CHIPTests/MTRDeviceTests.m | 2 +- .../CHIPTests/MTRXPCListenerSampleTests.m | 2 +- 10 files changed, 28 insertions(+), 60 deletions(-) diff --git a/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.h b/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.h index 1c48daba882f0a..7d62b1ba960fb4 100644 --- a/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.h +++ b/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.h @@ -26,8 +26,7 @@ @property MTRDeviceController * commissioner; @property MTRCommissioningParameters * params; -- (void)onPairingComplete:(NSError *)error; -- (void)onPairingDeleted:(NSError *)error; +- (void)onCommissioningSessionEstablishmentDone:(NSError *)error; - (void)onCommissioningComplete:(NSError *)error; @end diff --git a/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.mm b/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.mm index e83f81089b45b8..06dd78a7d8ffc8 100644 --- a/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.mm +++ b/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.mm @@ -44,7 +44,7 @@ - (void)onStatusUpdate:(MTRCommissioningStatus)status } } -- (void)onPairingComplete:(NSError *)error +- (void)onCommissioningSessionEstablishmentDone:(NSError *)error { if (error != nil) { ChipLogProgress(chipTool, "PASE establishment failed"); @@ -61,11 +61,6 @@ - (void)onPairingComplete:(NSError *)error } } -- (void)onPairingDeleted:(NSError *)error -{ - _commandBridge->SetCommandExitStatus(error, "Pairing Delete"); -} - - (void)onCommissioningComplete:(NSError *)error { _commandBridge->SetCommandExitStatus(error, "Pairing Commissioning Complete"); diff --git a/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h b/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h index 8c4fe33d0ea87f..8f031981bd82b3 100644 --- a/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h +++ b/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h @@ -49,8 +49,7 @@ constexpr const char * kDefaultKey = "default"; @property BOOL active; // Whether to pass on notifications to the commandBridge - (void)onStatusUpdate:(MTRCommissioningStatus)status; -- (void)onPairingComplete:(NSError * _Nullable)error; -- (void)onPairingDeleted:(NSError * _Nullable)error; +- (void)onCommissioningSessionEstablishmentDone:(NSError * _Nullable)error; - (void)onCommissioningComplete:(NSError * _Nullable)error; - (instancetype)init NS_UNAVAILABLE; @@ -543,7 +542,7 @@ NS_ASSUME_NONNULL_BEGIN } } -- (void)onPairingComplete:(NSError * _Nullable)error +- (void)onCommissioningSessionEstablishmentDone:(NSError * _Nullable)error { if (_active) { if (error != nil) { @@ -557,13 +556,6 @@ NS_ASSUME_NONNULL_BEGIN } } -- (void)onPairingDeleted:(NSError * _Nullable)error -{ - if (_active) { - _commandBridge->PairingDeleted(); - } -} - - (void)onCommissioningComplete:(NSError * _Nullable)error { if (_active) { diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.h b/src/darwin/Framework/CHIP/MTRDeviceController.h index 4f46861da7de3c..6a2616a53eeb00 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController.h +++ b/src/darwin/Framework/CHIP/MTRDeviceController.h @@ -58,9 +58,9 @@ typedef void (^MTRDeviceConnectionCallback)(MTRBaseDevice * _Nullable device, NS * provided discriminator. * * Then a PASE session will be established with the device, unless an error - * occurs. MTRDevicePairingDelegate will be notified as follows: + * occurs. MTRDeviceControllerDelegate will be notified as follows: * - * * Discovery fails: onStatusUpdate with MTRPairingStatusFailed. + * * Discovery fails: onStatusUpdate with MTRCommissioningStatusFailed. * * * Discovery succeeds but commissioning session setup fails: onPairingComplete * with an error. @@ -109,9 +109,9 @@ typedef void (^MTRDeviceConnectionCallback)(MTRBaseDevice * _Nullable device, NS + (instancetype)new NS_UNAVAILABLE; /** - * Set the Delegate for the Device Pairing as well as the Queue on which the Delegate callbacks will be triggered + * Set the Delegate for the device controller as well as the Queue on which the Delegate callbacks will be triggered * - * @param[in] delegate The delegate the pairing process should use + * @param[in] delegate The delegate the commissioning process should use * * @param[in] queue The queue on which the callbacks will be delivered */ diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.mm b/src/darwin/Framework/CHIP/MTRDeviceController.mm index 9dadeb117ce406..c183353d70658e 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceController.mm @@ -850,7 +850,7 @@ - (BOOL)respondsToSelector:(SEL)selector return [self.delegate respondsToSelector:@selector(onStatusUpdate:)]; } - if (selector == @selector(onPairingComplete:)) { + if (selector == @selector(onCommissioningSessionEstablishmentDone:)) { return [self.delegate respondsToSelector:@selector(onPairingComplete:)]; } @@ -858,10 +858,6 @@ - (BOOL)respondsToSelector:(SEL)selector return [self.delegate respondsToSelector:@selector(onCommissioningComplete:)]; } - if (selector == @selector(onPairingDeleted:)) { - return [self.delegate respondsToSelector:@selector(onPairingDeleted:)]; - } - return [super respondsToSelector:selector]; } @@ -870,7 +866,7 @@ - (void)onStatusUpdate:(MTRCommissioningStatus)status [self.delegate onStatusUpdate:static_cast(status)]; } -- (void)onPairingComplete:(NSError * _Nullable)error +- (void)onCommissioningSessionEstablishmentDone:(NSError * _Nullable)error { [self.delegate onPairingComplete:error]; } diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h index fc0c0d9ec2d008..3b549c45c674cf 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h @@ -27,7 +27,7 @@ typedef NS_ENUM(NSInteger, MTRCommissioningStatus) { } MTR_NEWLY_AVAILABLE; /** - * The protocol definition for the MTRDeviceControllerDelegate + * The protocol definition for the MTRDeviceControllerDelegate. * * All delegate methods will be called on the supplied Delegate Queue. */ @@ -35,29 +35,21 @@ MTR_NEWLY_AVAILABLE @protocol MTRDeviceControllerDelegate @optional /** - * Notify the delegate when pairing status gets updated - * + * Notify the delegate when commissioning status gets updated. */ - (void)onStatusUpdate:(MTRCommissioningStatus)status; /** - * Notify the delegate when pairing is completed - * + * Notify the delegate when a commissioning session is established or the + * establishment has errored out. */ -- (void)onPairingComplete:(NSError * _Nullable)error; +- (void)onCommissioningSessionEstablishmentDone:(NSError * _Nullable)error; /** - * Notify the delegate when commissioning is completed - * + * Notify the delegate when commissioning is completed. */ - (void)onCommissioningComplete:(NSError * _Nullable)error; -/** - * Notify the delegate when pairing is deleted - * - */ -- (void)onPairingDeleted:(NSError * _Nullable)error; - @end typedef NS_ENUM(NSUInteger, MTRPairingStatus) { diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm index 7ef07f87ce860c..f84a99e4d2664b 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm @@ -73,11 +73,11 @@ NSLog(@"DeviceControllerDelegate Pairing complete. Status %s", chip::ErrorStr(error)); id strongDelegate = mDelegate; - if ([strongDelegate respondsToSelector:@selector(onPairingComplete:)]) { + if ([strongDelegate respondsToSelector:@selector(onCommissioningSessionEstablishmentDone:)]) { if (strongDelegate && mQueue) { dispatch_async(mQueue, ^{ NSError * nsError = [MTRError errorForCHIPErrorCode:error]; - [strongDelegate onPairingComplete:nsError]; + [strongDelegate onCommissioningSessionEstablishmentDone:nsError]; }); } } @@ -87,15 +87,7 @@ { NSLog(@"DeviceControllerDelegate Pairing deleted. Status %s", chip::ErrorStr(error)); - id strongDelegate = mDelegate; - if ([strongDelegate respondsToSelector:@selector(onPairingDeleted:)]) { - if (strongDelegate && mQueue) { - dispatch_async(mQueue, ^{ - NSError * nsError = [MTRError errorForCHIPErrorCode:error]; - [strongDelegate onPairingDeleted:nsError]; - }); - } - } + // This is never actually called; just do nothing. } void MTRDeviceControllerDelegateBridge::OnCommissioningComplete(chip::NodeId nodeId, CHIP_ERROR error) diff --git a/src/darwin/Framework/CHIP/MTRSetupPayload.h b/src/darwin/Framework/CHIP/MTRSetupPayload.h index 3b50b86a974f46..2fdb9929e4471c 100644 --- a/src/darwin/Framework/CHIP/MTRSetupPayload.h +++ b/src/darwin/Framework/CHIP/MTRSetupPayload.h @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN typedef NS_OPTIONS(NSUInteger, MTRDiscoveryCapabilities) { - MTRDiscoveryCapabilitiesUnknown = 0, // Device capabilities are not known (e.g. all we have is a manual pairing code). + MTRDiscoveryCapabilitiesUnknown = 0, // Device capabilities are not known (e.g. all we have is a numeric code). MTRDiscoveryCapabilitiesNone MTR_NEWLY_DEPRECATED("Please use MTRDiscoveryCapabilitiesUnknown") = 0, MTRDiscoveryCapabilitiesSoftAP = 1 << 0, // Device supports WiFi softAP MTRDiscoveryCapabilitiesBLE = 1 << 1, // Device supports BLE @@ -31,8 +31,8 @@ typedef NS_OPTIONS(NSUInteger, MTRDiscoveryCapabilities) { }; typedef NS_ENUM(NSUInteger, MTRCommissioningFlow) { - MTRCommissioningFlowStandard = 0, // Device automatically enters pairing mode upon power-up - MTRCommissioningFlowUserActionRequired = 1, // Device requires a user interaction to enter pairing mode + MTRCommissioningFlowStandard = 0, // Device automatically enters commissioning mode upon power-up + MTRCommissioningFlowUserActionRequired = 1, // Device requires a user interaction to enter commissioning mode MTRCommissioningFlowCustom = 2, // Commissioning steps should be retrieved from the distributed compliance ledger MTRCommissioningFlowInvalid = 3, }; @@ -58,8 +58,10 @@ typedef NS_ENUM(NSUInteger, MTROptionalQRCodeInfoType) { @end /** - * A setup payload that can be created from a pairing code and serialized to a - * pairing code. + * A setup payload that can be created from a numeric code or QR code and + * serialized to a numeric code or QR code, though serializing to QR code after + * creating from numeric code will not work, because some required information + * will be missing. */ @interface MTRSetupPayload : NSObject diff --git a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m index 83b9762579f03f..2a7afeb112de66 100644 --- a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m +++ b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m @@ -94,7 +94,7 @@ - (id)initWithExpectation:(XCTestExpectation *)expectation return self; } -- (void)onPairingComplete:(NSError *)error +- (void)onCommissioningSessionEstablishmentDone:(NSError *)error { XCTAssertEqual(error.code, 0); diff --git a/src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m b/src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m index c9bd521dd9b877..ab6395921e54eb 100644 --- a/src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m +++ b/src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m @@ -419,7 +419,7 @@ - (id)initWithExpectation:(XCTestExpectation *)expectation return self; } -- (void)onPairingComplete:(NSError *)error +- (void)onCommissioningSessionEstablishmentDone:(NSError *)error { XCTAssertEqual(error.code, 0); NSError * commissionError = nil; From c6272c6b9c4d71173f20592411285aaba0997315 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 17 Nov 2022 11:33:08 -0500 Subject: [PATCH 5/8] Add missing endWork calls in MTRClusters. (#23659) We were missing endWork bits for command invokes when the command has a data (not status) response. This would end up permanently blocking the MTRDevice's work queue once such a command (e.g. UpdateFabricLabel) was issued. The changes here are as follows: 1) Rearrange the logic in MTRClusters-src.zapt so that the endWork happens regardless of whether hasSpecificResponse is true. 2) Add a deprecation message to the timedInvokeTimeoutMs field in _response_ command params, since that should never be used (ran into this when writing the tests for this PR). 3) Set resubscribeIfLost to NO on various subscriptions in MTRDeviceTests, so if another test takes a while we don't fail due to the canceled subscriptions re-subscribing and over-fullfilling the subscription expectations. 4) Add a test for a mix of passing and failing commands on MTRCluster instances, with some of the commands defined as getting status-only responses and some defined as getting data responses. This test fails without the endWork fix. --- .../CHIP/templates/MTRClusters-src.zapt | 10 +- .../templates/MTRCommandPayloadsObjc.zapt | 2 +- .../CHIP/zap-generated/MTRClusters.mm | 571 +++++++++++++++--- .../zap-generated/MTRCommandPayloadsObjc.h | 168 ++++-- .../Framework/CHIPTests/MTRDeviceTests.m | 89 +++ 5 files changed, 687 insertions(+), 153 deletions(-) diff --git a/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt b/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt index fa78f8f0439559..c427058683ea2d 100644 --- a/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt @@ -62,19 +62,19 @@ using chip::SessionHandle; MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice *baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; auto * bridge = new MTR{{>callbackName}}CallbackBridge(self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { {{#if hasSpecificResponse}} {{! This treats completion as taking an id for the data. This is not great from a type-safety perspective, of course. }} - completion, + completion(value, error); {{else}} {{! For now, don't change the bridge API; instead just use an adapter to invoke our completion handler. This is not great from a type-safety perspective, of course. }} - ^(id _Nullable value, NSError * _Nullable error) { - completion(error); - [workItem endWork]; - }, + completion(error); {{/if}} + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, {{>callbackName}}CallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { chip::Optional timedInvokeTimeoutMs; ListFreer listFreer; diff --git a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc.zapt b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc.zapt index 78a0c88f39d69f..3fab331d0edf2c 100644 --- a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc.zapt @@ -31,7 +31,7 @@ MTR_NEWLY_AVAILABLE * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs {{#if (isStrEqual source "server")}}MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"){{/if}}; - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm index f913d7b09f4e67..8476a3f78293bc 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm @@ -291,7 +291,12 @@ - (void)addGroupWithParams:(MTRGroupsClusterAddGroupParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRGroupsClusterAddGroupResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRGroupsClusterAddGroupResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, GroupsClusterAddGroupResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { chip::Optional timedInvokeTimeoutMs; @@ -337,7 +342,12 @@ - (void)viewGroupWithParams:(MTRGroupsClusterViewGroupParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRGroupsClusterViewGroupResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRGroupsClusterViewGroupResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, GroupsClusterViewGroupResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { chip::Optional timedInvokeTimeoutMs; @@ -382,7 +392,12 @@ - (void)getGroupMembershipWithParams:(MTRGroupsClusterGetGroupMembershipParams * MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRGroupsClusterGetGroupMembershipResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRGroupsClusterGetGroupMembershipResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, GroupsClusterGetGroupMembershipResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -449,7 +464,12 @@ - (void)removeGroupWithParams:(MTRGroupsClusterRemoveGroupParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRGroupsClusterRemoveGroupResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRGroupsClusterRemoveGroupResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, GroupsClusterRemoveGroupResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -761,7 +781,12 @@ - (void)addSceneWithParams:(MTRScenesClusterAddSceneParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRScenesClusterAddSceneResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRScenesClusterAddSceneResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, ScenesClusterAddSceneResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { chip::Optional timedInvokeTimeoutMs; @@ -883,7 +908,12 @@ - (void)viewSceneWithParams:(MTRScenesClusterViewSceneParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRScenesClusterViewSceneResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRScenesClusterViewSceneResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, ScenesClusterViewSceneResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { chip::Optional timedInvokeTimeoutMs; @@ -929,7 +959,12 @@ - (void)removeSceneWithParams:(MTRScenesClusterRemoveSceneParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRScenesClusterRemoveSceneResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRScenesClusterRemoveSceneResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, ScenesClusterRemoveSceneResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -976,7 +1011,12 @@ - (void)removeAllScenesWithParams:(MTRScenesClusterRemoveAllScenesParams *)param MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRScenesClusterRemoveAllScenesResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRScenesClusterRemoveAllScenesResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, ScenesClusterRemoveAllScenesResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -1022,7 +1062,12 @@ - (void)storeSceneWithParams:(MTRScenesClusterStoreSceneParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRScenesClusterStoreSceneResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRScenesClusterStoreSceneResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, ScenesClusterStoreSceneResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { chip::Optional timedInvokeTimeoutMs; @@ -1127,7 +1172,12 @@ - (void)getSceneMembershipWithParams:(MTRScenesClusterGetSceneMembershipParams * MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRScenesClusterGetSceneMembershipResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRScenesClusterGetSceneMembershipResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, ScenesClusterGetSceneMembershipResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -1173,7 +1223,12 @@ - (void)enhancedAddSceneWithParams:(MTRScenesClusterEnhancedAddSceneParams *)par MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRScenesClusterEnhancedAddSceneResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRScenesClusterEnhancedAddSceneResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, ScenesClusterEnhancedAddSceneResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -1296,7 +1351,12 @@ - (void)enhancedViewSceneWithParams:(MTRScenesClusterEnhancedViewSceneParams *)p MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRScenesClusterEnhancedViewSceneResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRScenesClusterEnhancedViewSceneResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, ScenesClusterEnhancedViewSceneResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -1343,7 +1403,12 @@ - (void)copySceneWithParams:(MTRScenesClusterCopySceneParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRScenesClusterCopySceneResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRScenesClusterCopySceneResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, ScenesClusterCopySceneResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { chip::Optional timedInvokeTimeoutMs; @@ -5026,7 +5091,12 @@ - (void)queryImageWithParams:(MTROtaSoftwareUpdateProviderClusterQueryImageParam MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTROtaSoftwareUpdateProviderClusterQueryImageResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTROtaSoftwareUpdateProviderClusterQueryImageResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, OtaSoftwareUpdateProviderClusterQueryImageResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -5114,7 +5184,12 @@ - (void)applyUpdateRequestWithParams:(MTROtaSoftwareUpdateProviderClusterApplyUp MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTROtaSoftwareUpdateProviderClusterApplyUpdateResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTROtaSoftwareUpdateProviderClusterApplyUpdateResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -6225,7 +6300,12 @@ - (void)armFailSafeWithParams:(MTRGeneralCommissioningClusterArmFailSafeParams * MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRGeneralCommissioningClusterArmFailSafeResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRGeneralCommissioningClusterArmFailSafeResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, GeneralCommissioningClusterArmFailSafeResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -6272,7 +6352,12 @@ - (void)setRegulatoryConfigWithParams:(MTRGeneralCommissioningClusterSetRegulato MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRGeneralCommissioningClusterSetRegulatoryConfigResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRGeneralCommissioningClusterSetRegulatoryConfigResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, GeneralCommissioningClusterSetRegulatoryConfigResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -6334,21 +6419,25 @@ - (void)commissioningCompleteWithParams:(MTRGeneralCommissioningClusterCommissio MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge - = new MTRGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge(self.callbackQueue, completion, - ^(ExchangeManager & exchangeManager, const SessionHandle & session, - GeneralCommissioningClusterCommissioningCompleteResponseCallbackType successCb, MTRErrorCallback failureCb, - MTRCallbackBridgeBase * bridge) { - chip::Optional timedInvokeTimeoutMs; - ListFreer listFreer; - GeneralCommissioning::Commands::CommissioningComplete::Type request; - if (timedInvokeTimeoutMsParam != nil) { - timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue); - } + auto * bridge = new MTRGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, + ^(ExchangeManager & exchangeManager, const SessionHandle & session, + GeneralCommissioningClusterCommissioningCompleteResponseCallbackType successCb, MTRErrorCallback failureCb, + MTRCallbackBridgeBase * bridge) { + chip::Optional timedInvokeTimeoutMs; + ListFreer listFreer; + GeneralCommissioning::Commands::CommissioningComplete::Type request; + if (timedInvokeTimeoutMsParam != nil) { + timedInvokeTimeoutMs.SetValue(timedInvokeTimeoutMsParam.unsignedShortValue); + } - chip::Controller::GeneralCommissioningCluster cppCluster(exchangeManager, session, self->_endpoint); - return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs); - }); + chip::Controller::GeneralCommissioningCluster cppCluster(exchangeManager, session, self->_endpoint); + return cppCluster.InvokeCommand(request, bridge, successCb, failureCb, timedInvokeTimeoutMs); + }); std::move(*bridge).DispatchAction(baseDevice); }; workItem.readyHandler = readyHandler; @@ -6567,7 +6656,12 @@ - (void)scanNetworksWithParams:(MTRNetworkCommissioningClusterScanNetworksParams MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRNetworkCommissioningClusterScanNetworksResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRNetworkCommissioningClusterScanNetworksResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, NetworkCommissioningClusterScanNetworksResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -6627,7 +6721,12 @@ - (void)addOrUpdateWiFiNetworkWithParams:(MTRNetworkCommissioningClusterAddOrUpd MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRNetworkCommissioningClusterNetworkConfigResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRNetworkCommissioningClusterNetworkConfigResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, NetworkCommissioningClusterNetworkConfigResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -6678,7 +6777,12 @@ - (void)addOrUpdateThreadNetworkWithParams:(MTRNetworkCommissioningClusterAddOrU MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRNetworkCommissioningClusterNetworkConfigResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRNetworkCommissioningClusterNetworkConfigResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, NetworkCommissioningClusterNetworkConfigResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -6728,7 +6832,12 @@ - (void)removeNetworkWithParams:(MTRNetworkCommissioningClusterRemoveNetworkPara MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRNetworkCommissioningClusterNetworkConfigResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRNetworkCommissioningClusterNetworkConfigResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, NetworkCommissioningClusterNetworkConfigResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -6778,7 +6887,12 @@ - (void)connectNetworkWithParams:(MTRNetworkCommissioningClusterConnectNetworkPa MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRNetworkCommissioningClusterConnectNetworkResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRNetworkCommissioningClusterConnectNetworkResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, NetworkCommissioningClusterConnectNetworkResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -6828,7 +6942,12 @@ - (void)reorderNetworkWithParams:(MTRNetworkCommissioningClusterReorderNetworkPa MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRNetworkCommissioningClusterNetworkConfigResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRNetworkCommissioningClusterNetworkConfigResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, NetworkCommissioningClusterNetworkConfigResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -7122,7 +7241,12 @@ - (void)retrieveLogsRequestWithParams:(MTRDiagnosticLogsClusterRetrieveLogsReque MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRDiagnosticLogsClusterRetrieveLogsResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRDiagnosticLogsClusterRetrieveLogsResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, DiagnosticLogsClusterRetrieveLogsResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -9352,7 +9476,12 @@ - (void)attestationRequestWithParams:(MTROperationalCredentialsClusterAttestatio MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTROperationalCredentialsClusterAttestationResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTROperationalCredentialsClusterAttestationResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, OperationalCredentialsClusterAttestationResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -9398,7 +9527,12 @@ - (void)certificateChainRequestWithParams:(MTROperationalCredentialsClusterCerti MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTROperationalCredentialsClusterCertificateChainResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTROperationalCredentialsClusterCertificateChainResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, OperationalCredentialsClusterCertificateChainResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -9444,7 +9578,12 @@ - (void)CSRRequestWithParams:(MTROperationalCredentialsClusterCSRRequestParams * MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTROperationalCredentialsClusterCSRResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTROperationalCredentialsClusterCSRResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, OperationalCredentialsClusterCSRResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -9494,7 +9633,12 @@ - (void)addNOCWithParams:(MTROperationalCredentialsClusterAddNOCParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTROperationalCredentialsClusterNOCResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTROperationalCredentialsClusterNOCResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, OperationalCredentialsClusterNOCResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -9548,7 +9692,12 @@ - (void)updateNOCWithParams:(MTROperationalCredentialsClusterUpdateNOCParams *)p MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTROperationalCredentialsClusterNOCResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTROperationalCredentialsClusterNOCResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, OperationalCredentialsClusterNOCResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -9598,7 +9747,12 @@ - (void)updateFabricLabelWithParams:(MTROperationalCredentialsClusterUpdateFabri MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTROperationalCredentialsClusterNOCResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTROperationalCredentialsClusterNOCResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, OperationalCredentialsClusterNOCResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -9644,7 +9798,12 @@ - (void)removeFabricWithParams:(MTROperationalCredentialsClusterRemoveFabricPara MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTROperationalCredentialsClusterNOCResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTROperationalCredentialsClusterNOCResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, OperationalCredentialsClusterNOCResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -10057,7 +10216,12 @@ - (void)keySetReadWithParams:(MTRGroupKeyManagementClusterKeySetReadParams *)par MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRGroupKeyManagementClusterKeySetReadResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRGroupKeyManagementClusterKeySetReadResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, GroupKeyManagementClusterKeySetReadResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -10152,7 +10316,12 @@ - (void)keySetReadAllIndicesWithParams:(MTRGroupKeyManagementClusterKeySetReadAl MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRGroupKeyManagementClusterKeySetReadAllIndicesResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRGroupKeyManagementClusterKeySetReadAllIndicesResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, GroupKeyManagementClusterKeySetReadAllIndicesResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -11064,7 +11233,12 @@ - (void)getWeekDayScheduleWithParams:(MTRDoorLockClusterGetWeekDayScheduleParams MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRDoorLockClusterGetWeekDayScheduleResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRDoorLockClusterGetWeekDayScheduleResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, DoorLockClusterGetWeekDayScheduleResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -11213,7 +11387,12 @@ - (void)getYearDayScheduleWithParams:(MTRDoorLockClusterGetYearDayScheduleParams MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRDoorLockClusterGetYearDayScheduleResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRDoorLockClusterGetYearDayScheduleResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, DoorLockClusterGetYearDayScheduleResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -11363,7 +11542,12 @@ - (void)getHolidayScheduleWithParams:(MTRDoorLockClusterGetHolidayScheduleParams MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRDoorLockClusterGetHolidayScheduleResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRDoorLockClusterGetHolidayScheduleResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, DoorLockClusterGetHolidayScheduleResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -11544,7 +11728,12 @@ - (void)getUserWithParams:(MTRDoorLockClusterGetUserParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRDoorLockClusterGetUserResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRDoorLockClusterGetUserResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, DoorLockClusterGetUserResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { chip::Optional timedInvokeTimeoutMs; @@ -11641,7 +11830,12 @@ - (void)setCredentialWithParams:(MTRDoorLockClusterSetCredentialParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRDoorLockClusterSetCredentialResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRDoorLockClusterSetCredentialResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, DoorLockClusterSetCredentialResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -11716,7 +11910,12 @@ - (void)getCredentialStatusWithParams:(MTRDoorLockClusterGetCredentialStatusPara MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRDoorLockClusterGetCredentialStatusResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRDoorLockClusterGetCredentialStatusResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, DoorLockClusterGetCredentialStatusResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -14349,7 +14548,12 @@ - (void)getWeeklyScheduleWithParams:(MTRThermostatClusterGetWeeklyScheduleParams MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRThermostatClusterGetWeeklyScheduleResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRThermostatClusterGetWeeklyScheduleResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, ThermostatClusterGetWeeklyScheduleResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -19238,7 +19442,12 @@ - (void)changeChannelWithParams:(MTRChannelClusterChangeChannelParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRChannelClusterChangeChannelResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRChannelClusterChangeChannelResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, ChannelClusterChangeChannelResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -19507,7 +19716,12 @@ - (void)navigateTargetWithParams:(MTRTargetNavigatorClusterNavigateTargetParams MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRTargetNavigatorClusterNavigateTargetResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRTargetNavigatorClusterNavigateTargetResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, TargetNavigatorClusterNavigateTargetResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -19661,7 +19875,12 @@ - (void)playWithParams:(MTRMediaPlaybackClusterPlayParams * _Nullable)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -19713,7 +19932,12 @@ - (void)pauseWithParams:(MTRMediaPlaybackClusterPauseParams * _Nullable)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -19768,7 +19992,12 @@ - (void)stopPlaybackWithParams:(MTRMediaPlaybackClusterStopPlaybackParams * _Nul MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -19823,7 +20052,12 @@ - (void)startOverWithParams:(MTRMediaPlaybackClusterStartOverParams * _Nullable) MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -19875,7 +20109,12 @@ - (void)previousWithParams:(MTRMediaPlaybackClusterPreviousParams * _Nullable)pa MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -19927,7 +20166,12 @@ - (void)nextWithParams:(MTRMediaPlaybackClusterNextParams * _Nullable)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -19979,7 +20223,12 @@ - (void)rewindWithParams:(MTRMediaPlaybackClusterRewindParams * _Nullable)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -20034,7 +20283,12 @@ - (void)fastForwardWithParams:(MTRMediaPlaybackClusterFastForwardParams * _Nulla MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -20079,7 +20333,12 @@ - (void)skipForwardWithParams:(MTRMediaPlaybackClusterSkipForwardParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -20125,7 +20384,12 @@ - (void)skipBackwardWithParams:(MTRMediaPlaybackClusterSkipBackwardParams *)para MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -20171,7 +20435,12 @@ - (void)seekWithParams:(MTRMediaPlaybackClusterSeekParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRMediaPlaybackClusterPlaybackResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, MediaPlaybackClusterPlaybackResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -21065,7 +21334,12 @@ - (void)sendKeyWithParams:(MTRKeypadInputClusterSendKeyParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRKeypadInputClusterSendKeyResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRKeypadInputClusterSendKeyResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, KeypadInputClusterSendKeyResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -21191,7 +21465,12 @@ - (void)launchContentWithParams:(MTRContentLauncherClusterLaunchContentParams *) MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRContentLauncherClusterLaunchResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRContentLauncherClusterLaunchResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, ContentLauncherClusterLaunchResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -21294,7 +21573,12 @@ - (void)launchURLWithParams:(MTRContentLauncherClusterLaunchURLParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRContentLauncherClusterLaunchResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRContentLauncherClusterLaunchResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, ContentLauncherClusterLaunchResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -21771,7 +22055,12 @@ - (void)launchAppWithParams:(MTRApplicationLauncherClusterLaunchAppParams *)para MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRApplicationLauncherClusterLauncherResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRApplicationLauncherClusterLauncherResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, ApplicationLauncherClusterLauncherResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -21822,7 +22111,12 @@ - (void)stopAppWithParams:(MTRApplicationLauncherClusterStopAppParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRApplicationLauncherClusterLauncherResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRApplicationLauncherClusterLauncherResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, ApplicationLauncherClusterLauncherResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -21869,7 +22163,12 @@ - (void)hideAppWithParams:(MTRApplicationLauncherClusterHideAppParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRApplicationLauncherClusterLauncherResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRApplicationLauncherClusterLauncherResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, ApplicationLauncherClusterLauncherResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -22189,7 +22488,12 @@ - (void)getSetupPINWithParams:(MTRAccountLoginClusterGetSetupPINParams *)params MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRAccountLoginClusterGetSetupPINResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRAccountLoginClusterGetSetupPINResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, AccountLoginClusterGetSetupPINResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -24018,7 +24322,12 @@ - (void)testSpecificWithParams:(MTRUnitTestingClusterTestSpecificParams * _Nulla MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRUnitTestingClusterTestSpecificResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRUnitTestingClusterTestSpecificResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, UnitTestingClusterTestSpecificResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -24120,7 +24429,12 @@ - (void)testAddArgumentsWithParams:(MTRUnitTestingClusterTestAddArgumentsParams MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRUnitTestingClusterTestAddArgumentsResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRUnitTestingClusterTestAddArgumentsResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, UnitTestingClusterTestAddArgumentsResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -24167,7 +24481,12 @@ - (void)testSimpleArgumentRequestWithParams:(MTRUnitTestingClusterTestSimpleArgu MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRUnitTestingClusterTestSimpleArgumentResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRUnitTestingClusterTestSimpleArgumentResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, UnitTestingClusterTestSimpleArgumentResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -24214,7 +24533,12 @@ - (void)testStructArrayArgumentRequestWithParams:(MTRUnitTestingClusterTestStruc MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRUnitTestingClusterTestStructArrayArgumentResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRUnitTestingClusterTestStructArrayArgumentResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, UnitTestingClusterTestStructArrayArgumentResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -24471,7 +24795,12 @@ - (void)testStructArgumentRequestWithParams:(MTRUnitTestingClusterTestStructArgu MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRUnitTestingClusterBooleanResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRUnitTestingClusterBooleanResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, UnitTestingClusterBooleanResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -24524,7 +24853,12 @@ - (void)testNestedStructArgumentRequestWithParams:(MTRUnitTestingClusterTestNest MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRUnitTestingClusterBooleanResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRUnitTestingClusterBooleanResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, UnitTestingClusterBooleanResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -24581,7 +24915,12 @@ - (void)testListStructArgumentRequestWithParams:(MTRUnitTestingClusterTestListSt MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRUnitTestingClusterBooleanResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRUnitTestingClusterBooleanResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, UnitTestingClusterBooleanResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -24657,7 +24996,12 @@ - (void)testListInt8UArgumentRequestWithParams:(MTRUnitTestingClusterTestListInt MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRUnitTestingClusterBooleanResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRUnitTestingClusterBooleanResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, UnitTestingClusterBooleanResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -24724,7 +25068,12 @@ - (void)testNestedStructListArgumentRequestWithParams:(MTRUnitTestingClusterTest MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRUnitTestingClusterBooleanResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRUnitTestingClusterBooleanResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, UnitTestingClusterBooleanResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -24879,7 +25228,12 @@ - (void)testListNestedStructListArgumentRequestWithParams: MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRUnitTestingClusterBooleanResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRUnitTestingClusterBooleanResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, UnitTestingClusterBooleanResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -25058,7 +25412,12 @@ - (void)testListInt8UReverseRequestWithParams:(MTRUnitTestingClusterTestListInt8 MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRUnitTestingClusterTestListInt8UReverseResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRUnitTestingClusterTestListInt8UReverseResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, UnitTestingClusterTestListInt8UReverseResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -25125,7 +25484,12 @@ - (void)testEnumsRequestWithParams:(MTRUnitTestingClusterTestEnumsRequestParams MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRUnitTestingClusterTestEnumsResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRUnitTestingClusterTestEnumsResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, UnitTestingClusterTestEnumsResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -25172,7 +25536,12 @@ - (void)testNullableOptionalRequestWithParams:(MTRUnitTestingClusterTestNullable MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRUnitTestingClusterTestNullableOptionalResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRUnitTestingClusterTestNullableOptionalResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, UnitTestingClusterTestNullableOptionalResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -25230,7 +25599,12 @@ - (void)testComplexNullableOptionalRequestWithParams:(MTRUnitTestingClusterTestC MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRUnitTestingClusterTestComplexNullableOptionalResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRUnitTestingClusterTestComplexNullableOptionalResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, UnitTestingClusterTestComplexNullableOptionalResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -25445,7 +25819,12 @@ - (void)simpleStructEchoRequestWithParams:(MTRUnitTestingClusterSimpleStructEcho MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRUnitTestingClusterSimpleStructResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRUnitTestingClusterSimpleStructResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, UnitTestingClusterSimpleStructResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -25612,7 +25991,12 @@ - (void)testEmitTestEventRequestWithParams:(MTRUnitTestingClusterTestEmitTestEve MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRUnitTestingClusterTestEmitTestEventResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRUnitTestingClusterTestEmitTestEventResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, UnitTestingClusterTestEmitTestEventResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { @@ -25663,7 +26047,12 @@ - (void)testEmitTestEventRequestWithParams:(MTRUnitTestingClusterTestEmitTestEve MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { MTRBaseDevice * baseDevice = [[MTRBaseDevice alloc] initWithNodeID:self.device.nodeID controller:self.device.deviceController]; - auto * bridge = new MTRUnitTestingClusterTestEmitTestFabricScopedEventResponseCallbackBridge(self.callbackQueue, completion, + auto * bridge = new MTRUnitTestingClusterTestEmitTestFabricScopedEventResponseCallbackBridge( + self.callbackQueue, + ^(id _Nullable value, NSError * _Nullable error) { + completion(value, error); + [workItem endWork]; + }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, UnitTestingClusterTestEmitTestFabricScopedEventResponseCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h index 6c5241cd905979..275e2e46bcd9db 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h @@ -109,7 +109,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -157,7 +158,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -203,7 +205,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -249,7 +252,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -349,7 +353,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -405,7 +410,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -455,7 +461,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -501,7 +508,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -551,7 +559,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -627,7 +636,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -683,7 +693,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -739,7 +750,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -795,7 +807,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -1557,7 +1570,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -1605,7 +1619,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -1707,7 +1722,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -1757,7 +1773,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -1801,7 +1818,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -1853,7 +1871,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -1953,7 +1972,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -2003,7 +2023,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -2083,7 +2104,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -2331,7 +2353,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -2375,7 +2398,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -2423,7 +2447,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -2503,7 +2528,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -2635,7 +2661,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -2701,7 +2728,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -2885,7 +2913,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -2991,7 +3020,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -3095,7 +3125,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -3213,7 +3244,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -3293,7 +3325,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -3345,7 +3378,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -3609,7 +3643,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -4289,7 +4324,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -4383,7 +4419,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -4611,7 +4648,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -4783,7 +4821,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -4859,7 +4898,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -4997,7 +5037,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -5041,7 +5082,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -5113,7 +5155,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -5165,7 +5208,8 @@ NS_ASSUME_NONNULL_BEGIN * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -5240,7 +5284,8 @@ MTR_NEWLY_AVAILABLE * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -5294,7 +5339,8 @@ MTR_NEWLY_AVAILABLE * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -5348,7 +5394,8 @@ MTR_NEWLY_AVAILABLE * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -5412,7 +5459,8 @@ MTR_NEWLY_AVAILABLE * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -5470,7 +5518,8 @@ MTR_NEWLY_AVAILABLE * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -5528,7 +5577,8 @@ MTR_NEWLY_AVAILABLE * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -5600,7 +5650,8 @@ MTR_NEWLY_AVAILABLE * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -5710,7 +5761,8 @@ MTR_NEWLY_AVAILABLE * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -5767,7 +5819,8 @@ MTR_NEWLY_AVAILABLE * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -5823,7 +5876,8 @@ MTR_NEWLY_AVAILABLE * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -5879,7 +5933,8 @@ MTR_NEWLY_AVAILABLE * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; @@ -5936,7 +5991,8 @@ MTR_NEWLY_AVAILABLE * request) within the timeout window. * */ -@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; +@property (nonatomic, copy, nullable) + NSNumber * timedInvokeTimeoutMs MTR_NEWLY_DEPRECATED("Timed invoke does not make sense for server to client commands"); - (instancetype)init; - (id)copyWithZone:(NSZone * _Nullable)zone; diff --git a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m index 2a7afeb112de66..db8e1050622e19 100644 --- a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m +++ b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m @@ -770,6 +770,7 @@ - (void)test011_ReadCachedAttribute // reportHandler returns TRUE if it got the things it was looking for or if there's an error. __block BOOL (^reportHandler)(NSArray * _Nullable value, NSError * _Nullable error); __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(2) maxInterval:@(60)]; + params.resubscribeIfLost = NO; [device subscribeWithQueue:queue params:params clusterStateCacheContainer:clusterStateCacheContainer @@ -836,6 +837,7 @@ - (void)test011_ReadCachedAttribute XCTestExpectation * newSubscriptionEstablished = [self expectationWithDescription:@"New subscription established"]; MTRSubscribeParams * newParams = [[MTRSubscribeParams alloc] initWithMinInterval:@(2) maxInterval:@(60)]; newParams.replaceExistingSubscriptions = NO; + newParams.resubscribeIfLost = NO; [cluster subscribeAttributeOnOffWithParams:newParams subscriptionEstablished:^{ NSLog(@"New subscription was established"); @@ -1023,6 +1025,7 @@ - (void)test012_SubscriptionError // Subscribe XCTestExpectation * expectation = [self expectationWithDescription:@"subscribe OnOff attribute"]; MTRSubscribeParams * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(1) maxInterval:@(10)]; + params.resubscribeIfLost = NO; [device subscribeToAttributesWithEndpointID:@1 clusterID:@6 attributeID:@0 @@ -1432,6 +1435,91 @@ - (void)test018_SubscriptionErrorWhenNotResubscribing [self waitForExpectations:@[ errorExpectation ] timeout:60]; } +- (void)test019_MTRDeviceMultipleCommands +{ +#if MANUAL_INDIVIDUAL_TEST + [self initStack]; + [self waitForCommissionee]; +#endif + + __auto_type * device = [MTRDevice deviceWithNodeID:kDeviceId deviceController:sController]; + dispatch_queue_t queue = dispatch_get_main_queue(); + + __auto_type * opcredsCluster = [[MTRClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:queue]; + __auto_type * onOffCluster = [[MTRClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:queue]; + __auto_type * badOnOffCluster = [[MTRClusterOnOff alloc] initWithDevice:device endpointID:@(0) queue:queue]; + + XCTestExpectation * onExpectation = [self expectationWithDescription:@"On command executed"]; + [onOffCluster onWithParams:nil + expectedValues:nil + expectedValueInterval:nil + completion:^(NSError * _Nullable error) { + XCTAssertNil(error); + [onExpectation fulfill]; + }]; + + XCTestExpectation * offFailedExpectation = [self expectationWithDescription:@"Off command failed"]; + [badOnOffCluster offWithParams:nil + expectedValues:nil + expectedValueInterval:nil + completion:^(NSError * _Nullable error) { + XCTAssertNotNil(error); + [offFailedExpectation fulfill]; + }]; + + XCTestExpectation * updateLabelExpectation = [self expectationWithDescription:@"Fabric label updated"]; + __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; + params.label = @("Test"); + [opcredsCluster updateFabricLabelWithParams:params + expectedValues:nil + expectedValueInterval:nil + completion:^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data, + NSError * _Nullable error) { + XCTAssertNil(error); + XCTAssertNotNil(data); + XCTAssertEqualObjects(data.statusCode, @(0)); + XCTAssertNotNil(data.fabricIndex); + [updateLabelExpectation fulfill]; + }]; + + XCTestExpectation * offExpectation = [self expectationWithDescription:@"Off command executed"]; + [onOffCluster offWithParams:nil + expectedValues:nil + expectedValueInterval:nil + completion:^(NSError * _Nullable error) { + XCTAssertNil(error); + [offExpectation fulfill]; + }]; + + XCTestExpectation * onFailedExpectation = [self expectationWithDescription:@"On command failed"]; + [badOnOffCluster onWithParams:nil + expectedValues:nil + expectedValueInterval:nil + completion:^(NSError * _Nullable error) { + XCTAssertNotNil(error); + [onFailedExpectation fulfill]; + }]; + + XCTestExpectation * updateLabelFailedExpectation = [self expectationWithDescription:@"Fabric label update failed"]; + params.label = @("12345678901234567890123445678901234567890"); // Too long + [opcredsCluster updateFabricLabelWithParams:params + expectedValues:nil + expectedValueInterval:nil + completion:^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data, + NSError * _Nullable error) { + XCTAssertNotNil(error); + XCTAssertNil(data); + [updateLabelFailedExpectation fulfill]; + }]; + + [self waitForExpectations:@[ + onExpectation, offFailedExpectation, updateLabelExpectation, offExpectation, onFailedExpectation, + updateLabelFailedExpectation + ] + timeout:60 + enforceOrder:YES]; +} + - (void)test900_SubscribeAllAttributes { #if MANUAL_INDIVIDUAL_TEST @@ -1453,6 +1541,7 @@ - (void)test900_SubscribeAllAttributes __block void (^reportHandler)(id _Nullable values, NSError * _Nullable error) = nil; MTRSubscribeParams * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(2) maxInterval:@(10)]; + params.resubscribeIfLost = NO; [device subscribeToAttributesWithEndpointID:@1 clusterID:@6 attributeID:@0xffffffff From 3fa2104a5c665e2f2507e4f145e34a739f7b2997 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 17 Nov 2022 18:37:30 +0100 Subject: [PATCH 6/8] Stop using :latest tag for docker images in bouffalolab (#23666) --- .github/workflows/examples-bouffalolab.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/examples-bouffalolab.yaml b/.github/workflows/examples-bouffalolab.yaml index 9c31fbd9ba581e..11539d512f579f 100644 --- a/.github/workflows/examples-bouffalolab.yaml +++ b/.github/workflows/examples-bouffalolab.yaml @@ -31,7 +31,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:latest + image: connectedhomeip/chip-build:0.6.06 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: @@ -87,7 +87,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:latest + image: connectedhomeip/chip-build:0.6.06 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: From c76b2588e8ead4057d745bc360f18d95c2470059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Ba=C5=82ys?= Date: Thu, 17 Nov 2022 20:15:25 +0100 Subject: [PATCH 7/8] [nrfconnect] Initial Matter over WiFi implementation. (#23607) * [nrfconnect] Initial Matter over WiFi implementation. Some WiFi related features might not work as expected yet. This will be fixed when the Zephyr NRF WiFi module is improved. All implementations have been synchronized to sdk-nrf v2.1.1. Commits included: - Prepare configuration for hci_rpmsg - Adapt Android CHIPTool guide to Wi-Fi devices Make the guide a little bit more aware of the world of Wi-Fi devices. - Disable Wi-Fi low-power mode Noticed Wi-Fi low-power mode causes performance issues, at least with some APs. - Implemented the WiFiNetworkIterator. Replaced dummy implementation of WiFiNetworkIterator This fixes an issue with infinite loop when using this iterator in Matter core. - Added including CHIPMemString.h to fix WiFi build Signed-off-by: Marcin Kajor Signed-off-by: Damian Krolik Signed-off-by: Kamil Kasperczyk Signed-off-by: Arkadiusz Balys * Restyled by prettier-markdown Restyled by gn Signed-off-by: Marcin Kajor Signed-off-by: Damian Krolik Signed-off-by: Kamil Kasperczyk Signed-off-by: Arkadiusz Balys Co-authored-by: Restyled.io --- config/nrfconnect/chip-module/CMakeLists.txt | 7 +- .../nrfconnect/chip-module/Kconfig.defaults | 64 ++- .../nrfconnect/chip-module/Kconfig.features | 25 + .../chip-module/Kconfig.hci_rpmsg.defaults | 99 ++++ .../chip-module/Kconfig.hci_rpmsg.root | 21 + config/zephyr/Kconfig | 2 +- .../images/CHIPTool_device_commissioned.jpg | Bin 15897 -> 0 bytes .../images/CHIPTool_device_commissioned.png | Bin 0 -> 15713 bytes .../nrfconnect_android_commissioning.md | 119 ++--- .../boards/nrf5340dk_nrf5340_cpuapp.overlay | 3 - .../nrfconnect/main/AppTask.cpp | 2 + .../boards/nrf5340dk_nrf5340_cpuapp.overlay | 3 - examples/chef/nrfconnect/main.cpp | 7 +- .../nrfconnect/main/AppTask.cpp | 4 + .../lighting-app/nrfconnect/main/AppTask.cpp | 4 + .../boards/nrf5340dk_nrf5340_cpuapp.overlay | 3 - examples/lock-app/nrfconnect/main/AppTask.cpp | 4 + examples/pump-app/nrfconnect/main/AppTask.cpp | 4 + .../nrfconnect/main/AppTask.cpp | 4 + .../boards/nrf5340dk_nrf5340_cpuapp.overlay | 3 - .../window-app/nrfconnect/main/AppTask.cpp | 4 + .../window-app/nrfconnect/prj_no_dfu.conf | 1 + .../window-app/nrfconnect/prj_release.conf | 1 + .../internal/GenericConnectivityManagerImpl.h | 2 +- src/inet/InetConfig.h | 22 + src/inet/UDPEndPointImplSockets.cpp | 9 +- src/platform/Zephyr/BLEManagerImpl.cpp | 1 + .../Zephyr/ConfigurationManagerImpl.cpp | 18 + .../Zephyr/ConfigurationManagerImpl.h | 5 - .../Zephyr/DiagnosticDataProviderImpl.cpp | 7 +- .../Zephyr/DiagnosticDataProviderImpl.h | 3 +- .../DiagnosticDataProviderImplGetter.cpp | 29 ++ src/platform/Zephyr/InetUtils.cpp | 41 ++ src/platform/Zephyr/InetUtils.h | 32 ++ src/platform/nrfconnect/BUILD.gn | 15 + .../nrfconnect/CHIPDevicePlatformConfig.h | 11 +- .../nrfconnect/ConnectivityManagerImpl.cpp | 4 +- .../nrfconnect/ConnectivityManagerImpl.h | 12 +- .../DiagnosticDataProviderImplNrf.cpp | 136 ++++++ .../DiagnosticDataProviderImplNrf.h | 60 +++ .../wifi/ConnectivityManagerImplWiFi.cpp | 228 +++++++++ .../wifi/ConnectivityManagerImplWiFi.h | 82 ++++ .../nrfconnect/wifi/NrfWiFiDriver.cpp | 284 +++++++++++ src/platform/nrfconnect/wifi/NrfWiFiDriver.h | 123 +++++ src/platform/nrfconnect/wifi/WiFiManager.cpp | 447 ++++++++++++++++++ src/platform/nrfconnect/wifi/WiFiManager.h | 171 +++++++ src/platform/telink/BUILD.gn | 1 + 47 files changed, 2029 insertions(+), 98 deletions(-) create mode 100644 config/nrfconnect/chip-module/Kconfig.hci_rpmsg.defaults create mode 100644 config/nrfconnect/chip-module/Kconfig.hci_rpmsg.root delete mode 100644 docs/guides/images/CHIPTool_device_commissioned.jpg create mode 100644 docs/guides/images/CHIPTool_device_commissioned.png create mode 100644 src/platform/Zephyr/DiagnosticDataProviderImplGetter.cpp create mode 100644 src/platform/Zephyr/InetUtils.cpp create mode 100644 src/platform/Zephyr/InetUtils.h create mode 100644 src/platform/nrfconnect/DiagnosticDataProviderImplNrf.cpp create mode 100644 src/platform/nrfconnect/DiagnosticDataProviderImplNrf.h create mode 100644 src/platform/nrfconnect/wifi/ConnectivityManagerImplWiFi.cpp create mode 100644 src/platform/nrfconnect/wifi/ConnectivityManagerImplWiFi.h create mode 100644 src/platform/nrfconnect/wifi/NrfWiFiDriver.cpp create mode 100644 src/platform/nrfconnect/wifi/NrfWiFiDriver.h create mode 100644 src/platform/nrfconnect/wifi/WiFiManager.cpp create mode 100644 src/platform/nrfconnect/wifi/WiFiManager.h diff --git a/config/nrfconnect/chip-module/CMakeLists.txt b/config/nrfconnect/chip-module/CMakeLists.txt index 305edd21e9c2e3..c27f4bfe55e2e6 100644 --- a/config/nrfconnect/chip-module/CMakeLists.txt +++ b/config/nrfconnect/chip-module/CMakeLists.txt @@ -219,6 +219,7 @@ chip_gn_arg_bool ("chip_progress_logging" CONFIG_MATTER_LOG_LE chip_gn_arg_bool ("chip_detail_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 4) chip_gn_arg_bool ("chip_automation_logging" "false") chip_gn_arg_bool ("chip_malloc_sys_heap" CONFIG_CHIP_MALLOC_SYS_HEAP) +chip_gn_arg_bool ("chip_enable_wifi" CONFIG_WIFI_NRF700X) if (CONFIG_CHIP_FACTORY_DATA) chip_gn_arg_bool ("chip_use_transitional_commissionable_data_provider" "false") @@ -232,8 +233,12 @@ if (CONFIG_CHIP_ROTATING_DEVICE_ID) chip_gn_arg_bool("chip_enable_additional_data_advertising" "true") endif() -if (CONFIG_CHIP_ENABLE_DNSSD_SRP) +if (CONFIG_NET_L2_OPENTHREAD) chip_gn_arg_string("chip_mdns" "platform") +elseif(CONFIG_WIFI_NRF700X) + chip_gn_arg_string("chip_mdns" "minimal") +else() + chip_gn_arg_string("chip_mdns" "none") endif() if (CONFIG_CHIP_CRYPTO_PSA) diff --git a/config/nrfconnect/chip-module/Kconfig.defaults b/config/nrfconnect/chip-module/Kconfig.defaults index 228dbaeb478089..e02d0d2981cc71 100644 --- a/config/nrfconnect/chip-module/Kconfig.defaults +++ b/config/nrfconnect/chip-module/Kconfig.defaults @@ -213,20 +213,72 @@ config NVS_LOOKUP_CACHE_SIZE int default 512 +# Enable OpenThread + +config NET_L2_OPENTHREAD + bool + default y if !WIFI_NRF700X + +if NET_L2_OPENTHREAD + # Increase the default RX stack size config IEEE802154_NRF5_RX_STACK_SIZE int default 1024 -# Enable OpenThread +endif -config NET_L2_OPENTHREAD +if CHIP_WIFI + +config NRF_WIFI_LOW_POWER bool - default y + default n + +config MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG + bool + default n + +config SYSTEM_WORKQUEUE_STACK_SIZE + int + default 1120 + +# align these numbers to match the OpenThread config +config NET_IF_UNICAST_IPV6_ADDR_COUNT + int + default 6 + +config NET_IF_MCAST_IPV6_ADDR_COUNT + int + default 8 + +config NET_SOCKETS_POSIX_NAMES + bool + default n + +config MBEDTLS_SSL_OUT_CONTENT_LEN + int + default 900 + +# options managed by IP4/IP6 simultaneous support +# aligned here to match OpenThread config +config NET_MAX_ROUTERS + int + default 1 + +config NET_MAX_CONN + int + default 4 + +config SHELL_STACK_SIZE + int + default 2616 + +config HEAP_MEM_POOL_SIZE + int + default 200000 + +endif -choice OPENTHREAD_STACK_VERSION - default OPENTHREAD_THREAD_VERSION_1_3 -endchoice # Enable mbedTLS from nrf_security library diff --git a/config/nrfconnect/chip-module/Kconfig.features b/config/nrfconnect/chip-module/Kconfig.features index 1f12053658f23e..6ff4aa5ea62527 100644 --- a/config/nrfconnect/chip-module/Kconfig.features +++ b/config/nrfconnect/chip-module/Kconfig.features @@ -19,6 +19,31 @@ if CHIP +config CHIP_WIFI + bool "Enable nrfconnect Wi-Fi support" + default y if SHIELD_NRF7002_EK || BOARD_NRF7002DK_NRF5340_CPUAPP + select WIFI_NRF700X + select WIFI + select WPA_SUPP + imply FLASH + imply SETTINGS + imply NVS + imply FLASH_MAP + imply NORDIC_SECURITY_BACKEND + imply MBEDTLS_ENTROPY_C + imply MBEDTLS_PSA_CRYPTO_C + imply NET_STATISTICS + imply NET_L2_ETHERNET + imply NET_PKT_TXTIME + imply NET_PKT_TIMESTAMP + imply MBEDTLS_PROMPTLESS + imply BUILD_OUTPUT_META + imply USE_DT_CODE_PARTITION # might be removed when the OTA is enabled + imply NET_IPV6_ND # enable Neighbor Discovery to handle Router Advertisements + imply NET_IPV6_NBR_CACHE + imply NET_STATISTICS_IPV6 + imply NET_STATISTICS_USER_API + config CHIP_QSPI_NOR bool "Enable QSPI NOR feature set" help diff --git a/config/nrfconnect/chip-module/Kconfig.hci_rpmsg.defaults b/config/nrfconnect/chip-module/Kconfig.hci_rpmsg.defaults new file mode 100644 index 00000000000000..8069d710047338 --- /dev/null +++ b/config/nrfconnect/chip-module/Kconfig.hci_rpmsg.defaults @@ -0,0 +1,99 @@ +# +# Copyright (c) 2022 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# The purpose of this file is to define new default values of settings used when building hci_rpmsg child image for Matter samples. + +config LOG + bool + default n + +config HEAP_MEM_POOL_SIZE + int + default 8192 + +config MAIN_STACK_SIZE + int + default 2048 + +config SYSTEM_WORKQUEUE_STACK_SIZE + int + default 2048 + +config BT + bool + default y + +config BT_HCI_RAW + bool + default y + +config BT_MAX_CONN + int + default 1 + +config BT_PERIPHERAL + bool + default y + +config BT_CENTRAL + bool + default n + +config BT_BUF_ACL_RX_SIZE + int + default 502 + +config BT_BUF_ACL_TX_SIZE + int + default 251 + +config BT_CTLR_DATA_LENGTH_MAX + int + default 251 + +config BT_CTLR_ASSERT_HANDLER + bool + default y + +config BT_HCI_RAW_RESERVE + int + default 1 + +# Workaround: Unable to allocate command buffer when using K_NO_WAIT since +# Host number of completed commands does not follow normal flow control. +config BT_BUF_CMD_TX_COUNT + int + default 10 + +config ASSERT + bool + default y + +config DEBUG_INFO + bool + default y + +config EXCEPTION_STACK_TRACE + bool + default y + +config IPC_SERVICE + bool + default y + +config MBOX + bool + default y diff --git a/config/nrfconnect/chip-module/Kconfig.hci_rpmsg.root b/config/nrfconnect/chip-module/Kconfig.hci_rpmsg.root new file mode 100644 index 00000000000000..8c4f6eee49cbc2 --- /dev/null +++ b/config/nrfconnect/chip-module/Kconfig.hci_rpmsg.root @@ -0,0 +1,21 @@ +# +# Copyright (c) 2022 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# The purpose of this file is to create a wrapper Kconfig file that will be set as +# hci_rpmsg_KCONFIG_ROOT and processed before any other Kconfig for hci_rpmsg child image. + +rsource "Kconfig.hci_rpmsg.defaults" +source "Kconfig.zephyr" diff --git a/config/zephyr/Kconfig b/config/zephyr/Kconfig index 9928bb35b49258..c7c5b356a160d9 100644 --- a/config/zephyr/Kconfig +++ b/config/zephyr/Kconfig @@ -112,7 +112,7 @@ config CHIP_ENABLE_PAIRING_AUTOSTART config CHIP_ENABLE_DNSSD_SRP bool "Enable support for service registration" - default y + default y if NET_L2_OPENTHREAD imply OPENTHREAD_ECDSA imply OPENTHREAD_SRP_CLIENT help diff --git a/docs/guides/images/CHIPTool_device_commissioned.jpg b/docs/guides/images/CHIPTool_device_commissioned.jpg deleted file mode 100644 index 85bbbdc2b8fefcefe2403852c3fa8d0afabf8b4d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15897 zcmd_R2UJwg(l5IAWMIfS4>{+YbIv(~gdqndDM>&?k{~(foCPEr02L5H5XnJB6a*9z z5k!#i#(#L{d*40Zx#wGNy|v!Gw`bMv>gww1>gr$j-ZQ)BV)5b~K%%RuqX~c@2wcN` zfQvQYhQ>87cL31Q;RR3t06+ja5CV|kI8Gdu6hi@4TrP>D-$@f2i1l~n$7ltHV?6=_ z!!>a-ERF*I%KdSf_y8Ip1Eif@ zgD&&>d*QUJb!|7<_!j1O$54_8N;9Wff z{cz(q$LX{G=>v`f0EQr35CpKkzE}ZEQGuX950~ITS3xh=-}Co(Vg!N!Q`{`70s^@C z^TmCzIL;Cf#a)ANv*-c10KvH26%YixaM%CX_HP^iukv8*HC$`}KrP^MSfH1OXD~)o zSVV#!qk(f9V-_6XkHv6b#kvG}1!H9~e?!8{AM1wo2*hH8T(G_YSO0*990u#>?By$q z`90vE-wl=h|A`)tAjaI&D+q%_59V@UfV&s28(h)X%N6S%gmuG&_`6{PG0qsZK&*4H zS11;v7U1U>;2(rh2@VeQatR6c3h);&^K=fxs`z^OV1L6IW8r@}ATSu$SpQEe81CPW z2I0W#`j-_Pc7GcY3<&fP`m3uTA(t?LAZH<*0U=+khqJG1fE$)a@OLbJpaiG@8h{p{1Ly$;fC*s6?FuXa8^8{5;Pw}8fCu0O_;6Sf1cU%#9IC_saX12I4> za07?~;(=R00+0wK0V%+3AQeah(t!*h6UYK`fLtIC$Oj66BA^&30m^`KpaQ4_s(~7y z7N`U2fkvPSXa-t8k7O$KzUFRR0dT*HBbZ81hqk3 zP!BW!jX-126f_4dKr7G&v<2-!NAMEp47!3?&;#@Yy+L2l9}EDmfI(mg7z$nk!@)@K zIv5Scf^lFxm;fe$$>41;4NM0!!E7)W%mWL+BCrH311rE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@6!d4E`Zys&X8?0k(?(iF;WLi zPYw2pwqmsZh!mJM7CljRO21{EyJU2H?*fR6!cXTr*1dl}`PPj7s15WUxlF;*ZrA*; zaLJ4XlF}MadU}pjPA&cvI*HI8mrAF`bM-pY*{AX^t1{VrKNqiOQ19KJzi(IfL*Yg& zCWOg#cRBPC)tR7`UBJ0NQeLpqyWvwAukL(@hO70u{%p^e?u{g-FuV9=Tc$iElCyn>OkG(`q}<*Zkj#4k7H-k{-hH*zp7tj)M5R;ci(WXF)TUV zH+TY5Gs!$eN(DOyfMBZG( z+(P|+Fpqz3>-gIE&$6d%&oq@9Yn28h451npM)4{PGYWS)TCrJsm3LK?GV;Qr@yS3( zvmpOlY1v+0AL^J)D9_pUMZXHIsf><49EisQo(x^rbl5oMmZ80xw^xAyng3`+^oL9v z&|1g7b$Sx_ry+p!__tE|AF`VW-$B8LouNKL+4wVYV|eP{f)<^%Wl>!tq-$>fRa diff --git a/docs/guides/images/CHIPTool_device_commissioned.png b/docs/guides/images/CHIPTool_device_commissioned.png new file mode 100644 index 0000000000000000000000000000000000000000..8756b4dbf6b0ca3fb98fe2cacb87ca7ebc733c59 GIT binary patch literal 15713 zcmb`uWpEqOwyhh-F~=A)J7#8Pc4Cy7ZJC*wnVFfHotT+PW@g9C%>1Cy61;f zU8+`hOKbI9V}4_FxPqJ{B0MhqmoHxse@Tfce)$5y0p5Osg$BQyP>-#EKd?0y6;&`d zH2m^~D&9GsR~k|nJy`IE_)J+C=Fb4?0(G$~2!rx^sUKnm0ktN7-Qn8pS7hV#X_wW% z(TU;d1%C=@^{NV^pbHO-5&f%-uiG4jN1f3yxg1XCPEBY17m3q$JdYHR4qCf5Bjf6> z!>;lz@h8+YGnASmur%=C8S38MO~F;Mg;uWpe0=B5NT8Ms&4AtpZ2Y?n4V zZV{cb__YnWT}Kat-lgo(w@W#Q6T5}J_V@bNRe4VDII`TEKEGvV-+Ld)9M#d*A%GLE z$ib0SvE9gJ7lrb75HTElm42M5kcAw}>l&x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TrZ-s+g&>B3u|g15*WCj*ZF?>prh|a z8v83mIxx&){i>wnpiouU=9G$zS~N91gq^`9fl3kpWA>hSQpqg)2I%ncF!X2AG9?;m zE32r6ML67!Ww53!DlH}b`SYtry2jB`b8f@I*{PQP;|0Iszh#T|n=2gP>0D`TUB}lt z(@VlEUROeJ;}8!z&Y;{*xSXNGX(%*CdJL+9fDcK;`$0^{8EN-d3jBPaKw`TlR$*l- zt54qoc&YAo!YYp%@pwIN7N32uVld)YDg|Bb_Bi9ZFq{cN{r*pkgu+gxBf~+Z(!$0?4rr z|AT)CqEi58`)93=EQCgE8AV!R1rq)jVBONkEVl%1Ex-k4l2l2Qt%i*+bS=**Kxkk(6*3yJ0~8{3 zV3wd11F17U8%9u&KixLC>5Emx4<7;>)y2hPHTtOxI!1?yacNW=0JO@ZBkVl{PEPeA zR4hD7P^asqfO@k{Ho63wYD7QckDAJ6W+vRxY<|xsK4@7MIk3Llum~^+I$g3AS}j+a zhSAYd_!@PtK1rUr( literal 0 HcmV?d00001 diff --git a/docs/guides/nrfconnect_android_commissioning.md b/docs/guides/nrfconnect_android_commissioning.md index 7bbc0e3e7aef21..0e2146ba980b8f 100644 --- a/docs/guides/nrfconnect_android_commissioning.md +++ b/docs/guides/nrfconnect_android_commissioning.md @@ -1,13 +1,14 @@ # Commissioning nRF Connect Accessory using Android CHIPTool You can use [CHIPTool](android_building.md) for Android smartphones to -commission a Nordic Semiconductor device running an nRF Connect platform example -onto a Matter-enabled Thread network. +commission a Nordic Semiconductor's development kit programmed with a Matter +example for the nRF Connect platform into a Matter fabric. -This guide references the nRF52840 DK and the door lock example application -based on the nRF Connect platform, but the instructions are also valid for the -nRF Connect lighting example application and can be adapted to other platforms -and applications as well. +This guide references the nRF52840 DK and Matter nRF Connect Lighting Example +Application that communicates with other nodes over a Thread network, but the +instructions can be adapted to other platforms and applications. In particular, +some sections of this guide include deviations from the original procedure that +are needed to test a Wi-Fi device.
@@ -30,8 +31,8 @@ The commissioning process is composed of the following main stages: 1. CHIPTool discovers a Matter accessory device over Bluetooth LE. 2. CHIPTool establishes a secure channel to the device over Bluetooth LE, and - sends Matter operational credentials and Thread provisioning data. -3. The accessory device joins a Matter-enabled Thread network. + sends Matter operational credentials and Thread or Wi-Fi credentials. +3. The accessory device joins the operational IPv6 network. CHIPTool uses both Bluetooth LE and the IPv6 connectivity. Bluetooth LE is used only during the commissioning phase. Afterwards, only the IPv6 connectivity @@ -41,13 +42,13 @@ commissioning process and CHIPTool must use DNS Service Discovery (DNS-SD) to learn or refresh the address before the controller initiates the IPv6-based communication. -Since a typical smartphone does not have a Thread radio built-in, extra effort -is needed to prepare the fully-fledged testing environment that includes a -Thread Border Router configured on a Raspberry Pi. +Since a typical smartphone does not have a Thread radio built-in, preparing the +fully-fledged testing environment for Matter over Thread requires a Thread +Border Router configured on a Raspberry Pi. The following diagram shows the connectivity between network components required -to allow communication between devices running the CHIPTool and Lock -applications: +to allow communication between devices running CHIPTool and Matter nRF Connect +Lighting Example Application: ![Matter nodes connectivity](./images/nrfconnect_android_connectivity.png) @@ -60,20 +61,26 @@ applications: You need the following hardware and software for commissioning the nRF Connect accessory using Android CHIPTool: -- Two nRF52840 DK (PCA10056) +- 1x smartphone with Android 8+ +- 1x Wi-Fi Access Point supporting IPv6 (without the IPv6 Router Advertisement + Guard enabled on the router) +- 1x nRF52840 DK (PCA10056) for running the example application. You can + replace this DK with another compatible device, such as the nRF5340 DK or + nRF7002 DK. nRF52840 DK and nRF5340 DK can be used to test Matter over + Thread, and nRF7002 DK can be used to test Matter over Wi-Fi. +- 1x nRF52840 DK for running the + [OpenThread Radio Co-Processor](https://openthread.io/platforms/co-processor) + firmware. You can replace this DK with another compatible device, such as + the nRF52840 Dongle. - - One nRF52840 DK is needed for running the - [OpenThread Radio Co-Processor](https://openthread.io/platforms/co-processor) - firmware. You can replace this DK with another compatible device, such - as the nRF52840 Dongle. - - One nRF52840 DK is needed for running the example application. You can - replace this DK with another compatible device, such as the nRF5340 DK. + > _Note:_ This piece of hardware is only needed if you're testing a Thread + > device. Skip it if the tested device operates in a Wi-Fi network. -- Smartphone compatible with Android 8.0 or later -- Raspberry Pi Model 3B+ or newer (along with an SD card with at least 8 GB of - memory) -- Wi-Fi Access Point supporting IPv6 (without the IPv6 Router Advertisement - Guard enabled on the router) +- 1x Raspberry Pi Model 3B+ or newer (along with an SD card with at least 8 GB + of memory) + + > _Note:_ This piece of hardware is only needed if you're testing a Thread + > device. Skip it if the tested device operates in a Wi-Fi network.
@@ -81,10 +88,15 @@ accessory using Android CHIPTool: ## Setting up Thread Border Router +> _Note:_ This step is only needed if you're testing a Thread device. Skip it if +> the tested device operates in a Wi-Fi network. + Follow the [OpenThread Border Router](openthread_border_router_pi.md) article to set up OpenThread Border Router on the Raspberry Pi, with either the nRF52840 DK or the nRF52840 Dongle acting as the [OpenThread Radio Co-Processor](https://openthread.io/platforms/co-processor). +During the setup, make sure that the Raspberry Pi is connected to your Wi-Fi +Access Point.
@@ -94,8 +106,8 @@ or the nRF52840 Dongle acting as the Build and program the example application onto your compatible device. -For this guide, see the documentation for the door lock example application to -learn how to build and program the example onto an nRF52840 DK. +For this guide, see the documentation of Matter nRF Connect Lighting Example +Application to learn how to build and program the example onto an nRF52840 DK.
@@ -164,24 +176,24 @@ To prepare the accessory device for commissioning, complete the following steps: ## Commissioning accessory device -To commission the accessory device onto the Thread network created in the -[Setting up Thread Border Router](#setting-up-thread-border-router) section, -complete the following steps: - -1. Enable **Bluetooth** and **Location** services on your smartphone. -2. Connect the smartphone to the same Wi-Fi network as the Raspberry Pi which - runs OpenThread Border Router. -3. Open the CHIPTool application on your smartphone. -4. Tap the **PROVISION CHIP DEVICE WITH THREAD** button and scan the - commissioning QR code. Several notifications will appear, informing you of - commissioning progress with scanning, connection, and pairing. At the end of - this process, the Thread network settings screen appears. -5. In the Thread network settings screen, use the default settings and tap the - **SAVE NETWORK** button to send a Thread provisioning message to the - accessory device. - -You will see the "Network provisioning completed" message when the accessory -device successfully joins the Thread network. +To commission the accessory device into the Matter fabric, complete the +following steps: + +1. Enable **Bluetooth** and **Location** services on your smartphone. +2. Connect the smartphone to your Wi-Fi Access Point. +3. Open the CHIPTool application on your smartphone. +4. Depending on your testing scenario, tap one of the following buttons and + scan the commissioning QR code: + + - **PROVISION CHIP DEVICE WITH THREAD** for Matter over Thread + - **PROVISION CHIP DEVICE WITH WI-FI** for Matter over Wi-Fi + + The network credentials screen appears. + +5. In the network credentials screen, specify parameters of network and tap the + **SAVE NETWORK** button. Several notifications appear, informing you of the + progress of scanning, connecting, and pairing with the device. At the end of + this process, the application returns to the main menu.
@@ -195,21 +207,16 @@ Check the IPv6 connectivity with the device using the following steps: 1. Tap **LIGHT ON/OFF & LEVEL CLUSTER**. The following screen appears: - ![CHIPTool device control screen](./images/CHIPTool_device_commissioned.jpg) + ![CHIPTool device control screen](./images/CHIPTool_device_commissioned.png) The two textboxes at the top contain **Fabric ID** and **Node ID** of the last commissioned device. -2. Tap **UPDATE ADDRESS** to learn or refresh the IPv6 address of the device. - CHIPTool will use a built-in DNS-SD client to resolve **Fabric ID** and - **Node ID** of the device to its IPv6 address. The result of the operation, - be it the address or an error message, will be displayed at the bottom of the - screen. -3. Tap the following buttons to change the lock state of the nRF Connect door - lock example application referenced in this guide: +2. Tap the following buttons to change the lighting state of the Matter nRF + Connect Lighting Example Application referenced in this guide: - - **ON** and **OFF** buttons lock and unlock the door, respectively. - - **TOGGLE** changes the lock state to the opposite. + - **ON** and **OFF** buttons turn on and off the light, respectively. + - **TOGGLE** changes the lighting state to the opposite. -The **LED 2** on the device turns on or off based on the changes of the lock +The **LED 2** on the device turns on or off based on the changes of the lighting state. diff --git a/examples/all-clusters-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay b/examples/all-clusters-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay index b8030f42c1def9..4b2eca8e4cd66b 100644 --- a/examples/all-clusters-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay +++ b/examples/all-clusters-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -25,9 +25,6 @@ &adc { status = "disabled"; }; -&gpio1 { - status = "disabled"; -}; &i2c1 { status = "disabled"; }; diff --git a/examples/all-clusters-app/nrfconnect/main/AppTask.cpp b/examples/all-clusters-app/nrfconnect/main/AppTask.cpp index 60519e928c6632..40b987b620332d 100644 --- a/examples/all-clusters-app/nrfconnect/main/AppTask.cpp +++ b/examples/all-clusters-app/nrfconnect/main/AppTask.cpp @@ -142,6 +142,7 @@ CHIP_ERROR AppTask::Init() return err; } +#if defined(CONFIG_NET_L2_OPENTHREAD) err = ThreadStackMgr().InitThreadStack(); if (err != CHIP_NO_ERROR) { @@ -159,6 +160,7 @@ CHIP_ERROR AppTask::Init() LOG_ERR("ConnectivityMgr().SetThreadDeviceType() failed"); return err; } +#endif // Initialize LEDs LEDWidget::InitGpio(); diff --git a/examples/all-clusters-minimal-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay b/examples/all-clusters-minimal-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay index b8030f42c1def9..4b2eca8e4cd66b 100644 --- a/examples/all-clusters-minimal-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay +++ b/examples/all-clusters-minimal-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -25,9 +25,6 @@ &adc { status = "disabled"; }; -&gpio1 { - status = "disabled"; -}; &i2c1 { status = "disabled"; }; diff --git a/examples/chef/nrfconnect/main.cpp b/examples/chef/nrfconnect/main.cpp index fe031e7145ff35..8c3061945838d7 100644 --- a/examples/chef/nrfconnect/main.cpp +++ b/examples/chef/nrfconnect/main.cpp @@ -79,7 +79,8 @@ int main() #if CHIP_DEVICE_CONFIG_ENABLE_WPA ConnectivityManagerImpl().StartWiFiManagement(); #endif -#if CHIP_ENABLE_OPENTHREAD + +#if defined(CHIP_ENABLE_OPENTHREAD) err = ThreadStackMgr().InitThreadStack(); if (err != CHIP_NO_ERROR) { @@ -97,7 +98,9 @@ int main() ChipLogError(AppServer, "ConnectivityMgr().SetThreadDeviceType() failed"); return 1; } -#endif /* CHIP_ENABLE_OPENTHREAD */ +#elif !defined(CONFIG_WIFI_NRF700X) + return CHIP_ERROR_INTERNAL; +#endif // Device Attestation & Onboarding codes chip::Credentials::SetDeviceAttestationCredentialsProvider(chip::Credentials::Examples::GetExampleDACProvider()); diff --git a/examples/light-switch-app/nrfconnect/main/AppTask.cpp b/examples/light-switch-app/nrfconnect/main/AppTask.cpp index dd388276964660..4eee5a57bfef8d 100644 --- a/examples/light-switch-app/nrfconnect/main/AppTask.cpp +++ b/examples/light-switch-app/nrfconnect/main/AppTask.cpp @@ -113,6 +113,7 @@ CHIP_ERROR AppTask::Init() return err; } +#if defined(CONFIG_NET_L2_OPENTHREAD) err = ThreadStackMgr().InitThreadStack(); if (err != CHIP_NO_ERROR) { @@ -130,6 +131,9 @@ CHIP_ERROR AppTask::Init() LOG_ERR("ConnectivityMgr().SetThreadDeviceType() failed: %s", ErrorStr(err)); return err; } +#elif !defined(CONFIG_WIFI_NRF700X) + return CHIP_ERROR_INTERNAL; +#endif LightSwitch::GetInstance().Init(kLightDimmerSwitchEndpointId, kLightGenericSwitchEndpointId); diff --git a/examples/lighting-app/nrfconnect/main/AppTask.cpp b/examples/lighting-app/nrfconnect/main/AppTask.cpp index c43a7c16334382..1ee75869d3ddfc 100644 --- a/examples/lighting-app/nrfconnect/main/AppTask.cpp +++ b/examples/lighting-app/nrfconnect/main/AppTask.cpp @@ -124,6 +124,7 @@ CHIP_ERROR AppTask::Init() return err; } +#if defined(CONFIG_NET_L2_OPENTHREAD) err = ThreadStackMgr().InitThreadStack(); if (err != CHIP_NO_ERROR) { @@ -138,6 +139,9 @@ CHIP_ERROR AppTask::Init() LOG_ERR("ConnectivityMgr().SetThreadDeviceType() failed"); return err; } +#elif !defined(CONFIG_WIFI_NRF700X) + return CHIP_ERROR_INTERNAL; +#endif // Initialize LEDs LEDWidget::InitGpio(); diff --git a/examples/lock-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay b/examples/lock-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay index 5ae48f5ba4b0da..d1d93c9dbf033d 100644 --- a/examples/lock-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay +++ b/examples/lock-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -25,9 +25,6 @@ &adc { status = "disabled"; }; -&gpio1 { - status = "disabled"; -}; &i2c1 { status = "disabled"; }; diff --git a/examples/lock-app/nrfconnect/main/AppTask.cpp b/examples/lock-app/nrfconnect/main/AppTask.cpp index cb46530b93df85..b7d4d02a42e75c 100644 --- a/examples/lock-app/nrfconnect/main/AppTask.cpp +++ b/examples/lock-app/nrfconnect/main/AppTask.cpp @@ -103,6 +103,7 @@ CHIP_ERROR AppTask::Init() return err; } +#if defined(CONFIG_NET_L2_OPENTHREAD) err = ThreadStackMgr().InitThreadStack(); if (err != CHIP_NO_ERROR) { @@ -120,6 +121,9 @@ CHIP_ERROR AppTask::Init() LOG_ERR("ConnectivityMgr().SetThreadDeviceType() failed"); return err; } +#else + return CHIP_ERROR_INTERNAL; +#endif // Initialize LEDs LEDWidget::InitGpio(); diff --git a/examples/pump-app/nrfconnect/main/AppTask.cpp b/examples/pump-app/nrfconnect/main/AppTask.cpp index 7ab470249da53b..d8ccc47f393f53 100644 --- a/examples/pump-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-app/nrfconnect/main/AppTask.cpp @@ -104,6 +104,7 @@ CHIP_ERROR AppTask::Init() return err; } +#if defined(CONFIG_NET_L2_OPENTHREAD) err = ThreadStackMgr().InitThreadStack(); if (err != CHIP_NO_ERROR) { @@ -117,6 +118,9 @@ CHIP_ERROR AppTask::Init() LOG_ERR("ConnectivityMgr().SetThreadDeviceType() failed"); return err; } +#elif !defined(CONFIG_WIFI_NRF700X) + return CHIP_ERROR_INTERNAL; +#endif // Initialize LEDs LEDWidget::InitGpio(); diff --git a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp index f473d0fa94534e..ea4bf106e0c437 100644 --- a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp @@ -101,6 +101,7 @@ CHIP_ERROR AppTask::Init() return err; } +#if defined(CONFIG_NET_L2_OPENTHREAD) err = ThreadStackMgr().InitThreadStack(); if (err != CHIP_NO_ERROR) { @@ -114,6 +115,9 @@ CHIP_ERROR AppTask::Init() LOG_ERR("ConnectivityMgr().SetThreadDeviceType() failed"); return err; } +#elif !defined(CONFIG_WIFI_NRF700X) + return CHIP_ERROR_INTERNAL; +#endif // Initialize LEDs LEDWidget::InitGpio(); diff --git a/examples/window-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay b/examples/window-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay index 5310e26238da64..f4559366c7df5c 100644 --- a/examples/window-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay +++ b/examples/window-app/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -45,9 +45,6 @@ &adc { status = "disabled"; }; -&gpio1 { - status = "disabled"; -}; &i2c1 { status = "disabled"; }; diff --git a/examples/window-app/nrfconnect/main/AppTask.cpp b/examples/window-app/nrfconnect/main/AppTask.cpp index 77ab1af1a4960c..08df914781835b 100644 --- a/examples/window-app/nrfconnect/main/AppTask.cpp +++ b/examples/window-app/nrfconnect/main/AppTask.cpp @@ -105,6 +105,7 @@ CHIP_ERROR AppTask::Init() return err; } +#if defined(CONFIG_NET_L2_OPENTHREAD) err = ThreadStackMgr().InitThreadStack(); if (err != CHIP_NO_ERROR) { @@ -125,6 +126,9 @@ CHIP_ERROR AppTask::Init() LOG_ERR("ConnectivityMgr().SetThreadDeviceType() failed"); return err; } +#elif !defined(CONFIG_WIFI_NRF700X) + return CHIP_ERROR_INTERNAL; +#endif // Initialize LEDs LEDWidget::InitGpio(); diff --git a/examples/window-app/nrfconnect/prj_no_dfu.conf b/examples/window-app/nrfconnect/prj_no_dfu.conf index 1a8816e44557af..f2787a7619fe73 100644 --- a/examples/window-app/nrfconnect/prj_no_dfu.conf +++ b/examples/window-app/nrfconnect/prj_no_dfu.conf @@ -23,6 +23,7 @@ CONFIG_STD_CPP14=y # Add support for LEDs and buttons on Nordic development kits CONFIG_DK_LIBRARY=y +CONFIG_PWM=y # OpenThread configs CONFIG_OPENTHREAD_NORDIC_LIBRARY_MTD=y diff --git a/examples/window-app/nrfconnect/prj_release.conf b/examples/window-app/nrfconnect/prj_release.conf index 0a1e7735a8455e..caf0ee1a5be1e9 100644 --- a/examples/window-app/nrfconnect/prj_release.conf +++ b/examples/window-app/nrfconnect/prj_release.conf @@ -23,6 +23,7 @@ CONFIG_STD_CPP14=y # Add support for LEDs and buttons on Nordic development kits CONFIG_DK_LIBRARY=y +CONFIG_PWM=y # OpenThread configs CONFIG_OPENTHREAD_NORDIC_LIBRARY_MTD=y diff --git a/src/include/platform/internal/GenericConnectivityManagerImpl.h b/src/include/platform/internal/GenericConnectivityManagerImpl.h index 6315c25a701b51..a56e92d17d0d8d 100644 --- a/src/include/platform/internal/GenericConnectivityManagerImpl.h +++ b/src/include/platform/internal/GenericConnectivityManagerImpl.h @@ -33,7 +33,7 @@ namespace Internal { * * This template contains implementations of select features from the ConnectivityManager abstract * interface that are suitable for use on all platforms. It is intended to be inherited (directly - * or indirectly) by the ConfigurationManagerImpl class, which also appears as the template's ImplClass + * or indirectly) by the ConnectivityManagerImpl class, which also appears as the template's ImplClass * parameter. */ template diff --git a/src/inet/InetConfig.h b/src/inet/InetConfig.h index d209328fde87a5..0631a7e14f77da 100644 --- a/src/inet/InetConfig.h +++ b/src/inet/InetConfig.h @@ -250,4 +250,26 @@ #ifndef INET_CONFIG_IP_MULTICAST_HOP_LIMIT #define INET_CONFIG_IP_MULTICAST_HOP_LIMIT (64) #endif // INET_CONFIG_IP_MULTICAST_HOP_LIMIT + +/** + * @def INET_CONFIG_UDP_SOCKET_PKTINFO + * + * @brief + * Use IP_PKTINFO and IPV6_PKTINFO control messages to specify the network + * interface and the source address of a sent UDP packet. + * + * @details + * When this flag is set, the socket-based implementation of UDP endpoints + * requires that IP_PKTINFO and IPV6_PKTINFO be supported. Otherwise, it is + * left to the operating system to select the network interface and the + * source address. + */ +#ifndef INET_CONFIG_UDP_SOCKET_PKTINFO +#ifndef __ZEPHYR__ +#define INET_CONFIG_UDP_SOCKET_PKTINFO 1 +#else +#define INET_CONFIG_UDP_SOCKET_PKTINFO 0 +#endif +#endif // INET_CONFIG_UDP_SOCKET_PKTINFO + // clang-format on diff --git a/src/inet/UDPEndPointImplSockets.cpp b/src/inet/UDPEndPointImplSockets.cpp index cd12fe42fb64d3..6c85906bb7a9ed 100644 --- a/src/inet/UDPEndPointImplSockets.cpp +++ b/src/inet/UDPEndPointImplSockets.cpp @@ -66,7 +66,7 @@ #define INET_IPV6_ADD_MEMBERSHIP IPV6_ADD_MEMBERSHIP #elif defined(IPV6_JOIN_GROUP) #define INET_IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP -#elif !__ZEPHYR__ +#elif !CHIP_SYSTEM_CONFIG_USE_PLATFORM_MULTICAST_API #error \ "Neither IPV6_ADD_MEMBERSHIP nor IPV6_JOIN_GROUP are defined which are required for generalized IPv6 multicast group support." #endif // IPV6_ADD_MEMBERSHIP @@ -75,7 +75,7 @@ #define INET_IPV6_DROP_MEMBERSHIP IPV6_DROP_MEMBERSHIP #elif defined(IPV6_LEAVE_GROUP) #define INET_IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP -#elif !__ZEPHYR__ +#elif !CHIP_SYSTEM_CONFIG_USE_PLATFORM_MULTICAST_API #error \ "Neither IPV6_DROP_MEMBERSHIP nor IPV6_LEAVE_GROUP are defined which are required for generalized IPv6 multicast group support." #endif // IPV6_DROP_MEMBERSHIP @@ -337,6 +337,7 @@ CHIP_ERROR UDPEndPointImplSockets::SendMsgImpl(const IPPacketInfo * aPktInfo, Sy intf = mBoundIntfId; } +#if INET_CONFIG_UDP_SOCKET_PKTINFO // If the packet should be sent over a specific interface, or with a specific source // address, construct an IP_PKTINFO/IPV6_PKTINFO "control message" to that effect // add add it to the message header. If the local OS doesn't support IP_PKTINFO/IPV6_PKTINFO @@ -401,6 +402,7 @@ CHIP_ERROR UDPEndPointImplSockets::SendMsgImpl(const IPPacketInfo * aPktInfo, Sy return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; #endif // !(defined(IP_PKTINFO) && defined(IPV6_PKTINFO)) } +#endif // INET_CONFIG_UDP_SOCKET_PKTINFO // Send IP packet. const ssize_t lenSent = sendmsg(mSocket, &msgHeader, 0); @@ -565,7 +567,8 @@ void UDPEndPointImplSockets::HandlePendingIO(System::SocketEvents events) System::PacketBufferHandle lBuffer; lPacketInfo.Clear(); - lPacketInfo.DestPort = mBoundPort; + lPacketInfo.DestPort = mBoundPort; + lPacketInfo.Interface = mBoundIntfId; lBuffer = System::PacketBufferHandle::New(System::PacketBuffer::kMaxSizeWithoutReserve, 0); diff --git a/src/platform/Zephyr/BLEManagerImpl.cpp b/src/platform/Zephyr/BLEManagerImpl.cpp index d65b7a903e5e34..88edbd3da061f5 100644 --- a/src/platform/Zephyr/BLEManagerImpl.cpp +++ b/src/platform/Zephyr/BLEManagerImpl.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include diff --git a/src/platform/Zephyr/ConfigurationManagerImpl.cpp b/src/platform/Zephyr/ConfigurationManagerImpl.cpp index 107579afbfbb03..378e35e1006fe3 100644 --- a/src/platform/Zephyr/ConfigurationManagerImpl.cpp +++ b/src/platform/Zephyr/ConfigurationManagerImpl.cpp @@ -27,8 +27,11 @@ #include #include + #include +#include "InetUtils.h" + #include #include @@ -201,6 +204,21 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) PlatformMgr().Shutdown(); } +CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) +{ +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + const net_if * const iface = InetUtils::GetInterface(); + VerifyOrReturnError(iface != nullptr && iface->if_dev != nullptr, CHIP_ERROR_INTERNAL); + + const auto linkAddrStruct = iface->if_dev->link_addr; + memcpy(buf, linkAddrStruct.addr, linkAddrStruct.len); + + return CHIP_NO_ERROR; +#else + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +#endif +} + ConfigurationManager & ConfigurationMgrImpl() { return ConfigurationManagerImpl::GetDefaultInstance(); diff --git a/src/platform/Zephyr/ConfigurationManagerImpl.h b/src/platform/Zephyr/ConfigurationManagerImpl.h index 166237fba32d81..87f9e30335b8fc 100644 --- a/src/platform/Zephyr/ConfigurationManagerImpl.h +++ b/src/platform/Zephyr/ConfigurationManagerImpl.h @@ -94,11 +94,6 @@ inline CHIP_ERROR ConfigurationManagerImpl::WritePersistedStorageValue(::chip::P return Internal::ZephyrConfig::WriteConfigValueCounter(key, value); } -inline CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * /* buf */) -{ - return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; -} - /** * Returns the platform-specific implementation of the ConfigurationManager object. * diff --git a/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp b/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp index 1eb24394f27be7..c1fb842e054e1d 100644 --- a/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp @@ -116,7 +116,7 @@ DiagnosticDataProviderImpl & DiagnosticDataProviderImpl::GetDefaultInstance() return sInstance; } -inline DiagnosticDataProviderImpl::DiagnosticDataProviderImpl() : mBootReason(DetermineBootReason()) +DiagnosticDataProviderImpl::DiagnosticDataProviderImpl() : mBootReason(DetermineBootReason()) { ChipLogDetail(DeviceLayer, "Boot reason: %u", static_cast(mBootReason)); } @@ -328,10 +328,5 @@ void DiagnosticDataProviderImpl::ReleaseNetworkInterfaces(NetworkInterface * net } } -DiagnosticDataProvider & GetDiagnosticDataProviderImpl() -{ - return DiagnosticDataProviderImpl::GetDefaultInstance(); -} - } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Zephyr/DiagnosticDataProviderImpl.h b/src/platform/Zephyr/DiagnosticDataProviderImpl.h index 2b46051d27b125..69bbae5bf04471 100644 --- a/src/platform/Zephyr/DiagnosticDataProviderImpl.h +++ b/src/platform/Zephyr/DiagnosticDataProviderImpl.h @@ -52,9 +52,10 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider CHIP_ERROR GetNetworkInterfaces(NetworkInterface ** netifpp) override; void ReleaseNetworkInterfaces(NetworkInterface * netifp) override; -private: +protected: DiagnosticDataProviderImpl(); +private: const BootReasonType mBootReason; }; diff --git a/src/platform/Zephyr/DiagnosticDataProviderImplGetter.cpp b/src/platform/Zephyr/DiagnosticDataProviderImplGetter.cpp new file mode 100644 index 00000000000000..6b920d1661ffc3 --- /dev/null +++ b/src/platform/Zephyr/DiagnosticDataProviderImplGetter.cpp @@ -0,0 +1,29 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "DiagnosticDataProviderImpl.h" + +namespace chip { +namespace DeviceLayer { + +DiagnosticDataProvider & GetDiagnosticDataProviderImpl() +{ + return DiagnosticDataProviderImpl::GetDefaultInstance(); +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Zephyr/InetUtils.cpp b/src/platform/Zephyr/InetUtils.cpp new file mode 100644 index 00000000000000..1169cf6362ad88 --- /dev/null +++ b/src/platform/Zephyr/InetUtils.cpp @@ -0,0 +1,41 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "InetUtils.h" + +namespace chip { +namespace DeviceLayer { +namespace InetUtils { + +in6_addr ToZephyrAddr(const chip::Inet::IPAddress & address) +{ + in6_addr zephyrAddr; + + static_assert(sizeof(zephyrAddr.s6_addr) == sizeof(address.Addr), "Unexpected address size"); + memcpy(zephyrAddr.s6_addr, address.Addr, sizeof(address.Addr)); + + return zephyrAddr; +} + +net_if * GetInterface(chip::Inet::InterfaceId ifaceId) +{ + return ifaceId.IsPresent() ? net_if_get_by_index(ifaceId.GetPlatformInterface()) : net_if_get_default(); +} + +} // namespace InetUtils +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Zephyr/InetUtils.h b/src/platform/Zephyr/InetUtils.h new file mode 100644 index 00000000000000..ad7c5e1dc9028f --- /dev/null +++ b/src/platform/Zephyr/InetUtils.h @@ -0,0 +1,32 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +struct in6_addr; +struct net_if; + +namespace chip { +namespace DeviceLayer { +namespace InetUtils { + +in6_addr ToZephyrAddr(const chip::Inet::IPAddress & address); +net_if * GetInterface(chip::Inet::InterfaceId ifaceId = chip::Inet::InterfaceId::Null()); + +} // namespace InetUtils +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nrfconnect/BUILD.gn b/src/platform/nrfconnect/BUILD.gn index a841a2bb374020..186b45e4a54219 100644 --- a/src/platform/nrfconnect/BUILD.gn +++ b/src/platform/nrfconnect/BUILD.gn @@ -41,6 +41,8 @@ static_library("nrfconnect") { "ConfigurationManagerImpl.h", "ConnectivityManagerImpl.cpp", "ConnectivityManagerImpl.h", + "DiagnosticDataProviderImplNrf.cpp", + "DiagnosticDataProviderImplNrf.h", "ExternalFlashManager.h", "InetPlatformConfig.h", "KeyValueStoreManagerImpl.h", @@ -80,6 +82,19 @@ static_library("nrfconnect") { } } + if (chip_enable_wifi) { + sources += [ + "../Zephyr/InetUtils.cpp", + "../Zephyr/InetUtils.h", + "wifi/ConnectivityManagerImplWiFi.cpp", + "wifi/ConnectivityManagerImplWiFi.h", + "wifi/NrfWiFiDriver.cpp", + "wifi/NrfWiFiDriver.h", + "wifi/WiFiManager.cpp", + "wifi/WiFiManager.h", + ] + } + if (chip_enable_nfc) { sources += [ "../Zephyr/NFCManagerImpl.cpp", diff --git a/src/platform/nrfconnect/CHIPDevicePlatformConfig.h b/src/platform/nrfconnect/CHIPDevicePlatformConfig.h index 3813c860725a56..5a82f16ad4e9d8 100644 --- a/src/platform/nrfconnect/CHIPDevicePlatformConfig.h +++ b/src/platform/nrfconnect/CHIPDevicePlatformConfig.h @@ -87,10 +87,17 @@ #define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING #endif +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_NET_L2_OPENTHREAD + +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI CONFIG_WIFI_NRF700X + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 1 +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0 +#else #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0 #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0 - -#define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_NET_L2_OPENTHREAD +#endif #define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE CONFIG_BT diff --git a/src/platform/nrfconnect/ConnectivityManagerImpl.cpp b/src/platform/nrfconnect/ConnectivityManagerImpl.cpp index c5029f37a67862..504b0d0460ccde 100644 --- a/src/platform/nrfconnect/ConnectivityManagerImpl.cpp +++ b/src/platform/nrfconnect/ConnectivityManagerImpl.cpp @@ -51,7 +51,9 @@ CHIP_ERROR ConnectivityManagerImpl::_Init() #if CHIP_DEVICE_CONFIG_ENABLE_THREAD GenericConnectivityManagerImpl_Thread::_Init(); #endif - +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + ReturnErrorOnFailure(InitWiFi()); +#endif return CHIP_NO_ERROR; } diff --git a/src/platform/nrfconnect/ConnectivityManagerImpl.h b/src/platform/nrfconnect/ConnectivityManagerImpl.h index 4c003f23a4861a..8ea6c2d76b6561 100644 --- a/src/platform/nrfconnect/ConnectivityManagerImpl.h +++ b/src/platform/nrfconnect/ConnectivityManagerImpl.h @@ -28,12 +28,18 @@ #else #include #endif + #if CHIP_DEVICE_CONFIG_ENABLE_THREAD #include #else #include #endif + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +#include "wifi/ConnectivityManagerImplWiFi.h" +#else #include +#endif #include @@ -65,7 +71,11 @@ class ConnectivityManagerImpl final : public ConnectivityManager, #else public Internal::GenericConnectivityManagerImpl_NoThread, #endif +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + public ConnectivityManagerImplWiFi +#else public Internal::GenericConnectivityManagerImpl_NoWiFi +#endif { // Allow the ConnectivityManager interface class to delegate method calls to // the implementation methods provided by this class. @@ -100,7 +110,7 @@ inline ConnectivityManager & ConnectivityMgr(void) * Returns the platform-specific implementation of the ConnectivityManager singleton object. * * chip applications can use this to gain access to features of the ConnectivityManager - * that are specific to the ESP32 platform. + * that are specific to the nrfconnect platform. */ inline ConnectivityManagerImpl & ConnectivityMgrImpl(void) { diff --git a/src/platform/nrfconnect/DiagnosticDataProviderImplNrf.cpp b/src/platform/nrfconnect/DiagnosticDataProviderImplNrf.cpp new file mode 100644 index 00000000000000..5f7bc1a6702b4e --- /dev/null +++ b/src/platform/nrfconnect/DiagnosticDataProviderImplNrf.cpp @@ -0,0 +1,136 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Provides an implementation of the DiagnosticDataProvider object + * for nrfconnect platform. + */ + +#include "DiagnosticDataProviderImplNrf.h" + +#ifdef CONFIG_WIFI_NRF700X +#include +#endif + +namespace chip { +namespace DeviceLayer { + +DiagnosticDataProvider & GetDiagnosticDataProviderImpl() +{ + return DiagnosticDataProviderImplNrf::GetDefaultInstance(); +} + +DiagnosticDataProviderImplNrf & DiagnosticDataProviderImplNrf::GetDefaultInstance() +{ + static DiagnosticDataProviderImplNrf sInstance; + return sInstance; +} + +#ifdef CONFIG_WIFI_NRF700X +CHIP_ERROR DiagnosticDataProviderImplNrf::GetWiFiBssId(ByteSpan & value) +{ + WiFiManager::WiFiInfo info; + CHIP_ERROR err = WiFiManager::Instance().GetWiFiInfo(info); + value = info.mBssId; + return err; +} + +CHIP_ERROR DiagnosticDataProviderImplNrf::GetWiFiSecurityType(uint8_t & securityType) +{ + WiFiManager::WiFiInfo info; + CHIP_ERROR err = WiFiManager::Instance().GetWiFiInfo(info); + securityType = info.mSecurityType; + return err; +} + +CHIP_ERROR DiagnosticDataProviderImplNrf::GetWiFiVersion(uint8_t & wiFiVersion) +{ + WiFiManager::WiFiInfo info; + CHIP_ERROR err = WiFiManager::Instance().GetWiFiInfo(info); + wiFiVersion = info.mWiFiVersion; + return err; +} + +CHIP_ERROR DiagnosticDataProviderImplNrf::GetWiFiChannelNumber(uint16_t & channelNumber) +{ + WiFiManager::WiFiInfo info; + CHIP_ERROR err = WiFiManager::Instance().GetWiFiInfo(info); + channelNumber = info.mChannel; + (void) err; + // above will return 0 until the wpa_supplicant driver API implementation is refined + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImplNrf::GetWiFiRssi(int8_t & rssi) +{ + WiFiManager::WiFiInfo info; + CHIP_ERROR err = WiFiManager::Instance().GetWiFiInfo(info); + rssi = info.mRssi; + (void) err; + // above will return -128 until the wpa_supplicant driver API implementation is refined + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +// below will be implemented when the WiFi driver exposes Zephyr NET_STATISTICS API +CHIP_ERROR DiagnosticDataProviderImplNrf::GetWiFiBeaconLostCount(uint32_t & beaconLostCount) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImplNrf::GetWiFiBeaconRxCount(uint32_t & beaconRxCount) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImplNrf::GetWiFiPacketMulticastRxCount(uint32_t & packetMulticastRxCount) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} +CHIP_ERROR DiagnosticDataProviderImplNrf::GetWiFiPacketMulticastTxCount(uint32_t & packetMulticastTxCount) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImplNrf::GetWiFiPacketUnicastRxCount(uint32_t & packetUnicastRxCount) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImplNrf::GetWiFiPacketUnicastTxCount(uint32_t & packetUnicastTxCount) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImplNrf::GetWiFiCurrentMaxRate(uint64_t & currentMaxRate) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImplNrf::GetWiFiOverrunCount(uint64_t & overrunCount) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImplNrf::ResetWiFiNetworkDiagnosticsCounts() +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} +#endif + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nrfconnect/DiagnosticDataProviderImplNrf.h b/src/platform/nrfconnect/DiagnosticDataProviderImplNrf.h new file mode 100644 index 00000000000000..3b770e627428e8 --- /dev/null +++ b/src/platform/nrfconnect/DiagnosticDataProviderImplNrf.h @@ -0,0 +1,60 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Provides an implementation of the DiagnosticDataProvider object + * for nrfconnect platform. + */ + +#pragma once + +#include + +namespace chip { +namespace DeviceLayer { + +class DiagnosticDataProviderImplNrf : public DiagnosticDataProviderImpl +{ +public: +#ifdef CONFIG_WIFI_NRF700X + CHIP_ERROR GetWiFiBssId(ByteSpan & value) override; + CHIP_ERROR GetWiFiSecurityType(uint8_t & securityType) override; + CHIP_ERROR GetWiFiVersion(uint8_t & wiFiVersion) override; + CHIP_ERROR GetWiFiChannelNumber(uint16_t & channelNumber) override; + CHIP_ERROR GetWiFiRssi(int8_t & rssi) override; + CHIP_ERROR GetWiFiBeaconLostCount(uint32_t & beaconLostCount) override; + CHIP_ERROR GetWiFiBeaconRxCount(uint32_t & beaconRxCount) override; + CHIP_ERROR GetWiFiPacketMulticastRxCount(uint32_t & packetMulticastRxCount) override; + CHIP_ERROR GetWiFiPacketMulticastTxCount(uint32_t & packetMulticastTxCount) override; + CHIP_ERROR GetWiFiPacketUnicastRxCount(uint32_t & packetUnicastRxCount) override; + CHIP_ERROR GetWiFiPacketUnicastTxCount(uint32_t & packetUnicastTxCount) override; + CHIP_ERROR GetWiFiCurrentMaxRate(uint64_t & currentMaxRate) override; + CHIP_ERROR GetWiFiOverrunCount(uint64_t & overrunCount) override; + CHIP_ERROR ResetWiFiNetworkDiagnosticsCounts() override; +#endif + + static DiagnosticDataProviderImplNrf & GetDefaultInstance(); + +private: + DiagnosticDataProviderImplNrf() = default; +}; + +DiagnosticDataProvider & GetDiagnosticDataProviderImpl(); + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nrfconnect/wifi/ConnectivityManagerImplWiFi.cpp b/src/platform/nrfconnect/wifi/ConnectivityManagerImplWiFi.cpp new file mode 100644 index 00000000000000..73e16303a03bc5 --- /dev/null +++ b/src/platform/nrfconnect/wifi/ConnectivityManagerImplWiFi.cpp @@ -0,0 +1,228 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* this file behaves like a config.h, comes first */ +#include + +#include +#include + +#include "ConnectivityManagerImplWiFi.h" +#include "WiFiManager.h" + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + +using namespace ::chip; +using namespace ::chip::Inet; +using namespace ::chip::System; +using namespace ::chip::TLV; + +namespace chip { +namespace DeviceLayer { + +CHIP_ERROR ConnectivityManagerImplWiFi::InitWiFi() +{ + return WiFiManager::Instance().Init(); +} + +ConnectivityManager::WiFiStationMode ConnectivityManagerImplWiFi::_GetWiFiStationMode(void) +{ + if (mStationMode != ConnectivityManager::WiFiStationMode::kWiFiStationMode_ApplicationControlled) + { + mStationMode = (WiFiManager::StationStatus::DISABLED == WiFiManager().Instance().GetStationStatus()) + ? ConnectivityManager::WiFiStationMode::kWiFiStationMode_Disabled + : ConnectivityManager::WiFiStationMode::kWiFiStationMode_Enabled; + } + return mStationMode; +} + +CHIP_ERROR ConnectivityManagerImplWiFi::_SetWiFiStationMode(ConnectivityManager::WiFiStationMode aMode) +{ + VerifyOrReturnError(ConnectivityManager::WiFiStationMode::kWiFiStationMode_NotSupported != aMode, + CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); + + if (aMode != mStationMode) + { + mStationMode = aMode; + if (mStationMode != ConnectivityManager::WiFiStationMode::kWiFiStationMode_ApplicationControlled) + { + bool doEnable{ ConnectivityManager::WiFiStationMode::kWiFiStationMode_Enabled == mStationMode }; + // TODO: when the connection/disconnection callback API is provided + // below calls should be used as a base of disconnect callback + if (doEnable) + { + OnStationConnected(); + } + else + { + OnStationDisconnected(); + } + } + } + + return CHIP_NO_ERROR; +} + +bool ConnectivityManagerImplWiFi::_IsWiFiStationEnabled(void) +{ + return (WiFiManager::StationStatus::DISABLED <= WiFiManager().Instance().GetStationStatus()); +} + +bool ConnectivityManagerImplWiFi::_IsWiFiStationApplicationControlled(void) +{ + return (ConnectivityManager::WiFiStationMode::kWiFiStationMode_ApplicationControlled == mStationMode); +} + +bool ConnectivityManagerImplWiFi::_IsWiFiStationConnected(void) +{ + return (WiFiManager::StationStatus::FULLY_PROVISIONED == WiFiManager().Instance().GetStationStatus()); +} + +System::Clock::Timeout ConnectivityManagerImplWiFi::_GetWiFiStationReconnectInterval(void) +{ + return mWiFiStationReconnectInterval; +} + +CHIP_ERROR ConnectivityManagerImplWiFi::_SetWiFiStationReconnectInterval(System::Clock::Timeout val) +{ + mWiFiStationReconnectInterval = val; + return CHIP_NO_ERROR; +} + +bool ConnectivityManagerImplWiFi::_IsWiFiStationProvisioned(void) +{ + // from Matter perspective `provisioned` means that the supplicant has been provided + // with SSID and password (doesn't matter if valid or not) + return (WiFiManager::StationStatus::CONNECTING <= WiFiManager().Instance().GetStationStatus()); +} + +void ConnectivityManagerImplWiFi::_ClearWiFiStationProvision(void) +{ + if (_IsWiFiStationProvisioned()) + { + if (CHIP_NO_ERROR != WiFiManager().Instance().ClearStationProvisioningData()) + { + ChipLogError(DeviceLayer, "Cannot clear WiFi station provisioning data"); + } + } +} + +bool ConnectivityManagerImplWiFi::_CanStartWiFiScan() +{ + return (WiFiManager::StationStatus::DISABLED != WiFiManager().Instance().GetStationStatus() && + WiFiManager::StationStatus::SCANNING != WiFiManager().Instance().GetStationStatus() && + WiFiManager::StationStatus::CONNECTING != WiFiManager().Instance().GetStationStatus()); +} + +void ConnectivityManagerImplWiFi::_OnWiFiStationProvisionChange() +{ + // do nothing +} + +void ConnectivityManagerImplWiFi::_OnWiFiScanDone() {} + +CHIP_ERROR ConnectivityManagerImplWiFi::_GetAndLogWiFiStatsCounters(void) +{ + // TODO: when network statistics are enabled + return CHIP_NO_ERROR; +} + +void ConnectivityManagerImplWiFi::OnStationConnected() +{ + // ensure the station is connected + if (_IsWiFiStationConnected()) + { + ChipDeviceEvent connectEvent{}; + connectEvent.Type = DeviceEventType::kWiFiConnectivityChange; + connectEvent.WiFiConnectivityChange.Result = kConnectivity_Established; + PlatformMgr().PostEventOrDie(&connectEvent); + } + else + { + ChipLogError(DeviceLayer, "WiFi Station is not connected!"); + } +} + +void ConnectivityManagerImplWiFi::OnStationDisconnected() +{ + // ensure the station is disconnected + if (WiFiManager::StationStatus::DISCONNECTED == WiFiManager().Instance().GetStationStatus()) + { + ChipDeviceEvent disconnectEvent{}; + disconnectEvent.Type = DeviceEventType::kWiFiConnectivityChange; + disconnectEvent.WiFiConnectivityChange.Result = kConnectivity_Lost; + PlatformMgr().PostEventOrDie(&disconnectEvent); + } + else + { + ChipLogError(DeviceLayer, "WiFi Station is not disconnected!"); + } +} + +ConnectivityManager::WiFiAPMode ConnectivityManagerImplWiFi::_GetWiFiAPMode(void) +{ + /* AP mode is unsupported */ + return ConnectivityManager::WiFiAPMode::kWiFiAPMode_NotSupported; +} + +CHIP_ERROR ConnectivityManagerImplWiFi::_SetWiFiAPMode(ConnectivityManager::WiFiAPMode mode) +{ + /* AP mode is unsupported */ + VerifyOrReturnError(ConnectivityManager::WiFiAPMode::kWiFiAPMode_NotSupported == mode || + ConnectivityManager::WiFiAPMode::kWiFiAPMode_Disabled == mode, + CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); + return CHIP_NO_ERROR; +} + +bool ConnectivityManagerImplWiFi::_IsWiFiAPActive(void) +{ + /* AP mode is unsupported */ + return false; +} + +bool ConnectivityManagerImplWiFi::_IsWiFiAPApplicationControlled(void) +{ + /* AP mode is unsupported */ + return false; +} + +void ConnectivityManagerImplWiFi::_DemandStartWiFiAP(void) +{ /* AP mode is unsupported */ +} + +void ConnectivityManagerImplWiFi::_StopOnDemandWiFiAP(void) +{ /* AP mode is unsupported */ +} + +void ConnectivityManagerImplWiFi::_MaintainOnDemandWiFiAP(void) +{ /* AP mode is unsupported */ +} + +System::Clock::Timeout ConnectivityManagerImplWiFi::_GetWiFiAPIdleTimeout(void) +{ + /* AP mode is unsupported */ + return System::Clock::kZero; +} + +void ConnectivityManagerImplWiFi::_SetWiFiAPIdleTimeout(System::Clock::Timeout val) +{ /* AP mode is unsupported */ +} + +} // namespace DeviceLayer +} // namespace chip + +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI diff --git a/src/platform/nrfconnect/wifi/ConnectivityManagerImplWiFi.h b/src/platform/nrfconnect/wifi/ConnectivityManagerImplWiFi.h new file mode 100644 index 00000000000000..8198453038417a --- /dev/null +++ b/src/platform/nrfconnect/wifi/ConnectivityManagerImplWiFi.h @@ -0,0 +1,82 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include + +#include + +namespace chip { +namespace Inet { +class IPAddress; +} // namespace Inet +} // namespace chip + +namespace chip { +namespace DeviceLayer { + +class ConnectivityManagerImplWiFi +{ + friend class ConnectivityManager; + +protected: + CHIP_ERROR InitWiFi(); + +private: + // Wi-Fi station + ConnectivityManager::WiFiStationMode _GetWiFiStationMode(void); + CHIP_ERROR _SetWiFiStationMode(ConnectivityManager::WiFiStationMode val); + bool _IsWiFiStationEnabled(void); + bool _IsWiFiStationApplicationControlled(void); + bool _IsWiFiStationConnected(void); + System::Clock::Timeout _GetWiFiStationReconnectInterval(void); + CHIP_ERROR _SetWiFiStationReconnectInterval(System::Clock::Timeout val); + bool _IsWiFiStationProvisioned(void); + void _ClearWiFiStationProvision(void); + CHIP_ERROR _GetAndLogWiFiStatsCounters(void); + bool _CanStartWiFiScan(); + void _OnWiFiScanDone(); + void _OnWiFiStationProvisionChange(); + void OnStationConnected(); + void OnStationDisconnected(); + + // Wi-Fi access point - not supported + ConnectivityManager::WiFiAPMode _GetWiFiAPMode(void); + CHIP_ERROR _SetWiFiAPMode(ConnectivityManager::WiFiAPMode val); + bool _IsWiFiAPActive(void); + bool _IsWiFiAPApplicationControlled(void); + void _DemandStartWiFiAP(void); + void _StopOnDemandWiFiAP(void); + void _MaintainOnDemandWiFiAP(void); + System::Clock::Timeout _GetWiFiAPIdleTimeout(void); + void _SetWiFiAPIdleTimeout(System::Clock::Timeout val); + + ConnectivityManager::WiFiStationMode mStationMode{ ConnectivityManager::WiFiStationMode::kWiFiStationMode_Disabled }; + ConnectivityManager::WiFiStationState mStationState{ ConnectivityManager::WiFiStationState::kWiFiStationState_NotConnected }; + System::Clock::Timeout mWiFiStationReconnectInterval{}; + + static const char * _WiFiStationModeToStr(ConnectivityManager::WiFiStationMode mode); + static const char * _WiFiAPModeToStr(ConnectivityManager::WiFiAPMode mode); + static const char * _WiFiStationStateToStr(ConnectivityManager::WiFiStationState state); + static const char * _WiFiAPStateToStr(ConnectivityManager::WiFiAPState state); +}; + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nrfconnect/wifi/NrfWiFiDriver.cpp b/src/platform/nrfconnect/wifi/NrfWiFiDriver.cpp new file mode 100644 index 00000000000000..5092384006fca0 --- /dev/null +++ b/src/platform/nrfconnect/wifi/NrfWiFiDriver.cpp @@ -0,0 +1,284 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "NrfWiFiDriver.h" + +#include "WiFiManager.h" +#include + +#include +#include +#include + +using namespace ::chip; +using namespace ::chip::DeviceLayer::Internal; +using namespace ::chip::DeviceLayer::PersistedStorage; + +namespace chip { +namespace DeviceLayer { +namespace NetworkCommissioning { + +size_t NrfWiFiDriver::WiFiNetworkIterator::Count() +{ + VerifyOrReturnValue(mDriver != nullptr, 0); + return mDriver->mStagingNetwork.IsConfigured() ? 1 : 0; +} + +bool NrfWiFiDriver::WiFiNetworkIterator::Next(Network & item) +{ + // we assume only one network is actually supported + // TODO: verify if this can be extended + if (mExhausted || 0 == Count()) + { + return false; + } + + memcpy(item.networkID, mDriver->mStagingNetwork.ssid, mDriver->mStagingNetwork.ssidLen); + item.networkIDLen = mDriver->mStagingNetwork.ssidLen; + item.connected = false; + + mExhausted = true; + + WiFiManager::WiFiInfo wifiInfo; + if (CHIP_NO_ERROR == WiFiManager::Instance().GetWiFiInfo(wifiInfo)) + { + if (WiFiManager::StationStatus::CONNECTED <= WiFiManager::Instance().GetStationStatus()) + { + if (wifiInfo.mSsidLen == item.networkIDLen && 0 == memcmp(wifiInfo.mSsid, item.networkID, wifiInfo.mSsidLen)) + { + item.connected = true; + } + } + } + return true; +} + +bool NrfWiFiScanResponseIterator::Next(WiFiScanResponse & item) +{ + if (mResultId < mResultCount) + { + item = mResults[mResultId++]; + return true; + } + return false; +} + +void NrfWiFiScanResponseIterator::Release() +{ + mResultId = mResultCount = 0; + Platform::MemoryFree(mResults); + mResults = nullptr; +} + +void NrfWiFiScanResponseIterator::Add(const WiFiScanResponse & result) +{ + void * newResults = Platform::MemoryRealloc(mResults, (mResultCount + 1) * sizeof(WiFiScanResponse)); + + if (newResults) + { + mResults = static_cast(newResults); + mResults[mResultCount++] = result; + } +} + +CHIP_ERROR NrfWiFiDriver::Init(NetworkStatusChangeCallback * networkStatusChangeCallback) +{ + mpNetworkStatusChangeCallback = networkStatusChangeCallback; + + LoadFromStorage(); + + if (mStagingNetwork.IsConfigured()) + { + WiFiManager::ConnectionHandling handling{ [] { Instance().OnNetworkStatusChanged(Status::kSuccess); }, + [] { Instance().OnNetworkStatusChanged(Status::kUnknownError); }, + System::Clock::Timeout{ 40000 } }; + ReturnErrorOnFailure( + WiFiManager::Instance().Connect(mStagingNetwork.GetSsidSpan(), mStagingNetwork.GetPassSpan(), handling)); + } + + return CHIP_NO_ERROR; +} + +void NrfWiFiDriver::OnNetworkStatusChanged(Status status) +{ + if (status == Status::kSuccess) + { + ConnectivityMgr().SetWiFiStationMode(ConnectivityManager::kWiFiStationMode_Enabled); + } + + if (mpNetworkStatusChangeCallback) + mpNetworkStatusChangeCallback->OnNetworkingStatusChange(status, NullOptional, NullOptional); +} + +void NrfWiFiDriver::Shutdown() +{ + mpNetworkStatusChangeCallback = nullptr; +} + +CHIP_ERROR NrfWiFiDriver::CommitConfiguration() +{ + ReturnErrorOnFailure(KeyValueStoreMgr().Put(kPassKey, mStagingNetwork.pass, mStagingNetwork.passLen)); + ReturnErrorOnFailure(KeyValueStoreMgr().Put(kSsidKey, mStagingNetwork.ssid, mStagingNetwork.ssidLen)); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR NrfWiFiDriver::RevertConfiguration() +{ + LoadFromStorage(); + + if (mStagingNetwork.IsConfigured()) + { + WiFiManager::ConnectionHandling handling{ [] { Instance().OnConnectWiFiNetwork(); }, + [] { Instance().OnConnectWiFiNetworkFailed(); }, + System::Clock::Timeout{ 40000 } }; + ReturnErrorOnFailure( + WiFiManager::Instance().Connect(mStagingNetwork.GetSsidSpan(), mStagingNetwork.GetPassSpan(), handling)); + } + + return CHIP_NO_ERROR; +} + +Status NrfWiFiDriver::AddOrUpdateNetwork(ByteSpan ssid, ByteSpan credentials, MutableCharSpan & outDebugText, + uint8_t & outNetworkIndex) +{ + outDebugText = {}; + outNetworkIndex = 0; + + VerifyOrReturnError(!mStagingNetwork.IsConfigured() || ssid.data_equal(mStagingNetwork.GetSsidSpan()), Status::kBoundsExceeded); + VerifyOrReturnError(ssid.size() <= sizeof(mStagingNetwork.ssid), Status::kOutOfRange); + VerifyOrReturnError(credentials.size() <= sizeof(mStagingNetwork.pass), Status::kOutOfRange); + + memcpy(mStagingNetwork.ssid, ssid.data(), ssid.size()); + memcpy(mStagingNetwork.pass, credentials.data(), credentials.size()); + mStagingNetwork.ssidLen = ssid.size(); + mStagingNetwork.passLen = credentials.size(); + + return Status::kSuccess; +} + +Status NrfWiFiDriver::RemoveNetwork(ByteSpan networkId, MutableCharSpan & outDebugText, uint8_t & outNetworkIndex) +{ + outDebugText = {}; + outNetworkIndex = 0; + + VerifyOrReturnError(networkId.data_equal(mStagingNetwork.GetSsidSpan()), Status::kNetworkIDNotFound); + mStagingNetwork.Clear(); + + return Status::kSuccess; +} + +Status NrfWiFiDriver::ReorderNetwork(ByteSpan networkId, uint8_t index, MutableCharSpan & outDebugText) +{ + outDebugText = {}; + + // Only one network is supported for now + VerifyOrReturnError(index == 0, Status::kOutOfRange); + VerifyOrReturnError(networkId.data_equal(mStagingNetwork.GetSsidSpan()), Status::kNetworkIDNotFound); + + return Status::kSuccess; +} + +void NrfWiFiDriver::ConnectNetwork(ByteSpan networkId, ConnectCallback * callback) +{ + Status status = Status::kSuccess; + WiFiManager::ConnectionHandling handling{ [] { Instance().OnConnectWiFiNetwork(); }, + [] { Instance().OnConnectWiFiNetworkFailed(); }, System::Clock::Timeout{ 40000 } }; + + VerifyOrExit(networkId.data_equal(mStagingNetwork.GetSsidSpan()), status = Status::kNetworkIDNotFound); + VerifyOrExit(mpConnectCallback == nullptr, status = Status::kUnknownError); + + mpConnectCallback = callback; + WiFiManager::Instance().Connect(mStagingNetwork.GetSsidSpan(), mStagingNetwork.GetPassSpan(), handling); + +exit: + if (status != Status::kSuccess) + { + mpConnectCallback = nullptr; + callback->OnResult(status, CharSpan(), 0); + } +} + +CHIP_ERROR GetConfiguredNetwork(Network & network) +{ + return CHIP_NO_ERROR; +} + +void NrfWiFiDriver::OnConnectWiFiNetwork() +{ + ConnectivityMgr().SetWiFiStationMode(ConnectivityManager::kWiFiStationMode_Enabled); + + if (mpConnectCallback) + { + mpConnectCallback->OnResult(Status::kSuccess, CharSpan(), 0); + mpConnectCallback = nullptr; + } +} + +void NrfWiFiDriver::OnConnectWiFiNetworkFailed() +{ + if (mpConnectCallback) + { + mpConnectCallback->OnResult(Status::kNetworkNotFound, CharSpan(), 0); + mpConnectCallback = nullptr; + } +} + +void NrfWiFiDriver::ScanNetworks(ByteSpan ssid, WiFiDriver::ScanCallback * callback) +{ + mScanCallback = callback; + CHIP_ERROR error = WiFiManager::Instance().Scan( + ssid, [](int status, WiFiScanResponse * response) { Instance().OnScanWiFiNetworkDone(status, response); }); + + if (error != CHIP_NO_ERROR) + { + mScanCallback = nullptr; + callback->OnFinished(Status::kUnknownError, CharSpan(), nullptr); + } +} + +void NrfWiFiDriver::OnScanWiFiNetworkDone(int status, WiFiScanResponse * response) +{ + if (response != nullptr) + { + StackLock lock; + VerifyOrReturn(mScanCallback != nullptr); + mScanResponseIterator.Add(*response); + return; + } + + // Scan complete + DeviceLayer::SystemLayer().ScheduleLambda([this, status]() { + VerifyOrReturn(mScanCallback != nullptr); + mScanCallback->OnFinished(status == 0 ? Status::kSuccess : Status::kUnknownError, CharSpan(), &mScanResponseIterator); + mScanCallback = nullptr; + }); +} + +void NrfWiFiDriver::LoadFromStorage() +{ + WiFiNetwork network; + + mStagingNetwork = {}; + ReturnOnFailure(KeyValueStoreMgr().Get(kSsidKey, network.ssid, sizeof(network.ssid), &network.ssidLen)); + ReturnOnFailure(KeyValueStoreMgr().Get(kPassKey, network.pass, sizeof(network.pass), &network.passLen)); + mStagingNetwork = network; +} + +} // namespace NetworkCommissioning +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nrfconnect/wifi/NrfWiFiDriver.h b/src/platform/nrfconnect/wifi/NrfWiFiDriver.h new file mode 100644 index 00000000000000..880cce80b69171 --- /dev/null +++ b/src/platform/nrfconnect/wifi/NrfWiFiDriver.h @@ -0,0 +1,123 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once +#include + +namespace chip { +namespace DeviceLayer { +namespace NetworkCommissioning { + +constexpr uint8_t kMaxWiFiNetworks = 1; +constexpr uint8_t kWiFiScanNetworksTimeOutSeconds = 10; +constexpr uint8_t kWiFiConnectNetworkTimeoutSeconds = 120; + +class NrfWiFiScanResponseIterator : public Iterator +{ +public: + size_t Count() override { return mResultCount; } + bool Next(WiFiScanResponse & item) override; + void Release() override; + void Add(const WiFiScanResponse & result); + +private: + size_t mResultId = 0; + size_t mResultCount = 0; + WiFiScanResponse * mResults = nullptr; +}; + +class NrfWiFiDriver final : public WiFiDriver +{ +public: + // Define non-volatile storage keys for SSID and password. + // The naming convention is aligned with DefaultStorageKeyAllocator class. + static constexpr const char * kSsidKey = "g/wi/s"; + static constexpr const char * kPassKey = "g/wi/p"; + + class WiFiNetworkIterator final : public NetworkIterator + { + public: + WiFiNetworkIterator(NrfWiFiDriver * aDriver) : mDriver(aDriver) {} + size_t Count() override; + bool Next(Network & item) override; + void Release() override { delete this; } + ~WiFiNetworkIterator() = default; + + private: + NrfWiFiDriver * mDriver; + bool mExhausted{ false }; + }; + + struct WiFiNetwork + { + uint8_t ssid[DeviceLayer::Internal::kMaxWiFiSSIDLength]; + size_t ssidLen = 0; + uint8_t pass[DeviceLayer::Internal::kMaxWiFiKeyLength]; + size_t passLen = 0; + + bool IsConfigured() const { return ssidLen > 0; } + ByteSpan GetSsidSpan() const { return ByteSpan(ssid, ssidLen); } + ByteSpan GetPassSpan() const { return ByteSpan(pass, passLen); } + void Clear() { ssidLen = 0; } + }; + + // BaseDriver + NetworkIterator * GetNetworks() override { return new WiFiNetworkIterator(this); } + CHIP_ERROR Init(NetworkStatusChangeCallback * networkStatusChangeCallback) override; + void Shutdown() override; + + // WirelessDriver + uint8_t GetMaxNetworks() override { return kMaxWiFiNetworks; } + uint8_t GetScanNetworkTimeoutSeconds() override { return kWiFiScanNetworksTimeOutSeconds; } + uint8_t GetConnectNetworkTimeoutSeconds() override { return kWiFiConnectNetworkTimeoutSeconds; } + + CHIP_ERROR CommitConfiguration() override; + CHIP_ERROR RevertConfiguration() override; + + Status RemoveNetwork(ByteSpan networkId, MutableCharSpan & outDebugText, uint8_t & outNetworkIndex) override; + Status ReorderNetwork(ByteSpan networkId, uint8_t index, MutableCharSpan & outDebugText) override; + void ConnectNetwork(ByteSpan networkId, ConnectCallback * callback) override; + + // WiFiDriver + Status AddOrUpdateNetwork(ByteSpan ssid, ByteSpan credentials, MutableCharSpan & outDebugText, + uint8_t & outNetworkIndex) override; + void ScanNetworks(ByteSpan ssid, ScanCallback * callback) override; + + static NrfWiFiDriver & Instance() + { + static NrfWiFiDriver sInstance; + return sInstance; + } + + void OnConnectWiFiNetwork(); + void OnConnectWiFiNetworkFailed(); + void OnNetworkStatusChanged(Status status); + void OnScanWiFiNetworkDone(int status, WiFiScanResponse * result); + +private: + void LoadFromStorage(); + + ConnectCallback * mpConnectCallback{ nullptr }; + NetworkStatusChangeCallback * mpNetworkStatusChangeCallback{ nullptr }; + WiFiNetwork mStagingNetwork; + NrfWiFiScanResponseIterator mScanResponseIterator; + ScanCallback * mScanCallback{ nullptr }; +}; + +} // namespace NetworkCommissioning +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nrfconnect/wifi/WiFiManager.cpp b/src/platform/nrfconnect/wifi/WiFiManager.cpp new file mode 100644 index 00000000000000..0a0e50cfdd0b1c --- /dev/null +++ b/src/platform/nrfconnect/wifi/WiFiManager.cpp @@ -0,0 +1,447 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Provides the wrapper for nRF WiFi API + */ + +#include "WiFiManager.h" + +#include +#include +#include +#include +#include + +#include +#include + +extern "C" { +#include +#include +#include +#include +#include +} + +extern struct wpa_global * global; + +static struct wpa_supplicant * wpa_s; + +namespace chip { +namespace DeviceLayer { + +namespace { + +NetworkCommissioning::WiFiScanResponse ToScanResponse(wifi_scan_result * result) +{ + NetworkCommissioning::WiFiScanResponse response = {}; + + if (result != nullptr) + { + static_assert(sizeof(response.ssid) == sizeof(result->ssid), "SSID length mismatch"); + static_assert(sizeof(response.bssid) == sizeof(result->mac), "BSSID length mismatch"); + + // TODO: Distinguish WPA versions + response.security.Set(result->security == WIFI_SECURITY_TYPE_PSK ? NetworkCommissioning::WiFiSecurity::kWpaPersonal + : NetworkCommissioning::WiFiSecurity::kUnencrypted); + response.channel = result->channel; + response.rssi = result->rssi; + response.ssidLen = result->ssid_length; + memcpy(response.ssid, result->ssid, result->ssid_length); + // TODO: MAC/BSSID is not filled by the Wi-Fi driver + memcpy(response.bssid, result->mac, result->mac_length); + } + + return response; +} + +} // namespace + +// These enums shall reflect the overall ordered disconnected->connected flow +const Map + WiFiManager::sStatusMap({ { WPA_DISCONNECTED, WiFiManager::StationStatus::DISCONNECTED }, + { WPA_INTERFACE_DISABLED, WiFiManager::StationStatus::DISABLED }, + { WPA_INACTIVE, WiFiManager::StationStatus::DISABLED }, + { WPA_SCANNING, WiFiManager::StationStatus::SCANNING }, + { WPA_AUTHENTICATING, WiFiManager::StationStatus::CONNECTING }, + { WPA_ASSOCIATING, WiFiManager::StationStatus::CONNECTING }, + { WPA_ASSOCIATED, WiFiManager::StationStatus::CONNECTED }, + { WPA_4WAY_HANDSHAKE, WiFiManager::StationStatus::PROVISIONING }, + { WPA_GROUP_HANDSHAKE, WiFiManager::StationStatus::PROVISIONING }, + { WPA_COMPLETED, WiFiManager::StationStatus::FULLY_PROVISIONED } }); + +// Map WiFi center frequency to the corresponding channel number +const Map WiFiManager::sFreqChannelMap( + { { 4915, 183 }, { 4920, 184 }, { 4925, 185 }, { 4935, 187 }, { 4940, 188 }, { 4945, 189 }, { 4960, 192 }, + { 4980, 196 }, { 5035, 7 }, { 5040, 8 }, { 5045, 9 }, { 5055, 11 }, { 5060, 12 }, { 5080, 16 }, + { 5170, 34 }, { 5180, 36 }, { 5190, 38 }, { 5200, 40 }, { 5210, 42 }, { 5220, 44 }, { 5230, 46 }, + { 5240, 48 }, { 5260, 52 }, { 5280, 56 }, { 5300, 60 }, { 5320, 64 }, { 5500, 100 }, { 5520, 104 }, + { 5540, 108 }, { 5560, 112 }, { 5580, 116 }, { 5600, 120 }, { 5620, 124 }, { 5640, 128 }, { 5660, 132 }, + { 5680, 136 }, { 5700, 140 }, { 5745, 149 }, { 5765, 153 }, { 5785, 157 }, { 5805, 161 }, { 5825, 165 } }); + +CHIP_ERROR WiFiManager::Init() +{ + // wpa_supplicant instance is initialized in dedicated supplicant thread, so wait until + // the initialization is completed. + // TODO: fix thread-safety of the solution. + constexpr size_t kInitTimeoutMs = 5000; + const int64_t initStartTime = k_uptime_get(); + // TODO: Handle multiple VIFs + const char * ifname = "wlan0"; + + while (!global || !(wpa_s = wpa_supplicant_get_iface(global, ifname))) + { + if (k_uptime_get() > initStartTime + kInitTimeoutMs) + { + ChipLogError(DeviceLayer, "wpa_supplicant is not initialized!"); + return CHIP_ERROR_INTERNAL; + } + + k_msleep(200); + } + + // TODO: consider moving these to ConnectivityManagerImpl to be prepared for handling multiple interfaces on a single device. + Inet::UDPEndPointImplSockets::SetJoinMulticastGroupHandler([](Inet::InterfaceId interfaceId, const Inet::IPAddress & address) { + const in6_addr addr = InetUtils::ToZephyrAddr(address); + net_if * iface = InetUtils::GetInterface(interfaceId); + VerifyOrReturnError(iface != nullptr, INET_ERROR_UNKNOWN_INTERFACE); + + net_if_mcast_addr * maddr = net_if_ipv6_maddr_add(iface, &addr); + + if (maddr && !net_if_ipv6_maddr_is_joined(maddr) && !net_ipv6_is_addr_mcast_link_all_nodes(&addr)) + { + net_if_ipv6_maddr_join(maddr); + } + + return CHIP_NO_ERROR; + }); + + Inet::UDPEndPointImplSockets::SetLeaveMulticastGroupHandler([](Inet::InterfaceId interfaceId, const Inet::IPAddress & address) { + const in6_addr addr = InetUtils::ToZephyrAddr(address); + net_if * iface = InetUtils::GetInterface(interfaceId); + VerifyOrReturnError(iface != nullptr, INET_ERROR_UNKNOWN_INTERFACE); + + if (!net_ipv6_is_addr_mcast_link_all_nodes(&addr) && !net_if_ipv6_maddr_rm(iface, &addr)) + { + return CHIP_ERROR_INVALID_ADDRESS; + } + + return CHIP_NO_ERROR; + }); + + ChipLogDetail(DeviceLayer, "wpa_supplicant has been initialized"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR WiFiManager::AddNetwork(const ByteSpan & ssid, const ByteSpan & credentials) +{ + ChipLogDetail(DeviceLayer, "Adding WiFi network"); + mpWpaNetwork = wpa_supplicant_add_network(wpa_s); + if (mpWpaNetwork) + { + static constexpr size_t kMaxSsidLen{ 32 }; + mpWpaNetwork->ssid = (u8 *) k_malloc(kMaxSsidLen); + + if (mpWpaNetwork->ssid) + { + memcpy(mpWpaNetwork->ssid, ssid.data(), ssid.size()); + mpWpaNetwork->ssid_len = ssid.size(); + mpWpaNetwork->key_mgmt = WPA_KEY_MGMT_NONE; + mpWpaNetwork->disabled = 1; + wpa_s->conf->filter_ssids = 1; + + return AddPsk(credentials); + } + } + + return CHIP_ERROR_INTERNAL; +} + +CHIP_ERROR WiFiManager::Scan(const ByteSpan & ssid, ScanCallback callback) +{ + const StationStatus stationStatus = GetStationStatus(); + VerifyOrReturnError(stationStatus != StationStatus::DISABLED && stationStatus != StationStatus::SCANNING && + stationStatus != StationStatus::CONNECTING, + CHIP_ERROR_INCORRECT_STATE); + + net_if * const iface = InetUtils::GetInterface(); + VerifyOrReturnError(iface != nullptr, CHIP_ERROR_INTERNAL); + + const device * dev = net_if_get_device(iface); + VerifyOrReturnError(dev != nullptr, CHIP_ERROR_INTERNAL); + + const net_wifi_mgmt_offload * ops = static_cast(dev->api); + VerifyOrReturnError(ops != nullptr, CHIP_ERROR_INTERNAL); + + mScanCallback = callback; + + // TODO: Use saner API once such exists. + // TODO: Take 'ssid' into account. + VerifyOrReturnError(ops->scan(dev, + [](net_if *, int status, wifi_scan_result * result) { + VerifyOrReturn(Instance().mScanCallback != nullptr); + NetworkCommissioning::WiFiScanResponse response = ToScanResponse(result); + Instance().mScanCallback(status, result != nullptr ? &response : nullptr); + }) == 0, + CHIP_ERROR_INTERNAL); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR WiFiManager::Connect(const ByteSpan & ssid, const ByteSpan & credentials, const ConnectionHandling & handling) +{ + ChipLogDetail(DeviceLayer, "Connecting to WiFi network"); + + mConnectionSuccessClbk = handling.mOnConnectionSuccess; + mConnectionFailedClbk = handling.mOnConnectionFailed; + mConnectionTimeoutMs = handling.mConnectionTimeoutMs; + + CHIP_ERROR err = AddNetwork(ssid, credentials); + if (CHIP_NO_ERROR == err) + { + EnableStation(true); + wpa_supplicant_select_network(wpa_s, mpWpaNetwork); + WaitForConnectionAsync(); + } + else + { + OnConnectionFailed(); + } + return err; +} + +void WiFiManager::OnConnectionSuccess() +{ + if (mConnectionSuccessClbk) + mConnectionSuccessClbk(); +} + +void WiFiManager::OnConnectionFailed() +{ + if (mConnectionFailedClbk) + mConnectionFailedClbk(); +} + +CHIP_ERROR WiFiManager::AddPsk(const ByteSpan & credentials) +{ + mpWpaNetwork->key_mgmt = WPA_KEY_MGMT_PSK; + str_clear_free(mpWpaNetwork->passphrase); + mpWpaNetwork->passphrase = dup_binstr(credentials.data(), credentials.size()); + + if (mpWpaNetwork->passphrase) + { + wpa_config_update_psk(mpWpaNetwork); + return CHIP_NO_ERROR; + } + + return CHIP_ERROR_INTERNAL; +} + +WiFiManager::StationStatus WiFiManager::GetStationStatus() const +{ + if (wpa_s) + { + return StatusFromWpaStatus(wpa_s->wpa_state); + } + else + { + ChipLogError(DeviceLayer, "wpa_supplicant is not initialized!"); + return StationStatus::NONE; + } +} + +WiFiManager::StationStatus WiFiManager::StatusFromWpaStatus(const wpa_states & status) +{ + ChipLogDetail(DeviceLayer, "WPA internal status: %d", static_cast(status)); + return WiFiManager::sStatusMap[status]; +} + +CHIP_ERROR WiFiManager::EnableStation(bool enable) +{ + VerifyOrReturnError(nullptr != wpa_s && nullptr != mpWpaNetwork, CHIP_ERROR_INTERNAL); + if (enable) + { + wpa_supplicant_enable_network(wpa_s, mpWpaNetwork); + } + else + { + wpa_supplicant_disable_network(wpa_s, mpWpaNetwork); + } + + return CHIP_NO_ERROR; +} + +CHIP_ERROR WiFiManager::ClearStationProvisioningData() +{ + VerifyOrReturnError(nullptr != wpa_s && nullptr != mpWpaNetwork, CHIP_ERROR_INTERNAL); + wpa_supplicant_cancel_scan(wpa_s); + wpa_clear_keys(wpa_s, mpWpaNetwork->bssid); + str_clear_free(mpWpaNetwork->passphrase); + wpa_config_update_psk(mpWpaNetwork); + wpa_supplicant_set_state(wpa_s, WPA_INACTIVE); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR WiFiManager::DisconnectStation() +{ + VerifyOrReturnError(nullptr != wpa_s, CHIP_ERROR_INTERNAL); + wpa_supplicant_cancel_scan(wpa_s); + wpas_request_disconnection(wpa_s); + + return CHIP_NO_ERROR; +} + +void WiFiManager::WaitForConnectionAsync() +{ + chip::DeviceLayer::SystemLayer().StartTimer( + static_cast(1000), [](System::Layer *, void *) { Instance().PollTimerCallback(); }, nullptr); +} + +void WiFiManager::PollTimerCallback() +{ + const uint32_t kMaxRetriesNumber{ mConnectionTimeoutMs.count() / 1000 }; + static uint32_t retriesNumber{ 0 }; + + if (WiFiManager::StationStatus::FULLY_PROVISIONED == GetStationStatus()) + { + retriesNumber = 0; + OnConnectionSuccess(); + } + else + { + if (retriesNumber++ < kMaxRetriesNumber) + { + // wait more time + WaitForConnectionAsync(); + } + else + { + // connection timeout + retriesNumber = 0; + OnConnectionFailed(); + } + } +} + +CHIP_ERROR WiFiManager::GetWiFiInfo(WiFiInfo & info) const +{ + VerifyOrReturnError(nullptr != wpa_s, CHIP_ERROR_INTERNAL); + VerifyOrReturnError(nullptr != mpWpaNetwork, CHIP_ERROR_INTERNAL); + + static uint8_t sBssid[ETH_ALEN]; + if (WiFiManager::StationStatus::CONNECTED <= GetStationStatus()) + { + memcpy(sBssid, wpa_s->bssid, ETH_ALEN); + info.mBssId = ByteSpan(sBssid, ETH_ALEN); + info.mSecurityType = GetSecurityType(); + // TODO: this should reflect the real connection compliance + // i.e. the AP might support WiFi 5 only even though the station + // is WiFi 6 ready (so the connection is WiFi 5 effectively). + // For now just return what the station supports. + info.mWiFiVersion = EMBER_ZCL_WI_FI_VERSION_TYPE_802__11AX; + + wpa_signal_info signalInfo{}; + if (0 == wpa_drv_signal_poll(wpa_s, &signalInfo)) + { + info.mRssi = signalInfo.current_signal; // dBm + info.mChannel = FrequencyToChannel(signalInfo.frequency); + } + else + { + // this values should be nullable according to the Matter spec + info.mRssi = std::numeric_limits::min(); + info.mChannel = std::numeric_limits::min(); + } + + memcpy(info.mSsid, mpWpaNetwork->ssid, mpWpaNetwork->ssid_len); + info.mSsidLen = mpWpaNetwork->ssid_len; + + return CHIP_NO_ERROR; + } + + return CHIP_ERROR_INTERNAL; +} + +uint8_t WiFiManager::GetSecurityType() const +{ + VerifyOrReturnValue(nullptr != mpWpaNetwork, EMBER_ZCL_SECURITY_TYPE_UNSPECIFIED); + + if ((mpWpaNetwork->key_mgmt & WPA_KEY_MGMT_NONE) || !wpa_key_mgmt_wpa_any(mpWpaNetwork->key_mgmt)) + { + return EMBER_ZCL_SECURITY_TYPE_NONE; + } + else if (wpa_key_mgmt_wpa_psk_no_sae(mpWpaNetwork->key_mgmt)) + { + return (mpWpaNetwork->pairwise_cipher & (WPA_CIPHER_TKIP | WPA_CIPHER_CCMP)) ? EMBER_ZCL_SECURITY_TYPE_WPA2 + : EMBER_ZCL_SECURITY_TYPE_WPA3; + } + else if (wpa_key_mgmt_sae(mpWpaNetwork->key_mgmt)) + { + return EMBER_ZCL_SECURITY_TYPE_WPA3; + } + else + { + return EMBER_ZCL_SECURITY_TYPE_WEP; + } + + return EMBER_ZCL_SECURITY_TYPE_UNSPECIFIED; +} + +uint8_t WiFiManager::FrequencyToChannel(uint16_t freq) +{ + static constexpr uint16_t k24MinFreq{ 2401 }; + static constexpr uint16_t k24MaxFreq{ 2484 }; + static constexpr uint8_t k24FreqConstDiff{ 5 }; + + if (freq >= k24MinFreq && freq < k24MaxFreq) + { + return static_cast((freq - k24MinFreq) / k24FreqConstDiff + 1); + } + else if (freq == k24MaxFreq) + { + return 14; + } + else if (freq > k24MaxFreq) + { + // assume we are in 5GH band + return sFreqChannelMap[freq]; + } + return 0; +} + +CHIP_ERROR WiFiManager::GetNetworkStatistics(NetworkStatistics & stats) const +{ + // TODO: below will not work (result will be all zeros) until + // the get_stats handler is implemented in WiFi driver + net_stats_eth data{}; + net_mgmt(NET_REQUEST_STATS_GET_ETHERNET, InetUtils::GetInterface(), &data, sizeof(data)); + + stats.mPacketMulticastRxCount = data.multicast.rx; + stats.mPacketMulticastTxCount = data.multicast.tx; + stats.mPacketUnicastRxCount = data.pkts.rx - data.multicast.rx - data.broadcast.rx; + stats.mPacketUnicastTxCount = data.pkts.tx - data.multicast.tx - data.broadcast.tx; + stats.mOverruns = 0; // TODO: clarify if this can be queried from mgmt API (e.g. data.tx_dropped) + + return CHIP_NO_ERROR; +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nrfconnect/wifi/WiFiManager.h b/src/platform/nrfconnect/wifi/WiFiManager.h new file mode 100644 index 00000000000000..b068cd99705eef --- /dev/null +++ b/src/platform/nrfconnect/wifi/WiFiManager.h @@ -0,0 +1,171 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Provides the wrapper for nRF wpa_supplicant API + */ + +#pragma once + +#include +#include +#include +#include + +#include + +extern "C" { +#include +#include +} + +struct net_if; +struct wpa_ssid; +using WpaNetwork = struct wpa_ssid; + +namespace chip { +namespace DeviceLayer { + +// emulation of dictionary - might be moved to utils +template +class Map +{ + struct Pair + { + T1 key; + T2 value; + }; + +public: + Map(const Pair (&list)[N]) + { + int idx{ 0 }; + for (const auto & pair : list) + { + mMap[idx++] = pair; + } + } + + T2 operator[](const T1 & key) const + { + for (const auto & it : mMap) + { + if (key == it.key) + return it.value; + } + + return T2{}; + } + + Map() = delete; + Map(const Map &) = delete; + Map(Map &&) = delete; + Map & operator=(const Map &) = delete; + Map & operator=(Map &&) = delete; + ~Map() = default; + +private: + Pair mMap[N]; +}; + +class WiFiManager +{ + using ConnectionCallback = void (*)(); + +public: + enum class StationStatus : uint8_t + { + NONE, + DISCONNECTED, + DISABLED, + SCANNING, + CONNECTING, + CONNECTED, + PROVISIONING, + FULLY_PROVISIONED + }; + + static WiFiManager & Instance() + { + static WiFiManager sInstance; + return sInstance; + } + + using ScanCallback = void (*)(int /* status */, NetworkCommissioning::WiFiScanResponse *); + + struct ConnectionHandling + { + ConnectionCallback mOnConnectionSuccess{}; + ConnectionCallback mOnConnectionFailed{}; + System::Clock::Timeout mConnectionTimeoutMs{}; + }; + + struct WiFiInfo + { + ByteSpan mBssId{}; + uint8_t mSecurityType{}; + uint8_t mWiFiVersion{}; + uint16_t mChannel{}; + int8_t mRssi{}; + uint8_t mSsid[DeviceLayer::Internal::kMaxWiFiSSIDLength]; + size_t mSsidLen{ 0 }; + }; + + struct NetworkStatistics + { + uint32_t mPacketMulticastRxCount{}; + uint32_t mPacketMulticastTxCount{}; + uint32_t mPacketUnicastRxCount{}; + uint32_t mPacketUnicastTxCount{}; + uint32_t mOverruns{}; + }; + + CHIP_ERROR Init(); + CHIP_ERROR Scan(const ByteSpan & ssid, ScanCallback callback); + CHIP_ERROR Connect(const ByteSpan & ssid, const ByteSpan & credentials, const ConnectionHandling & handling); + StationStatus GetStationStatus() const; + CHIP_ERROR ClearStationProvisioningData(); + CHIP_ERROR DisconnectStation(); + CHIP_ERROR GetWiFiInfo(WiFiInfo & info) const; + CHIP_ERROR GetNetworkStatistics(NetworkStatistics & stats) const; + +private: + CHIP_ERROR AddPsk(const ByteSpan & credentials); + CHIP_ERROR EnableStation(bool enable); + CHIP_ERROR AddNetwork(const ByteSpan & ssid, const ByteSpan & credentials); + void PollTimerCallback(); + void WaitForConnectionAsync(); + void OnConnectionSuccess(); + void OnConnectionFailed(); + uint8_t GetSecurityType() const; + + WpaNetwork * mpWpaNetwork{ nullptr }; + ConnectionCallback mConnectionSuccessClbk; + ConnectionCallback mConnectionFailedClbk; + System::Clock::Timeout mConnectionTimeoutMs; + ScanCallback mScanCallback{ nullptr }; + + static uint8_t FrequencyToChannel(uint16_t freq); + static StationStatus StatusFromWpaStatus(const wpa_states & status); + + static const Map sStatusMap; + static const Map sFreqChannelMap; +}; + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/telink/BUILD.gn b/src/platform/telink/BUILD.gn index b13a9d185ee8dd..1a4c90395dbe7c 100644 --- a/src/platform/telink/BUILD.gn +++ b/src/platform/telink/BUILD.gn @@ -26,6 +26,7 @@ static_library("telink") { "../Zephyr/ConfigurationManagerImpl.cpp", "../Zephyr/DiagnosticDataProviderImpl.cpp", "../Zephyr/DiagnosticDataProviderImpl.h", + "../Zephyr/DiagnosticDataProviderImplGetter.cpp", "../Zephyr/KeyValueStoreManagerImpl.cpp", "../Zephyr/Logging.cpp", "../Zephyr/PlatformManagerImpl.cpp", From b568009a15b4b9cd262c47b2e5087df57829ef47 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Thu, 17 Nov 2022 11:16:47 -0800 Subject: [PATCH 8/8] [linux]: Use LocationCapability if GetRegulatoryLocation fail (#23602) * [linux]: Use LocationCapability if GetRegulatoryLocation fail * Address the review comment --- src/platform/Linux/ConfigurationManagerImpl.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/platform/Linux/ConfigurationManagerImpl.cpp b/src/platform/Linux/ConfigurationManagerImpl.cpp index 2f603f1f3ba31e..afcd6c68bd309f 100644 --- a/src/platform/Linux/ConfigurationManagerImpl.cpp +++ b/src/platform/Linux/ConfigurationManagerImpl.cpp @@ -369,17 +369,23 @@ CHIP_ERROR ConfigurationManagerImpl::StoreBootReason(uint32_t bootReason) CHIP_ERROR ConfigurationManagerImpl::GetRegulatoryLocation(uint8_t & location) { - uint32_t value = 0; + uint32_t value; - CHIP_ERROR err = ReadConfigValue(PosixConfig::kConfigKey_RegulatoryLocation, value); + if (CHIP_NO_ERROR != ReadConfigValue(PosixConfig::kConfigKey_RegulatoryLocation, value)) + { + ReturnErrorOnFailure(GetLocationCapability(location)); - if (err == CHIP_NO_ERROR) + if (CHIP_NO_ERROR != StoreRegulatoryLocation(location)) + { + ChipLogError(DeviceLayer, "Failed to store RegulatoryLocation"); + } + } + else { - VerifyOrReturnError(value <= UINT8_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); location = static_cast(value); } - return err; + return CHIP_NO_ERROR; } CHIP_ERROR ConfigurationManagerImpl::GetLocationCapability(uint8_t & location)