From efc210964953a27ad5089225370f7fd3b3df9774 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 14 Jun 2022 09:29:21 -0400 Subject: [PATCH 01/53] Enable "Application" read test. (#19543) This works now that we run MC tests against tv-app. Fixes https://github.com/project-chip/connectedhomeip/issues/18103 Fixes https://github.com/project-chip/connectedhomeip/issues/14645 --- src/app/tests/suites/certification/Test_TC_MC_9_1.yaml | 2 -- zzz_generated/chip-tool/zap-generated/test/Commands.h | 1 - .../darwin-framework-tool/zap-generated/test/Commands.h | 4 ---- 3 files changed, 7 deletions(-) diff --git a/src/app/tests/suites/certification/Test_TC_MC_9_1.yaml b/src/app/tests/suites/certification/Test_TC_MC_9_1.yaml index 85f3f9e09684fd..cdd224c9d7744b 100644 --- a/src/app/tests/suites/certification/Test_TC_MC_9_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_MC_9_1.yaml @@ -70,9 +70,7 @@ tests: constraints: type: uint16 - #Issue 18103 - label: "Reads the Application attribute" - PICS: PICS_SKIP_SAMPLE_APP command: "readAttribute" attribute: "Application" response: diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index f6da56d8b6a647..6b404f77b111ba 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -20894,7 +20894,6 @@ class Test_TC_MC_9_1Suite : public TestCommand } case 6: { LogStep(6, "Reads the Application attribute"); - VerifyOrDo(!ShouldSkip("PICS_SKIP_SAMPLE_APP"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); return ReadAttribute(kIdentityAlpha, GetEndpoint(3), ApplicationBasic::Id, ApplicationBasic::Attributes::Application::Id, true, chip::NullOptional); } diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index 307c3f6f9a69c0..3c80c562841d5b 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -34152,10 +34152,6 @@ class Test_TC_MC_9_1 : public TestCommandBridge { break; case 6: ChipLogProgress(chipTool, " ***** Test Step 6 : Reads the Application attribute\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } err = TestReadsTheApplicationAttribute_6(); break; case 7: From 7690b965074854034d19d759223f039b1cfb8d12 Mon Sep 17 00:00:00 2001 From: amitnj <74272437+amitnj@users.noreply.github.com> Date: Tue, 14 Jun 2022 06:56:11 -0700 Subject: [PATCH 02/53] Enable command passing from clients to content apps (#19506) --- .../tv/app/api/MatterIntentConstants.java | 3 + .../content-app/src/main/AndroidManifest.xml | 2 +- .../receiver/MatterCommandReceiver.java | 15 ++- .../src/main/res/raw/static_matter_clusters | 14 ++- .../platform-app/src/main/AndroidManifest.xml | 1 - .../ContentAppEndpointManagerImpl.java | 5 +- .../service/ContentAppAgentService.java | 33 ++++--- .../tv/server/service/MatterServant.java | 2 +- .../tv/server/service/ResponseRegistry.java | 58 ++++++++++++ examples/tv-app/android/BUILD.gn | 2 +- examples/tv-app/android/java/AppImpl.cpp | 42 ++++++--- examples/tv-app/android/java/AppImpl.h | 14 +-- .../java/ContentAppCommandDelegate.cpp | 93 +++++++++++++++++++ .../android/java/ContentAppCommandDelegate.h | 34 +++++-- examples/tv-app/android/java/TVApp-JNI.cpp | 4 +- .../chip/tvapp/ContentAppEndpointManager.java | 2 +- .../tvapp/ContentAppEndpointManagerStub.java | 15 --- .../java/src/com/tcl/chip/tvapp/TvApp.java | 2 +- 18 files changed, 270 insertions(+), 71 deletions(-) create mode 100644 examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/ResponseRegistry.java delete mode 100644 examples/tv-app/android/java/src/com/tcl/chip/tvapp/ContentAppEndpointManagerStub.java diff --git a/examples/tv-app/android/App/common-api/src/main/java/com/matter/tv/app/api/MatterIntentConstants.java b/examples/tv-app/android/App/common-api/src/main/java/com/matter/tv/app/api/MatterIntentConstants.java index 4ee15e4a84c496..d5e95061b6f6c5 100644 --- a/examples/tv-app/android/App/common-api/src/main/java/com/matter/tv/app/api/MatterIntentConstants.java +++ b/examples/tv-app/android/App/common-api/src/main/java/com/matter/tv/app/api/MatterIntentConstants.java @@ -17,4 +17,7 @@ public class MatterIntentConstants { public static final String EXTRA_DIRECTIVE_RESPONSE_PENDING_INTENT = "EXTRA_DIRECTIVE_RESPONSE_PENDING_INTENT"; + + public static final String EXTRA_COMMAND_ID = "EXTRA_COMMAND_ID"; + public static final String EXTRA_CLUSTER_ID = "EXTRA_CLUSTER_ID"; } diff --git a/examples/tv-app/android/App/content-app/src/main/AndroidManifest.xml b/examples/tv-app/android/App/content-app/src/main/AndroidManifest.xml index 9ba74639750d1d..e9fa3b028f6f58 100644 --- a/examples/tv-app/android/App/content-app/src/main/AndroidManifest.xml +++ b/examples/tv-app/android/App/content-app/src/main/AndroidManifest.xml @@ -18,7 +18,7 @@ android:theme="@style/Theme.ContentApp"> - + - diff --git a/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/handlers/ContentAppEndpointManagerImpl.java b/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/handlers/ContentAppEndpointManagerImpl.java index 035e7cd84e8c44..56575545883a32 100644 --- a/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/handlers/ContentAppEndpointManagerImpl.java +++ b/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/handlers/ContentAppEndpointManagerImpl.java @@ -16,14 +16,15 @@ public ContentAppEndpointManagerImpl(Context context) { this.context = context; } - public String sendCommand(int endpointId, String commandPayload) { + public String sendCommand(int endpointId, int clusterId, int commandId, String commandPayload) { Log.d(TAG, "Received a command for endpointId " + endpointId + ". Message " + commandPayload); for (ContentApp app : ContentAppDiscoveryService.getReceiverInstance().getDiscoveredContentApps().values()) { if (app.getEndpointId() == endpointId) { Log.d( TAG, "Sending a command for endpointId " + endpointId + ". Message " + commandPayload); - ContentAppAgentService.sendCommand(context, app.getAppName(), commandPayload); + return ContentAppAgentService.sendCommand( + context, app.getAppName(), clusterId, commandId, commandPayload); } } return "Success"; diff --git a/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/ContentAppAgentService.java b/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/ContentAppAgentService.java index b1799990f99575..ccc72e4a9221b2 100644 --- a/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/ContentAppAgentService.java +++ b/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/ContentAppAgentService.java @@ -11,6 +11,7 @@ import androidx.annotation.Nullable; import com.matter.tv.app.api.IMatterAppAgent; import com.matter.tv.app.api.MatterIntentConstants; +import java.util.concurrent.TimeUnit; public class ContentAppAgentService extends Service { @@ -20,6 +21,8 @@ public class ContentAppAgentService extends Service { public static final String EXTRA_RESPONSE_RECEIVING_PACKAGE = "EXTRA_RESPONSE_RECEIVING_PACKAGE"; public static final String EXTRA_RESPONSE_ID = "EXTRA_RESPONSE_ID"; + private static ResponseRegistry responseRegistry = new ResponseRegistry(); + private final IBinder appAgentBinder = new IMatterAppAgent.Stub() { @Override @@ -51,23 +54,34 @@ public IBinder onBind(final Intent intent) { return null; } - public static void sendCommand(Context context, String packageName, String payload) { + public static String sendCommand( + Context context, String packageName, int clusterId, int commandId, String payload) { Intent in = new Intent(MatterIntentConstants.ACTION_MATTER_COMMAND); Bundle extras = new Bundle(); extras.putByteArray(MatterIntentConstants.EXTRA_COMMAND_PAYLOAD, payload.getBytes()); + extras.putInt(MatterIntentConstants.EXTRA_COMMAND_ID, commandId); + extras.putInt(MatterIntentConstants.EXTRA_CLUSTER_ID, clusterId); in.putExtras(extras); in.setPackage(packageName); int flags = Intent.FLAG_INCLUDE_STOPPED_PACKAGES; flags |= Intent.FLAG_RECEIVER_FOREGROUND; in.setFlags(flags); + int messageId = responseRegistry.getNextMessageCounter(); in.putExtra( MatterIntentConstants.EXTRA_DIRECTIVE_RESPONSE_PENDING_INTENT, - getPendingIntentForResponse(context, packageName, "0")); + getPendingIntentForResponse(context, packageName, messageId)); context.sendBroadcast(in); + responseRegistry.waitForMessage(messageId, 10, TimeUnit.SECONDS); + String response = responseRegistry.readAndRemoveResponse(messageId); + if (response == null) { + response = ""; + } + Log.d(TAG, "Response " + response + " being returned for message " + messageId); + return response; } private static PendingIntent getPendingIntentForResponse( - final Context context, final String targetPackage, final String responseId) { + final Context context, final String targetPackage, final int responseId) { Intent ackBackIntent = new Intent(ACTION_MATTER_RESPONSE); ackBackIntent.setClass(context, ContentAppAgentService.class); ackBackIntent.putExtra(EXTRA_RESPONSE_RECEIVING_PACKAGE, targetPackage); @@ -78,16 +92,13 @@ private static PendingIntent getPendingIntentForResponse( @Override public int onStartCommand(final Intent intent, final int flags, final int startId) { - Log.d(TAG, "onStartCommand"); - if (intent != null && ACTION_MATTER_RESPONSE.equals(intent.getAction())) { - Log.d( - TAG, - "Command response " - + new String(intent.getByteArrayExtra(MatterIntentConstants.EXTRA_RESPONSE_PAYLOAD))); - // Send the response back to the client. + String response = + new String(intent.getByteArrayExtra(MatterIntentConstants.EXTRA_RESPONSE_PAYLOAD)); + int messageId = intent.getIntExtra(EXTRA_RESPONSE_ID, Integer.MAX_VALUE); + Log.d(TAG, "Response " + response + " received for message " + messageId); + responseRegistry.receivedMessageResponse(messageId, response); } - return START_NOT_STICKY; } } diff --git a/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/MatterServant.java b/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/MatterServant.java index e248a4bcc300f6..bd11cb5c525d8f 100644 --- a/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/MatterServant.java +++ b/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/MatterServant.java @@ -145,7 +145,7 @@ public void onCommissioningComplete() { chipAppServer = new ChipAppServer(); chipAppServer.startApp(); - mTvApp.postServerInit(); + mTvApp.postServerInit(new ContentAppEndpointManagerImpl(context)); } public void restart() { diff --git a/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/ResponseRegistry.java b/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/ResponseRegistry.java new file mode 100644 index 00000000000000..9c1ebc0c0b6031 --- /dev/null +++ b/examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/ResponseRegistry.java @@ -0,0 +1,58 @@ +package com.matter.tv.server.service; + +import android.util.Log; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +public class ResponseRegistry { + + private static final String TAG = "ResponseRegistry"; + + private AtomicInteger messageCounter = new AtomicInteger(); + + private Map responses = new ConcurrentHashMap<>(); + + private Map latches = new ConcurrentHashMap<>(); + + public int getNextMessageCounter() { + int counter = messageCounter.incrementAndGet(); + // MAX_VALUE used for error scenarios + if (counter == Integer.MAX_VALUE) { + counter = messageCounter.incrementAndGet(); + } + latches.put(counter, new CountDownLatch(1)); + return counter; + } + + public void waitForMessage(int counter, long timeout, TimeUnit unit) { + CountDownLatch latch = latches.get(counter); + if (latch == null) { + return; + } + try { + if (!latch.await(timeout, unit)) { + Log.i(TAG, "Timed out while waiting for response for message " + counter); + } + } catch (InterruptedException e) { + Log.i(TAG, "Interrupted while waiting for response for message " + counter); + } + } + + public void receivedMessageResponse(int counter, String response) { + CountDownLatch latch = latches.remove(counter); + if (latch == null) { + // no point adding response to memory if no one is going to read it. + return; + } + responses.put(counter, response); + latch.countDown(); + } + + public String readAndRemoveResponse(int counter) { + // caller should manage null values + return responses.remove(counter); + } +} diff --git a/examples/tv-app/android/BUILD.gn b/examples/tv-app/android/BUILD.gn index b227f97fe47101..e478c946d3b9d7 100644 --- a/examples/tv-app/android/BUILD.gn +++ b/examples/tv-app/android/BUILD.gn @@ -78,6 +78,7 @@ shared_library("jni") { "${chip_root}/examples/tv-app/tv-common", "${chip_root}/src/app/server/java:jni", "${chip_root}/src/lib", + "${chip_root}/src/lib/support/jsontlv", "${chip_root}/third_party/inipp", ] @@ -108,7 +109,6 @@ android_library("java") { "java/src/com/tcl/chip/tvapp/ChannelManagerStub.java", "java/src/com/tcl/chip/tvapp/Clusters.java", "java/src/com/tcl/chip/tvapp/ContentAppEndpointManager.java", - "java/src/com/tcl/chip/tvapp/ContentAppEndpointManagerStub.java", "java/src/com/tcl/chip/tvapp/ContentLaunchBrandingInformation.java", "java/src/com/tcl/chip/tvapp/ContentLaunchManager.java", "java/src/com/tcl/chip/tvapp/ContentLaunchManagerStub.java", diff --git a/examples/tv-app/android/java/AppImpl.cpp b/examples/tv-app/android/java/AppImpl.cpp index 61f770a4c09383..a0564d2efc3832 100644 --- a/examples/tv-app/android/java/AppImpl.cpp +++ b/examples/tv-app/android/java/AppImpl.cpp @@ -21,11 +21,13 @@ #include "AppImpl.h" +#include "ContentAppCommandDelegate.h" #include #include #include #include #include +#include #include #include #include @@ -328,12 +330,12 @@ ContentApp * ContentAppFactoryImpl::LoadContentApp(const CatalogVendorApp & vend { auto & app = mContentApps.at(i); - ChipLogProgress(DeviceLayer, " Looking next=%s ", app.GetApplicationBasicDelegate()->GetCatalogVendorApp()->applicationId); - if (app.GetApplicationBasicDelegate()->GetCatalogVendorApp()->Matches(vendorApp)) + ChipLogProgress(DeviceLayer, " Looking next=%s ", app->GetApplicationBasicDelegate()->GetCatalogVendorApp()->applicationId); + if (app->GetApplicationBasicDelegate()->GetCatalogVendorApp()->Matches(vendorApp)) { - ContentAppPlatform::GetInstance().AddContentApp(&app, &contentAppEndpoint, Span(gDataVersions[i]), + ContentAppPlatform::GetInstance().AddContentApp(app, &contentAppEndpoint, Span(gDataVersions[i]), Span(gContentAppDeviceType)); - return &app; + return app; } } ChipLogProgress(DeviceLayer, "LoadContentAppByAppId NOT FOUND catalogVendorId=%d applicationId=%s ", vendorApp.catalogVendorId, @@ -342,13 +344,13 @@ ContentApp * ContentAppFactoryImpl::LoadContentApp(const CatalogVendorApp & vend return nullptr; } -EndpointId ContentAppFactoryImpl::AddContentApp(ContentAppImpl & app) +EndpointId ContentAppFactoryImpl::AddContentApp(ContentAppImpl * app) { DataVersion dataVersionBuf[ArraySize(contentAppClusters)]; - EndpointId epId = ContentAppPlatform::GetInstance().AddContentApp(&app, &contentAppEndpoint, Span(dataVersionBuf), + EndpointId epId = ContentAppPlatform::GetInstance().AddContentApp(app, &contentAppEndpoint, Span(dataVersionBuf), Span(gContentAppDeviceType)); ChipLogProgress(DeviceLayer, "ContentAppFactoryImpl AddContentApp endpoint returned %d. Endpoint set %d", epId, - app.GetEndpointId()); + app->GetEndpointId()); mContentApps.push_back(app); return epId; } @@ -380,9 +382,9 @@ void ContentAppFactoryImpl::SendTestMessage(EndpointId epId, const char * messag ChipLogProgress(DeviceLayer, "ContentAppFactoryImpl SendTestMessage called with message %s & endpointId %d", message, epId); for (size_t i = 0; i < mContentApps.size(); ++i) { - ContentAppImpl app = mContentApps.at(i); - ChipLogProgress(DeviceLayer, "ContentAppFactoryImpl checking app with endpointId %d", app.ContentApp::GetEndpointId()); - if (app.GetEndpointId() == epId) + ContentAppImpl * app = mContentApps.at(i); + ChipLogProgress(DeviceLayer, "ContentAppFactoryImpl checking app with endpointId %d", app->GetEndpointId()); + if (app->GetEndpointId() == epId) { ChipLogProgress(DeviceLayer, "ContentAppFactoryImpl SendTestMessage endpoint found"); app::ConcreteCommandPath commandPath(epId, app::Clusters::ContentLauncher::Id, @@ -391,8 +393,8 @@ void ContentAppFactoryImpl::SendTestMessage(EndpointId epId, const char * messag app::CommandHandler commandHandler(&callback); CommandResponseHelper helper(&commandHandler, commandPath); chip::app::Clusters::ContentLauncher::Structs::BrandingInformation::Type branding; - app.GetContentLauncherDelegate()->HandleLaunchUrl(helper, CharSpan::fromCharString(message), - CharSpan::fromCharString("Temp Display"), branding); + app->GetContentLauncherDelegate()->HandleLaunchUrl(helper, CharSpan::fromCharString(message), + CharSpan::fromCharString("Temp Display"), branding); } } } @@ -402,11 +404,21 @@ void ContentAppFactoryImpl::SendTestMessage(EndpointId epId, const char * messag #endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED -CHIP_ERROR InitVideoPlayerPlatform(JNIMyUserPrompter * userPrompter) +CHIP_ERROR InitVideoPlayerPlatform(JNIMyUserPrompter * userPrompter, jobject contentAppEndpointManager) { #if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED ContentAppPlatform::GetInstance().SetupAppPlatform(); ContentAppPlatform::GetInstance().SetContentAppFactory(&gFactory); + + ChipLogProgress(AppServer, "Starting registration of command handler delegates"); + for (size_t i = 0; i < ArraySize(contentAppClusters); i++) + { + ContentAppCommandDelegate * delegate = + new ContentAppCommandDelegate(contentAppEndpointManager, contentAppClusters[i].clusterId); + chip::app::InteractionModelEngine::GetInstance()->RegisterCommandHandler(delegate); + ChipLogProgress(AppServer, "Registered command handler delegate for cluster %d", contentAppClusters[i].clusterId); + } + #endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED #if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE @@ -443,8 +455,8 @@ EndpointId AddContentApp(const char * szVendorName, uint16_t vendorId, const cha const char * szApplicationVersion, jobject manager) { #if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED - ContentAppImpl app = - ContentAppImpl(szVendorName, vendorId, szApplicationName, productId, szApplicationVersion, "34567890", manager); + ContentAppImpl * app = + new ContentAppImpl(szVendorName, vendorId, szApplicationName, productId, szApplicationVersion, "20202021", manager); ChipLogProgress(DeviceLayer, "AppImpl: AddContentApp vendorId=%d applicationName=%s ", vendorId, szApplicationName); return gFactory.AddContentApp(app); #endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED diff --git a/examples/tv-app/android/java/AppImpl.h b/examples/tv-app/android/java/AppImpl.h index bcd31ccd061fb9..98a6d61798bc07 100644 --- a/examples/tv-app/android/java/AppImpl.h +++ b/examples/tv-app/android/java/AppImpl.h @@ -52,7 +52,7 @@ #include #include -CHIP_ERROR InitVideoPlayerPlatform(JNIMyUserPrompter * userPrompter); +CHIP_ERROR InitVideoPlayerPlatform(JNIMyUserPrompter * userPrompter, jobject contentAppEndpointManager); CHIP_ERROR PreServerInit(); EndpointId AddContentApp(const char * szVendorName, uint16_t vendorId, const char * szApplicationName, uint16_t productId, const char * szApplicationVersion, jobject manager); @@ -131,7 +131,7 @@ class DLL_EXPORT ContentAppFactoryImpl : public ContentAppFactory // Lookup ContentApp for this catalog id / app id and load it ContentApp * LoadContentApp(const CatalogVendorApp & vendorApp) override; - EndpointId AddContentApp(ContentAppImpl & app); + EndpointId AddContentApp(ContentAppImpl * app); void SendTestMessage(EndpointId epID, const char * message); @@ -143,11 +143,11 @@ class DLL_EXPORT ContentAppFactoryImpl : public ContentAppFactory CHIP_ERROR ConvertToPlatformCatalogVendorApp(const CatalogVendorApp & sourceApp, CatalogVendorApp * destinationApp) override; protected: - std::vector mContentApps{ - ContentAppImpl("Vendor1", 1, "exampleid", 11, "Version1", "34567890", nullptr), - ContentAppImpl("Vendor2", 65521, "exampleString", 32768, "Version2", "20202021", nullptr), - ContentAppImpl("Vendor3", 9050, "App3", 22, "Version3", "20202021", nullptr), - ContentAppImpl("TestSuiteVendor", 1111, "applicationId", 22, "v2", "20202021", nullptr) + std::vector mContentApps{ + new ContentAppImpl("Vendor1", 1, "exampleid", 11, "Version1", "20202021", nullptr), + new ContentAppImpl("Vendor2", 65520, "exampleString", 32768, "Version2", "20202021", nullptr), + new ContentAppImpl("Vendor3", 9050, "App3", 22, "Version3", "20202021", nullptr), + new ContentAppImpl("TestSuiteVendor", 1111, "applicationId", 22, "v2", "20202021", nullptr) }; }; diff --git a/examples/tv-app/android/java/ContentAppCommandDelegate.cpp b/examples/tv-app/android/java/ContentAppCommandDelegate.cpp index a4d23881b6be3f..1cc25f57ee6098 100644 --- a/examples/tv-app/android/java/ContentAppCommandDelegate.cpp +++ b/examples/tv-app/android/java/ContentAppCommandDelegate.cpp @@ -22,14 +22,21 @@ #include "ContentAppCommandDelegate.h" +#include +#include #include #include #include #include +#include +#include namespace chip { namespace AppPlatform { +using CommandHandlerInterface = chip::app::CommandHandlerInterface; +using LaunchResponseType = chip::app::Clusters::ContentLauncher::Commands::LaunchResponse::Type; + const char * ContentAppCommandDelegate::sendCommand(chip::EndpointId epID, std::string commandPayload) { // to support the hardcoded sample apps. @@ -55,5 +62,91 @@ const char * ContentAppCommandDelegate::sendCommand(chip::EndpointId epID, std:: return ret; } +void ContentAppCommandDelegate::InvokeCommand(CommandHandlerInterface::HandlerContext & handlerContext) +{ + if (handlerContext.mRequestPath.mEndpointId >= FIXED_ENDPOINT_COUNT) + { + TLV::TLVReader readerForJson; + readerForJson.Init(handlerContext.mPayload); + + CHIP_ERROR err = CHIP_NO_ERROR; + Json::Value json; + err = TlvToJson(readerForJson, json); + if (err != CHIP_NO_ERROR) + { + // TODO : Add an interface to let the apps know a message came but there was a serialization error. + handlerContext.SetCommandNotHandled(); + return; + } + + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + UtfString jsonString(env, JsonToString(json).c_str()); + + ChipLogProgress(Zcl, "ContentAppCommandDelegate::InvokeCommand send command being called with payload %s", + JsonToString(json).c_str()); + + jstring resp = (jstring) env->CallObjectMethod( + mContentAppEndpointManager, mSendCommandMethod, static_cast(handlerContext.mRequestPath.mEndpointId), + static_cast(handlerContext.mRequestPath.mClusterId), static_cast(handlerContext.mRequestPath.mCommandId), + jsonString.jniValue()); + if (env->ExceptionCheck()) + { + ChipLogError(Zcl, "Java exception in ContentAppCommandDelegate::sendCommand"); + env->ExceptionDescribe(); + env->ExceptionClear(); + FormatResponseData(handlerContext, "{\"value\":{}}"); + return; + } + const char * respStr = env->GetStringUTFChars(resp, 0); + ChipLogProgress(Zcl, "ContentAppCommandDelegate::InvokeCommand got response %s", respStr); + FormatResponseData(handlerContext, respStr); + } + else + { + handlerContext.SetCommandNotHandled(); + } +} + +void ContentAppCommandDelegate::FormatResponseData(CommandHandlerInterface::HandlerContext & handlerContext, const char * response) +{ + Json::Reader reader; + Json::Value resJson; + reader.parse(response, resJson); + Json::Value value = resJson["value"]; + + switch (handlerContext.mRequestPath.mClusterId) + { + case app::Clusters::ContentLauncher::Id: { + LaunchResponseType launchResponse; + if (value["0"].empty()) + { + launchResponse.status = chip::app::Clusters::ContentLauncher::ContentLaunchStatusEnum::kAuthFailed; + } + else + { + launchResponse.status = static_cast(value["0"].asInt()); + if (!value["1"].empty()) + { + launchResponse.data = chip::MakeOptional(CharSpan::fromCharString(value["1"].asCString())); + } + } + handlerContext.mCommandHandler.AddResponseData(handlerContext.mRequestPath, launchResponse); + handlerContext.SetCommandHandled(); + break; + } + + // case app::Clusters::TargetNavigator::Id: + // break; + + // case app::Clusters::MediaPlayback::Id: + // break; + + // case app::Clusters::AccountLogin::Id: + // break; + default: + handlerContext.SetCommandNotHandled(); + } +} + } // namespace AppPlatform } // namespace chip diff --git a/examples/tv-app/android/java/ContentAppCommandDelegate.h b/examples/tv-app/android/java/ContentAppCommandDelegate.h index 2d45906c51049b..908b2e4d1cc0e9 100644 --- a/examples/tv-app/android/java/ContentAppCommandDelegate.h +++ b/examples/tv-app/android/java/ContentAppCommandDelegate.h @@ -22,6 +22,8 @@ #pragma once +#include +#include #include #include #include @@ -29,10 +31,22 @@ namespace chip { namespace AppPlatform { -class ContentAppCommandDelegate +using CommandHandlerInterface = chip::app::CommandHandlerInterface; + +class ContentAppCommandDelegate : public CommandHandlerInterface { public: - ContentAppCommandDelegate(jobject manager) + ContentAppCommandDelegate(jobject manager, ClusterId aClusterId) : CommandHandlerInterface(Optional(), aClusterId) + { + if (manager == nullptr) + { + // To support the existing hardcoded sample apps. + return; + } + InitializeJNIObjects(manager); + }; + + ContentAppCommandDelegate(jobject manager) : CommandHandlerInterface(Optional(), app::Clusters::ContentLauncher::Id) { if (manager == nullptr) @@ -40,7 +54,16 @@ class ContentAppCommandDelegate // To support the existing hardcoded sample apps. return; } + InitializeJNIObjects(manager); + }; + + void InvokeCommand(CommandHandlerInterface::HandlerContext & handlerContext) override; + const char * sendCommand(chip::EndpointId epID, std::string commandPayload); + +private: + void InitializeJNIObjects(jobject manager) + { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Failed to GetEnvForCurrentThread for ContentAppEndpointManager")); @@ -53,17 +76,16 @@ class ContentAppCommandDelegate ChipLogError(Zcl, "Failed to get ContentAppEndpointManager Java class")); mSendCommandMethod = - env->GetMethodID(ContentAppEndpointManagerClass, "sendCommand", "(ILjava/lang/String;)Ljava/lang/String;"); + env->GetMethodID(ContentAppEndpointManagerClass, "sendCommand", "(IIILjava/lang/String;)Ljava/lang/String;"); if (mSendCommandMethod == nullptr) { ChipLogError(Zcl, "Failed to access ContentAppEndpointManager 'sendCommand' method"); env->ExceptionClear(); } - }; + } - const char * sendCommand(chip::EndpointId epID, std::string commandPayload); + void FormatResponseData(CommandHandlerInterface::HandlerContext & handlerContext, const char * response); -private: jobject mContentAppEndpointManager = nullptr; jmethodID mSendCommandMethod = nullptr; }; diff --git a/examples/tv-app/android/java/TVApp-JNI.cpp b/examples/tv-app/android/java/TVApp-JNI.cpp index 9043a66864ff47..455f1d9da19eab 100644 --- a/examples/tv-app/android/java/TVApp-JNI.cpp +++ b/examples/tv-app/android/java/TVApp-JNI.cpp @@ -157,12 +157,12 @@ JNI_METHOD(void, preServerInit)(JNIEnv *, jobject app) PreServerInit(); } -JNI_METHOD(void, postServerInit)(JNIEnv *, jobject app) +JNI_METHOD(void, postServerInit)(JNIEnv *, jobject app, jobject contentAppEndpointManager) { chip::DeviceLayer::StackLock lock; ChipLogProgress(Zcl, "TvAppJNI::postServerInit"); - InitVideoPlayerPlatform(userPrompter); + InitVideoPlayerPlatform(userPrompter, contentAppEndpointManager); } JNI_METHOD(void, setOnOffManager)(JNIEnv *, jobject, jint endpoint, jobject manager) diff --git a/examples/tv-app/android/java/src/com/tcl/chip/tvapp/ContentAppEndpointManager.java b/examples/tv-app/android/java/src/com/tcl/chip/tvapp/ContentAppEndpointManager.java index 09bf1f0a0f8b54..119ff8bd231f5f 100644 --- a/examples/tv-app/android/java/src/com/tcl/chip/tvapp/ContentAppEndpointManager.java +++ b/examples/tv-app/android/java/src/com/tcl/chip/tvapp/ContentAppEndpointManager.java @@ -2,5 +2,5 @@ public interface ContentAppEndpointManager { - public String sendCommand(int endpointId, String commandPayload); + public String sendCommand(int endpointId, int clusterId, int commandId, String commandPayload); } diff --git a/examples/tv-app/android/java/src/com/tcl/chip/tvapp/ContentAppEndpointManagerStub.java b/examples/tv-app/android/java/src/com/tcl/chip/tvapp/ContentAppEndpointManagerStub.java deleted file mode 100644 index 3de920ef95f938..00000000000000 --- a/examples/tv-app/android/java/src/com/tcl/chip/tvapp/ContentAppEndpointManagerStub.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.tcl.chip.tvapp; - -public class ContentAppEndpointManagerStub implements ContentAppEndpointManager { - - ContentAppEndpointManager delegate; - - public ContentAppEndpointManagerStub(ContentAppEndpointManager delegate) { - this.delegate = delegate; - } - - @Override - public String sendCommand(int endpointId, String commandPayload) { - return delegate.sendCommand(endpointId, commandPayload); - } -} diff --git a/examples/tv-app/android/java/src/com/tcl/chip/tvapp/TvApp.java b/examples/tv-app/android/java/src/com/tcl/chip/tvapp/TvApp.java index d79e760f18c05d..a7cf235ca46265 100644 --- a/examples/tv-app/android/java/src/com/tcl/chip/tvapp/TvApp.java +++ b/examples/tv-app/android/java/src/com/tcl/chip/tvapp/TvApp.java @@ -41,7 +41,7 @@ private void postClusterInit(int clusterId, int endpoint) { public native void preServerInit(); // called after Matter server is inited - public native void postServerInit(); + public native void postServerInit(ContentAppEndpointManager manager); public native void setKeypadInputManager(int endpoint, KeypadInputManager manager); From 3ffd066e0e438e397bc859b47cb2c75b38c0e3f2 Mon Sep 17 00:00:00 2001 From: Jandy Gou Date: Tue, 14 Jun 2022 22:02:05 +0800 Subject: [PATCH 03/53] make platform zephyr stand alone (#19504) --- build_overrides/zephyr.gni | 15 + config/zephyr/README.md | 10 + .../app/copy-flashbundle-firmware.cmake | 25 ++ config/zephyr/app/enable-gnu-std.cmake | 6 + config/zephyr/app/flashing.cmake | 55 ++++ config/zephyr/app/overlay-usb_support.conf | 24 ++ config/zephyr/chip-gn/.gn | 29 ++ config/zephyr/chip-gn/BUILD.gn | 40 +++ config/zephyr/chip-gn/args.gni | 27 ++ config/zephyr/chip-gn/toolchain/BUILD.gn | 33 +++ config/zephyr/chip-module/CMakeLists.txt | 257 ++++++++++++++++++ config/zephyr/chip-module/Kconfig | 17 ++ config/zephyr/chip-module/Kconfig.defaults | 225 +++++++++++++++ config/zephyr/chip-module/Kconfig.features | 68 +++++ .../chip-module/Kconfig.mcuboot.defaults | 89 ++++++ .../zephyr/chip-module/Kconfig.mcuboot.root | 21 ++ .../Kconfig.multiprotocol_rpmsg.defaults | 91 +++++++ .../Kconfig.multiprotocol_rpmsg.root | 21 ++ config/zephyr/chip-module/make_gn_args.py | 73 +++++ config/zephyr/chip-module/zephyr/module.yml | 22 ++ src/platform/BUILD.gn | 7 + src/platform/Zephyr/BUILD.gn | 79 ++++++ src/platform/Zephyr/BlePlatformConfig.h | 36 +++ .../Zephyr/CHIPDevicePlatformConfig.h | 132 +++++++++ src/platform/Zephyr/CHIPDevicePlatformEvent.h | 2 +- src/platform/Zephyr/CHIPPlatformConfig.h | 55 ++++ .../Zephyr/ConfigurationManagerImpl.h | 2 +- .../Zephyr/ConnectivityManagerImpl.cpp | 61 +++++ src/platform/Zephyr/ConnectivityManagerImpl.h | 103 +++++++ .../DeviceNetworkProvisioningDelegateImpl.cpp | 44 +++ .../DeviceNetworkProvisioningDelegateImpl.h | 43 +++ .../Zephyr/DiagnosticDataProviderImpl.cpp | 4 +- src/platform/Zephyr/InetPlatformConfig.h | 46 ++++ src/platform/Zephyr/SystemPlatformConfig.h | 58 ++++ src/platform/Zephyr/args.gni | 5 + src/platform/device.gni | 9 +- 36 files changed, 1828 insertions(+), 6 deletions(-) create mode 100644 build_overrides/zephyr.gni create mode 100644 config/zephyr/README.md create mode 100644 config/zephyr/app/copy-flashbundle-firmware.cmake create mode 100644 config/zephyr/app/enable-gnu-std.cmake create mode 100644 config/zephyr/app/flashing.cmake create mode 100644 config/zephyr/app/overlay-usb_support.conf create mode 100644 config/zephyr/chip-gn/.gn create mode 100644 config/zephyr/chip-gn/BUILD.gn create mode 100644 config/zephyr/chip-gn/args.gni create mode 100644 config/zephyr/chip-gn/toolchain/BUILD.gn create mode 100644 config/zephyr/chip-module/CMakeLists.txt create mode 100644 config/zephyr/chip-module/Kconfig create mode 100644 config/zephyr/chip-module/Kconfig.defaults create mode 100644 config/zephyr/chip-module/Kconfig.features create mode 100644 config/zephyr/chip-module/Kconfig.mcuboot.defaults create mode 100644 config/zephyr/chip-module/Kconfig.mcuboot.root create mode 100644 config/zephyr/chip-module/Kconfig.multiprotocol_rpmsg.defaults create mode 100644 config/zephyr/chip-module/Kconfig.multiprotocol_rpmsg.root create mode 100644 config/zephyr/chip-module/make_gn_args.py create mode 100644 config/zephyr/chip-module/zephyr/module.yml create mode 100644 src/platform/Zephyr/BUILD.gn create mode 100644 src/platform/Zephyr/BlePlatformConfig.h create mode 100644 src/platform/Zephyr/CHIPDevicePlatformConfig.h create mode 100644 src/platform/Zephyr/CHIPPlatformConfig.h create mode 100644 src/platform/Zephyr/ConnectivityManagerImpl.cpp create mode 100644 src/platform/Zephyr/ConnectivityManagerImpl.h create mode 100644 src/platform/Zephyr/DeviceNetworkProvisioningDelegateImpl.cpp create mode 100644 src/platform/Zephyr/DeviceNetworkProvisioningDelegateImpl.h create mode 100644 src/platform/Zephyr/InetPlatformConfig.h create mode 100644 src/platform/Zephyr/SystemPlatformConfig.h create mode 100644 src/platform/Zephyr/args.gni diff --git a/build_overrides/zephyr.gni b/build_overrides/zephyr.gni new file mode 100644 index 00000000000000..9ad63cf8d53544 --- /dev/null +++ b/build_overrides/zephyr.gni @@ -0,0 +1,15 @@ +# Copyright (c) 2021 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. + +# place holder diff --git a/config/zephyr/README.md b/config/zephyr/README.md new file mode 100644 index 00000000000000..bb780288a34606 --- /dev/null +++ b/config/zephyr/README.md @@ -0,0 +1,10 @@ +# Zephyr build and configuration files + +This directory contains build scripts and common configuration files used by +CHIP Zephyr applications. It is structured as follows: + +| File/Folder | Contents | +| ----------- | ----------------------------------------------------------------------------------------------------------------------------------- | +| chip-gn | GN project used to build selected CHIP libraries with the _Zephyr_ platform integration layer | +| chip-module | CMake wrapper for the GN project defined in `chip-gn` directory, and other components that allow one to use CHIP as a Zephyr module | +| app | Common and optional Kconfig configuration files that can be used in Zephyr applications | diff --git a/config/zephyr/app/copy-flashbundle-firmware.cmake b/config/zephyr/app/copy-flashbundle-firmware.cmake new file mode 100644 index 00000000000000..93464f7aceb837 --- /dev/null +++ b/config/zephyr/app/copy-flashbundle-firmware.cmake @@ -0,0 +1,25 @@ +# +# 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. +# + +# Copy the merged.hex file if it exists, otherwise copy zephyr.hex + +set(HEX_NAME merged.hex) + +if(EXISTS "zephyr/${HEX_NAME}") + configure_file("zephyr/${HEX_NAME}" "${FLASHBUNDLE_FIRMWARE}" COPYONLY) +else() + configure_file("zephyr/${KERNEL_HEX_NAME}" "${FLASHBUNDLE_FIRMWARE}" COPYONLY) +endif() diff --git a/config/zephyr/app/enable-gnu-std.cmake b/config/zephyr/app/enable-gnu-std.cmake new file mode 100644 index 00000000000000..5f31e1a5c62ab8 --- /dev/null +++ b/config/zephyr/app/enable-gnu-std.cmake @@ -0,0 +1,6 @@ +add_library(gnu17 INTERFACE) +target_compile_options(gnu17 + INTERFACE + $<$:-std=gnu++17> + -D_SYS__PTHREADTYPES_H_) +target_link_libraries(app PRIVATE gnu17) diff --git a/config/zephyr/app/flashing.cmake b/config/zephyr/app/flashing.cmake new file mode 100644 index 00000000000000..b70e166ff28cfe --- /dev/null +++ b/config/zephyr/app/flashing.cmake @@ -0,0 +1,55 @@ +# +# Copyright (c) 2021 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. +# + +# Adds rules to generate a flashing wrapper script for an nrfconnect firmware. + +set(FLASHBUNDLE_FLASHER_COMMON ${CMAKE_PROJECT_NAME}/firmware_utils.py) +set(FLASHBUNDLE_FLASHER_PLATFORM ${CMAKE_PROJECT_NAME}/nrfconnect_firmware_utils.py) +set(FLASHBUNDLE_FLASHER_WRAPPER ${CMAKE_PROJECT_NAME}/${CMAKE_PROJECT_NAME}.flash.py) +set(FLASHBUNDLE_FIRMWARE ${CMAKE_PROJECT_NAME}/${CMAKE_PROJECT_NAME}.hex) +set(FLASHBUNDLE_FILES ${FLASHBUNDLE_FLASHER_COMMON} ${FLASHBUNDLE_FLASHER_PLATFORM} ${FLASHBUNDLE_FLASHER_WRAPPER} ${FLASHBUNDLE_FIRMWARE}) + +get_filename_component(FLASHBUNDLE_FIRMWARE_BASENAME ${FLASHBUNDLE_FIRMWARE} NAME) + +list(JOIN FLASHBUNDLE_FILES "\n" FLASHBUNDLE_MANIFEST) + +file(GENERATE + OUTPUT ${CMAKE_PROJECT_NAME}.flashbundle.txt + CONTENT "${FLASHBUNDLE_MANIFEST}\n" + ) + +add_custom_command(OUTPUT "${FLASHBUNDLE_FLASHER_COMMON}" + COMMAND ${CMAKE_COMMAND} ARGS -E copy "${PROJECT_SOURCE_DIR}/third_party/connectedhomeip/scripts/flashing/firmware_utils.py" "${FLASHBUNDLE_FLASHER_COMMON}" + VERBATIM) + +add_custom_command(OUTPUT "${FLASHBUNDLE_FLASHER_PLATFORM}" + COMMAND ${CMAKE_COMMAND} ARGS -E copy "${PROJECT_SOURCE_DIR}/third_party/connectedhomeip/scripts/flashing/nrfconnect_firmware_utils.py" "${FLASHBUNDLE_FLASHER_PLATFORM}" + VERBATIM) + +add_custom_command(OUTPUT "${FLASHBUNDLE_FIRMWARE}" + DEPENDS zephyr/${KERNEL_HEX_NAME} + COMMAND ${CMAKE_COMMAND} ARGS -DFLASHBUNDLE_FIRMWARE=${FLASHBUNDLE_FIRMWARE} -DKERNEL_HEX_NAME=${KERNEL_HEX_NAME} -P "${CHIP_ROOT}/config/nrfconnect/app/copy-flashbundle-firmware.cmake" + VERBATIM) + +add_custom_command(OUTPUT "${CMAKE_PROJECT_NAME}/${CMAKE_PROJECT_NAME}.flash.py" + COMMAND ${python} + "${PROJECT_SOURCE_DIR}/third_party/connectedhomeip/scripts/flashing/gen_flashing_script.py" nrfconnect + --output "${FLASHBUNDLE_FLASHER_WRAPPER}" + --application "${FLASHBUNDLE_FIRMWARE_BASENAME}" + COMMENT "To flash ${FLASHBUNDLE_FIRMWARE_BASENAME} run ${FLASHBUNDLE_FLASHER_WRAPPER}" + VERBATIM) + +add_custom_target(flashing_script DEPENDS ${FLASHBUNDLE_FILES}) diff --git a/config/zephyr/app/overlay-usb_support.conf b/config/zephyr/app/overlay-usb_support.conf new file mode 100644 index 00000000000000..1b4a2d56fe8490 --- /dev/null +++ b/config/zephyr/app/overlay-usb_support.conf @@ -0,0 +1,24 @@ +# +# Copyright (c) 2020 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. +# + +CONFIG_GPIO=y + +CONFIG_USB=y +CONFIG_USB_DEVICE_STACK=y +CONFIG_USB_UART_CONSOLE=y + +CONFIG_UART_INTERRUPT_DRIVEN=y +CONFIG_UART_LINE_CTRL=y diff --git a/config/zephyr/chip-gn/.gn b/config/zephyr/chip-gn/.gn new file mode 100644 index 00000000000000..2024e95fed6079 --- /dev/null +++ b/config/zephyr/chip-gn/.gn @@ -0,0 +1,29 @@ +# Copyright (c) 2020 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. + +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") + +# The location of the build configuration file. +buildconfig = "${build_root}/config/BUILDCONFIG.gn" + +# CHIP uses angle bracket includes. +check_system_includes = true + +default_args = { + target_cpu = "" + target_os = "zephyr" + + import("${chip_root}/config/zephyr/chip-gn/args.gni") +} diff --git a/config/zephyr/chip-gn/BUILD.gn b/config/zephyr/chip-gn/BUILD.gn new file mode 100644 index 00000000000000..85288992c84812 --- /dev/null +++ b/config/zephyr/chip-gn/BUILD.gn @@ -0,0 +1,40 @@ +# Copyright (c) 2020 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. + +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/chip/tests.gni") + +assert(current_os == "zephyr") + +declare_args() { + chip_build_example_providers = false +} + +group("zephyr") { + deps = [ "${chip_root}/src/lib" ] + + if (chip_build_tests) { + deps += [ "${chip_root}/src:tests" ] + } + + if (chip_build_example_providers) { + deps += [ "${chip_root}/examples/providers:device_info_provider" ] + } +} + +group("default") { + deps = [ ":zephyr" ] +} diff --git a/config/zephyr/chip-gn/args.gni b/config/zephyr/chip-gn/args.gni new file mode 100644 index 00000000000000..e5d5aedf5bc17d --- /dev/null +++ b/config/zephyr/chip-gn/args.gni @@ -0,0 +1,27 @@ +# Copyright (c) 2020 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. + +import("//build_overrides/chip.gni") + +chip_device_platform = "zephyr" + +chip_build_tests = false + +chip_project_config_include = "" +chip_system_project_config_include = "" +chip_ble_project_config_include = "" + +custom_toolchain = "${chip_root}/config/zephyr/chip-gn/toolchain:zephyr" + +pw_build_PIP_CONSTRAINTS = [ "${chip_root}/scripts/constraints.txt" ] diff --git a/config/zephyr/chip-gn/toolchain/BUILD.gn b/config/zephyr/chip-gn/toolchain/BUILD.gn new file mode 100644 index 00000000000000..28fbe6d8e939b0 --- /dev/null +++ b/config/zephyr/chip-gn/toolchain/BUILD.gn @@ -0,0 +1,33 @@ +# Copyright (c) 2020 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. + +import("//build/toolchain/gcc_toolchain.gni") +import("//build_overrides/build.gni") + +declare_args() { + zephyr_ar = "" + zephyr_cc = "" + zephyr_cxx = "" +} + +gcc_toolchain("zephyr") { + ar = zephyr_ar + cc = zephyr_cc + cxx = zephyr_cxx + + toolchain_args = { + current_os = "zephyr" + is_clang = false + } +} diff --git a/config/zephyr/chip-module/CMakeLists.txt b/config/zephyr/chip-module/CMakeLists.txt new file mode 100644 index 00000000000000..ba25a316f57a2e --- /dev/null +++ b/config/zephyr/chip-module/CMakeLists.txt @@ -0,0 +1,257 @@ +# +# 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 +# CMake sub-project defining 'chip' target which represents CHIP library +# Since CHIP doesn't provide native CMake support, ExternalProject +# module is used to build the required artifacts with GN meta-build +# system. It is assumed that find_package(Zephyr) has been called before +# including this file. +# + +if (CONFIG_CHIP) + +include(ExternalProject) +include(../zephyr-util.cmake) + +# ============================================================================== +# Declare configuration variables and define constants +# ============================================================================== + +# C/C++ compiler flags passed to CHIP build system +list(APPEND CHIP_CFLAGS) + +# C compiler flags passed to CHIP build system +list(APPEND CHIP_CFLAGS_C) + +# C++ compiler flags passed to CHIP build system +list(APPEND CHIP_CFLAGS_CC) + +# CHIP libraries that the application should be linked with +list(APPEND CHIP_LIBRARIES) + +# GN meta-build system arguments in the form of 'key1 = value1\nkey2 = value2...' string +string(APPEND CHIP_GN_ARGS) + +# C/C++ compiler flags which should not be forwarded to CHIP +# build system (e.g. because CHIP configures them on its own) +set(CHIP_CFLAG_EXCLUDES + "-fno-asynchronous-unwind-tables" + "-fno-common" + "-fno-defer-pop" + "-fno-reorder-functions" + "-ffunction-sections" + "-fdata-sections" + "-g*" + "-O*" + "-W*" +) + +# ============================================================================== +# Helper macros +# ============================================================================== + +macro(chip_gn_arg_import FILE) + string(APPEND CHIP_GN_ARGS "import(\"${FILE}\")\n") +endmacro() + +macro(chip_gn_arg_string ARG STRING) + string(APPEND CHIP_GN_ARGS "${ARG} = \"${STRING}\"\n") +endmacro() + +macro(chip_gn_arg_bool ARG BOOLEAN) + if (${BOOLEAN}) + string(APPEND CHIP_GN_ARGS "${ARG} = true\n") + else() + string(APPEND CHIP_GN_ARGS "${ARG} = false\n") + endif() +endmacro() + +macro(chip_gn_arg_cflags ARG CFLAGS) + set(CFLAG_EXCLUDES "[") + foreach(cflag ${CHIP_CFLAG_EXCLUDES}) + string(APPEND CFLAG_EXCLUDES "\"${cflag}\", ") + endforeach() + string(APPEND CFLAG_EXCLUDES "]") + string(APPEND CHIP_GN_ARGS "${ARG} = filter_exclude(string_split(\"${CFLAGS}\"), ${CFLAG_EXCLUDES})\n") +endmacro() + +# ============================================================================== +# Prepare CHIP configuration based on the project Kconfig configuration +# ============================================================================== + +if (NOT CHIP_ROOT) + get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH) +endif() + +set(GN_ROOT_TARGET ${CHIP_ROOT}/config/zephyr/chip-gn) + +if (CONFIG_POSIX_API) + list(APPEND CHIP_CFLAGS + -D_SYS__PTHREADTYPES_H_ + -isystem${ZEPHYR_BASE}/include/zephyr/posix + ) +endif() + +list(APPEND CHIP_CFLAGS -isystem${ZEPHYR_BASE}/../modules/crypto/mbedtls/include/) + +zephyr_get_compile_flags(CHIP_CFLAGS_C C) +zephyr_get_compile_flags(CHIP_CFLAGS_CC CXX) +zephyr_get_gnu_cpp_standard(CHIP_CFLAGS_CC) + +convert_list_of_flags_to_string_of_flags(CHIP_CFLAGS CHIP_CFLAGS) +convert_list_of_flags_to_string_of_flags(CHIP_CFLAGS_C CHIP_CFLAGS_C) +convert_list_of_flags_to_string_of_flags(CHIP_CFLAGS_CC CHIP_CFLAGS_CC) + +# Prepare CHIP libraries that the application should be linked with + +if (NOT CHIP_LIBRARIES) + set(CHIP_LIBRARIES -lCHIP) +endif() + +if (CONFIG_CHIP_LIB_SHELL) + list(APPEND CHIP_LIBRARIES -lCHIPShell) +endif() + +if (CONFIG_CHIP_PW_RPC) + list(APPEND CHIP_LIBRARIES -lPwRpc) +endif() + + +# Set up CHIP project configuration file + +if (CONFIG_CHIP_PROJECT_CONFIG) + get_filename_component(CHIP_PROJECT_CONFIG + ${CONFIG_CHIP_PROJECT_CONFIG} + REALPATH + BASE_DIR ${CMAKE_SOURCE_DIR} + ) + set(CHIP_PROJECT_CONFIG "<${CHIP_PROJECT_CONFIG}>") +else() + set(CHIP_PROJECT_CONFIG "") +endif() + +# Set up custom OpenThread configuration + +if (CONFIG_CHIP_OPENTHREAD_CONFIG) + get_filename_component(CHIP_OPENTHREAD_CONFIG + ${CONFIG_CHIP_OPENTHREAD_CONFIG} + REALPATH + BASE_DIR ${CMAKE_SOURCE_DIR} + ) + zephyr_set_openthread_config(${CHIP_OPENTHREAD_CONFIG}) +endif() + +# Find required programs + +find_program(GN_EXECUTABLE gn) +if (${GN_EXECUTABLE} STREQUAL GN_EXECUTABLE-NOTFOUND) + message(FATAL_ERROR "The 'gn' command was not found. Make sure you have GN installed.") +else() + # Parse the 'gn --version' output to find the installed version. + set(MIN_GN_VERSION 1000) + execute_process( + COMMAND + ${GN_EXECUTABLE} --version + OUTPUT_VARIABLE gn_version_output + ERROR_VARIABLE gn_error_output + RESULT_VARIABLE gn_status + ) + + if(${gn_status} EQUAL 0) + if(gn_version_output VERSION_LESS ${MIN_GN_VERSION}) + message(FATAL_ERROR "Found unsuitable version of 'gn'. Required is at least ${MIN_GN_VERSION}") + endif() + else() + message(FATAL_ERROR "Could NOT find working gn: Found gn (${GN_EXECUTABLE}), but failed to load with:\n ${gn_error_output}") + endif() +endif() + +find_package(Python3 REQUIRED) + +# ============================================================================== +# Generate configuration for CHIP GN build system +# ============================================================================== +chip_gn_arg_cflags("target_cflags" ${CHIP_CFLAGS}) +chip_gn_arg_cflags("target_cflags_c" ${CHIP_CFLAGS_C}) +chip_gn_arg_cflags("target_cflags_cc" ${CHIP_CFLAGS_CC}) +chip_gn_arg_string("zephyr_ar" ${CMAKE_AR}) +chip_gn_arg_string("zephyr_cc" ${CMAKE_C_COMPILER}) +chip_gn_arg_string("zephyr_cxx" ${CMAKE_CXX_COMPILER}) +chip_gn_arg_string("chip_project_config_include" "${CHIP_PROJECT_CONFIG}") +chip_gn_arg_string("chip_system_project_config_include" "${CHIP_PROJECT_CONFIG}") +chip_gn_arg_bool ("is_debug" CONFIG_DEBUG) +chip_gn_arg_bool ("chip_enable_openthread" CONFIG_NET_L2_OPENTHREAD) +chip_gn_arg_bool ("chip_openthread_ftd" CONFIG_OPENTHREAD_FTD) +chip_gn_arg_bool ("chip_inet_config_enable_ipv4" CONFIG_NET_IPV4) +chip_gn_arg_bool ("chip_build_tests" CONFIG_CHIP_BUILD_TESTS) +chip_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" CONFIG_CHIP_BUILD_TESTS) +chip_gn_arg_bool ("chip_build_libshell" CONFIG_CHIP_LIB_SHELL) + +if (CONFIG_CHIP_ENABLE_DNSSD_SRP) + chip_gn_arg_string("chip_mdns" "platform") +endif() + +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/args.gn CONTENT ${CHIP_GN_ARGS}) + +# ============================================================================== +# Define 'chip-gn' target that builds CHIP library(ies) with GN build system +# ============================================================================== + +ExternalProject_Add( + chip-gn + PREFIX ${CMAKE_CURRENT_BINARY_DIR} + SOURCE_DIR ${CHIP_ROOT} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} + CONFIGURE_COMMAND ${GN_EXECUTABLE} + --root=${CHIP_ROOT} + --root-target=${GN_ROOT_TARGET} + --dotfile=${GN_ROOT_TARGET}/.gn + --script-executable=${Python3_EXECUTABLE} + gen --check --fail-on-unused-args ${CMAKE_CURRENT_BINARY_DIR} + BUILD_COMMAND ninja + INSTALL_COMMAND "" + BUILD_BYPRODUCTS ${CHIP_LIBRARIES} + BUILD_ALWAYS TRUE + USES_TERMINAL_CONFIGURE TRUE + USES_TERMINAL_BUILD TRUE +) +add_dependencies(chip-gn kernel) + +# ============================================================================== +# Define 'chip' target that exposes CHIP headers & libraries to the application +# ============================================================================== + +zephyr_interface_library_named(chip) +target_compile_definitions(chip INTERFACE CHIP_HAVE_CONFIG_H) +target_include_directories(chip INTERFACE + ${CHIP_ROOT}/src + ${CHIP_ROOT}/src/include + ${CHIP_ROOT}/src/lib + ${CHIP_ROOT}/third_party/nlassert/repo/include + ${CMAKE_CURRENT_BINARY_DIR}/gen/include +) +target_link_directories(chip INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/lib) + +if (CONFIG_CHIP_LIB_SHELL) + target_link_options(chip INTERFACE -Wl,--whole-archive -lCHIPShell -Wl,--no-whole-archive) +endif() + +target_link_libraries(chip INTERFACE -Wl,--start-group ${CHIP_LIBRARIES} -Wl,--end-group) +add_dependencies(chip chip-gn) + +endif() # CONFIG_CHIP \ No newline at end of file diff --git a/config/zephyr/chip-module/Kconfig b/config/zephyr/chip-module/Kconfig new file mode 100644 index 00000000000000..90c7d73f470b8f --- /dev/null +++ b/config/zephyr/chip-module/Kconfig @@ -0,0 +1,17 @@ +# +# Copyright (c) 2021 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. +# + +rsource "../Kconfig" \ No newline at end of file diff --git a/config/zephyr/chip-module/Kconfig.defaults b/config/zephyr/chip-module/Kconfig.defaults new file mode 100644 index 00000000000000..4cf4edea17a939 --- /dev/null +++ b/config/zephyr/chip-module/Kconfig.defaults @@ -0,0 +1,225 @@ +# +# 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 Matter samples. +# This file only changes defaults and thus all symbols here must be promptless +# and safeguarded so that they only are applied when building Matter. + +if CHIP + +config LOG + bool + default y + +if LOG + +choice LOG_MODE + default LOG_MODE_MINIMAL +endchoice + +choice MATTER_LOG_LEVEL_CHOICE + default MATTER_LOG_LEVEL_DBG +endchoice + +config LOG_DEFAULT_LEVEL + int + default 2 + +endif + +config PRINTK_SYNC + bool + default y + +config ASSERT + bool + default y + +config HW_STACK_PROTECTION + bool + default y + +config FPU + bool + default y + +config SHELL + bool + default y + +# Enable getting reboot reasons information +config HWINFO + bool + default y + +# Generic networking options +config NET_SOCKETS_POSIX_NAMES + bool + default n + +# Application stack size +config MAIN_STACK_SIZE + int + default 8192 + +config INIT_STACKS + bool + default y + +config CHIP_DEVICE_VENDOR_ID + int + default 65521 + +config CHIP_DEVICE_PRODUCT_ID + int + default 32768 + +# Disable certain parts of Zephyr IPv6 stack +config NET_IPV6_NBR_CACHE + bool + default n + +config NET_IPV6_MLD + bool + default y + +config NET_IF_MCAST_IPV6_ADDR_COUNT + int + default 14 + +# Network buffers +config NET_PKT_RX_COUNT + int + default 16 + +config NET_PKT_TX_COUNT + int + default 16 + +config NET_BUF_RX_COUNT + int + default 80 + +config NET_BUF_TX_COUNT + int + default 80 + +# Bluetooth Low Energy configs +config BT + bool + default y + +config BT_PERIPHERAL + bool + default y + +config BT_PERIPHERAL_PREF_MIN_INT + int + default 36 + +config BT_PERIPHERAL_PREF_MAX_INT + int + default 36 + +config BT_GAP_AUTO_UPDATE_CONN_PARAMS + bool + default y + +config BT_GATT_DYNAMIC_DB + bool + default y + +config BT_DEVICE_NAME_DYNAMIC + bool + default y + +config BT_DEVICE_NAME_MAX + int + default 15 + +config BT_MAX_CONN + int + default 1 + +config BT_L2CAP_TX_MTU + int + default 247 + +config BT_BUF_ACL_RX_SIZE + int + default 251 + +config BT_BUF_ACL_TX_SIZE + int + default 251 + +config BT_RX_STACK_SIZE + int + default 1200 + +config CHIP_OTA_REQUESTOR + bool + default y + +# Enable extended discovery +config CHIP_EXTENDED_DISCOVERY + bool + default y + +config NVS_LOOKUP_CACHE + bool + default y + +# Enable OpenThread +config NET_L2_OPENTHREAD + bool + default y + +# Enable mbedTLS +config MBEDTLS_ENABLE_HEAP + bool + default y + +config MBEDTLS_HEAP_SIZE + int + default 15360 + +# Disable not used shell modules +config SENSOR_SHELL + bool + default n + +config DEVICE_SHELL + bool + default n + +config DATE_SHELL + bool + default n + +config DEVMEM_SHELL + bool + default n + +config MCUBOOT_SHELL + bool + default n + +config FLASH_SHELL + bool + default n + +endif # CHIP diff --git a/config/zephyr/chip-module/Kconfig.features b/config/zephyr/chip-module/Kconfig.features new file mode 100644 index 00000000000000..bc800095dc7ce0 --- /dev/null +++ b/config/zephyr/chip-module/Kconfig.features @@ -0,0 +1,68 @@ +# +# 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 Kconfig options enabling specific features. +# Feature options will define defaults for settings that are related to the specific feature. + +if CHIP + +# MCU Manager and SMP configuration +config MCUMGR + bool + default y + +config MCUMGR_CMD_IMG_MGMT + bool + default y + +config MCUMGR_CMD_OS_MGMT + bool + default y + +config MCUMGR_SMP_BT + bool + default y + +config MCUMGR_SMP_BT_AUTHEN + bool + default n + +config MCUMGR_BUF_COUNT + int + default 6 + +# Increase BT MTU and RX buffer for big size DFU messages +config BT_L2CAP_TX_MTU + int + default 498 + +config BT_BUF_ACL_RX_SIZE + int + default 502 + +# Increase MCUMGR_BUF_SIZE, as it must be big enough to fit MAX MTU + overhead and for single-image DFU default is 384 B +config MCUMGR_BUF_SIZE + int + default 1024 + +# Increase system workqueue size, as SMP is processed within it +config SYSTEM_WORKQUEUE_STACK_SIZE + int + default 2800 + +endif # CHIP_DFU_OVER_BT_SMP + +endif # CHIP diff --git a/config/zephyr/chip-module/Kconfig.mcuboot.defaults b/config/zephyr/chip-module/Kconfig.mcuboot.defaults new file mode 100644 index 00000000000000..4d5979330000f4 --- /dev/null +++ b/config/zephyr/chip-module/Kconfig.mcuboot.defaults @@ -0,0 +1,89 @@ +# +# 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 mcuboot child image for Matter samples. + +config MAIN_STACK_SIZE + int + default 10240 + +config BOOT_SWAP_SAVE_ENCTLV + bool + default n + +config BOOT_ENCRYPT_RSA + bool + default n + +config BOOT_ENCRYPT_EC256 + bool + default n + +config BOOT_ENCRYPT_X25519 + bool + default n + +config BOOT_BOOTSTRAP + bool + default n + +config PM + bool + default n + +config FLASH + bool + default y + +config FPROTECT + bool + default y + +config BOOT_MAX_IMG_SECTORS + int + default 256 + +config LOG + bool + default n + +config CONSOLE_HANDLER + bool + default n + +config BOOT_BANNER + bool + default n + +config TIMESLICING + bool + default n + +config RESET_ON_FATAL_ERROR + bool + default n + +config MULTITHREADING + bool + default n + +config TICKLESS_KERNEL + bool + default n + +config TIMEOUT_64BIT + bool + default n diff --git a/config/zephyr/chip-module/Kconfig.mcuboot.root b/config/zephyr/chip-module/Kconfig.mcuboot.root new file mode 100644 index 00000000000000..e8756636dfd66d --- /dev/null +++ b/config/zephyr/chip-module/Kconfig.mcuboot.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 +# mcuboot_KCONFIG_ROOT and processed before any other Kconfig for mcuboot child image. + +rsource "Kconfig.mcuboot.defaults" +source "${ZEPHYR_BASE}/../bootloader/mcuboot/boot/zephyr/Kconfig" diff --git a/config/zephyr/chip-module/Kconfig.multiprotocol_rpmsg.defaults b/config/zephyr/chip-module/Kconfig.multiprotocol_rpmsg.defaults new file mode 100644 index 00000000000000..dea52bae56e2f4 --- /dev/null +++ b/config/zephyr/chip-module/Kconfig.multiprotocol_rpmsg.defaults @@ -0,0 +1,91 @@ +# +# 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 multiprotocol_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 diff --git a/config/zephyr/chip-module/Kconfig.multiprotocol_rpmsg.root b/config/zephyr/chip-module/Kconfig.multiprotocol_rpmsg.root new file mode 100644 index 00000000000000..b34c82243585b4 --- /dev/null +++ b/config/zephyr/chip-module/Kconfig.multiprotocol_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 +# multiprotocol_rpmsg_KCONFIG_ROOT and processed before any other Kconfig for multiprotocol_rpmsg child image. + +rsource "Kconfig.multiprotocol_rpmsg.defaults" +source "Kconfig.zephyr" diff --git a/config/zephyr/chip-module/make_gn_args.py b/config/zephyr/chip-module/make_gn_args.py new file mode 100644 index 00000000000000..f30cd459a6e7d4 --- /dev/null +++ b/config/zephyr/chip-module/make_gn_args.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python3 + +# +# Copyright (c) 2021 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. +# + +import argparse +import re +import sys + +GN_SPECIAL_CHARACTERS = r'(["$\\])' +GN_CFLAG_EXCLUDES = [ + '-fno-asynchronous-unwind-tables', + '-fno-common', + '-fno-defer-pop', + '-fno-reorder-functions', + '-ffunction-sections', + '-fdata-sections', + '-g*', + '-O*', + '-W*', +] + + +def escape_strings(gn_args): + return [[key, re.sub(GN_SPECIAL_CHARACTERS, r'\\\1', value)] for key, value in gn_args] + + +def write_gn_args(args): + if args.module: + sys.stdout.write('import("{}")\n'.format(args.module)) + + for key, value in args.arg: + sys.stdout.write('{} = {}\n'.format(key, value)) + + for key, value in args.arg_string: + sys.stdout.write('{} = "{}"\n'.format(key, value)) + + cflag_excludes = ', '.join(['"{}"'.format(exclude) + for exclude in GN_CFLAG_EXCLUDES]) + + for key, value in args.arg_cflags: + sys.stdout.write('{} = filter_exclude(string_split("{}"), [{}])\n'.format( + key, value, cflag_excludes)) + + +def main(): + parser = argparse.ArgumentParser(fromfile_prefix_chars='@') + parser.add_argument('--module', action='store') + parser.add_argument('--arg', action='append', nargs=2, default=[]) + parser.add_argument('--arg-string', action='append', nargs=2, default=[]) + parser.add_argument('--arg-cflags', action='append', nargs=2, default=[]) + args = parser.parse_args() + args.arg_string = escape_strings(args.arg_string) + args.arg_cflags = escape_strings(args.arg_cflags) + write_gn_args(args) + + +if __name__ == "__main__": + main() diff --git a/config/zephyr/chip-module/zephyr/module.yml b/config/zephyr/chip-module/zephyr/module.yml new file mode 100644 index 00000000000000..c09c9ea59e218a --- /dev/null +++ b/config/zephyr/chip-module/zephyr/module.yml @@ -0,0 +1,22 @@ +# +# Copyright (c) 2021 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. +# + +name: connectedhomeip +build: + cmake: . + kconfig: Kconfig + depends: + - openthread diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index 3dde9e09081332..773fa52d93fa05 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -258,6 +258,11 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { ] defines -= [ "CHIP_DEVICE_CONFIG_ENABLE_WPA=${chip_device_config_enable_wpa}" ] + } else if (chip_device_platform == "zephyr") { + defines += [ + "CHIP_DEVICE_LAYER_TARGET_ZEPHYR=1", + "CHIP_DEVICE_LAYER_TARGET=Zephyr", + ] } } } else if (chip_device_platform == "none") { @@ -413,6 +418,8 @@ if (chip_device_platform != "none") { _platform_target = "fake" } else if (chip_device_platform == "cyw30739") { _platform_target = "CYW30739" + } else if (chip_device_platform == "zephyr") { + _platform_target = "Zephyr" } else { assert(false, "Unknown chip_device_platform: ${chip_device_platform}") } diff --git a/src/platform/Zephyr/BUILD.gn b/src/platform/Zephyr/BUILD.gn new file mode 100644 index 00000000000000..c4f2820b4da8df --- /dev/null +++ b/src/platform/Zephyr/BUILD.gn @@ -0,0 +1,79 @@ +# Copyright (c) 2021 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. + +import("//build_overrides/chip.gni") +import("//build_overrides/chip.gni") +import("//build_overrides/zephyr.gni") + +import("${chip_root}/src/platform/Zephyr/args.gni") +import("${chip_root}/src/platform/device.gni") + +assert(chip_device_platform == "zephyr") + +static_library("Zephyr") { + sources = [ + "../SingletonConfigurationManager.cpp", + "BLEManagerImpl.cpp", + "BLEManagerImpl.h", + "BlePlatformConfig.h", + "CHIPDevicePlatformConfig.h", + "CHIPDevicePlatformEvent.h", + "CHIPPlatformConfig.h", + "ConfigurationManagerImpl.cpp", + "ConfigurationManagerImpl.h", + "ConnectivityManagerImpl.cpp", + "ConnectivityManagerImpl.h", + "DeviceNetworkProvisioningDelegateImpl.cpp", + "DeviceNetworkProvisioningDelegateImpl.h", + "DiagnosticDataProviderImpl.cpp", + "DiagnosticDataProviderImpl.h", + "InetPlatformConfig.h", + "KeyValueStoreManagerImpl.cpp", + "KeyValueStoreManagerImpl.h", + "Logging.cpp", + "PlatformManagerImpl.cpp", + "PlatformManagerImpl.h", + "SysHeapMalloc.h", + "SystemPlatformConfig.h", + "SystemTimeSupport.cpp", + "ZephyrConfig.cpp", + "ZephyrConfig.h", + ] + + public_deps = [ "${chip_root}/src/platform:platform_base" ] + + if (chip_enable_openthread) { + sources += [ + "../OpenThread/OpenThreadUtils.cpp", + "ThreadStackManagerImpl.cpp", + "ThreadStackManagerImpl.h", + ] + + if (chip_mdns == "platform") { + sources += [ "../OpenThread/DnssdImpl.cpp" ] + deps = [ "${chip_root}/src/lib/dnssd:platform_header" ] + } + } + + if (chip_enable_nfc) { + sources += [ + "NFCManagerImpl.cpp", + "NFCManagerImpl.h", + ] + } + + if (chip_malloc_sys_heap) { + sources += [ "SysHeapMalloc.cpp" ] + } +} diff --git a/src/platform/Zephyr/BlePlatformConfig.h b/src/platform/Zephyr/BlePlatformConfig.h new file mode 100644 index 00000000000000..9f49cd73dcfec3 --- /dev/null +++ b/src/platform/Zephyr/BlePlatformConfig.h @@ -0,0 +1,36 @@ +/* + * + * Copyright (c) 2020 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 + * Platform-specific configuration overrides for the CHIP BLE + * Layer on Zephyr platform. + * + */ + +#pragma once + +// ==================== Platform Adaptations ==================== + +struct bt_conn; +#define BLE_CONNECTION_OBJECT bt_conn * +#define BLE_CONNECTION_UNINITIALIZED nullptr +#define BLE_MAX_RECEIVE_WINDOW_SIZE 5 + +// ========== Platform-specific Configuration Overrides ========= + +/* none so far */ diff --git a/src/platform/Zephyr/CHIPDevicePlatformConfig.h b/src/platform/Zephyr/CHIPDevicePlatformConfig.h new file mode 100644 index 00000000000000..c591a51af4c070 --- /dev/null +++ b/src/platform/Zephyr/CHIPDevicePlatformConfig.h @@ -0,0 +1,132 @@ +/* + * + * 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 + * Platform-specific configuration overrides for the chip Device Layer + * on Zephyr platform. + */ + +#pragma once + +#include "autoconf.h" + +// ==================== Platform Adaptations ==================== + +#ifndef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID +#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID CONFIG_CHIP_DEVICE_VENDOR_ID +#endif + +#ifndef CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID CONFIG_CHIP_DEVICE_PRODUCT_ID +#endif + +#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION CONFIG_CHIP_DEVICE_SOFTWARE_VERSION +#endif + +#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING +#endif + +#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 + +#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE CONFIG_BT + +#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 0 + +// ========== Platform-specific Configuration ========= + +// These are configuration options that are unique to Zephyr platforms. +// These can be overridden by the application as needed. + +#ifndef CHIP_DEVICE_CONFIG_SETTINGS_KEY +/// Key for all Matter persistent data stored using the Zephyr Settings API +#define CHIP_DEVICE_CONFIG_SETTINGS_KEY "mt" +#endif // CHIP_DEVICE_CONFIG_SETTINGS_KEY + +#ifndef CHIP_DEVICE_CONFIG_OTA_REQUESTOR_REBOOT_DELAY_MS +/// Delay between completing a firmware update download and reboot to apply the update +#define CHIP_DEVICE_CONFIG_OTA_REQUESTOR_REBOOT_DELAY_MS 1000 +#endif // CHIP_DEVICE_CONFIG_OTA_REQUESTOR_REBOOT_DELAY_MS + +#ifndef CHIP_DEVICE_CONFIG_SERVER_SHUTDOWN_ACTIONS_SLEEP_MS +/// Time to sleep after running server shutdown actions to let lower layers complete the actions. +/// This may include transmitting packets created by the actions. +#define CHIP_DEVICE_CONFIG_SERVER_SHUTDOWN_ACTIONS_SLEEP_MS 500 +#endif // CHIP_DEVICE_CONFIG_SERVER_SHUTDOWN_ACTIONS_SLEEP_MS + +#ifndef CHIP_DEVICE_CONFIG_HEAP_STATISTICS_MALLINFO +#if !defined(CONFIG_CHIP_MALLOC_SYS_HEAP) && defined(CONFIG_NEWLIB_LIBC) +/// Use mallinfo() to obtain the heap usage statistics exposed by SoftwareDiagnostics cluster attributes. +#define CHIP_DEVICE_CONFIG_HEAP_STATISTICS_MALLINFO 1 +#endif // !defined(CONFIG_CHIP_MALLOC_SYS_HEAP) && defined(CONFIG_NEWLIB_LIBC) +#endif // CHIP_DEVICE_CONFIG_HEAP_STATISTICS_MALLINFO + +// ========== Platform-specific Configuration Overrides ========= + +#ifndef CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY +#define CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY (K_PRIO_PREEMPT(1)) +#endif // CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY + +#ifndef CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE +#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE 8192 +#endif // CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE + +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY 0 +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY 0 +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL 0 +#define CHIP_DEVICE_CONFIG_LOG_PROVISIONING_HASH 0 + +#define CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED CONFIG_CHIP_DISABLE_CHIPOBLE_ADVERTISING_WHEN_PROVISIONED + +#define CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART 0 + +#ifndef CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART +#define CHIP_DEVICE_CONFIG_ENABLE_PAIRING_AUTOSTART 0 +#else +#define CHIP_DEVICE_CONFIG_ENABLE_PAIRING_AUTOSTART CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART +#endif // CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART + +#ifdef CONFIG_CHIP_ENABLE_DNSSD_SRP +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT 1 +#define CHIP_DEVICE_CONFIG_THREAD_SRP_MAX_SERVICES (CHIP_CONFIG_MAX_FABRICS + 1) +#ifdef CONFIG_CHIP_ENABLE_DNS_CLIENT +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT 1 +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_COMMISSIONABLE_DISCOVERY 1 +#endif // CONFIG_CHIP_ENABLE_DNS_CLIENT +#endif // CONFIG_CHIP_ENABLE_DNSSD_SRP + +#ifdef CONFIG_CHIP_ENABLE_SLEEPY_END_DEVICE_SUPPORT +#define CHIP_DEVICE_CONFIG_ENABLE_SED 1 +#define CHIP_DEVICE_CONFIG_THREAD_SSED CONFIG_CHIP_THREAD_SSED +#endif // CONFIG_CHIP_ENABLE_SLEEPY_END_DEVICE_SUPPORT + +#ifdef CONFIG_CHIP_COMMISSIONABLE_DEVICE_TYPE +#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DEVICE_TYPE 1 +#endif // CONFIG_CHIP_COMMISSIONABLE_DEVICE_TYPE + +#ifdef CONFIG_CHIP_DEVICE_TYPE +#define CHIP_DEVICE_CONFIG_DEVICE_TYPE CONFIG_CHIP_DEVICE_TYPE +#endif // CONFIG_CHIP_DEVICE_TYPE + +#ifdef CONFIG_CHIP_EXTENDED_DISCOVERY +#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1 +#endif // CONFIG_CHIP_EXTENDED_DISCOVERY diff --git a/src/platform/Zephyr/CHIPDevicePlatformEvent.h b/src/platform/Zephyr/CHIPDevicePlatformEvent.h index ba29c164e49eef..5687945287c2b1 100644 --- a/src/platform/Zephyr/CHIPDevicePlatformEvent.h +++ b/src/platform/Zephyr/CHIPDevicePlatformEvent.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * 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. diff --git a/src/platform/Zephyr/CHIPPlatformConfig.h b/src/platform/Zephyr/CHIPPlatformConfig.h new file mode 100644 index 00000000000000..c463fb21da88f2 --- /dev/null +++ b/src/platform/Zephyr/CHIPPlatformConfig.h @@ -0,0 +1,55 @@ +/* + * + * 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. + */ + +/** + * @file + * Platform-specific configuration overrides for CHIP on + * Zephyr platform. + */ + +#pragma once + +// ==================== General Platform Adaptations ==================== + +#define CHIP_CONFIG_ABORT() abort() + +#define CHIP_CONFIG_PERSISTED_STORAGE_KEY_TYPE const char * +#define CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH 2 + +#define CHIP_CONFIG_LIFETIIME_PERSISTED_COUNTER_KEY "rc" + +// ==================== General Configuration Overrides ==================== + +#ifndef CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS +#define CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS 8 +#endif // CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS + +#ifndef CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS +#define CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS 8 +#endif // CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS + +#ifndef CHIP_LOG_FILTERING +#define CHIP_LOG_FILTERING 0 +#endif // CHIP_LOG_FILTERING + +#ifndef CHIP_CONFIG_BDX_MAX_NUM_TRANSFERS +#define CHIP_CONFIG_BDX_MAX_NUM_TRANSFERS 1 +#endif // CHIP_CONFIG_BDX_MAX_NUM_TRANSFERS + +#ifndef CHIP_CONFIG_MAX_FABRICS +#define CHIP_CONFIG_MAX_FABRICS 5 +#endif diff --git a/src/platform/Zephyr/ConfigurationManagerImpl.h b/src/platform/Zephyr/ConfigurationManagerImpl.h index e678b5a5146868..5f331d14d81897 100644 --- a/src/platform/Zephyr/ConfigurationManagerImpl.h +++ b/src/platform/Zephyr/ConfigurationManagerImpl.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * 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. diff --git a/src/platform/Zephyr/ConnectivityManagerImpl.cpp b/src/platform/Zephyr/ConnectivityManagerImpl.cpp new file mode 100644 index 00000000000000..c09181db994e8d --- /dev/null +++ b/src/platform/Zephyr/ConnectivityManagerImpl.cpp @@ -0,0 +1,61 @@ +/* + * + * Copyright (c) 2020 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 + +#include +#include + +#include +#include + +#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE +#include +#endif + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#include +#endif + +using namespace ::chip; +using namespace ::chip::TLV; +using namespace ::chip::DeviceLayer::Internal; + +namespace chip { +namespace DeviceLayer { + +ConnectivityManagerImpl ConnectivityManagerImpl::sInstance; + +CHIP_ERROR ConnectivityManagerImpl::_Init() +{ +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + GenericConnectivityManagerImpl_Thread::_Init(); +#endif + + return CHIP_NO_ERROR; +} + +void ConnectivityManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) +{ + // Forward the event to the generic base classes as needed. +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + GenericConnectivityManagerImpl_Thread::_OnPlatformEvent(event); +#endif +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Zephyr/ConnectivityManagerImpl.h b/src/platform/Zephyr/ConnectivityManagerImpl.h new file mode 100644 index 00000000000000..16e39cdb1b63db --- /dev/null +++ b/src/platform/Zephyr/ConnectivityManagerImpl.h @@ -0,0 +1,103 @@ +/* + * + * Copyright (c) 2020 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 +#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE +#include +#else +#include +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#include +#else +#include +#endif +#include + +#include + +namespace chip { +namespace Inet { +class IPAddress; +} // namespace Inet +} // namespace chip + +namespace chip { +namespace DeviceLayer { + +/** + * Concrete implementation of the ConnectivityManager singleton object for Zephyr platforms. + */ +class ConnectivityManagerImpl final : public ConnectivityManager, + public Internal::GenericConnectivityManagerImpl, +#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE + public Internal::GenericConnectivityManagerImpl_BLE, +#else + public Internal::GenericConnectivityManagerImpl_NoBLE, +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + public Internal::GenericConnectivityManagerImpl_Thread, +#else + public Internal::GenericConnectivityManagerImpl_NoThread, +#endif + public Internal::GenericConnectivityManagerImpl_NoWiFi +{ + // Allow the ConnectivityManager interface class to delegate method calls to + // the implementation methods provided by this class. + friend class ConnectivityManager; + +private: + // ===== Members that implement the ConnectivityManager abstract interface. + + CHIP_ERROR _Init(void); + void _OnPlatformEvent(const ChipDeviceEvent * event); + + // ===== Members for internal use by the following friends. + + friend ConnectivityManager & ConnectivityMgr(void); + friend ConnectivityManagerImpl & ConnectivityMgrImpl(void); + + static ConnectivityManagerImpl sInstance; +}; + +/** + * Returns the public interface of the ConnectivityManager singleton object. + * + * chip applications should use this to access features of the ConnectivityManager object + * that are common to all platforms. + */ +inline ConnectivityManager & ConnectivityMgr(void) +{ + return ConnectivityManagerImpl::sInstance; +} + +/** + * 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. + */ +inline ConnectivityManagerImpl & ConnectivityMgrImpl(void) +{ + return ConnectivityManagerImpl::sInstance; +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Zephyr/DeviceNetworkProvisioningDelegateImpl.cpp b/src/platform/Zephyr/DeviceNetworkProvisioningDelegateImpl.cpp new file mode 100644 index 00000000000000..2e75cfc0022518 --- /dev/null +++ b/src/platform/Zephyr/DeviceNetworkProvisioningDelegateImpl.cpp @@ -0,0 +1,44 @@ +/* + * + * 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 "DeviceNetworkProvisioningDelegateImpl.h" + +#if CHIP_ENABLE_OPENTHREAD +#include +#endif + +namespace chip { +namespace DeviceLayer { + +CHIP_ERROR +DeviceNetworkProvisioningDelegateImpl::_ProvisionThreadNetwork(ByteSpan threadData) +{ +#if CHIP_ENABLE_OPENTHREAD + CHIP_ERROR error = CHIP_NO_ERROR; + + SuccessOrExit(error = ThreadStackMgr().SetThreadEnabled(false)); + SuccessOrExit(error = ThreadStackMgr().SetThreadProvision(threadData)); + SuccessOrExit(error = ThreadStackMgr().SetThreadEnabled(true)); +exit: + return error; +#else + return CHIP_ERROR_NOT_IMPLEMENTED; +#endif // CHIP_ENABLE_OPENTHREAD +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Zephyr/DeviceNetworkProvisioningDelegateImpl.h b/src/platform/Zephyr/DeviceNetworkProvisioningDelegateImpl.h new file mode 100644 index 00000000000000..e799358e4b7536 --- /dev/null +++ b/src/platform/Zephyr/DeviceNetworkProvisioningDelegateImpl.h @@ -0,0 +1,43 @@ +/* + * + * Copyright (c) 2020 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 Internal { + +template +class GenericDeviceNetworkProvisioningDelegateImpl; + +} // namespace Internal + +class DeviceNetworkProvisioningDelegateImpl final + : public Internal::GenericDeviceNetworkProvisioningDelegateImpl +{ + friend class GenericDeviceNetworkProvisioningDelegateImpl; + +private: + CHIP_ERROR _ProvisionWiFiNetwork(const char * ssid, const char * passwd) { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR _ProvisionThreadNetwork(ByteSpan threadData); +}; + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp b/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp index 162a0d3ea19820..e3cee6927ea74b 100644 --- a/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2021 Project CHIP Authors + * 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. @@ -18,7 +18,7 @@ /** * @file * Provides an implementation of the DiagnosticDataProvider object - * for Zephy platform. + * for Zephyr platform. */ #include diff --git a/src/platform/Zephyr/InetPlatformConfig.h b/src/platform/Zephyr/InetPlatformConfig.h new file mode 100644 index 00000000000000..a5d03a9d0614d5 --- /dev/null +++ b/src/platform/Zephyr/InetPlatformConfig.h @@ -0,0 +1,46 @@ +/* + * + * Copyright (c) 2020 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 + * Platform-specific configuration overrides for the CHIP Inet + * Layer on Zephyr platform. + * + */ + +#pragma once + +// ==================== Platform Adaptations ==================== + +#ifndef INET_CONFIG_ENABLE_IPV4 +#error Inet IPv4 configuration should be configured at build generation time +#endif + +// ========== Platform-specific Configuration Overrides ========= + +#ifndef INET_CONFIG_NUM_TCP_ENDPOINTS +#define INET_CONFIG_NUM_TCP_ENDPOINTS 4 +#endif // INET_CONFIG_NUM_TCP_ENDPOINTS + +#ifndef INET_CONFIG_NUM_UDP_ENDPOINTS +#define INET_CONFIG_NUM_UDP_ENDPOINTS 4 +#endif // INET_CONFIG_NUM_UDP_ENDPOINTS + +// Although Zephyr defines SO_BINDTODEVICE, it's currently unimplemented +#ifdef HAVE_SO_BINDTODEVICE +#undef HAVE_SO_BINDTODEVICE +#endif // HAVE_SO_BINDTODEVICE diff --git a/src/platform/Zephyr/SystemPlatformConfig.h b/src/platform/Zephyr/SystemPlatformConfig.h new file mode 100644 index 00000000000000..6fa52c1728c093 --- /dev/null +++ b/src/platform/Zephyr/SystemPlatformConfig.h @@ -0,0 +1,58 @@ +/* + * + * Copyright (c) 2020 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 + * Platform-specific configuration overrides for the CHIP System + * Layer on Zephyr platform. + * + */ + +#pragma once + +#include + +namespace chip { +namespace DeviceLayer { +struct ChipDeviceEvent; +} // namespace DeviceLayer +} // namespace chip + +// ==================== Platform Adaptations ==================== + +#define CHIP_SYSTEM_CONFIG_POSIX_LOCKING 1 +#define CHIP_SYSTEM_CONFIG_FREERTOS_LOCKING 0 +#define CHIP_SYSTEM_CONFIG_NO_LOCKING 0 + +#ifndef CHIP_SYSTEM_CONFIG_USE_POSIX_TIME_FUNCTS +#define CHIP_SYSTEM_CONFIG_USE_POSIX_TIME_FUNCTS 0 +#endif // CHIP_SYSTEM_CONFIG_USE_POSIX_TIME_FUNCTS + +#if CHIP_SYSTEM_CONFIG_USE_POSIX_TIME_FUNCTS +#define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_TIME 0 +#else // CHIP_SYSTEM_CONFIG_USE_POSIX_TIME_FUNCTS +#define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_TIME 1 +#endif // CHIP_SYSTEM_CONFIG_USE_POSIX_TIME_FUNCTS + +#define CHIP_SYSTEM_CONFIG_USE_LWIP 0 +#define CHIP_SYSTEM_CONFIG_USE_SOCKETS 1 + +// ========== Platform-specific Configuration Overrides ========= + +#ifndef CHIP_SYSTEM_CONFIG_NUM_TIMERS +#define CHIP_SYSTEM_CONFIG_NUM_TIMERS 16 +#endif // CHIP_SYSTEM_CONFIG_NUM_TIMERS diff --git a/src/platform/Zephyr/args.gni b/src/platform/Zephyr/args.gni new file mode 100644 index 00000000000000..cc9de74cddd561 --- /dev/null +++ b/src/platform/Zephyr/args.gni @@ -0,0 +1,5 @@ +chip_device_platform = "zephyr" + +declare_args() { + chip_malloc_sys_heap = false +} diff --git a/src/platform/device.gni b/src/platform/device.gni index 17f2551def2b43..ec758393b98664 100755 --- a/src/platform/device.gni +++ b/src/platform/device.gni @@ -16,7 +16,7 @@ import("//build_overrides/chip.gni") import("${chip_root}/src/ble/ble.gni") declare_args() { - # Device platform layer: cc13x2_26x2, darwin, efr32, esp32, external, freertos, linux, nrfconnect, k32w0, qpg, tizen, cyw30739, bl602, none. + # Device platform layer: cc13x2_26x2, darwin, efr32, esp32, external, freertos, linux, nrfconnect, k32w0, qpg, tizen, cyw30739, bl602, zephyr, none. chip_device_platform = "auto" chip_platform_target = "" @@ -38,6 +38,8 @@ if (chip_device_platform == "auto") { chip_device_platform = "android" } else if (current_os == "webos") { chip_device_platform = "webos" + } else if (current_os == "zephyr") { + chip_device_platform = "zephyr" } else { chip_device_platform = "none" } @@ -125,6 +127,8 @@ if (chip_device_platform == "cc13x2_26x2") { _chip_device_layer = "CYW30739" } else if (chip_device_platform == "webos") { _chip_device_layer = "webos" +} else if (chip_device_platform == "zephyr") { + _chip_device_layer = "Zephyr" } if (chip_device_platform != "external") { @@ -182,5 +186,6 @@ assert( chip_device_platform == "telink" || chip_device_platform == "mbed" || chip_device_platform == "p6" || chip_device_platform == "android" || chip_device_platform == "ameba" || chip_device_platform == "cyw30739" || - chip_device_platform == "webos" || chip_device_platform == "bl602", + chip_device_platform == "webos" || chip_device_platform == "bl602" || + chip_device_platform == "zephyr", "Please select a valid value for chip_device_platform") From 6f41d8b7903c11379e9310a6787301adce2a236a Mon Sep 17 00:00:00 2001 From: manjunath-grl <102359958+manjunath-grl@users.noreply.github.com> Date: Tue, 14 Jun 2022 19:53:27 +0530 Subject: [PATCH 04/53] Modified MF tests May 17 (#19381) * Added MF tests TC-MF-1.9 TC-MF-1.10 modified tests TC-MF-1.5 TC-MF-1.6 TC-MF-1.15 * Added auto generated files * Modified scripts * Added auto generated files * Added auto generated files * Removed MF-1,10 from Darwin test * Auto generated files * Increased timeout for tests.yaml file * Modified darwin workflow timeout * Modified scripts TC-MF-1.19 and TC-MF-1.10 * Auto generated files * Removed MF test MF-1.10 and MF-1.9 from Darwinjs * Auto generated files * Increased Timeout for Darwin (no-ble-asan-clang) * Auto generated files --- .github/workflows/darwin-tests.yaml | 4 +- .github/workflows/tests.yaml | 8 +- .../suites/certification/Test_TC_MF_1_10.yaml | 426 ++++- .../suites/certification/Test_TC_MF_1_15.yaml | 52 +- .../suites/certification/Test_TC_MF_1_5.yaml | 26 +- .../suites/certification/Test_TC_MF_1_6.yaml | 26 +- .../suites/certification/Test_TC_MF_1_9.yaml | 397 ++++- src/app/tests/suites/tests.js | 4 +- .../chip-tool/zap-generated/test/Commands.h | 1189 +++++++++---- .../zap-generated/test/Commands.h | 1538 +++++++++++++---- 10 files changed, 2765 insertions(+), 905 deletions(-) diff --git a/.github/workflows/darwin-tests.yaml b/.github/workflows/darwin-tests.yaml index c6603eaac00f4e..0f0f57b57104a5 100644 --- a/.github/workflows/darwin-tests.yaml +++ b/.github/workflows/darwin-tests.yaml @@ -29,7 +29,7 @@ concurrency: jobs: test_suites_chip_tool_darwin: name: Test Suites - Darwin - timeout-minutes: 120 + timeout-minutes: 135 strategy: matrix: @@ -96,7 +96,7 @@ jobs: --copy-artifacts-to objdir-clone \ " - name: Run Tests - timeout-minutes: 45 + timeout-minutes: 60 run: | ./scripts/run_in_build_env.sh \ "./scripts/tests/run_test_suite.py \ diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index d0e5c774c023cd..ebb81d9ed58df4 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -28,7 +28,7 @@ concurrency: jobs: test_suites_linux: name: Test Suites - Linux - timeout-minutes: 120 + timeout-minutes: 140 strategy: matrix: @@ -90,7 +90,7 @@ jobs: --copy-artifacts-to objdir-clone \ " - name: Run Tests - timeout-minutes: 40 + timeout-minutes: 60 run: | ./scripts/run_in_build_env.sh \ "./scripts/tests/run_test_suite.py \ @@ -121,7 +121,7 @@ jobs: retention-days: 5 test_suites_darwin: name: Test Suites - Darwin - timeout-minutes: 120 + timeout-minutes: 140 strategy: matrix: @@ -190,7 +190,7 @@ jobs: --copy-artifacts-to objdir-clone \ " - name: Run Tests - timeout-minutes: 50 + timeout-minutes: 70 run: | ./scripts/run_in_build_env.sh \ "./scripts/tests/run_test_suite.py \ diff --git a/src/app/tests/suites/certification/Test_TC_MF_1_10.yaml b/src/app/tests/suites/certification/Test_TC_MF_1_10.yaml index af86c1cb5ed809..a951ea5f4e3d42 100644 --- a/src/app/tests/suites/certification/Test_TC_MF_1_10.yaml +++ b/src/app/tests/suites/certification/Test_TC_MF_1_10.yaml @@ -18,63 +18,377 @@ name: config: nodeId: 0x12344321 - cluster: "Basic" + timeout: 700 + nodeIdForDuplicateCommissioning: + type: NODE_ID + defaultValue: 0x11 + nodeId2: + type: NODE_ID + defaultValue: 0xCAFE + nodeId3: + type: NODE_ID + defaultValue: 0xC00FEE endpoint: 0 + discriminator: + type: INT16U + defaultValue: 3840 + payload: + type: CHAR_STRING + defaultValue: "MT:0000000000I31506010" + payload2: + type: CHAR_STRING + defaultValue: "MT:0000000000I.0648G00" tests: + - label: "Reboot target device" + cluster: "SystemCommands" + command: "Reboot" + arguments: + values: + - name: "discriminator" + value: discriminator + - label: "TH_CR1 starts a commissioning process with DUT_CE" - verification: | - 1. Provision the device using 1st python controller on the raspi (use above instructions) - disabled: true - - - label: - "TH_CR1 opens a commissioning window on DUT_CE using a commissioning - timeout of PIXIT_COMM_WIN seconds using BCM" - verification: | - On 1st controller using chip tool, open commissioning window using BCM - - ./chip-tool administratorcommissioning open-basic-commissioning-window 500 1 0 - - - [1635871562.958905][4336:4341] CHIP:DMG: InvokeCommand = - [1635871562.958976][4336:4341] CHIP:DMG: { - [1635871562.959031][4336:4341] CHIP:DMG: CommandList = - [1635871562.959095][4336:4341] CHIP:DMG: [ - [1635871562.959161][4336:4341] CHIP:DMG: CommandDataIB = - [1635871562.959225][4336:4341] CHIP:DMG: { - [1635871562.959290][4336:4341] CHIP:DMG: CommandPathIB = - [1635871562.959368][4336:4341] CHIP:DMG: { - [1635871562.959434][4336:4341] CHIP:DMG: EndpointId = 0x0, - [1635871562.959530][4336:4341] CHIP:DMG: ClusterId = 0x3c, - [1635871562.959625][4336:4341] CHIP:DMG: CommandId = 0x1, - [1635871562.959698][4336:4341] CHIP:DMG: }, - [1635871562.959776][4336:4341] CHIP:DMG: - [1635871562.959841][4336:4341] CHIP:DMG: StatusIB = - [1635871562.959911][4336:4341] CHIP:DMG: { - [1635871562.959980][4336:4341] CHIP:DMG: status = 0x0, - [1635871562.960064][4336:4341] CHIP:DMG: }, - [1635871562.960313][4336:4341] CHIP:DMG: - [1635871562.960459][4336:4341] CHIP:DMG: }, - [1635871562.960544][4336:4341] CHIP:DMG: - [1635871562.960604][4336:4341] CHIP:DMG: ], - [1635871562.960668][4336:4341] CHIP:DMG: - [1635871562.960723][4336:4341] CHIP:DMG: } - [1635871562.960824][4336:4341] CHIP:DMG: Received Command Response Status for Endpoint=0 Cluster=0x0000_003C Command=0x0000_0001 Status=0x0 - [1635871562.960894][4336:4341] CHIP:TOO: Default Success Response - disabled: true - - - label: - "Set up a TH_CR2 to start attempting to do PASE to DUT_CE and failing - 20 times. This can be done using an invalid passcode" - verification: | - On 2nd controller, using chip-tool connect using wrong passcode. Repeat the step for 20 times. - - ./chip-tool pairing onnetwork 1 20202019 (With wrong passcode) - disabled: true - - - label: "TH_CR2 starts a 21st commissioning process" - verification: | - On 2nd controller, using chip tool connect using correct passcode. - - ./chip-tool pairing onnetwork 1 20202021 (correct passcode) - disabled: true + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId + + - label: "TH_CR1 opens a commissioning window on DUT_CE" + cluster: "AdministratorCommissioning" + command: "OpenBasicCommissioningWindow" + timedInteractionTimeoutMs: 10000 + arguments: + values: + - name: "CommissioningTimeout" + value: 180 + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: "TH_CR3 starts a commissioning process with DUT_CE" + identity: "gamma" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId3 + - name: "payload" + value: payload + response: + error: FAILURE diff --git a/src/app/tests/suites/certification/Test_TC_MF_1_15.yaml b/src/app/tests/suites/certification/Test_TC_MF_1_15.yaml index 966145dea3b4ab..d0f4bf1728d29c 100644 --- a/src/app/tests/suites/certification/Test_TC_MF_1_15.yaml +++ b/src/app/tests/suites/certification/Test_TC_MF_1_15.yaml @@ -167,31 +167,7 @@ tests: arguments: values: - name: "ms" - value: 54000 - - - label: "Wait for the expiration of PIXIT_COMM_WIN seconds" - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 54000 - - - label: "Wait for the expiration of PIXIT_COMM_WIN seconds" - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 54000 - - - label: "Wait for the expiration of PIXIT_COMM_WIN seconds" - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 18000 + value: 180000 - label: "TH_CR1 re-opens new commissioning window on DUT_CE" identity: "alpha" @@ -253,31 +229,7 @@ tests: arguments: values: - name: "ms" - value: 54000 - - - label: "Wait for the expiration of PIXIT_COMM_WIN seconds" - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 54000 - - - label: "Wait for the expiration of PIXIT_COMM_WIN seconds" - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 54000 - - - label: "Wait for the expiration of PIXIT_COMM_WIN seconds" - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 18000 + value: 180000 - label: "TH_CR1 opens a new commissioning window on DUT_CE" identity: "alpha" diff --git a/src/app/tests/suites/certification/Test_TC_MF_1_5.yaml b/src/app/tests/suites/certification/Test_TC_MF_1_5.yaml index e3eee90b82d022..e04f931bcce9bf 100644 --- a/src/app/tests/suites/certification/Test_TC_MF_1_5.yaml +++ b/src/app/tests/suites/certification/Test_TC_MF_1_5.yaml @@ -76,31 +76,7 @@ tests: arguments: values: - name: "ms" - value: 54000 - - - label: "Wait for PIXIT_COMM_WIN(180) + 10 seconds" - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 54000 - - - label: "Wait for PIXIT_COMM_WIN(180) + 10 seconds" - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 54000 - - - label: "Wait for PIXIT_COMM_WIN(180) + 10 seconds" - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 28000 + value: 190000 - label: "TH_CR2 starts a commissioning process with DUT_CE" identity: "beta" diff --git a/src/app/tests/suites/certification/Test_TC_MF_1_6.yaml b/src/app/tests/suites/certification/Test_TC_MF_1_6.yaml index c749c95dc5c958..2fb15ce3b7dbed 100644 --- a/src/app/tests/suites/certification/Test_TC_MF_1_6.yaml +++ b/src/app/tests/suites/certification/Test_TC_MF_1_6.yaml @@ -75,31 +75,7 @@ tests: arguments: values: - name: "ms" - value: 54000 - - - label: "Wait for PIXIT_COMM_WIN(180) + 10" - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 54000 - - - label: "Wait for PIXIT_COMM_WIN(180) + 10" - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 54000 - - - label: "Wait for PIXIT_COMM_WIN(180) + 10" - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 28000 + value: 190000 - label: "Commission from beta" identity: "beta" diff --git a/src/app/tests/suites/certification/Test_TC_MF_1_9.yaml b/src/app/tests/suites/certification/Test_TC_MF_1_9.yaml index 4022bf84d2996e..ad3116782d7c7a 100644 --- a/src/app/tests/suites/certification/Test_TC_MF_1_9.yaml +++ b/src/app/tests/suites/certification/Test_TC_MF_1_9.yaml @@ -18,46 +18,385 @@ name: config: nodeId: 0x12344321 - cluster: "Basic" + timeout: 700 + nodeIdForDuplicateCommissioning: + type: NODE_ID + defaultValue: 0x11 + nodeId2: + type: NODE_ID + defaultValue: 0xCAFE + nodeId3: + type: NODE_ID + defaultValue: 0xC00FEE endpoint: 0 + discriminator: + type: INT16U + defaultValue: 3840 + payload: + type: CHAR_STRING + defaultValue: "MT:-24J0AFN00KA0648G00" + payload2: + type: CHAR_STRING + defaultValue: "MT:0000000000I.0648G00" tests: + - label: "Reboot target device" + cluster: "SystemCommands" + command: "Reboot" + arguments: + values: + - name: "discriminator" + value: discriminator + - label: "TH_CR1 starts a commissioning process with DUT_CE" - verification: | - 1. Provision the device using 1st python controller on the raspi (use above instructions) - disabled: true + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId + + - label: "TH_CR1 opens a new commissioning window on DUT_CE" + cluster: "AdministratorCommissioning" + command: "OpenCommissioningWindow" + timedInteractionTimeoutMs: 10000 + arguments: + values: + - name: "CommissioningTimeout" + value: 180 + - name: "PAKEVerifier" + value: "\x06\xc7\x56\xdf\xfc\xd7\x22\x65\x34\x52\xa1\x2d\xcd\x94\x5d\x8c\x54\xda\x2b\x0f\x3c\xbd\x1b\x4d\xc3\xf1\xad\xb2\x23\xae\xb2\x6b\x04\x7c\xd2\x4c\x96\x86\x6f\x97\x9b\x1d\x83\xec\x50\xe2\xb4\xae\x30\xcd\xf2\xfd\xb3\x2b\xd8\xa2\x11\xb8\x37\xdc\x94\xed\xcd\x56\xf4\xd1\x43\x77\x19\x10\x76\xbf\xc5\x9d\x99\xb7\xdd\x30\x53\xef\xd6\xf0\x2c\x44\x34\xf2\xbd\xd2\x7a\xa4\xf9\xce\xa7\x0d\x73\x8e\x4c" + - name: "discriminator" + value: discriminator + - name: "iterations" + value: 1000 + - name: "salt" + value: "SPAKE2P Key Salt" + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE - label: - "TH_CR1 opens a commissioning window on DUT_CE using a commissioning - timeout of PIXIT_COMM_WIN seconds using ECM" - verification: | - On 1st controller, using chip-tool, send the open-commissioning-window CMD for ECM. -t stands for timeout value, -o for OriginalSetupCode/TokenWithRandomPIN/TokenWithProvidedPIN , -d for descriminator -i for iteration count. Ref to cmd help. + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE - ./chip-tool pairing open-commissioning-window 1 1 200 1000 3840 + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE - [1635864513.699433][3850:3855] CHIP:DMG: ICR moving to [CommandSen] - [1635864513.699489][3850:3855] CHIP:CTL: Manual pairing code: [36177160937] - [1635864513.699566][3850:3855] CHIP:CTL: SetupQRCode: [MT:00000CQM00YZN476420] - [1635864513.699636][3850:3855] CHIP:EM: Sending Standalone Ack for MessageCounter:2599714227 on exchange 60688i - [1635864513.699685][3850:3855] CHIP:IN: Prepared plaintext message 0xffff8a7cd960 to 0x0000000000000000 of type 0x10 and protocolId (0, 0) on exchange 60688i with MessageCounter:3019982536. - [1635864513.699737][3850:3855] CHIP:IN: Sending plaintext msg 0xffff8a7cd960 with MessageCounter:3019982536 to 0x0000000000000000 at monotonic time: 6085358 msec - [1635864513.699834][3850:3855] CHIP:EM: Flushed pending ack for MessageCounter:2599714227 on exchange 60688i + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE - The setup pin code is extracted from the manual pairing code in the log and that will be used when pairing the 2nd admin controller. - disabled: true + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE - label: - "Set up a TH_CR2 to start attempting to do PASE to DUT_CE and failing - 20 times. This can be done using an invalid passcode" - verification: | - 1. On 2nd controller using chip-tool connect using wrong manual code. Repeat the step for 20 times. + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE - ./chip-tool pairing code 1 36177160938 (With wrong manual code) - disabled: true + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE - - label: "TH_CR2 starts a 21st commissioning process" - verification: | - 1. On 2nd controller using chip tool connect using correct passcode. + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE + + - label: + "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup + code" + identity: "beta" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId2 + - name: "payload" + value: payload2 + response: + error: FAILURE - ./chip-tool pairing code 1 36177160937 (correct passcode) - disabled: true + - label: "TH_CR3 starts a commissioning process with DUT_CE" + identity: "gamma" + cluster: "CommissionerCommands" + command: "PairWithCode" + arguments: + values: + - name: "nodeId" + value: nodeId3 + - name: "payload" + value: payload + response: + error: FAILURE diff --git a/src/app/tests/suites/tests.js b/src/app/tests/suites/tests.js index ac0ff6cd9bf22d..0601716cc8e728 100644 --- a/src/app/tests/suites/tests.js +++ b/src/app/tests/suites/tests.js @@ -228,8 +228,6 @@ function getManualTests() { 'Test_TC_MF_1_2', 'Test_TC_MF_1_7', 'Test_TC_MF_1_8', - 'Test_TC_MF_1_9', - 'Test_TC_MF_1_10', 'Test_TC_MF_1_11', 'Test_TC_MF_1_12', 'Test_TC_MF_1_13', @@ -642,6 +640,8 @@ function getTests() { 'Test_TC_MF_1_4', 'Test_TC_MF_1_5', 'Test_TC_MF_1_6', + 'Test_TC_MF_1_9', + 'Test_TC_MF_1_10', 'Test_TC_MF_1_15', ]; diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 6b404f77b111ba..3a63f8d86d752e 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -122,6 +122,8 @@ class TestList : public Command printf("Test_TC_MF_1_4\n"); printf("Test_TC_MF_1_5\n"); printf("Test_TC_MF_1_6\n"); + printf("Test_TC_MF_1_9\n"); + printf("Test_TC_MF_1_10\n"); printf("Test_TC_MF_1_15\n"); printf("OTA_SuccessfulTransfer\n"); printf("Test_TC_OCC_1_1\n"); @@ -388,8 +390,6 @@ class ManualTestList : public Command printf("Test_TC_MF_1_2\n"); printf("Test_TC_MF_1_7\n"); printf("Test_TC_MF_1_8\n"); - printf("Test_TC_MF_1_9\n"); - printf("Test_TC_MF_1_10\n"); printf("Test_TC_MF_1_11\n"); printf("Test_TC_MF_1_12\n"); printf("Test_TC_MF_1_13\n"); @@ -21693,7 +21693,7 @@ class Test_TC_MF_1_4Suite : public TestCommand class Test_TC_MF_1_5Suite : public TestCommand { public: - Test_TC_MF_1_5Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_MF_1_5", 17, credsIssuerConfig) + Test_TC_MF_1_5Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_MF_1_5", 14, credsIssuerConfig) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); AddArgument("timeout", 0, UINT16_MAX, &mTimeout); @@ -21747,38 +21747,26 @@ class Test_TC_MF_1_5Suite : public TestCommand shouldContinue = true; break; case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); shouldContinue = true; break; case 5: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; break; case 6: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; break; case 7: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); shouldContinue = true; break; case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 9: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - shouldContinue = true; - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { chip::CharSpan value; @@ -21786,14 +21774,14 @@ class Test_TC_MF_1_5Suite : public TestCommand VerifyOrReturn(CheckValueAsString("nodeLabel", value, chip::CharSpan("chiptest", 8))); } break; - case 14: + case 11: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; - case 15: + case 12: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); shouldContinue = true; break; - case 16: + case 13: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); shouldContinue = true; break; @@ -21849,29 +21837,46 @@ class Test_TC_MF_1_5Suite : public TestCommand LogStep(3, "Wait for PIXIT_COMM_WIN(180) + 10 seconds"); ListFreer listFreer; chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; + value.ms = 190000UL; return WaitForMs(kIdentityAlpha, value); } case 4: { - LogStep(4, "Wait for PIXIT_COMM_WIN(180) + 10 seconds"); + LogStep(4, "TH_CR2 starts a commissioning process with DUT_CE"); ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs(kIdentityAlpha, value); + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode(kIdentityBeta, value); } case 5: { - LogStep(5, "Wait for PIXIT_COMM_WIN(180) + 10 seconds"); + LogStep(5, "TH_CR1 opens a new commissioning window on DUT_CE"); ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs(kIdentityAlpha, value); + chip::app::Clusters::AdministratorCommissioning::Commands::OpenCommissioningWindow::Type value; + value.commissioningTimeout = 180U; + value.PAKEVerifier = chip::ByteSpan( + chip::Uint8::from_const_char("\006\307V\337\374\327\042e4R\241-\315\224]\214T\332+\017<\275\033M\303\361\255\262#" + "\256\262k\004|\322L\226\206o\227\233\035\203\354P\342\264\2560\315\362\375\263+" + "\330\242\021\2707\334\224\355\315V\364\321Cw\031\020v\277\305\235\231\267\3350S\357" + "\326\360,D4\362\275\322z\244\371\316\247\015s\216Lgarbage: not in length on purpose"), + 97); + value.discriminator = 3840U; + value.iterations = 1000UL; + value.salt = chip::ByteSpan(chip::Uint8::from_const_char("SPAKE2P Key Saltgarbage: not in length on purpose"), 16); + return SendCommand(kIdentityAlpha, GetEndpoint(0), AdministratorCommissioning::Id, + AdministratorCommissioning::Commands::OpenCommissioningWindow::Id, value, + chip::Optional(10000), chip::NullOptional + + ); } case 6: { - LogStep(6, "Wait for PIXIT_COMM_WIN(180) + 10 seconds"); + LogStep(6, "TH_CR1 revokes the commissioning window on DUT_CE"); ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 28000UL; - return WaitForMs(kIdentityAlpha, value); + chip::app::Clusters::AdministratorCommissioning::Commands::RevokeCommissioning::Type value; + return SendCommand(kIdentityAlpha, GetEndpoint(0), AdministratorCommissioning::Id, + AdministratorCommissioning::Commands::RevokeCommissioning::Id, value, + chip::Optional(10000), chip::NullOptional + + ); } case 7: { LogStep(7, "TH_CR2 starts a commissioning process with DUT_CE"); @@ -21882,7 +21887,30 @@ class Test_TC_MF_1_5Suite : public TestCommand return PairWithCode(kIdentityBeta, value); } case 8: { - LogStep(8, "TH_CR1 opens a new commissioning window on DUT_CE"); + LogStep(8, "TH_CR1 revokes the commissioning window on DUT_CE"); + ListFreer listFreer; + chip::app::Clusters::AdministratorCommissioning::Commands::RevokeCommissioning::Type value; + return SendCommand(kIdentityAlpha, GetEndpoint(0), AdministratorCommissioning::Id, + AdministratorCommissioning::Commands::RevokeCommissioning::Id, value, + chip::Optional(10000), chip::NullOptional + + ); + } + case 9: { + LogStep(9, "TH_CR1 writes the mandatory attribute NodeLabel of DUT_CE"); + ListFreer listFreer; + chip::CharSpan value; + value = chip::Span("chiptestgarbage: not in length on purpose", 8); + return WriteAttribute(kIdentityAlpha, GetEndpoint(0), Basic::Id, Basic::Attributes::NodeLabel::Id, value, + chip::NullOptional, chip::NullOptional); + } + case 10: { + LogStep(10, "TH_CR1 read the mandatory attribute NodeLabel of DUT_CE"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(0), Basic::Id, Basic::Attributes::NodeLabel::Id, true, + chip::NullOptional); + } + case 11: { + LogStep(11, "TH_CR1 opens a new commissioning window on DUT_CE"); ListFreer listFreer; chip::app::Clusters::AdministratorCommissioning::Commands::OpenCommissioningWindow::Type value; value.commissioningTimeout = 180U; @@ -21901,8 +21929,206 @@ class Test_TC_MF_1_5Suite : public TestCommand ); } - case 9: { - LogStep(9, "TH_CR1 revokes the commissioning window on DUT_CE"); + case 12: { + LogStep(12, "TH_CR2 starts a commissioning process with DUT_CE"); + VerifyOrDo(!ShouldSkip("PICS_SKIP_SAMPLE_APP"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 13: { + LogStep(13, "TH_CR3 starts a commissioning process with DUT_CE"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId3.HasValue() ? mNodeId3.Value() : 12586990ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode(kIdentityGamma, value); + } + } + return CHIP_NO_ERROR; + } +}; + +class Test_TC_MF_1_6Suite : public TestCommand +{ +public: + Test_TC_MF_1_6Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_MF_1_6", 16, credsIssuerConfig) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + AddArgument("nodeIdForDuplicateCommissioning", 0, UINT64_MAX, &mNodeIdForDuplicateCommissioning); + AddArgument("nodeId2", 0, UINT64_MAX, &mNodeId2); + AddArgument("nodeId3", 0, UINT64_MAX, &mNodeId3); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); + AddArgument("payload", &mPayload); + } + + ~Test_TC_MF_1_6Suite() {} + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(300)); } + +private: + chip::Optional mNodeId; + chip::Optional mTimeout; + chip::Optional mNodeIdForDuplicateCommissioning; + chip::Optional mNodeId2; + chip::Optional mNodeId3; + chip::Optional mEndpoint; + chip::Optional mDiscriminator; + chip::Optional mPayload; + + chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } + + // + // Tests methods + // + + void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override + { + bool shouldContinue = false; + + switch (mTestIndex - 1) + { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + shouldContinue = true; + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + shouldContinue = true; + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + shouldContinue = true; + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + shouldContinue = true; + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::CharSpan value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValueAsString("nodeLabel", value, chip::CharSpan("chiptest", 8))); + } + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + shouldContinue = true; + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + shouldContinue = true; + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + default: + LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); + } + + if (shouldContinue) + { + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + } + + CHIP_ERROR DoTestStep(uint16_t testIndex) override + { + using namespace chip::app::Clusters; + switch (testIndex) + { + case 0: { + LogStep(0, "Stop target device"); + ListFreer listFreer; + chip::app::Clusters::SystemCommands::Commands::Stop::Type value; + return Stop(kIdentityAlpha, value); + } + case 1: { + LogStep(1, "Start target device with the provided discriminator for basic commissioning advertisement"); + ListFreer listFreer; + chip::app::Clusters::SystemCommands::Commands::Start::Type value; + value.discriminator.Emplace(); + value.discriminator.Value() = mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U; + return Start(kIdentityAlpha, value); + } + case 2: { + LogStep(2, "TH_CR1 starts a commissioning process with DUT_CE"); + ListFreer listFreer; + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee(kIdentityAlpha, value); + } + case 3: { + LogStep(3, "TH_CR1 opens a commissioning window on DUT_CE"); + ListFreer listFreer; + chip::app::Clusters::AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Type value; + value.commissioningTimeout = 180U; + return SendCommand(kIdentityAlpha, GetEndpoint(0), AdministratorCommissioning::Id, + AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Id, value, + chip::Optional(10000), chip::NullOptional + + ); + } + case 4: { + LogStep(4, "Wait for PIXIT_COMM_WIN(180) + 10"); + ListFreer listFreer; + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 190000UL; + return WaitForMs(kIdentityAlpha, value); + } + case 5: { + LogStep(5, "Commission from beta"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 6: { + LogStep(6, "TH_CR1 opens a commissioning window on DUT_CE"); + ListFreer listFreer; + chip::app::Clusters::AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Type value; + value.commissioningTimeout = 180U; + return SendCommand(kIdentityAlpha, GetEndpoint(0), AdministratorCommissioning::Id, + AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Id, value, + chip::Optional(10000), chip::NullOptional + + ); + } + case 7: { + LogStep(7, "TH_CR1 revokes the commissioning window on DUT_CE"); ListFreer listFreer; chip::app::Clusters::AdministratorCommissioning::Commands::RevokeCommissioning::Type value; return SendCommand(kIdentityAlpha, GetEndpoint(0), AdministratorCommissioning::Id, @@ -21911,16 +22137,16 @@ class Test_TC_MF_1_5Suite : public TestCommand ); } - case 10: { - LogStep(10, "TH_CR2 starts a commissioning process with DUT_CE"); + case 8: { + LogStep(8, "Commission from beta"); ListFreer listFreer; chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); return PairWithCode(kIdentityBeta, value); } - case 11: { - LogStep(11, "TH_CR1 revokes the commissioning window on DUT_CE"); + case 9: { + LogStep(9, "TH_CR1 revokes the commissioning window on DUT_CE"); ListFreer listFreer; chip::app::Clusters::AdministratorCommissioning::Commands::RevokeCommissioning::Type value; return SendCommand(kIdentityAlpha, GetEndpoint(0), AdministratorCommissioning::Id, @@ -21929,21 +22155,230 @@ class Test_TC_MF_1_5Suite : public TestCommand ); } - case 12: { - LogStep(12, "TH_CR1 writes the mandatory attribute NodeLabel of DUT_CE"); + case 10: { + LogStep(10, "TH_CR1 writes the mandatory attribute NodeLabel of DUT_CE"); ListFreer listFreer; chip::CharSpan value; value = chip::Span("chiptestgarbage: not in length on purpose", 8); return WriteAttribute(kIdentityAlpha, GetEndpoint(0), Basic::Id, Basic::Attributes::NodeLabel::Id, value, chip::NullOptional, chip::NullOptional); } - case 13: { - LogStep(13, "TH_CR1 read the mandatory attribute NodeLabel of DUT_CE"); + case 11: { + LogStep(11, "TH_CR1 read the mandatory attribute NodeLabel of DUT_CE"); return ReadAttribute(kIdentityAlpha, GetEndpoint(0), Basic::Id, Basic::Attributes::NodeLabel::Id, true, chip::NullOptional); } + case 12: { + LogStep(12, "TH_CR1 opens a commissioning window on DUT_CE"); + ListFreer listFreer; + chip::app::Clusters::AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Type value; + value.commissioningTimeout = 180U; + return SendCommand(kIdentityAlpha, GetEndpoint(0), AdministratorCommissioning::Id, + AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Id, value, + chip::Optional(10000), chip::NullOptional + + ); + } + case 13: { + LogStep(13, "Commission from beta"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } case 14: { - LogStep(14, "TH_CR1 opens a new commissioning window on DUT_CE"); + LogStep(14, "TH_CR2 starts a commissioning process on DUT_CE"); + ListFreer listFreer; + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + return WaitForCommissionee(kIdentityBeta, value); + } + case 15: { + LogStep(15, "TH_CR3 starts a commissioning process with DUT_CE"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId3.HasValue() ? mNodeId3.Value() : 12586990ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode(kIdentityGamma, value); + } + } + return CHIP_NO_ERROR; + } +}; + +class Test_TC_MF_1_9Suite : public TestCommand +{ +public: + Test_TC_MF_1_9Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_MF_1_9", 25, credsIssuerConfig) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + AddArgument("nodeIdForDuplicateCommissioning", 0, UINT64_MAX, &mNodeIdForDuplicateCommissioning); + AddArgument("nodeId2", 0, UINT64_MAX, &mNodeId2); + AddArgument("nodeId3", 0, UINT64_MAX, &mNodeId3); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); + AddArgument("payload", &mPayload); + AddArgument("payload2", &mPayload2); + } + + ~Test_TC_MF_1_9Suite() {} + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(700)); } + +private: + chip::Optional mNodeId; + chip::Optional mTimeout; + chip::Optional mNodeIdForDuplicateCommissioning; + chip::Optional mNodeId2; + chip::Optional mNodeId3; + chip::Optional mEndpoint; + chip::Optional mDiscriminator; + chip::Optional mPayload; + chip::Optional mPayload2; + + chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } + + // + // Tests methods + // + + void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override + { + bool shouldContinue = false; + + switch (mTestIndex - 1) + { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + shouldContinue = true; + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + shouldContinue = true; + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + default: + LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); + } + + if (shouldContinue) + { + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + } + + CHIP_ERROR DoTestStep(uint16_t testIndex) override + { + using namespace chip::app::Clusters; + switch (testIndex) + { + case 0: { + LogStep(0, "Reboot target device"); + ListFreer listFreer; + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot(kIdentityAlpha, value); + } + case 1: { + LogStep(1, "TH_CR1 starts a commissioning process with DUT_CE"); + ListFreer listFreer; + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee(kIdentityAlpha, value); + } + case 2: { + LogStep(2, "TH_CR1 opens a new commissioning window on DUT_CE"); ListFreer listFreer; chip::app::Clusters::AdministratorCommissioning::Commands::OpenCommissioningWindow::Type value; value.commissioningTimeout = 180U; @@ -21953,7 +22388,7 @@ class Test_TC_MF_1_5Suite : public TestCommand "\330\242\021\2707\334\224\355\315V\364\321Cw\031\020v\277\305\235\231\267\3350S\357" "\326\360,D4\362\275\322z\244\371\316\247\015s\216Lgarbage: not in length on purpose"), 97); - value.discriminator = 3840U; + value.discriminator = mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U; value.iterations = 1000UL; value.salt = chip::ByteSpan(chip::Uint8::from_const_char("SPAKE2P Key Saltgarbage: not in length on purpose"), 16); return SendCommand(kIdentityAlpha, GetEndpoint(0), AdministratorCommissioning::Id, @@ -21962,17 +22397,176 @@ class Test_TC_MF_1_5Suite : public TestCommand ); } + case 3: { + LogStep(3, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 4: { + LogStep(4, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 5: { + LogStep(5, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 6: { + LogStep(6, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 7: { + LogStep(7, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 8: { + LogStep(8, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 9: { + LogStep(9, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 10: { + LogStep(10, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 11: { + LogStep(11, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 12: { + LogStep(12, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 13: { + LogStep(13, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 14: { + LogStep(14, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } case 15: { - LogStep(15, "TH_CR2 starts a commissioning process with DUT_CE"); - VerifyOrDo(!ShouldSkip("PICS_SKIP_SAMPLE_APP"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); + LogStep(15, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); ListFreer listFreer; chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); return PairWithCode(kIdentityBeta, value); } case 16: { - LogStep(16, "TH_CR3 starts a commissioning process with DUT_CE"); + LogStep(16, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 17: { + LogStep(17, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 18: { + LogStep(18, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 19: { + LogStep(19, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 20: { + LogStep(20, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 21: { + LogStep(21, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 22: { + LogStep(22, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 23: { + LogStep(23, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 24: { + LogStep(24, "TH_CR3 starts a commissioning process with DUT_CE"); ListFreer listFreer; chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; value.nodeId = mNodeId3.HasValue() ? mNodeId3.Value() : 12586990ULL; @@ -21984,10 +22578,10 @@ class Test_TC_MF_1_5Suite : public TestCommand } }; -class Test_TC_MF_1_6Suite : public TestCommand +class Test_TC_MF_1_10Suite : public TestCommand { public: - Test_TC_MF_1_6Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_MF_1_6", 19, credsIssuerConfig) + Test_TC_MF_1_10Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_MF_1_10", 25, credsIssuerConfig) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); AddArgument("timeout", 0, UINT16_MAX, &mTimeout); @@ -21997,11 +22591,12 @@ class Test_TC_MF_1_6Suite : public TestCommand AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); AddArgument("payload", &mPayload); + AddArgument("payload2", &mPayload2); } - ~Test_TC_MF_1_6Suite() {} + ~Test_TC_MF_1_10Suite() {} - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(300)); } + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(700)); } private: chip::Optional mNodeId; @@ -22012,6 +22607,7 @@ class Test_TC_MF_1_6Suite : public TestCommand chip::Optional mEndpoint; chip::Optional mDiscriminator; chip::Optional mPayload; + chip::Optional mPayload2; chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } @@ -22035,25 +22631,25 @@ class Test_TC_MF_1_6Suite : public TestCommand break; case 2: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; break; case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; break; case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); shouldContinue = true; break; case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); shouldContinue = true; break; case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); shouldContinue = true; break; case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); shouldContinue = true; break; case 8: @@ -22061,10 +22657,12 @@ class Test_TC_MF_1_6Suite : public TestCommand shouldContinue = true; break; case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; break; case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; break; case 11: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); @@ -22072,33 +22670,56 @@ class Test_TC_MF_1_6Suite : public TestCommand break; case 12: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; break; case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; break; case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::CharSpan value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValueAsString("nodeLabel", value, chip::CharSpan("chiptest", 8))); - } + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; break; case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; break; case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); shouldContinue = true; break; case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); shouldContinue = true; break; case 18: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); shouldContinue = true; break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + shouldContinue = true; + break; default: LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); } @@ -22115,28 +22736,20 @@ class Test_TC_MF_1_6Suite : public TestCommand switch (testIndex) { case 0: { - LogStep(0, "Stop target device"); + LogStep(0, "Reboot target device"); ListFreer listFreer; - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop(kIdentityAlpha, value); + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot(kIdentityAlpha, value); } case 1: { - LogStep(1, "Start target device with the provided discriminator for basic commissioning advertisement"); - ListFreer listFreer; - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.discriminator.Emplace(); - value.discriminator.Value() = mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U; - return Start(kIdentityAlpha, value); - } - case 2: { - LogStep(2, "TH_CR1 starts a commissioning process with DUT_CE"); + LogStep(1, "TH_CR1 starts a commissioning process with DUT_CE"); ListFreer listFreer; chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; return WaitForCommissionee(kIdentityAlpha, value); } - case 3: { - LogStep(3, "TH_CR1 opens a commissioning window on DUT_CE"); + case 2: { + LogStep(2, "TH_CR1 opens a commissioning window on DUT_CE"); ListFreer listFreer; chip::app::Clusters::AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Type value; value.commissioningTimeout = 180U; @@ -22146,126 +22759,180 @@ class Test_TC_MF_1_6Suite : public TestCommand ); } + case 3: { + LogStep(3, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } case 4: { - LogStep(4, "Wait for PIXIT_COMM_WIN(180) + 10"); + LogStep(4, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs(kIdentityAlpha, value); + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); } case 5: { - LogStep(5, "Wait for PIXIT_COMM_WIN(180) + 10"); + LogStep(5, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs(kIdentityAlpha, value); + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); } case 6: { - LogStep(6, "Wait for PIXIT_COMM_WIN(180) + 10"); + LogStep(6, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs(kIdentityAlpha, value); + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); } case 7: { - LogStep(7, "Wait for PIXIT_COMM_WIN(180) + 10"); + LogStep(7, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 28000UL; - return WaitForMs(kIdentityAlpha, value); + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); } case 8: { - LogStep(8, "Commission from beta"); + LogStep(8, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); ListFreer listFreer; chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); return PairWithCode(kIdentityBeta, value); } case 9: { - LogStep(9, "TH_CR1 opens a commissioning window on DUT_CE"); + LogStep(9, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); ListFreer listFreer; - chip::app::Clusters::AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Type value; - value.commissioningTimeout = 180U; - return SendCommand(kIdentityAlpha, GetEndpoint(0), AdministratorCommissioning::Id, - AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Id, value, - chip::Optional(10000), chip::NullOptional - - ); + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); } case 10: { - LogStep(10, "TH_CR1 revokes the commissioning window on DUT_CE"); + LogStep(10, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); ListFreer listFreer; - chip::app::Clusters::AdministratorCommissioning::Commands::RevokeCommissioning::Type value; - return SendCommand(kIdentityAlpha, GetEndpoint(0), AdministratorCommissioning::Id, - AdministratorCommissioning::Commands::RevokeCommissioning::Id, value, - chip::Optional(10000), chip::NullOptional - - ); + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); } case 11: { - LogStep(11, "Commission from beta"); + LogStep(11, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); ListFreer listFreer; chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); return PairWithCode(kIdentityBeta, value); } case 12: { - LogStep(12, "TH_CR1 revokes the commissioning window on DUT_CE"); + LogStep(12, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); ListFreer listFreer; - chip::app::Clusters::AdministratorCommissioning::Commands::RevokeCommissioning::Type value; - return SendCommand(kIdentityAlpha, GetEndpoint(0), AdministratorCommissioning::Id, - AdministratorCommissioning::Commands::RevokeCommissioning::Id, value, - chip::Optional(10000), chip::NullOptional - - ); + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); } case 13: { - LogStep(13, "TH_CR1 writes the mandatory attribute NodeLabel of DUT_CE"); + LogStep(13, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); ListFreer listFreer; - chip::CharSpan value; - value = chip::Span("chiptestgarbage: not in length on purpose", 8); - return WriteAttribute(kIdentityAlpha, GetEndpoint(0), Basic::Id, Basic::Attributes::NodeLabel::Id, value, - chip::NullOptional, chip::NullOptional); + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); } case 14: { - LogStep(14, "TH_CR1 read the mandatory attribute NodeLabel of DUT_CE"); - return ReadAttribute(kIdentityAlpha, GetEndpoint(0), Basic::Id, Basic::Attributes::NodeLabel::Id, true, - chip::NullOptional); + LogStep(14, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); } case 15: { - LogStep(15, "TH_CR1 opens a commissioning window on DUT_CE"); + LogStep(15, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); ListFreer listFreer; - chip::app::Clusters::AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Type value; - value.commissioningTimeout = 180U; - return SendCommand(kIdentityAlpha, GetEndpoint(0), AdministratorCommissioning::Id, - AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Id, value, - chip::Optional(10000), chip::NullOptional - - ); + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); } case 16: { - LogStep(16, "Commission from beta"); + LogStep(16, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); ListFreer listFreer; chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); return PairWithCode(kIdentityBeta, value); } case 17: { - LogStep(17, "TH_CR2 starts a commissioning process on DUT_CE"); + LogStep(17, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - return WaitForCommissionee(kIdentityBeta, value); + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); } case 18: { - LogStep(18, "TH_CR3 starts a commissioning process with DUT_CE"); + LogStep(18, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 19: { + LogStep(19, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 20: { + LogStep(20, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 21: { + LogStep(21, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 22: { + LogStep(22, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 23: { + LogStep(23, "TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code"); + ListFreer listFreer; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode(kIdentityBeta, value); + } + case 24: { + LogStep(24, "TH_CR3 starts a commissioning process with DUT_CE"); ListFreer listFreer; chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; value.nodeId = mNodeId3.HasValue() ? mNodeId3.Value() : 12586990ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:0000000000I31506010", 22); return PairWithCode(kIdentityGamma, value); } } @@ -22276,7 +22943,7 @@ class Test_TC_MF_1_6Suite : public TestCommand class Test_TC_MF_1_15Suite : public TestCommand { public: - Test_TC_MF_1_15Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_MF_1_15", 24, credsIssuerConfig) + Test_TC_MF_1_15Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_MF_1_15", 18, credsIssuerConfig) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); AddArgument("timeout", 0, UINT16_MAX, &mTimeout); @@ -22376,23 +23043,11 @@ class Test_TC_MF_1_15Suite : public TestCommand break; case 12: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; break; case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; - case 17: + case 14: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { chip::app::DataModel::DecodableList< @@ -22412,26 +23067,14 @@ class Test_TC_MF_1_15Suite : public TestCommand VerifyOrReturn(CheckConstraintType("value", "", "list")); } break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 21: + case 15: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); shouldContinue = true; break; - case 22: + case 16: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; - case 23: + case 17: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; default: @@ -22554,32 +23197,11 @@ class Test_TC_MF_1_15Suite : public TestCommand LogStep(11, "Wait for the expiration of PIXIT_COMM_WIN seconds"); ListFreer listFreer; chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; + value.ms = 180000UL; return WaitForMs(kIdentityAlpha, value); } case 12: { - LogStep(12, "Wait for the expiration of PIXIT_COMM_WIN seconds"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 13: { - LogStep(13, "Wait for the expiration of PIXIT_COMM_WIN seconds"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 14: { - LogStep(14, "Wait for the expiration of PIXIT_COMM_WIN seconds"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 18000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 15: { - LogStep(15, "TH_CR1 re-opens new commissioning window on DUT_CE"); + LogStep(12, "TH_CR1 re-opens new commissioning window on DUT_CE"); ListFreer listFreer; chip::app::Clusters::AdministratorCommissioning::Commands::OpenCommissioningWindow::Type value; value.commissioningTimeout = 180U; @@ -22598,8 +23220,8 @@ class Test_TC_MF_1_15Suite : public TestCommand ); } - case 16: { - LogStep(16, "TH_CR3 opens a new commissioning window on DUT_CE"); + case 13: { + LogStep(13, "TH_CR3 opens a new commissioning window on DUT_CE"); ListFreer listFreer; chip::app::Clusters::AdministratorCommissioning::Commands::OpenCommissioningWindow::Type value; value.commissioningTimeout = 180U; @@ -22618,41 +23240,20 @@ class Test_TC_MF_1_15Suite : public TestCommand ); } - case 17: { - LogStep(17, "TH_CR1 reads the list of Fabrics on DUT_CE"); + case 14: { + LogStep(14, "TH_CR1 reads the list of Fabrics on DUT_CE"); return ReadAttribute(kIdentityAlpha, GetEndpoint(0), OperationalCredentials::Id, OperationalCredentials::Attributes::Fabrics::Id, false, chip::NullOptional); } - case 18: { - LogStep(18, "Wait for the expiration of PIXIT_COMM_WIN seconds"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 19: { - LogStep(19, "Wait for the expiration of PIXIT_COMM_WIN seconds"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 20: { - LogStep(20, "Wait for the expiration of PIXIT_COMM_WIN seconds"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 21: { - LogStep(21, "Wait for the expiration of PIXIT_COMM_WIN seconds"); + case 15: { + LogStep(15, "Wait for the expiration of PIXIT_COMM_WIN seconds"); ListFreer listFreer; chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 18000UL; + value.ms = 180000UL; return WaitForMs(kIdentityAlpha, value); } - case 22: { - LogStep(22, "TH_CR1 opens a new commissioning window on DUT_CE"); + case 16: { + LogStep(16, "TH_CR1 opens a new commissioning window on DUT_CE"); ListFreer listFreer; chip::app::Clusters::AdministratorCommissioning::Commands::OpenCommissioningWindow::Type value; value.commissioningTimeout = 180U; @@ -22671,8 +23272,8 @@ class Test_TC_MF_1_15Suite : public TestCommand ); } - case 23: { - LogStep(23, "TH_CR2 opens a new commissioning window on DUT_CE"); + case 17: { + LogStep(17, "TH_CR2 opens a new commissioning window on DUT_CE"); ListFreer listFreer; chip::app::Clusters::AdministratorCommissioning::Commands::OpenCommissioningWindow::Type value; value.commissioningTimeout = 180U; @@ -75538,118 +76139,6 @@ class Test_TC_MF_1_8Suite : public TestCommand } }; -class Test_TC_MF_1_9Suite : public TestCommand -{ -public: - Test_TC_MF_1_9Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_MF_1_9", 0, credsIssuerConfig) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_MF_1_9Suite() {} - - chip::System::Clock::Timeout GetWaitDuration() const override - { - return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); - } - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MF_1_10Suite : public TestCommand -{ -public: - Test_TC_MF_1_10Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_MF_1_10", 0, credsIssuerConfig) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_MF_1_10Suite() {} - - chip::System::Clock::Timeout GetWaitDuration() const override - { - return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); - } - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - } - return CHIP_NO_ERROR; - } -}; - class Test_TC_MF_1_11Suite : public TestCommand { public: @@ -83216,6 +83705,8 @@ void registerCommandsTests(Commands & commands, CredentialIssuerCommands * creds make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), @@ -83471,8 +83962,6 @@ void registerCommandsTests(Commands & commands, CredentialIssuerCommands * creds make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), - make_unique(credsIssuerConfig), - make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index 3c80c562841d5b..c2dc5476781413 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -121,6 +121,8 @@ class TestList : public Command { printf("Test_TC_MF_1_4\n"); printf("Test_TC_MF_1_5\n"); printf("Test_TC_MF_1_6\n"); + printf("Test_TC_MF_1_9\n"); + printf("Test_TC_MF_1_10\n"); printf("Test_TC_MF_1_15\n"); printf("OTA_SuccessfulTransfer\n"); printf("Test_TC_OCC_1_1\n"); @@ -35728,60 +35730,48 @@ class Test_TC_MF_1_5 : public TestCommandBridge { err = TestWaitForPixitCommWin18010Seconds_3(); break; case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait for PIXIT_COMM_WIN(180) + 10 seconds\n"); - err = TestWaitForPixitCommWin18010Seconds_4(); + ChipLogProgress(chipTool, " ***** Test Step 4 : TH_CR2 starts a commissioning process with DUT_CE\n"); + err = TestThCr2StartsACommissioningProcessWithDutCe_4(); break; case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for PIXIT_COMM_WIN(180) + 10 seconds\n"); - err = TestWaitForPixitCommWin18010Seconds_5(); + ChipLogProgress(chipTool, " ***** Test Step 5 : TH_CR1 opens a new commissioning window on DUT_CE\n"); + err = TestThCr1OpensANewCommissioningWindowOnDutCe_5(); break; case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait for PIXIT_COMM_WIN(180) + 10 seconds\n"); - err = TestWaitForPixitCommWin18010Seconds_6(); + ChipLogProgress(chipTool, " ***** Test Step 6 : TH_CR1 revokes the commissioning window on DUT_CE\n"); + err = TestThCr1RevokesTheCommissioningWindowOnDutCe_6(); break; case 7: ChipLogProgress(chipTool, " ***** Test Step 7 : TH_CR2 starts a commissioning process with DUT_CE\n"); err = TestThCr2StartsACommissioningProcessWithDutCe_7(); break; case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : TH_CR1 opens a new commissioning window on DUT_CE\n"); - err = TestThCr1OpensANewCommissioningWindowOnDutCe_8(); + ChipLogProgress(chipTool, " ***** Test Step 8 : TH_CR1 revokes the commissioning window on DUT_CE\n"); + err = TestThCr1RevokesTheCommissioningWindowOnDutCe_8(); break; case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : TH_CR1 revokes the commissioning window on DUT_CE\n"); - err = TestThCr1RevokesTheCommissioningWindowOnDutCe_9(); + ChipLogProgress(chipTool, " ***** Test Step 9 : TH_CR1 writes the mandatory attribute NodeLabel of DUT_CE\n"); + err = TestThCr1WritesTheMandatoryAttributeNodeLabelOfDutCe_9(); break; case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : TH_CR2 starts a commissioning process with DUT_CE\n"); - err = TestThCr2StartsACommissioningProcessWithDutCe_10(); + ChipLogProgress(chipTool, " ***** Test Step 10 : TH_CR1 read the mandatory attribute NodeLabel of DUT_CE\n"); + err = TestThCr1ReadTheMandatoryAttributeNodeLabelOfDutCe_10(); break; case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : TH_CR1 revokes the commissioning window on DUT_CE\n"); - err = TestThCr1RevokesTheCommissioningWindowOnDutCe_11(); + ChipLogProgress(chipTool, " ***** Test Step 11 : TH_CR1 opens a new commissioning window on DUT_CE\n"); + err = TestThCr1OpensANewCommissioningWindowOnDutCe_11(); break; case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : TH_CR1 writes the mandatory attribute NodeLabel of DUT_CE\n"); - err = TestThCr1WritesTheMandatoryAttributeNodeLabelOfDutCe_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : TH_CR1 read the mandatory attribute NodeLabel of DUT_CE\n"); - err = TestThCr1ReadTheMandatoryAttributeNodeLabelOfDutCe_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : TH_CR1 opens a new commissioning window on DUT_CE\n"); - err = TestThCr1OpensANewCommissioningWindowOnDutCe_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : TH_CR2 starts a commissioning process with DUT_CE\n"); + ChipLogProgress(chipTool, " ***** Test Step 12 : TH_CR2 starts a commissioning process with DUT_CE\n"); if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { NextTest(); return; } - err = TestThCr2StartsACommissioningProcessWithDutCe_15(); + err = TestThCr2StartsACommissioningProcessWithDutCe_12(); break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : TH_CR3 starts a commissioning process with DUT_CE\n"); - err = TestThCr3StartsACommissioningProcessWithDutCe_16(); + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : TH_CR3 starts a commissioning process with DUT_CE\n"); + err = TestThCr3StartsACommissioningProcessWithDutCe_13(); break; } @@ -35807,7 +35797,7 @@ class Test_TC_MF_1_5 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 5: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); @@ -35819,30 +35809,21 @@ class Test_TC_MF_1_5 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 9: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 12: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; } @@ -35855,7 +35836,7 @@ class Test_TC_MF_1_5 : public TestCommandBridge { private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 17; + const uint16_t mTestCount = 14; chip::Optional mNodeId; chip::Optional mTimeout; @@ -35913,32 +35894,11 @@ class Test_TC_MF_1_5 : public TestCommandBridge { CHIP_ERROR TestWaitForPixitCommWin18010Seconds_3() { chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestWaitForPixitCommWin18010Seconds_4() - { - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestWaitForPixitCommWin18010Seconds_5() - { - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestWaitForPixitCommWin18010Seconds_6() - { - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 28000UL; + value.ms = 190000UL; return WaitForMs("alpha", value); } - CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCe_7() + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCe_4() { chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; @@ -35946,7 +35906,7 @@ class Test_TC_MF_1_5 : public TestCommandBridge { return PairWithCode("beta", value); } - CHIP_ERROR TestThCr1OpensANewCommissioningWindowOnDutCe_8() + CHIP_ERROR TestThCr1OpensANewCommissioningWindowOnDutCe_5() { CHIPDevice * device = GetDevice("alpha"); CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device @@ -35977,7 +35937,7 @@ class Test_TC_MF_1_5 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestThCr1RevokesTheCommissioningWindowOnDutCe_9() + CHIP_ERROR TestThCr1RevokesTheCommissioningWindowOnDutCe_6() { CHIPDevice * device = GetDevice("alpha"); CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device @@ -35996,7 +35956,7 @@ class Test_TC_MF_1_5 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCe_10() + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCe_7() { chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; @@ -36004,7 +35964,7 @@ class Test_TC_MF_1_5 : public TestCommandBridge { return PairWithCode("beta", value); } - CHIP_ERROR TestThCr1RevokesTheCommissioningWindowOnDutCe_11() + CHIP_ERROR TestThCr1RevokesTheCommissioningWindowOnDutCe_8() { CHIPDevice * device = GetDevice("alpha"); CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device @@ -36022,7 +35982,7 @@ class Test_TC_MF_1_5 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestThCr1WritesTheMandatoryAttributeNodeLabelOfDutCe_12() + CHIP_ERROR TestThCr1WritesTheMandatoryAttributeNodeLabelOfDutCe_9() { CHIPDevice * device = GetDevice("alpha"); CHIPTestBasic * cluster = [[CHIPTestBasic alloc] initWithDevice:device endpoint:0 queue:mCallbackQueue]; @@ -36042,7 +36002,7 @@ class Test_TC_MF_1_5 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestThCr1ReadTheMandatoryAttributeNodeLabelOfDutCe_13() + CHIP_ERROR TestThCr1ReadTheMandatoryAttributeNodeLabelOfDutCe_10() { CHIPDevice * device = GetDevice("alpha"); CHIPTestBasic * cluster = [[CHIPTestBasic alloc] initWithDevice:device endpoint:0 queue:mCallbackQueue]; @@ -36064,7 +36024,7 @@ class Test_TC_MF_1_5 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestThCr1OpensANewCommissioningWindowOnDutCe_14() + CHIP_ERROR TestThCr1OpensANewCommissioningWindowOnDutCe_11() { CHIPDevice * device = GetDevice("alpha"); CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device @@ -36095,7 +36055,7 @@ class Test_TC_MF_1_5 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCe_15() + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCe_12() { chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; @@ -36103,7 +36063,7 @@ class Test_TC_MF_1_5 : public TestCommandBridge { return PairWithCode("beta", value); } - CHIP_ERROR TestThCr3StartsACommissioningProcessWithDutCe_16() + CHIP_ERROR TestThCr3StartsACommissioningProcessWithDutCe_13() { chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; value.nodeId = mNodeId3.HasValue() ? mNodeId3.Value() : 12586990ULL; @@ -36176,60 +36136,999 @@ class Test_TC_MF_1_6 : public TestCommandBridge { err = TestWaitForPixitCommWin18010_4(); break; case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for PIXIT_COMM_WIN(180) + 10\n"); - err = TestWaitForPixitCommWin18010_5(); + ChipLogProgress(chipTool, " ***** Test Step 5 : Commission from beta\n"); + err = TestCommissionFromBeta_5(); break; case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait for PIXIT_COMM_WIN(180) + 10\n"); - err = TestWaitForPixitCommWin18010_6(); + ChipLogProgress(chipTool, " ***** Test Step 6 : TH_CR1 opens a commissioning window on DUT_CE\n"); + err = TestThCr1OpensACommissioningWindowOnDutCe_6(); break; case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Wait for PIXIT_COMM_WIN(180) + 10\n"); - err = TestWaitForPixitCommWin18010_7(); + ChipLogProgress(chipTool, " ***** Test Step 7 : TH_CR1 revokes the commissioning window on DUT_CE\n"); + err = TestThCr1RevokesTheCommissioningWindowOnDutCe_7(); break; case 8: ChipLogProgress(chipTool, " ***** Test Step 8 : Commission from beta\n"); err = TestCommissionFromBeta_8(); break; case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : TH_CR1 opens a commissioning window on DUT_CE\n"); - err = TestThCr1OpensACommissioningWindowOnDutCe_9(); + ChipLogProgress(chipTool, " ***** Test Step 9 : TH_CR1 revokes the commissioning window on DUT_CE\n"); + err = TestThCr1RevokesTheCommissioningWindowOnDutCe_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : TH_CR1 writes the mandatory attribute NodeLabel of DUT_CE\n"); + err = TestThCr1WritesTheMandatoryAttributeNodeLabelOfDutCe_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : TH_CR1 read the mandatory attribute NodeLabel of DUT_CE\n"); + err = TestThCr1ReadTheMandatoryAttributeNodeLabelOfDutCe_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : TH_CR1 opens a commissioning window on DUT_CE\n"); + err = TestThCr1OpensACommissioningWindowOnDutCe_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Commission from beta\n"); + err = TestCommissionFromBeta_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : TH_CR2 starts a commissioning process on DUT_CE\n"); + err = TestThCr2StartsACommissioningProcessOnDutCe_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : TH_CR3 starts a commissioning process with DUT_CE\n"); + err = TestThCr3StartsACommissioningProcessWithDutCe_15(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(300)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 16; + + chip::Optional mNodeId; + chip::Optional mTimeout; + chip::Optional mNodeIdForDuplicateCommissioning; + chip::Optional mNodeId2; + chip::Optional mNodeId3; + chip::Optional mEndpoint; + chip::Optional mDiscriminator; + chip::Optional mPayload; + + CHIP_ERROR TestStopTargetDevice_0() + { + chip::app::Clusters::SystemCommands::Commands::Stop::Type value; + return Stop("alpha", value); + } + + CHIP_ERROR TestStartTargetDeviceWithTheProvidedDiscriminatorForBasicCommissioningAdvertisement_1() + { + chip::app::Clusters::SystemCommands::Commands::Start::Type value; + value.discriminator.Emplace(); + value.discriminator.Value() = mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U; + return Start("alpha", value); + } + + CHIP_ERROR TestThCr1StartsACommissioningProcessWithDutCe_2() + { + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestThCr1OpensACommissioningWindowOnDutCe_3() + { + CHIPDevice * device = GetDevice("alpha"); + CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device + endpoint:0 + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[CHIPAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; + params.commissioningTimeout = [NSNumber numberWithUnsignedShort:180U]; + [cluster openBasicCommissioningWindowWithParams:params + completionHandler:^(NSError * _Nullable err) { + NSLog(@"TH_CR1 opens a commissioning window on DUT_CE Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitForPixitCommWin18010_4() + { + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 190000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestCommissionFromBeta_5() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr1OpensACommissioningWindowOnDutCe_6() + { + CHIPDevice * device = GetDevice("alpha"); + CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device + endpoint:0 + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[CHIPAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; + params.commissioningTimeout = [NSNumber numberWithUnsignedShort:180U]; + [cluster openBasicCommissioningWindowWithParams:params + completionHandler:^(NSError * _Nullable err) { + NSLog(@"TH_CR1 opens a commissioning window on DUT_CE Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThCr1RevokesTheCommissioningWindowOnDutCe_7() + { + CHIPDevice * device = GetDevice("alpha"); + CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device + endpoint:0 + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster revokeCommissioningWithCompletionHandler:^(NSError * _Nullable err) { + NSLog(@"TH_CR1 revokes the commissioning window on DUT_CE Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCommissionFromBeta_8() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr1RevokesTheCommissioningWindowOnDutCe_9() + { + CHIPDevice * device = GetDevice("alpha"); + CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device + endpoint:0 + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster revokeCommissioningWithCompletionHandler:^(NSError * _Nullable err) { + NSLog(@"TH_CR1 revokes the commissioning window on DUT_CE Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, EMBER_ZCL_STATUS_FAILURE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThCr1WritesTheMandatoryAttributeNodeLabelOfDutCe_10() + { + CHIPDevice * device = GetDevice("alpha"); + CHIPTestBasic * cluster = [[CHIPTestBasic alloc] initWithDevice:device endpoint:0 queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nodeLabelArgument; + nodeLabelArgument = @"chiptest"; + [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument + completionHandler:^(NSError * _Nullable err) { + NSLog(@"TH_CR1 writes the mandatory attribute NodeLabel of DUT_CE Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThCr1ReadTheMandatoryAttributeNodeLabelOfDutCe_11() + { + CHIPDevice * device = GetDevice("alpha"); + CHIPTestBasic * cluster = [[CHIPTestBasic alloc] initWithDevice:device endpoint:0 queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNodeLabelWithCompletionHandler:^(NSString * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH_CR1 read the mandatory attribute NodeLabel of DUT_CE Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("NodeLabel", actualValue, @"chiptest")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThCr1OpensACommissioningWindowOnDutCe_12() + { + CHIPDevice * device = GetDevice("alpha"); + CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device + endpoint:0 + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[CHIPAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; + params.commissioningTimeout = [NSNumber numberWithUnsignedShort:180U]; + [cluster openBasicCommissioningWindowWithParams:params + completionHandler:^(NSError * _Nullable err) { + NSLog(@"TH_CR1 opens a commissioning window on DUT_CE Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCommissionFromBeta_13() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessOnDutCe_14() + { + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + return WaitForCommissionee("beta", value); + } + + CHIP_ERROR TestThCr3StartsACommissioningProcessWithDutCe_15() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId3.HasValue() ? mNodeId3.Value() : 12586990ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode("gamma", value); + } +}; + +class Test_TC_MF_1_9 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_MF_1_9() + : TestCommandBridge("Test_TC_MF_1_9") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + AddArgument("nodeIdForDuplicateCommissioning", 0, UINT64_MAX, &mNodeIdForDuplicateCommissioning); + AddArgument("nodeId2", 0, UINT64_MAX, &mNodeId2); + AddArgument("nodeId3", 0, UINT64_MAX, &mNodeId3); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); + AddArgument("payload", &mPayload); + AddArgument("payload2", &mPayload2); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_MF_1_9() {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_MF_1_9\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MF_1_9\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Reboot target device\n"); + err = TestRebootTargetDevice_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : TH_CR1 starts a commissioning process with DUT_CE\n"); + err = TestThCr1StartsACommissioningProcessWithDutCe_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : TH_CR1 opens a new commissioning window on DUT_CE\n"); + err = TestThCr1OpensANewCommissioningWindowOnDutCe_2(); + break; + case 3: + ChipLogProgress( + chipTool, " ***** Test Step 3 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_3(); + break; + case 4: + ChipLogProgress( + chipTool, " ***** Test Step 4 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_4(); + break; + case 5: + ChipLogProgress( + chipTool, " ***** Test Step 5 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_5(); + break; + case 6: + ChipLogProgress( + chipTool, " ***** Test Step 6 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_6(); + break; + case 7: + ChipLogProgress( + chipTool, " ***** Test Step 7 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_7(); + break; + case 8: + ChipLogProgress( + chipTool, " ***** Test Step 8 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_8(); + break; + case 9: + ChipLogProgress( + chipTool, " ***** Test Step 9 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_9(); break; case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : TH_CR1 revokes the commissioning window on DUT_CE\n"); - err = TestThCr1RevokesTheCommissioningWindowOnDutCe_10(); + ChipLogProgress( + chipTool, " ***** Test Step 10 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_10(); break; case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Commission from beta\n"); - err = TestCommissionFromBeta_11(); + ChipLogProgress( + chipTool, " ***** Test Step 11 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_11(); break; case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : TH_CR1 revokes the commissioning window on DUT_CE\n"); - err = TestThCr1RevokesTheCommissioningWindowOnDutCe_12(); + ChipLogProgress( + chipTool, " ***** Test Step 12 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_12(); break; case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : TH_CR1 writes the mandatory attribute NodeLabel of DUT_CE\n"); - err = TestThCr1WritesTheMandatoryAttributeNodeLabelOfDutCe_13(); + ChipLogProgress( + chipTool, " ***** Test Step 13 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_13(); break; case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : TH_CR1 read the mandatory attribute NodeLabel of DUT_CE\n"); - err = TestThCr1ReadTheMandatoryAttributeNodeLabelOfDutCe_14(); + ChipLogProgress( + chipTool, " ***** Test Step 14 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_14(); break; case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : TH_CR1 opens a commissioning window on DUT_CE\n"); - err = TestThCr1OpensACommissioningWindowOnDutCe_15(); + ChipLogProgress( + chipTool, " ***** Test Step 15 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_15(); break; case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Commission from beta\n"); - err = TestCommissionFromBeta_16(); + ChipLogProgress( + chipTool, " ***** Test Step 16 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_16(); break; case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : TH_CR2 starts a commissioning process on DUT_CE\n"); - err = TestThCr2StartsACommissioningProcessOnDutCe_17(); + ChipLogProgress( + chipTool, " ***** Test Step 17 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_17(); break; case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : TH_CR3 starts a commissioning process with DUT_CE\n"); - err = TestThCr3StartsACommissioningProcessWithDutCe_18(); + ChipLogProgress( + chipTool, " ***** Test Step 18 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_18(); + break; + case 19: + ChipLogProgress( + chipTool, " ***** Test Step 19 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_19(); + break; + case 20: + ChipLogProgress( + chipTool, " ***** Test Step 20 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_20(); + break; + case 21: + ChipLogProgress( + chipTool, " ***** Test Step 21 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_21(); + break; + case 22: + ChipLogProgress( + chipTool, " ***** Test Step 22 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_22(); + break; + case 23: + ChipLogProgress( + chipTool, " ***** Test Step 23 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : TH_CR3 starts a commissioning process with DUT_CE\n"); + err = TestThCr3StartsACommissioningProcessWithDutCe_24(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(700)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 25; + + chip::Optional mNodeId; + chip::Optional mTimeout; + chip::Optional mNodeIdForDuplicateCommissioning; + chip::Optional mNodeId2; + chip::Optional mNodeId3; + chip::Optional mEndpoint; + chip::Optional mDiscriminator; + chip::Optional mPayload; + chip::Optional mPayload2; + + CHIP_ERROR TestRebootTargetDevice_0() + { + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot("alpha", value); + } + + CHIP_ERROR TestThCr1StartsACommissioningProcessWithDutCe_1() + { + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestThCr1OpensANewCommissioningWindowOnDutCe_2() + { + CHIPDevice * device = GetDevice("alpha"); + CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device + endpoint:0 + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[CHIPAdministratorCommissioningClusterOpenCommissioningWindowParams alloc] init]; + params.commissioningTimeout = [NSNumber numberWithUnsignedShort:180U]; + params.pakeVerifier = + [[NSData alloc] initWithBytes:"\006\307V\337\374\327\042e4R\241-\315\224]\214T\332+\017<\275\033M\303\361\255\262#" + "\256\262k\004|\322L\226\206o\227\233\035\203\354P\342\264\2560\315\362\375\263+" + "\330\242\021\2707\334\224\355\315V\364\321Cw\031\020v\277\305\235\231\267\3350S\357\326" + "\360,D4\362\275\322z\244\371\316\247\015s\216L" + length:97]; + params.discriminator = mDiscriminator.HasValue() ? [NSNumber numberWithUnsignedShort:mDiscriminator.Value()] + : [NSNumber numberWithUnsignedShort:3840U]; + params.iterations = [NSNumber numberWithUnsignedInt:1000UL]; + params.salt = [[NSData alloc] initWithBytes:"SPAKE2P Key Salt" length:16]; + [cluster openCommissioningWindowWithParams:params + completionHandler:^(NSError * _Nullable err) { + NSLog(@"TH_CR1 opens a new commissioning window on DUT_CE Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_3() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_4() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_5() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_6() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_7() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_8() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_9() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_10() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_11() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_12() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_13() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_14() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_15() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_16() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_17() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_18() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_19() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_20() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_21() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_22() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_23() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestThCr3StartsACommissioningProcessWithDutCe_24() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId3.HasValue() ? mNodeId3.Value() : 12586990ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode("gamma", value); + } +}; + +class Test_TC_MF_1_10 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_MF_1_10() + : TestCommandBridge("Test_TC_MF_1_10") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + AddArgument("nodeIdForDuplicateCommissioning", 0, UINT64_MAX, &mNodeIdForDuplicateCommissioning); + AddArgument("nodeId2", 0, UINT64_MAX, &mNodeId2); + AddArgument("nodeId3", 0, UINT64_MAX, &mNodeId3); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); + AddArgument("payload", &mPayload); + AddArgument("payload2", &mPayload2); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_MF_1_10() {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_MF_1_10\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MF_1_10\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Reboot target device\n"); + err = TestRebootTargetDevice_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : TH_CR1 starts a commissioning process with DUT_CE\n"); + err = TestThCr1StartsACommissioningProcessWithDutCe_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : TH_CR1 opens a commissioning window on DUT_CE\n"); + err = TestThCr1OpensACommissioningWindowOnDutCe_2(); + break; + case 3: + ChipLogProgress( + chipTool, " ***** Test Step 3 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_3(); + break; + case 4: + ChipLogProgress( + chipTool, " ***** Test Step 4 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_4(); + break; + case 5: + ChipLogProgress( + chipTool, " ***** Test Step 5 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_5(); + break; + case 6: + ChipLogProgress( + chipTool, " ***** Test Step 6 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_6(); + break; + case 7: + ChipLogProgress( + chipTool, " ***** Test Step 7 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_7(); + break; + case 8: + ChipLogProgress( + chipTool, " ***** Test Step 8 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_8(); + break; + case 9: + ChipLogProgress( + chipTool, " ***** Test Step 9 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_9(); + break; + case 10: + ChipLogProgress( + chipTool, " ***** Test Step 10 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_10(); + break; + case 11: + ChipLogProgress( + chipTool, " ***** Test Step 11 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_11(); + break; + case 12: + ChipLogProgress( + chipTool, " ***** Test Step 12 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_12(); + break; + case 13: + ChipLogProgress( + chipTool, " ***** Test Step 13 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_13(); + break; + case 14: + ChipLogProgress( + chipTool, " ***** Test Step 14 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_14(); + break; + case 15: + ChipLogProgress( + chipTool, " ***** Test Step 15 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_15(); + break; + case 16: + ChipLogProgress( + chipTool, " ***** Test Step 16 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_16(); + break; + case 17: + ChipLogProgress( + chipTool, " ***** Test Step 17 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_17(); + break; + case 18: + ChipLogProgress( + chipTool, " ***** Test Step 18 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_18(); + break; + case 19: + ChipLogProgress( + chipTool, " ***** Test Step 19 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_19(); + break; + case 20: + ChipLogProgress( + chipTool, " ***** Test Step 20 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_20(); + break; + case 21: + ChipLogProgress( + chipTool, " ***** Test Step 21 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_21(); + break; + case 22: + ChipLogProgress( + chipTool, " ***** Test Step 22 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_22(); + break; + case 23: + ChipLogProgress( + chipTool, " ***** Test Step 23 : TH_CR2 starts a commissioning process with DUT_CE using Invalid setup code\n"); + err = TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : TH_CR3 starts a commissioning process with DUT_CE\n"); + err = TestThCr3StartsACommissioningProcessWithDutCe_24(); break; } @@ -36252,28 +37151,28 @@ class Test_TC_MF_1_6 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 8: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 11: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); @@ -36282,34 +37181,52 @@ class Test_TC_MF_1_6 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 18: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; } // Go on to the next test. ContinueOnChipMainThread(CHIP_NO_ERROR); } - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(300)); } + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(700)); } private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 19; + const uint16_t mTestCount = 25; chip::Optional mNodeId; chip::Optional mTimeout; @@ -36319,29 +37236,22 @@ class Test_TC_MF_1_6 : public TestCommandBridge { chip::Optional mEndpoint; chip::Optional mDiscriminator; chip::Optional mPayload; + chip::Optional mPayload2; - CHIP_ERROR TestStopTargetDevice_0() - { - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTargetDeviceWithTheProvidedDiscriminatorForBasicCommissioningAdvertisement_1() + CHIP_ERROR TestRebootTargetDevice_0() { - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.discriminator.Emplace(); - value.discriminator.Value() = mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U; - return Start("alpha", value); + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot("alpha", value); } - CHIP_ERROR TestThCr1StartsACommissioningProcessWithDutCe_2() + CHIP_ERROR TestThCr1StartsACommissioningProcessWithDutCe_1() { chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; return WaitForCommissionee("alpha", value); } - CHIP_ERROR TestThCr1OpensACommissioningWindowOnDutCe_3() + CHIP_ERROR TestThCr1OpensACommissioningWindowOnDutCe_2() { CHIPDevice * device = GetDevice("alpha"); CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device @@ -36363,193 +37273,179 @@ class Test_TC_MF_1_6 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestWaitForPixitCommWin18010_4() + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_3() { - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs("alpha", value); + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); } - CHIP_ERROR TestWaitForPixitCommWin18010_5() + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_4() { - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs("alpha", value); + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); } - CHIP_ERROR TestWaitForPixitCommWin18010_6() + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_5() { - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs("alpha", value); + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); } - CHIP_ERROR TestWaitForPixitCommWin18010_7() + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_6() { - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 28000UL; - return WaitForMs("alpha", value); + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); } - CHIP_ERROR TestCommissionFromBeta_8() + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_7() { chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); return PairWithCode("beta", value); } - CHIP_ERROR TestThCr1OpensACommissioningWindowOnDutCe_9() + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_8() { - CHIPDevice * device = GetDevice("alpha"); - CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device - endpoint:0 - queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[CHIPAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params - completionHandler:^(NSError * _Nullable err) { - NSLog(@"TH_CR1 opens a commissioning window on DUT_CE Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); } - CHIP_ERROR TestThCr1RevokesTheCommissioningWindowOnDutCe_10() + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_9() { - CHIPDevice * device = GetDevice("alpha"); - CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device - endpoint:0 - queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster revokeCommissioningWithCompletionHandler:^(NSError * _Nullable err) { - NSLog(@"TH_CR1 revokes the commissioning window on DUT_CE Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); } - CHIP_ERROR TestCommissionFromBeta_11() + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_10() { chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); return PairWithCode("beta", value); } - CHIP_ERROR TestThCr1RevokesTheCommissioningWindowOnDutCe_12() + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_11() { - CHIPDevice * device = GetDevice("alpha"); - CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device - endpoint:0 - queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster revokeCommissioningWithCompletionHandler:^(NSError * _Nullable err) { - NSLog(@"TH_CR1 revokes the commissioning window on DUT_CE Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); } - CHIP_ERROR TestThCr1WritesTheMandatoryAttributeNodeLabelOfDutCe_13() + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_12() { - CHIPDevice * device = GetDevice("alpha"); - CHIPTestBasic * cluster = [[CHIPTestBasic alloc] initWithDevice:device endpoint:0 queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"chiptest"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument - completionHandler:^(NSError * _Nullable err) { - NSLog(@"TH_CR1 writes the mandatory attribute NodeLabel of DUT_CE Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); } - CHIP_ERROR TestThCr1ReadTheMandatoryAttributeNodeLabelOfDutCe_14() + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_13() { - CHIPDevice * device = GetDevice("alpha"); - CHIPTestBasic * cluster = [[CHIPTestBasic alloc] initWithDevice:device endpoint:0 queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNodeLabelWithCompletionHandler:^(NSString * _Nullable value, NSError * _Nullable err) { - NSLog(@"TH_CR1 read the mandatory attribute NodeLabel of DUT_CE Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("NodeLabel", actualValue, @"chiptest")); - } + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_14() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } - NextTest(); - }]; + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_15() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } - return CHIP_NO_ERROR; + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_16() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); } - CHIP_ERROR TestThCr1OpensACommissioningWindowOnDutCe_15() + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_17() { - CHIPDevice * device = GetDevice("alpha"); - CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device - endpoint:0 - queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } - __auto_type * params = [[CHIPAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params - completionHandler:^(NSError * _Nullable err) { - NSLog(@"TH_CR1 opens a commissioning window on DUT_CE Error: %@", err); + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_18() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_19() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } - NextTest(); - }]; + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_20() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); + } - return CHIP_NO_ERROR; + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_21() + { + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); } - CHIP_ERROR TestCommissionFromBeta_16() + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_22() { chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); return PairWithCode("beta", value); } - CHIP_ERROR TestThCr2StartsACommissioningProcessOnDutCe_17() + CHIP_ERROR TestThCr2StartsACommissioningProcessWithDutCeUsingInvalidSetupCode_23() { - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - return WaitForCommissionee("beta", value); + value.payload = mPayload2.HasValue() ? mPayload2.Value() : chip::Span("MT:0000000000I.0648G00", 22); + return PairWithCode("beta", value); } - CHIP_ERROR TestThCr3StartsACommissioningProcessWithDutCe_18() + CHIP_ERROR TestThCr3StartsACommissioningProcessWithDutCe_24() { chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; value.nodeId = mNodeId3.HasValue() ? mNodeId3.Value() : 12586990ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:0000000000I31506010", 22); return PairWithCode("gamma", value); } }; @@ -36645,52 +37541,28 @@ class Test_TC_MF_1_15 : public TestCommandBridge { err = TestWaitForTheExpirationOfPixitCommWinSeconds_11(); break; case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait for the expiration of PIXIT_COMM_WIN seconds\n"); - err = TestWaitForTheExpirationOfPixitCommWinSeconds_12(); + ChipLogProgress(chipTool, " ***** Test Step 12 : TH_CR1 re-opens new commissioning window on DUT_CE\n"); + err = TestThCr1ReOpensNewCommissioningWindowOnDutCe_12(); break; case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait for the expiration of PIXIT_COMM_WIN seconds\n"); - err = TestWaitForTheExpirationOfPixitCommWinSeconds_13(); + ChipLogProgress(chipTool, " ***** Test Step 13 : TH_CR3 opens a new commissioning window on DUT_CE\n"); + err = TestThCr3OpensANewCommissioningWindowOnDutCe_13(); break; case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait for the expiration of PIXIT_COMM_WIN seconds\n"); - err = TestWaitForTheExpirationOfPixitCommWinSeconds_14(); + ChipLogProgress(chipTool, " ***** Test Step 14 : TH_CR1 reads the list of Fabrics on DUT_CE\n"); + err = TestThCr1ReadsTheListOfFabricsOnDutCe_14(); break; case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : TH_CR1 re-opens new commissioning window on DUT_CE\n"); - err = TestThCr1ReOpensNewCommissioningWindowOnDutCe_15(); + ChipLogProgress(chipTool, " ***** Test Step 15 : Wait for the expiration of PIXIT_COMM_WIN seconds\n"); + err = TestWaitForTheExpirationOfPixitCommWinSeconds_15(); break; case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : TH_CR3 opens a new commissioning window on DUT_CE\n"); - err = TestThCr3OpensANewCommissioningWindowOnDutCe_16(); + ChipLogProgress(chipTool, " ***** Test Step 16 : TH_CR1 opens a new commissioning window on DUT_CE\n"); + err = TestThCr1OpensANewCommissioningWindowOnDutCe_16(); break; case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : TH_CR1 reads the list of Fabrics on DUT_CE\n"); - err = TestThCr1ReadsTheListOfFabricsOnDutCe_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait for the expiration of PIXIT_COMM_WIN seconds\n"); - err = TestWaitForTheExpirationOfPixitCommWinSeconds_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Wait for the expiration of PIXIT_COMM_WIN seconds\n"); - err = TestWaitForTheExpirationOfPixitCommWinSeconds_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait for the expiration of PIXIT_COMM_WIN seconds\n"); - err = TestWaitForTheExpirationOfPixitCommWinSeconds_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Wait for the expiration of PIXIT_COMM_WIN seconds\n"); - err = TestWaitForTheExpirationOfPixitCommWinSeconds_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : TH_CR1 opens a new commissioning window on DUT_CE\n"); - err = TestThCr1OpensANewCommissioningWindowOnDutCe_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : TH_CR2 opens a new commissioning window on DUT_CE\n"); - err = TestThCr2OpensANewCommissioningWindowOnDutCe_23(); + ChipLogProgress(chipTool, " ***** Test Step 17 : TH_CR2 opens a new commissioning window on DUT_CE\n"); + err = TestThCr2OpensANewCommissioningWindowOnDutCe_17(); break; } @@ -36743,7 +37615,7 @@ class Test_TC_MF_1_15 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 14: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); @@ -36752,27 +37624,9 @@ class Test_TC_MF_1_15 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: + case 17: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; } @@ -36785,7 +37639,7 @@ class Test_TC_MF_1_15 : public TestCommandBridge { private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; + const uint16_t mTestCount = 18; chip::Optional mNodeId; chip::Optional mTimeout; @@ -36972,32 +37826,11 @@ class Test_TC_MF_1_15 : public TestCommandBridge { CHIP_ERROR TestWaitForTheExpirationOfPixitCommWinSeconds_11() { chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestWaitForTheExpirationOfPixitCommWinSeconds_12() - { - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestWaitForTheExpirationOfPixitCommWinSeconds_13() - { - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestWaitForTheExpirationOfPixitCommWinSeconds_14() - { - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 18000UL; + value.ms = 180000UL; return WaitForMs("alpha", value); } - CHIP_ERROR TestThCr1ReOpensNewCommissioningWindowOnDutCe_15() + CHIP_ERROR TestThCr1ReOpensNewCommissioningWindowOnDutCe_12() { CHIPDevice * device = GetDevice("alpha"); CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device @@ -37028,7 +37861,7 @@ class Test_TC_MF_1_15 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestThCr3OpensANewCommissioningWindowOnDutCe_16() + CHIP_ERROR TestThCr3OpensANewCommissioningWindowOnDutCe_13() { CHIPDevice * device = GetDevice("gamma"); CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device @@ -37058,7 +37891,7 @@ class Test_TC_MF_1_15 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestThCr1ReadsTheListOfFabricsOnDutCe_17() + CHIP_ERROR TestThCr1ReadsTheListOfFabricsOnDutCe_14() { CHIPDevice * device = GetDevice("alpha"); CHIPTestOperationalCredentials * cluster = [[CHIPTestOperationalCredentials alloc] initWithDevice:device @@ -37092,35 +37925,14 @@ class Test_TC_MF_1_15 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestWaitForTheExpirationOfPixitCommWinSeconds_18() - { - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestWaitForTheExpirationOfPixitCommWinSeconds_19() - { - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestWaitForTheExpirationOfPixitCommWinSeconds_20() - { - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 54000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestWaitForTheExpirationOfPixitCommWinSeconds_21() + CHIP_ERROR TestWaitForTheExpirationOfPixitCommWinSeconds_15() { chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 18000UL; + value.ms = 180000UL; return WaitForMs("alpha", value); } - CHIP_ERROR TestThCr1OpensANewCommissioningWindowOnDutCe_22() + CHIP_ERROR TestThCr1OpensANewCommissioningWindowOnDutCe_16() { CHIPDevice * device = GetDevice("alpha"); CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device @@ -37151,7 +37963,7 @@ class Test_TC_MF_1_15 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestThCr2OpensANewCommissioningWindowOnDutCe_23() + CHIP_ERROR TestThCr2OpensANewCommissioningWindowOnDutCe_17() { CHIPDevice * device = GetDevice("beta"); CHIPTestAdministratorCommissioning * cluster = [[CHIPTestAdministratorCommissioning alloc] initWithDevice:device @@ -108739,6 +109551,8 @@ void registerCommandsTests(Commands & commands) make_unique(), make_unique(), make_unique(), + make_unique(), + make_unique(), make_unique(), make_unique(), make_unique(), From 9bd7915e3bcf75c17fae2754c942ba34cbbce548 Mon Sep 17 00:00:00 2001 From: joonhaengHeo <85541460+joonhaengHeo@users.noreply.github.com> Date: Tue, 14 Jun 2022 23:23:38 +0900 Subject: [PATCH 05/53] Add Android Open Commissioning Callback API (#19441) * Add Android Open Commissioning Callback API * Restyled by google-java-format * Restyled by clang-format * Restyled by gn * Fix code below reviewer comment * Restyled by whitespace * Restyled by clang-format Co-authored-by: Restyled.io --- .../clusterclient/MultiAdminClientFragment.kt | 35 +++- .../layout/multi_admin_client_fragment.xml | 14 +- .../app/src/main/res/values/strings.xml | 1 + .../java/AndroidCommissioningWindowOpener.cpp | 178 ++++++++++++++++++ .../java/AndroidCommissioningWindowOpener.h | 61 ++++++ src/controller/java/BUILD.gn | 3 + .../java/CHIPDeviceController-JNI.cpp | 58 ++++++ .../ChipDeviceController.java | 28 +++ .../OpenCommissioningCallback.java | 24 +++ 9 files changed, 394 insertions(+), 8 deletions(-) create mode 100644 src/controller/java/AndroidCommissioningWindowOpener.cpp create mode 100644 src/controller/java/AndroidCommissioningWindowOpener.h create mode 100644 src/controller/java/src/chip/devicecontroller/OpenCommissioningCallback.java diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt index 240553514740ff..ff61638b9bac0b 100644 --- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt +++ b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt @@ -9,16 +9,17 @@ import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope import chip.devicecontroller.ChipClusters import chip.devicecontroller.ChipDeviceController +import chip.devicecontroller.OpenCommissioningCallback import com.google.chip.chiptool.ChipClient import com.google.chip.chiptool.GenericChipDeviceListener import com.google.chip.chiptool.R import kotlinx.android.synthetic.main.multi_admin_client_fragment.discriminatorEd +import kotlinx.android.synthetic.main.multi_admin_client_fragment.timeoutEd import kotlinx.android.synthetic.main.multi_admin_client_fragment.multiAdminClusterCommandStatus import kotlinx.android.synthetic.main.multi_admin_client_fragment.setupPinCodeEd import kotlinx.android.synthetic.main.multi_admin_client_fragment.view.basicCommissioningMethodBtn import kotlinx.android.synthetic.main.multi_admin_client_fragment.view.enhancedCommissioningMethodBtn import kotlinx.android.synthetic.main.multi_admin_client_fragment.view.revokeBtn -import kotlinx.android.synthetic.main.on_off_client_fragment.* import kotlinx.coroutines.* class MultiAdminClientFragment : Fragment() { @@ -53,8 +54,10 @@ class MultiAdminClientFragment : Fragment() { // TODO: use the discriminator and setupPinCode that was used to commission the device val testDiscriminator = "3840" val testSetupPinCode = 20202021L + val testDuration = 180 discriminatorEd.setText(testDiscriminator) setupPinCodeEd.setText(testSetupPinCode.toString()) + timeoutEd.setText(testDuration.toString()) } inner class ChipControllerCallback : GenericChipDeviceListener() { @@ -78,23 +81,41 @@ class MultiAdminClientFragment : Fragment() { } private suspend fun sendBasicCommissioningCommandClick() { - val testDuration = 100 - deviceController.openPairingWindow( + val testDuration = timeoutEd.text.toString().toInt() + deviceController.openPairingWindowCallback( ChipClient.getConnectedDevicePointer( requireContext(), addressUpdateFragment.deviceId - ), testDuration + ), testDuration, + object:OpenCommissioningCallback { + override fun onError(status: Int, deviceId: Long) { + showMessage("OpenBasicCommissioning Fail! \nDevice ID : $deviceId\nErrorCode : $status") + } + + override fun onSuccess(deviceId: Long, manualPairingCode: String?, qrCode: String?) { + showMessage("OpenBasicCommissioning Success! \n Node ID: $deviceId") + } + } ) } private suspend fun sendEnhancedCommissioningCommandClick() { - val testDuration = 100 + val testDuration = timeoutEd.text.toString().toInt() val testIteration = 1000 val devicePointer = ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) - deviceController.openPairingWindowWithPIN( + deviceController.openPairingWindowWithPINCallback( devicePointer, testDuration, testIteration.toLong(), - discriminatorEd.text.toString().toInt(), setupPinCodeEd.text.toString().toULong().toLong() + discriminatorEd.text.toString().toInt(), setupPinCodeEd.text.toString().toULong().toLong(), + object:OpenCommissioningCallback { + override fun onError(status: Int, deviceId: Long) { + showMessage("OpenCommissioning Fail! \nDevice ID : $deviceId\nErrorCode : $status") + } + + override fun onSuccess(deviceId: Long, manualPairingCode: String?, qrCode: String?) { + showMessage("OpenCommissioning Success! \n Node ID: $deviceId\n\tManual : $manualPairingCode\n\tQRCode : $qrCode") + } + } ) } diff --git a/src/android/CHIPTool/app/src/main/res/layout/multi_admin_client_fragment.xml b/src/android/CHIPTool/app/src/main/res/layout/multi_admin_client_fragment.xml index fb872bd9b8022f..95e5458f8164b0 100644 --- a/src/android/CHIPTool/app/src/main/res/layout/multi_admin_client_fragment.xml +++ b/src/android/CHIPTool/app/src/main/res/layout/multi_admin_client_fragment.xml @@ -14,6 +14,18 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/> + +