diff --git a/src/controller/java/BUILD.gn b/src/controller/java/BUILD.gn index e63d8969524b85..76ed4b21b8494d 100644 --- a/src/controller/java/BUILD.gn +++ b/src/controller/java/BUILD.gn @@ -34,6 +34,7 @@ shared_library("jni") { "CHIPDeviceController-JNI.cpp", "zap-generated/CHIPClusters-JNI.cpp", "zap-generated/CHIPClustersRead-JNI.cpp", + "zap-generated/CHIPClustersSubscribe-JNI.cpp", "zap-generated/CHIPInvokeCallbacks.cpp", "zap-generated/CHIPInvokeCallbacks.h", "zap-generated/CHIPReadCallbacks.cpp", diff --git a/src/controller/java/templates/CHIPClusters-JNI.zapt b/src/controller/java/templates/CHIPClusters-JNI.zapt index 8d9b4f1a858f20..ce90191764f06b 100644 --- a/src/controller/java/templates/CHIPClusters-JNI.zapt +++ b/src/controller/java/templates/CHIPClusters-JNI.zapt @@ -140,39 +140,6 @@ JNI_METHOD(void, {{asUpperCamelCase ../name}}Cluster, write{{asUpperCamelCase na onFailure.release(); } {{/if}} -{{#if isReportableAttribute}} -JNI_METHOD(void, {{asCamelCased ../name false}}Cluster, subscribe{{asCamelCased name false}}Attribute)(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - {{~#*inline "callbackName"~}} - {{~#if_in_global_responses~}} - CHIP{{chipCallback.name}}AttributeCallback - {{~else~}} - CHIP{{asCamelCased parent.name false}}{{asCamelCased name false}}AttributeCallback - {{~/if_in_global_responses~}} - {{~/inline}} - - std::unique_ptr<{{>callbackName}}, void (*)({{>callbackName}} *)> onSuccess(Platform::New<{{>callbackName}}>(callback, true), chip::Platform::Delete<{{>callbackName}}>); - VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure(Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - {{asCamelCased ../name false}}Cluster * cppCluster = reinterpret_cast<{{asCamelCased ../name false}}Cluster *>(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::{{asUpperCamelCase parent.name}}::Attributes::{{asUpperCamelCase name}}::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), static_cast(maxInterval), {{>callbackName}}::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -{{/if}} {{/unless}} {{/chip_server_cluster_attributes}} {{/chip_client_clusters}} diff --git a/src/controller/java/templates/CHIPClustersSubscribe-JNI.zapt b/src/controller/java/templates/CHIPClustersSubscribe-JNI.zapt new file mode 100644 index 00000000000000..0109d03b007e03 --- /dev/null +++ b/src/controller/java/templates/CHIPClustersSubscribe-JNI.zapt @@ -0,0 +1,56 @@ +{{> header}} +{{#if (chip_has_client_clusters)}} +#include "CHIPReadCallbacks.h" + +#include +#include + +#include +#include +#include +#include +#include + +#define JNI_METHOD(RETURN, CLASS_NAME, METHOD_NAME) \ + extern "C" JNIEXPORT RETURN JNICALL Java_chip_devicecontroller_ChipClusters_00024##CLASS_NAME##_##METHOD_NAME + +{{#chip_client_clusters}} +{{#chip_server_cluster_attributes}} +{{#unless (isStrEqual chipCallback.name "Unsupported")}} +{{#if isReportableAttribute}} +JNI_METHOD(void, {{asCamelCased ../name false}}Cluster, subscribe{{asCamelCased name false}}Attribute)(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + {{~#*inline "callbackName"~}} + {{~#if_in_global_responses~}} + CHIP{{chipCallback.name}}AttributeCallback + {{~else~}} + CHIP{{asCamelCased parent.name false}}{{asCamelCased name false}}AttributeCallback + {{~/if_in_global_responses~}} + {{~/inline}} + + std::unique_ptr<{{>callbackName}}, void (*)({{>callbackName}} *)> onSuccess(chip::Platform::New<{{>callbackName}}>(callback, true), chip::Platform::Delete<{{>callbackName}}>); + VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure(chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::{{asCamelCased ../name false}}Cluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::{{asUpperCamelCase parent.name}}::Attributes::{{asUpperCamelCase name}}::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), static_cast(maxInterval), {{>callbackName}}::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +{{/if}} +{{/unless}} +{{/chip_server_cluster_attributes}} +{{/chip_client_clusters}} +{{/if}} \ No newline at end of file diff --git a/src/controller/java/templates/templates.json b/src/controller/java/templates/templates.json index 3e8df7ecefbb87..5216100b1b721c 100644 --- a/src/controller/java/templates/templates.json +++ b/src/controller/java/templates/templates.json @@ -64,6 +64,11 @@ "name": "CHIP ZCL API for Java (native code for reads)", "output": "src/controller/java/zap-generated/CHIPClustersRead-JNI.cpp" }, + { + "path": "CHIPClustersSubscribe-JNI.zapt", + "name": "CHIP ZCL API for Java (native code for subscribes)", + "output": "src/controller/java/zap-generated/CHIPClustersSubscribe-JNI.cpp" + }, { "path": "CHIPReadCallbacks.zapt", "name": "CHIP cluster attribute read callback for Java (native code)", diff --git a/src/controller/java/zap-generated/CHIPClusters-JNI.cpp b/src/controller/java/zap-generated/CHIPClusters-JNI.cpp index 138ce492e75c0e..0c754b796fc603 100644 --- a/src/controller/java/zap-generated/CHIPClusters-JNI.cpp +++ b/src/controller/java/zap-generated/CHIPClusters-JNI.cpp @@ -262,44 +262,6 @@ JNI_METHOD(void, AccessControlCluster, writeAclAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, AccessControlCluster, subscribeAclAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - AccessControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::AccessControl::Attributes::Acl::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPAccessControlAclAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} JNI_METHOD(void, AccessControlCluster, writeExtensionAttribute) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) @@ -389,119 +351,6 @@ JNI_METHOD(void, AccessControlCluster, writeExtensionAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, AccessControlCluster, subscribeExtensionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - AccessControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::AccessControl::Attributes::Extension::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPAccessControlExtensionAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, AccessControlCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - AccessControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::AccessControl::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPAccessControlAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, AccessControlCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - AccessControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::AccessControl::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} JNI_METHOD(jlong, AccountLoginCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; @@ -669,81 +518,6 @@ JNI_METHOD(void, AccountLoginCluster, logoutRequest) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, AccountLoginCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - AccountLoginCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::AccountLogin::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPAccountLoginAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, AccountLoginCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - AccountLoginCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::AccountLogin::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} JNI_METHOD(jlong, AdministratorCommissioningCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; @@ -929,586 +703,379 @@ JNI_METHOD(void, AdministratorCommissioningCluster, revokeCommissioning) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, AdministratorCommissioningCluster, subscribeWindowStatusAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, ApplicationBasicCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - AdministratorCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + ApplicationBasicCluster * cppCluster = new ApplicationBasicCluster(); - using TypeInfo = chip::app::Clusters::AdministratorCommissioning::Attributes::WindowStatus::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); +JNI_METHOD(jlong, ApplicationLauncherCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + ApplicationLauncherCluster * cppCluster = new ApplicationLauncherCluster(); - onSuccess.release(); - onFailure.release(); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); } -JNI_METHOD(void, AdministratorCommissioningCluster, subscribeAdminFabricIndexAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ApplicationLauncherCluster, hideAppRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject application, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ApplicationLauncherCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::ApplicationLauncher::Commands::HideAppRequest::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + jobject application_catalogVendorIdItem_0; + chip::JniReferences::GetInstance().GetObjectField(application, "catalogVendorId", "Ljava/lang/Integer;", + application_catalogVendorIdItem_0); + request.application.catalogVendorId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(application_catalogVendorIdItem_0)); + jobject application_applicationIdItem_0; + chip::JniReferences::GetInstance().GetObjectField(application, "applicationId", "Ljava/lang/String;", + application_applicationIdItem_0); + auto application_applicationIdItem_0Jni = + chip::Platform::New(env, static_cast(application_applicationIdItem_0)); + cleanupStrings.push_back(application_applicationIdItem_0Jni); + request.application.applicationId = application_applicationIdItem_0Jni->charSpan(); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - AdministratorCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::AdministratorCommissioning::Attributes::AdminFabricIndex::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPAdministratorCommissioningAdminFabricIndexAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, AdministratorCommissioningCluster, subscribeAdminVendorIdAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, ApplicationLauncherCluster, launchAppRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring data, jobject application, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - AdministratorCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::AdministratorCommissioning::Attributes::AdminVendorId::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + CHIP_ERROR err = CHIP_NO_ERROR; + ApplicationLauncherCluster * cppCluster; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + ListFreer listFreer; + chip::app::Clusters::ApplicationLauncher::Commands::LaunchAppRequest::Type request; - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, AdministratorCommissioningCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + auto dataJni = chip::Platform::New(env, static_cast(data)); + cleanupStrings.push_back(dataJni); + request.data = dataJni->charSpan(); + jobject application_catalogVendorIdItem_0; + chip::JniReferences::GetInstance().GetObjectField(application, "catalogVendorId", "Ljava/lang/Integer;", + application_catalogVendorIdItem_0); + request.application.catalogVendorId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(application_catalogVendorIdItem_0)); + jobject application_applicationIdItem_0; + chip::JniReferences::GetInstance().GetObjectField(application, "applicationId", "Ljava/lang/String;", + application_applicationIdItem_0); + auto application_applicationIdItem_0Jni = + chip::Platform::New(env, static_cast(application_applicationIdItem_0)); + cleanupStrings.push_back(application_applicationIdItem_0Jni); + request.application.applicationId = application_applicationIdItem_0Jni->charSpan(); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - AdministratorCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::AdministratorCommissioning::Attributes::AttributeList::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPAdministratorCommissioningAttributeListAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, AdministratorCommissioningCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, ApplicationLauncherCluster, stopAppRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject application, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ApplicationLauncherCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::ApplicationLauncher::Commands::StopAppRequest::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + jobject application_catalogVendorIdItem_0; + chip::JniReferences::GetInstance().GetObjectField(application, "catalogVendorId", "Ljava/lang/Integer;", + application_catalogVendorIdItem_0); + request.application.catalogVendorId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(application_catalogVendorIdItem_0)); + jobject application_applicationIdItem_0; + chip::JniReferences::GetInstance().GetObjectField(application, "applicationId", "Ljava/lang/String;", + application_applicationIdItem_0); + auto application_applicationIdItem_0Jni = + chip::Platform::New(env, static_cast(application_applicationIdItem_0)); + cleanupStrings.push_back(application_applicationIdItem_0Jni); + request.application.applicationId = application_applicationIdItem_0Jni->charSpan(); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - AdministratorCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::AdministratorCommissioning::Attributes::ClusterRevision::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, ApplicationBasicCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +JNI_METHOD(jlong, AudioOutputCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - ApplicationBasicCluster * cppCluster = new ApplicationBasicCluster(); + AudioOutputCluster * cppCluster = new AudioOutputCluster(); cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); return reinterpret_cast(cppCluster); } -JNI_METHOD(void, ApplicationBasicCluster, subscribeVendorNameAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, AudioOutputCluster, renameOutputRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject index, jstring name, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + AudioOutputCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::AudioOutput::Commands::RenameOutputRequest::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.index = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(index)); + auto nameJni = chip::Platform::New(env, static_cast(name)); + cleanupStrings.push_back(nameJni); + request.name = nameJni->charSpan(); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ApplicationBasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ApplicationBasic::Attributes::VendorName::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ApplicationBasicCluster, subscribeVendorIdAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, AudioOutputCluster, selectOutputRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject index, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + AudioOutputCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::AudioOutput::Commands::SelectOutputRequest::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.index = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(index)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ApplicationBasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ApplicationBasic::Attributes::VendorId::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ApplicationBasicCluster, subscribeApplicationNameAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, BarrierControlCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ApplicationBasicCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ApplicationBasic::Attributes::ApplicationName::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ApplicationBasicCluster, subscribeProductIdAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ApplicationBasicCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ApplicationBasic::Attributes::ProductId::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ApplicationBasicCluster, subscribeApplicationStatusAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ApplicationBasicCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ApplicationBasic::Attributes::ApplicationStatus::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ApplicationBasicCluster, subscribeApplicationVersionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ApplicationBasicCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ApplicationBasic::Attributes::ApplicationVersion::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ApplicationBasicCluster, subscribeAllowedVendorListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ApplicationBasicCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ApplicationBasic::Attributes::AllowedVendorList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPApplicationBasicAllowedVendorListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ApplicationBasicCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ApplicationBasicCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ApplicationBasic::Attributes::AttributeList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPApplicationBasicAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ApplicationBasicCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ApplicationBasicCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ApplicationBasic::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, ApplicationLauncherCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - ApplicationLauncherCluster * cppCluster = new ApplicationLauncherCluster(); + BarrierControlCluster * cppCluster = new BarrierControlCluster(); cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); return reinterpret_cast(cppCluster); } -JNI_METHOD(void, ApplicationLauncherCluster, hideAppRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject application, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, BarrierControlCluster, barrierControlGoToPercent) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject percentOpen, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ApplicationLauncherCluster * cppCluster; + BarrierControlCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::ApplicationLauncher::Commands::HideAppRequest::Type request; + chip::app::Clusters::BarrierControl::Commands::BarrierControlGoToPercent::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - jobject application_catalogVendorIdItem_0; - chip::JniReferences::GetInstance().GetObjectField(application, "catalogVendorId", "Ljava/lang/Integer;", - application_catalogVendorIdItem_0); - request.application.catalogVendorId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(application_catalogVendorIdItem_0)); - jobject application_applicationIdItem_0; - chip::JniReferences::GetInstance().GetObjectField(application, "applicationId", "Ljava/lang/String;", - application_applicationIdItem_0); - auto application_applicationIdItem_0Jni = - chip::Platform::New(env, static_cast(application_applicationIdItem_0)); - cleanupStrings.push_back(application_applicationIdItem_0Jni); - request.application.applicationId = application_applicationIdItem_0Jni->charSpan(); + request.percentOpen = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(percentOpen)); - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -1518,13 +1085,12 @@ JNI_METHOD(void, ApplicationLauncherCluster, hideAppRequest) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -1548,38 +1114,21 @@ JNI_METHOD(void, ApplicationLauncherCluster, hideAppRequest) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ApplicationLauncherCluster, launchAppRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring data, jobject application, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, BarrierControlCluster, barrierControlStop) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ApplicationLauncherCluster * cppCluster; + BarrierControlCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::ApplicationLauncher::Commands::LaunchAppRequest::Type request; + chip::app::Clusters::BarrierControl::Commands::BarrierControlStop::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - auto dataJni = chip::Platform::New(env, static_cast(data)); - cleanupStrings.push_back(dataJni); - request.data = dataJni->charSpan(); - jobject application_catalogVendorIdItem_0; - chip::JniReferences::GetInstance().GetObjectField(application, "catalogVendorId", "Ljava/lang/Integer;", - application_catalogVendorIdItem_0); - request.application.catalogVendorId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(application_catalogVendorIdItem_0)); - jobject application_applicationIdItem_0; - chip::JniReferences::GetInstance().GetObjectField(application, "applicationId", "Ljava/lang/String;", - application_applicationIdItem_0); - auto application_applicationIdItem_0Jni = - chip::Platform::New(env, static_cast(application_applicationIdItem_0)); - cleanupStrings.push_back(application_applicationIdItem_0Jni); - request.application.applicationId = application_applicationIdItem_0Jni->charSpan(); - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -1589,13 +1138,12 @@ JNI_METHOD(void, ApplicationLauncherCluster, launchAppRequest) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -1619,35 +1167,30 @@ JNI_METHOD(void, ApplicationLauncherCluster, launchAppRequest) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ApplicationLauncherCluster, stopAppRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject application, jobject timedInvokeTimeoutMs) +JNI_METHOD(jlong, BasicCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + BasicCluster * cppCluster = new BasicCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(void, BasicCluster, mfgSpecificPing) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ApplicationLauncherCluster * cppCluster; + BasicCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::ApplicationLauncher::Commands::StopAppRequest::Type request; + chip::app::Clusters::Basic::Commands::MfgSpecificPing::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - jobject application_catalogVendorIdItem_0; - chip::JniReferences::GetInstance().GetObjectField(application, "catalogVendorId", "Ljava/lang/Integer;", - application_catalogVendorIdItem_0); - request.application.catalogVendorId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(application_catalogVendorIdItem_0)); - jobject application_applicationIdItem_0; - chip::JniReferences::GetInstance().GetObjectField(application, "applicationId", "Ljava/lang/String;", - application_applicationIdItem_0); - auto application_applicationIdItem_0Jni = - chip::Platform::New(env, static_cast(application_applicationIdItem_0)); - cleanupStrings.push_back(application_applicationIdItem_0Jni); - request.application.applicationId = application_applicationIdItem_0Jni->charSpan(); - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -1657,13 +1200,12 @@ JNI_METHOD(void, ApplicationLauncherCluster, stopAppRequest) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -1687,181 +1229,235 @@ JNI_METHOD(void, ApplicationLauncherCluster, stopAppRequest) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ApplicationLauncherCluster, subscribeApplicationLauncherListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, BasicCluster, writeNodeLabelAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::Basic::Attributes::NodeLabel::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + auto valueJni = chip::Platform::New(env, static_cast(value)); + cleanupStrings.push_back(valueJni); + cppValue = valueJni->charSpan(); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ApplicationLauncherCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + BasicCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ApplicationLauncher::Attributes::ApplicationLauncherList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPApplicationLauncherApplicationLauncherListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ApplicationLauncherCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, BasicCluster, writeLocationAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::Basic::Attributes::Location::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + auto valueJni = chip::Platform::New(env, static_cast(value)); + cleanupStrings.push_back(valueJni); + cppValue = valueJni->charSpan(); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ApplicationLauncherCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + BasicCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ApplicationLauncher::Attributes::AttributeList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPApplicationLauncherAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ApplicationLauncherCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, BasicCluster, writeLocalConfigDisabledAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::Basic::Attributes::LocalConfigDisabled::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ApplicationLauncherCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + BasicCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ApplicationLauncher::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, AudioOutputCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +JNI_METHOD(jlong, BinaryInputBasicCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - AudioOutputCluster * cppCluster = new AudioOutputCluster(); + BinaryInputBasicCluster * cppCluster = new BinaryInputBasicCluster(); cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); return reinterpret_cast(cppCluster); } -JNI_METHOD(void, AudioOutputCluster, renameOutputRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject index, jstring name, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, BinaryInputBasicCluster, writeOutOfServiceAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - AudioOutputCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::AudioOutput::Commands::RenameOutputRequest::Type request; + using TypeInfo = chip::app::Clusters::BinaryInputBasic::Attributes::OutOfService::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.index = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(index)); - auto nameJni = chip::Platform::New(env, static_cast(name)); - cleanupStrings.push_back(nameJni); - request.name = nameJni->charSpan(); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + BinaryInputBasicCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -1871,53 +1467,55 @@ JNI_METHOD(void, AudioOutputCluster, renameOutputRequest) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, AudioOutputCluster, selectOutputRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject index, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, BinaryInputBasicCluster, writePresentValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - AudioOutputCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::AudioOutput::Commands::SelectOutputRequest::Type request; + using TypeInfo = chip::app::Clusters::BinaryInputBasic::Attributes::PresentValue::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.index = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(index)); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + BinaryInputBasicCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), @@ -1926,179 +1524,179 @@ JNI_METHOD(void, AudioOutputCluster, selectOutputRequest) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, AudioOutputCluster, subscribeAudioOutputListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, BindingCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - AudioOutputCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::AudioOutput::Attributes::AudioOutputList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPAudioOutputAudioOutputListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + BindingCluster * cppCluster = new BindingCluster(); - onSuccess.release(); - onFailure.release(); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); } -JNI_METHOD(void, AudioOutputCluster, subscribeCurrentAudioOutputAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, BindingCluster, bind) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject nodeId, jobject groupId, jobject endpointId, + jobject clusterId, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + BindingCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::Binding::Commands::Bind::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.nodeId = + static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(nodeId)); + request.groupId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); + request.endpointId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(endpointId)); + request.clusterId = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(clusterId)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - AudioOutputCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::AudioOutput::Attributes::CurrentAudioOutput::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, AudioOutputCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, BindingCluster, unbind) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject nodeId, jobject groupId, jobject endpointId, + jobject clusterId, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + BindingCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::Binding::Commands::Unbind::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.nodeId = + static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(nodeId)); + request.groupId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); + request.endpointId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(endpointId)); + request.clusterId = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(clusterId)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - AudioOutputCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::AudioOutput::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPAudioOutputAttributeListAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, AudioOutputCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, BooleanStateCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - AudioOutputCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::AudioOutput::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + BooleanStateCluster * cppCluster = new BooleanStateCluster(); - onSuccess.release(); - onFailure.release(); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); } -JNI_METHOD(jlong, BarrierControlCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) + +JNI_METHOD(jlong, BridgedActionsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - BarrierControlCluster * cppCluster = new BarrierControlCluster(); + BridgedActionsCluster * cppCluster = new BridgedActionsCluster(); cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); return reinterpret_cast(cppCluster); } -JNI_METHOD(void, BarrierControlCluster, barrierControlGoToPercent) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject percentOpen, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, BridgedActionsCluster, disableAction) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - BarrierControlCluster * cppCluster; + BridgedActionsCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::BarrierControl::Commands::BarrierControlGoToPercent::Type request; + chip::app::Clusters::BridgedActions::Commands::DisableAction::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.percentOpen = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(percentOpen)); + request.actionID = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); + if (invokeID != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); + } std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -2111,7 +1709,7 @@ JNI_METHOD(void, BarrierControlCluster, barrierControlGoToPercent) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -2140,18 +1738,31 @@ JNI_METHOD(void, BarrierControlCluster, barrierControlGoToPercent) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BarrierControlCluster, barrierControlStop) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, BridgedActionsCluster, disableActionWithDuration) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject duration, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - BarrierControlCluster * cppCluster; + BridgedActionsCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::BarrierControl::Commands::BarrierControlStop::Type request; + chip::app::Clusters::BridgedActions::Commands::DisableActionWithDuration::Type request; std::list cleanupByteArrays; std::list cleanupStrings; + request.actionID = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); + if (invokeID != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); + } + request.duration = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(duration)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -2164,7 +1775,7 @@ JNI_METHOD(void, BarrierControlCluster, barrierControlStop) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -2193,250 +1804,223 @@ JNI_METHOD(void, BarrierControlCluster, barrierControlStop) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BarrierControlCluster, subscribeBarrierMovingStateAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, BridgedActionsCluster, enableAction) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + BridgedActionsCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::BridgedActions::Commands::EnableAction::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.actionID = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); + if (invokeID != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); + } + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BarrierControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::BarrierControl::Attributes::BarrierMovingState::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, BarrierControlCluster, subscribeBarrierSafetyStatusAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - BarrierControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::BarrierControl::Attributes::BarrierSafetyStatus::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BarrierControlCluster, subscribeBarrierCapabilitiesAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, BridgedActionsCluster, enableActionWithDuration) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject duration, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - BarrierControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::BarrierControl::Attributes::BarrierCapabilities::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + CHIP_ERROR err = CHIP_NO_ERROR; + BridgedActionsCluster * cppCluster; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + ListFreer listFreer; + chip::app::Clusters::BridgedActions::Commands::EnableActionWithDuration::Type request; - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, BarrierControlCluster, subscribeBarrierPositionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + request.actionID = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); + if (invokeID != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); + } + request.duration = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(duration)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BarrierControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::BarrierControl::Attributes::BarrierPosition::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BarrierControlCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, BridgedActionsCluster, instantAction) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - BarrierControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::BarrierControl::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + CHIP_ERROR err = CHIP_NO_ERROR; + BridgedActionsCluster * cppCluster; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBarrierControlAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + ListFreer listFreer; + chip::app::Clusters::BridgedActions::Commands::InstantAction::Type request; - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, BarrierControlCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + request.actionID = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); + if (invokeID != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); + } + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BarrierControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::BarrierControl::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, BasicCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - BasicCluster * cppCluster = new BasicCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, BasicCluster, mfgSpecificPing) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, BridgedActionsCluster, instantActionWithTransition) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject transitionTime, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster; + BridgedActionsCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::Basic::Commands::MfgSpecificPing::Type request; + chip::app::Clusters::BridgedActions::Commands::InstantActionWithTransition::Type request; std::list cleanupByteArrays; std::list cleanupStrings; + request.actionID = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); + if (invokeID != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); + } + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -2449,7 +2033,7 @@ JNI_METHOD(void, BasicCluster, mfgSpecificPing) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -2478,238 +2062,189 @@ JNI_METHOD(void, BasicCluster, mfgSpecificPing) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BasicCluster, subscribeInteractionModelVersionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, BridgedActionsCluster, pauseAction) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + BridgedActionsCluster * cppCluster; - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + ListFreer listFreer; + chip::app::Clusters::BridgedActions::Commands::PauseAction::Type request; - using TypeInfo = chip::app::Clusters::Basic::Attributes::InteractionModelVersion::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, BasicCluster, subscribeVendorNameAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + request.actionID = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); + if (invokeID != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); + } + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Basic::Attributes::VendorName::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, BasicCluster, subscribeVendorIDAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Basic::Attributes::VendorID::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBasicVendorIDAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BasicCluster, subscribeProductNameAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, BridgedActionsCluster, pauseActionWithDuration) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject duration, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Basic::Attributes::ProductName::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + CHIP_ERROR err = CHIP_NO_ERROR; + BridgedActionsCluster * cppCluster; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + ListFreer listFreer; + chip::app::Clusters::BridgedActions::Commands::PauseActionWithDuration::Type request; - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, BasicCluster, subscribeProductIDAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + request.actionID = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); + if (invokeID != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); + } + request.duration = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(duration)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Basic::Attributes::ProductID::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } - -JNI_METHOD(void, BasicCluster, writeNodeLabelAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring value, jobject timedWriteTimeoutMs) +JNI_METHOD(void, BridgedActionsCluster, resumeAction) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::Basic::Attributes::NodeLabel::TypeInfo; - TypeInfo::Type cppValue; + CHIP_ERROR err = CHIP_NO_ERROR; + BridgedActionsCluster * cppCluster; - std::vector cleanupByteArrays; - std::vector cleanupStrings; + ListFreer listFreer; + chip::app::Clusters::BridgedActions::Commands::ResumeAction::Type request; - auto valueJni = chip::Platform::New(env, static_cast(value)); - cleanupStrings.push_back(valueJni); - cppValue = valueJni->charSpan(); + std::list cleanupByteArrays; + std::list cleanupStrings; + request.actionID = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); + if (invokeID != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); + } std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedWriteTimeoutMs == nullptr) + if (timedInvokeTimeoutMs == nullptr) { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -2719,91 +2254,60 @@ JNI_METHOD(void, BasicCluster, writeNodeLabelAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BasicCluster, subscribeNodeLabelAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, BridgedActionsCluster, startAction) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Basic::Attributes::NodeLabel::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + CHIP_ERROR err = CHIP_NO_ERROR; + BridgedActionsCluster * cppCluster; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + ListFreer listFreer; + chip::app::Clusters::BridgedActions::Commands::StartAction::Type request; - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, BasicCluster, writeLocationAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::Basic::Attributes::Location::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - auto valueJni = chip::Platform::New(env, static_cast(value)); - cleanupStrings.push_back(valueJni); - cppValue = valueJni->charSpan(); + std::list cleanupByteArrays; + std::list cleanupStrings; + request.actionID = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); + if (invokeID != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); + } std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedWriteTimeoutMs == nullptr) + if (timedInvokeTimeoutMs == nullptr) { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -2813,421 +2317,646 @@ JNI_METHOD(void, BasicCluster, writeLocationAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BasicCluster, subscribeLocationAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, BridgedActionsCluster, startActionWithDuration) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject duration, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + BridgedActionsCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::BridgedActions::Commands::StartActionWithDuration::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.actionID = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); + if (invokeID != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); + } + request.duration = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(duration)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Basic::Attributes::Location::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BasicCluster, subscribeHardwareVersionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, BridgedActionsCluster, stopAction) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + BridgedActionsCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::BridgedActions::Commands::StopAction::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.actionID = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); + if (invokeID != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); + auto & definedValue_0 = request.invokeID.Emplace(); + definedValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); + } + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Basic::Attributes::HardwareVersion::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BasicCluster, subscribeHardwareVersionStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, BridgedDeviceBasicCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + BridgedDeviceBasicCluster * cppCluster = new BridgedDeviceBasicCluster(); - using TypeInfo = chip::app::Clusters::Basic::Attributes::HardwareVersionString::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); +JNI_METHOD(jlong, ChannelCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + ChannelCluster * cppCluster = new ChannelCluster(); - onSuccess.release(); - onFailure.release(); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); } -JNI_METHOD(void, BasicCluster, subscribeSoftwareVersionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ChannelCluster, changeChannelByNumberRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject majorNumber, jobject minorNumber, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ChannelCluster * cppCluster; + ListFreer listFreer; + chip::app::Clusters::Channel::Commands::ChangeChannelByNumberRequest::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.majorNumber = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(majorNumber)); + request.minorNumber = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(minorNumber)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Basic::Attributes::SoftwareVersion::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); + onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BasicCluster, subscribeSoftwareVersionStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, ChannelCluster, changeChannelRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring match, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ChannelCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::Channel::Commands::ChangeChannelRequest::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + auto matchJni = chip::Platform::New(env, static_cast(match)); + cleanupStrings.push_back(matchJni); + request.match = matchJni->charSpan(); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Basic::Attributes::SoftwareVersionString::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BasicCluster, subscribeManufacturingDateAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, ChannelCluster, skipChannelRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject count, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ChannelCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::Channel::Commands::SkipChannelRequest::Type request; + std::list cleanupByteArrays; + std::list cleanupStrings; + request.count = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(count)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Basic::Attributes::ManufacturingDate::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BasicCluster, subscribePartNumberAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, ColorControlCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + ColorControlCluster * cppCluster = new ColorControlCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(void, ColorControlCluster, colorLoopSet) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject updateFlags, jobject action, jobject direction, + jobject time, jobject startHue, jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) +{ + chip::DeviceLayer::StackLock lock; + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::ColorControl::Commands::ColorLoopSet::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.updateFlags = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(updateFlags)); + request.action = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(action)); + request.direction = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(direction)); + request.time = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(time)); + request.startHue = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(startHue)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Basic::Attributes::PartNumber::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BasicCluster, subscribeProductURLAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, ColorControlCluster, enhancedMoveHue) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject moveMode, jobject rate, jobject optionsMask, + jobject optionsOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::ColorControl::Commands::EnhancedMoveHue::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.moveMode = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(moveMode)); + request.rate = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(rate)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Basic::Attributes::ProductURL::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BasicCluster, subscribeProductLabelAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, ColorControlCluster, enhancedMoveToHue) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject enhancedHue, jobject direction, jobject transitionTime, + jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::ColorControl::Commands::EnhancedMoveToHue::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.enhancedHue = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(enhancedHue)); + request.direction = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(direction)); + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Basic::Attributes::ProductLabel::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BasicCluster, subscribeSerialNumberAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, ColorControlCluster, enhancedMoveToHueAndSaturation) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject enhancedHue, jobject saturation, jobject transitionTime, + jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::ColorControl::Commands::EnhancedMoveToHueAndSaturation::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.enhancedHue = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(enhancedHue)); + request.saturation = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(saturation)); + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Basic::Attributes::SerialNumber::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } - -JNI_METHOD(void, BasicCluster, writeLocalConfigDisabledAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) +JNI_METHOD(void, ColorControlCluster, enhancedStepHue) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject stepMode, jobject stepSize, jobject transitionTime, + jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::Basic::Attributes::LocalConfigDisabled::TypeInfo; - TypeInfo::Type cppValue; + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster; - std::vector cleanupByteArrays; - std::vector cleanupStrings; + ListFreer listFreer; + chip::app::Clusters::ColorControl::Commands::EnhancedStepHue::Type request; - cppValue = - static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(value)); + std::list cleanupByteArrays; + std::list cleanupStrings; + request.stepMode = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(stepMode)); + request.stepSize = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(stepSize)); + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedWriteTimeoutMs == nullptr) + if (timedInvokeTimeoutMs == nullptr) { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -3237,246 +2966,313 @@ JNI_METHOD(void, BasicCluster, writeLocalConfigDisabledAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BasicCluster, subscribeLocalConfigDisabledAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, ColorControlCluster, moveColor) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject rateX, jobject rateY, jobject optionsMask, + jobject optionsOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::ColorControl::Commands::MoveColor::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.rateX = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(rateX)); + request.rateY = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(rateY)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Basic::Attributes::LocalConfigDisabled::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BasicCluster, subscribeReachableAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, ColorControlCluster, moveColorTemperature) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject moveMode, jobject rate, jobject colorTemperatureMinimum, + jobject colorTemperatureMaximum, jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster; - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + ListFreer listFreer; + chip::app::Clusters::ColorControl::Commands::MoveColorTemperature::Type request; - using TypeInfo = chip::app::Clusters::Basic::Attributes::Reachable::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, BasicCluster, subscribeUniqueIDAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + request.moveMode = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(moveMode)); + request.rate = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(rate)); + request.colorTemperatureMinimum = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(colorTemperatureMinimum)); + request.colorTemperatureMaximum = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(colorTemperatureMaximum)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Basic::Attributes::UniqueID::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BasicCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, ColorControlCluster, moveHue) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject moveMode, jobject rate, jobject optionsMask, + jobject optionsOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::ColorControl::Commands::MoveHue::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.moveMode = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(moveMode)); + request.rate = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(rate)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Basic::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBasicAttributeListAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BasicCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, ColorControlCluster, moveSaturation) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject moveMode, jobject rate, jobject optionsMask, + jobject optionsOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster; + ListFreer listFreer; + chip::app::Clusters::ColorControl::Commands::MoveSaturation::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.moveMode = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(moveMode)); + request.rate = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(rate)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Basic::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, BinaryInputBasicCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +JNI_METHOD(void, ColorControlCluster, moveToColor) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject colorX, jobject colorY, jobject transitionTime, + jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - BinaryInputBasicCluster * cppCluster = new BinaryInputBasicCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster; -JNI_METHOD(void, BinaryInputBasicCluster, writeOutOfServiceAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; ListFreer listFreer; - using TypeInfo = chip::app::Clusters::BinaryInputBasic::Attributes::OutOfService::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; + chip::app::Clusters::ColorControl::Commands::MoveToColor::Type request; - cppValue = - static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(value)); + std::list cleanupByteArrays; + std::list cleanupStrings; + request.colorX = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(colorX)); + request.colorY = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(colorY)); + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BinaryInputBasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedWriteTimeoutMs == nullptr) + if (timedInvokeTimeoutMs == nullptr) { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -3486,91 +3282,59 @@ JNI_METHOD(void, BinaryInputBasicCluster, writeOutOfServiceAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BinaryInputBasicCluster, subscribeOutOfServiceAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, ColorControlCluster, moveToColorTemperature) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject colorTemperature, jobject transitionTime, + jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster; - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - BinaryInputBasicCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::BinaryInputBasic::Attributes::OutOfService::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, BinaryInputBasicCluster, writePresentValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; ListFreer listFreer; - using TypeInfo = chip::app::Clusters::BinaryInputBasic::Attributes::PresentValue::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; + chip::app::Clusters::ColorControl::Commands::MoveToColorTemperature::Type request; - cppValue = - static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(value)); + std::list cleanupByteArrays; + std::list cleanupStrings; + request.colorTemperature = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(colorTemperature)); + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BinaryInputBasicCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedWriteTimeoutMs == nullptr) + if (timedInvokeTimeoutMs == nullptr) { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -3580,186 +3344,29 @@ JNI_METHOD(void, BinaryInputBasicCluster, writePresentValueAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BinaryInputBasicCluster, subscribePresentValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - BinaryInputBasicCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::BinaryInputBasic::Attributes::PresentValue::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, BinaryInputBasicCluster, subscribeStatusFlagsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - BinaryInputBasicCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::BinaryInputBasic::Attributes::StatusFlags::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, BinaryInputBasicCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - BinaryInputBasicCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::BinaryInputBasic::Attributes::AttributeList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBinaryInputBasicAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, BinaryInputBasicCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - BinaryInputBasicCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::BinaryInputBasic::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, BindingCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - BindingCluster * cppCluster = new BindingCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, BindingCluster, bind) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject nodeId, jobject groupId, jobject endpointId, - jobject clusterId, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, ColorControlCluster, moveToHue) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject hue, jobject direction, jobject transitionTime, + jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - BindingCluster * cppCluster; + ColorControlCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::Binding::Commands::Bind::Type request; + chip::app::Clusters::ColorControl::Commands::MoveToHue::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.nodeId = - static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(nodeId)); - request.groupId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); - request.endpointId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(endpointId)); - request.clusterId = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(clusterId)); + request.hue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(hue)); + request.direction = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(direction)); + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -3772,7 +3379,7 @@ JNI_METHOD(void, BindingCluster, bind) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -3801,27 +3408,29 @@ JNI_METHOD(void, BindingCluster, bind) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BindingCluster, unbind) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject nodeId, jobject groupId, jobject endpointId, - jobject clusterId, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, ColorControlCluster, moveToHueAndSaturation) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject hue, jobject saturation, jobject transitionTime, + jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - BindingCluster * cppCluster; + ColorControlCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::Binding::Commands::Unbind::Type request; + chip::app::Clusters::ColorControl::Commands::MoveToHueAndSaturation::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.nodeId = - static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(nodeId)); - request.groupId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); - request.endpointId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(endpointId)); - request.clusterId = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(clusterId)); + request.hue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(hue)); + request.saturation = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(saturation)); + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -3834,7 +3443,7 @@ JNI_METHOD(void, BindingCluster, unbind) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -3863,233 +3472,27 @@ JNI_METHOD(void, BindingCluster, unbind) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BindingCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - BindingCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Binding::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBindingAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, BindingCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - BindingCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Binding::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, BooleanStateCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - BooleanStateCluster * cppCluster = new BooleanStateCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, BooleanStateCluster, subscribeStateValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - BooleanStateCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::BooleanState::Attributes::StateValue::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, BooleanStateCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - BooleanStateCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::BooleanState::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanStateAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, BooleanStateCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - BooleanStateCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::BooleanState::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, BridgedActionsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - BridgedActionsCluster * cppCluster = new BridgedActionsCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, BridgedActionsCluster, disableAction) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, ColorControlCluster, moveToSaturation) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject saturation, jobject transitionTime, jobject optionsMask, + jobject optionsOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - BridgedActionsCluster * cppCluster; + ColorControlCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::BridgedActions::Commands::DisableAction::Type request; + chip::app::Clusters::ColorControl::Commands::MoveToSaturation::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.actionID = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); - if (invokeID != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); - auto & definedValue_0 = request.invokeID.Emplace(); - definedValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); - } + request.saturation = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(saturation)); + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -4102,7 +3505,7 @@ JNI_METHOD(void, BridgedActionsCluster, disableAction) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -4131,31 +3534,29 @@ JNI_METHOD(void, BridgedActionsCluster, disableAction) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BridgedActionsCluster, disableActionWithDuration) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject duration, - jobject timedInvokeTimeoutMs) +JNI_METHOD(void, ColorControlCluster, stepColor) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject stepX, jobject stepY, jobject transitionTime, + jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - BridgedActionsCluster * cppCluster; + ColorControlCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::BridgedActions::Commands::DisableActionWithDuration::Type request; + chip::app::Clusters::ColorControl::Commands::StepColor::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.actionID = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); - if (invokeID != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); - auto & definedValue_0 = request.invokeID.Emplace(); - definedValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); - } - request.duration = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(duration)); + request.stepX = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(stepX)); + request.stepY = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(stepY)); + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -4168,7 +3569,7 @@ JNI_METHOD(void, BridgedActionsCluster, disableActionWithDuration) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -4197,28 +3598,34 @@ JNI_METHOD(void, BridgedActionsCluster, disableActionWithDuration) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BridgedActionsCluster, enableAction) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, ColorControlCluster, stepColorTemperature) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject stepMode, jobject stepSize, jobject transitionTime, + jobject colorTemperatureMinimum, jobject colorTemperatureMaximum, jobject optionsMask, jobject optionsOverride, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - BridgedActionsCluster * cppCluster; + ColorControlCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::BridgedActions::Commands::EnableAction::Type request; + chip::app::Clusters::ColorControl::Commands::StepColorTemperature::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.actionID = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); - if (invokeID != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); - auto & definedValue_0 = request.invokeID.Emplace(); - definedValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); - } + request.stepMode = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(stepMode)); + request.stepSize = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(stepSize)); + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + request.colorTemperatureMinimum = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(colorTemperatureMinimum)); + request.colorTemperatureMaximum = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(colorTemperatureMaximum)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -4231,7 +3638,7 @@ JNI_METHOD(void, BridgedActionsCluster, enableAction) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -4260,31 +3667,29 @@ JNI_METHOD(void, BridgedActionsCluster, enableAction) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BridgedActionsCluster, enableActionWithDuration) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject duration, - jobject timedInvokeTimeoutMs) +JNI_METHOD(void, ColorControlCluster, stepHue) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject stepMode, jobject stepSize, jobject transitionTime, + jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - BridgedActionsCluster * cppCluster; + ColorControlCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::BridgedActions::Commands::EnableActionWithDuration::Type request; + chip::app::Clusters::ColorControl::Commands::StepHue::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.actionID = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); - if (invokeID != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); - auto & definedValue_0 = request.invokeID.Emplace(); - definedValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); - } - request.duration = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(duration)); + request.stepMode = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(stepMode)); + request.stepSize = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(stepSize)); + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -4297,7 +3702,7 @@ JNI_METHOD(void, BridgedActionsCluster, enableActionWithDuration) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -4326,28 +3731,29 @@ JNI_METHOD(void, BridgedActionsCluster, enableActionWithDuration) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BridgedActionsCluster, instantAction) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, ColorControlCluster, stepSaturation) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject stepMode, jobject stepSize, jobject transitionTime, + jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - BridgedActionsCluster * cppCluster; + ColorControlCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::BridgedActions::Commands::InstantAction::Type request; + chip::app::Clusters::ColorControl::Commands::StepSaturation::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.actionID = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); - if (invokeID != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); - auto & definedValue_0 = request.invokeID.Emplace(); - definedValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); - } + request.stepMode = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(stepMode)); + request.stepSize = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(stepSize)); + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -4360,7 +3766,7 @@ JNI_METHOD(void, BridgedActionsCluster, instantAction) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -4389,31 +3795,23 @@ JNI_METHOD(void, BridgedActionsCluster, instantAction) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BridgedActionsCluster, instantActionWithTransition) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject transitionTime, +JNI_METHOD(void, ColorControlCluster, stopMoveStep) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - BridgedActionsCluster * cppCluster; + ColorControlCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::BridgedActions::Commands::InstantActionWithTransition::Type request; + chip::app::Clusters::ColorControl::Commands::StopMoveStep::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.actionID = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); - if (invokeID != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); - auto & definedValue_0 = request.invokeID.Emplace(); - definedValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); - } - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + request.optionsMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); + request.optionsOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -4426,7 +3824,7 @@ JNI_METHOD(void, BridgedActionsCluster, instantActionWithTransition) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -4455,60 +3853,54 @@ JNI_METHOD(void, BridgedActionsCluster, instantActionWithTransition) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BridgedActionsCluster, pauseAction) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, ColorControlCluster, writeColorControlOptionsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - BridgedActionsCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::BridgedActions::Commands::PauseAction::Type request; + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorControlOptions::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.actionID = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); - if (invokeID != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); - auto & definedValue_0 = request.invokeID.Emplace(); - definedValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); - } + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -4518,63 +3910,54 @@ JNI_METHOD(void, BridgedActionsCluster, pauseAction) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BridgedActionsCluster, pauseActionWithDuration) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject duration, - jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, ColorControlCluster, writeWhitePointXAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - BridgedActionsCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::BridgedActions::Commands::PauseActionWithDuration::Type request; + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::WhitePointX::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.actionID = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); - if (invokeID != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); - auto & definedValue_0 = request.invokeID.Emplace(); - definedValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); - } - request.duration = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(duration)); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -4584,60 +3967,54 @@ JNI_METHOD(void, BridgedActionsCluster, pauseActionWithDuration) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BridgedActionsCluster, resumeAction) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, ColorControlCluster, writeWhitePointYAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - BridgedActionsCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::BridgedActions::Commands::ResumeAction::Type request; + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::WhitePointY::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.actionID = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); - if (invokeID != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); - auto & definedValue_0 = request.invokeID.Emplace(); - definedValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); - } + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -4647,60 +4024,54 @@ JNI_METHOD(void, BridgedActionsCluster, resumeAction) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BridgedActionsCluster, startAction) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, ColorControlCluster, writeColorPointRXAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - BridgedActionsCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::BridgedActions::Commands::StartAction::Type request; + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointRX::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.actionID = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); - if (invokeID != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); - auto & definedValue_0 = request.invokeID.Emplace(); - definedValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); - } + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -4710,63 +4081,54 @@ JNI_METHOD(void, BridgedActionsCluster, startAction) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BridgedActionsCluster, startActionWithDuration) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject duration, - jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, ColorControlCluster, writeColorPointRYAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - BridgedActionsCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::BridgedActions::Commands::StartActionWithDuration::Type request; + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointRY::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.actionID = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); - if (invokeID != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); - auto & definedValue_0 = request.invokeID.Emplace(); - definedValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); - } - request.duration = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(duration)); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -4776,60 +4138,54 @@ JNI_METHOD(void, BridgedActionsCluster, startActionWithDuration) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BridgedActionsCluster, stopAction) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject actionID, jobject invokeID, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, ColorControlCluster, writeColorPointRIntensityAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - BridgedActionsCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::BridgedActions::Commands::StopAction::Type request; + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointRIntensity::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.actionID = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(actionID)); - if (invokeID != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(invokeID, optionalValue_0); - auto & definedValue_0 = request.invokeID.Emplace(); - definedValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(optionalValue_0)); - } + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -4839,365 +4195,539 @@ JNI_METHOD(void, BridgedActionsCluster, stopAction) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BridgedActionsCluster, subscribeActionListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ColorControlCluster, writeColorPointGXAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointGX::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BridgedActionsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::BridgedActions::Attributes::ActionList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBridgedActionsActionListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BridgedActionsCluster, subscribeEndpointListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ColorControlCluster, writeColorPointGYAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointGY::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BridgedActionsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::BridgedActions::Attributes::EndpointList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBridgedActionsEndpointListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); + onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BridgedActionsCluster, subscribeSetupUrlAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ColorControlCluster, writeColorPointGIntensityAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointGIntensity::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BridgedActionsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::BridgedActions::Attributes::SetupUrl::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BridgedActionsCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ColorControlCluster, writeColorPointBXAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointBX::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BridgedActionsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::BridgedActions::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBridgedActionsAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BridgedActionsCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ColorControlCluster, writeColorPointBYAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointBY::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BridgedActionsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::BridgedActions::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, BridgedDeviceBasicCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) + +JNI_METHOD(void, ColorControlCluster, writeColorPointBIntensityAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - BridgedDeviceBasicCluster * cppCluster = new BridgedDeviceBasicCluster(); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointBIntensity::TypeInfo; + TypeInfo::Type cppValue; - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} + std::vector cleanupByteArrays; + std::vector cleanupStrings; -JNI_METHOD(void, BridgedDeviceBasicCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BridgedDeviceBasicCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::BridgedDeviceBasic::Attributes::AttributeList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBridgedDeviceBasicAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, BridgedDeviceBasicCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ColorControlCluster, writeStartUpColorTemperatureMiredsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::StartUpColorTemperatureMireds::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - BridgedDeviceBasicCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::BridgedDeviceBasic::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, ChannelCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +JNI_METHOD(jlong, ContentLauncherCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - ChannelCluster * cppCluster = new ChannelCluster(); + ContentLauncherCluster * cppCluster = new ContentLauncherCluster(); cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); return reinterpret_cast(cppCluster); } -JNI_METHOD(void, ChannelCluster, changeChannelByNumberRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject majorNumber, jobject minorNumber, +JNI_METHOD(void, ContentLauncherCluster, launchContentRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject autoPlay, jstring data, jobject search, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ChannelCluster * cppCluster; + ContentLauncherCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::Channel::Commands::ChangeChannelByNumberRequest::Type request; + chip::app::Clusters::ContentLauncher::Commands::LaunchContentRequest::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.majorNumber = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(majorNumber)); - request.minorNumber = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(minorNumber)); + request.autoPlay = static_cast>( + chip::JniReferences::GetInstance().BooleanToPrimitive(autoPlay)); + auto dataJni = chip::Platform::New(env, static_cast(data)); + cleanupStrings.push_back(dataJni); + request.data = dataJni->charSpan(); + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + jint searchSize; + chip::JniReferences::GetInstance().GetArrayListSize(search, searchSize); + if (searchSize != 0) + { + auto * listHolder_0 = new ListHolder(searchSize); + listFreer.add(listHolder_0); - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + for (size_t i_0 = 0; i_0 < static_cast(searchSize); ++i_0) + { + jobject element_0; + chip::JniReferences::GetInstance().GetArrayListItem(search, i_0, element_0); + jobject element_0_parameterListItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "parameterList", "Ljava/util/ArrayList;", + element_0_parameterListItem_1); + { + using ListType_2 = std::remove_reference_tmList[i_0].parameterList)>; + using ListMemberType_2 = ListMemberTypeGetter::Type; + jint element_0_parameterListItem_1Size; + chip::JniReferences::GetInstance().GetArrayListSize(element_0_parameterListItem_1, + element_0_parameterListItem_1Size); + if (element_0_parameterListItem_1Size != 0) + { + auto * listHolder_2 = new ListHolder(element_0_parameterListItem_1Size); + listFreer.add(listHolder_2); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + for (size_t i_2 = 0; i_2 < static_cast(element_0_parameterListItem_1Size); ++i_2) + { + jobject element_2; + chip::JniReferences::GetInstance().GetArrayListItem(element_0_parameterListItem_1, i_2, element_2); + jobject element_2_typeItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_2, "type", "Ljava/lang/Integer;", + element_2_typeItem_3); + listHolder_2->mList[i_2].type = + static_castmList[i_2].type)>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_2_typeItem_3)); + jobject element_2_valueItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_2, "value", "Ljava/lang/String;", + element_2_valueItem_3); + auto element_2_valueItem_3Jni = + chip::Platform::New(env, static_cast(element_2_valueItem_3)); + cleanupStrings.push_back(element_2_valueItem_3Jni); + listHolder_2->mList[i_2].value = element_2_valueItem_3Jni->charSpan(); + jobject element_2_externalIDListItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_2, "externalIDList", "Ljava/util/ArrayList;", + element_2_externalIDListItem_3); + { + using ListType_4 = std::remove_reference_tmList[i_2].externalIDList)>; + using ListMemberType_4 = ListMemberTypeGetter::Type; + jint element_2_externalIDListItem_3Size; + chip::JniReferences::GetInstance().GetArrayListSize(element_2_externalIDListItem_3, + element_2_externalIDListItem_3Size); + if (element_2_externalIDListItem_3Size != 0) + { + auto * listHolder_4 = new ListHolder(element_2_externalIDListItem_3Size); + listFreer.add(listHolder_4); - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + for (size_t i_4 = 0; i_4 < static_cast(element_2_externalIDListItem_3Size); ++i_4) + { + jobject element_4; + chip::JniReferences::GetInstance().GetArrayListItem(element_2_externalIDListItem_3, i_4, + element_4); + jobject element_4_nameItem_5; + chip::JniReferences::GetInstance().GetObjectField(element_4, "name", "Ljava/lang/String;", + element_4_nameItem_5); + auto element_4_nameItem_5Jni = chip::Platform::New( + env, static_cast(element_4_nameItem_5)); + cleanupStrings.push_back(element_4_nameItem_5Jni); + listHolder_4->mList[i_4].name = element_4_nameItem_5Jni->charSpan(); + jobject element_4_valueItem_5; + chip::JniReferences::GetInstance().GetObjectField(element_4, "value", "Ljava/lang/String;", + element_4_valueItem_5); + auto element_4_valueItem_5Jni = chip::Platform::New( + env, static_cast(element_4_valueItem_5)); + cleanupStrings.push_back(element_4_valueItem_5Jni); + listHolder_4->mList[i_4].value = element_4_valueItem_5Jni->charSpan(); + } + listHolder_2->mList[i_2].externalIDList = + ListType_4(listHolder_4->mList, element_2_externalIDListItem_3Size); + } + else + { + listHolder_2->mList[i_2].externalIDList = ListType_4(); + } + } + } + listHolder_0->mList[i_0].parameterList = ListType_2(listHolder_2->mList, element_0_parameterListItem_1Size); + } + else + { + listHolder_0->mList[i_0].parameterList = ListType_2(); + } + } + } + request.search = ListType_0(listHolder_0->mList, searchSize); + } + else + { + request.search = ListType_0(); + } } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ChannelCluster, changeChannelRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring match, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ChannelCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::Channel::Commands::ChangeChannelRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - auto matchJni = chip::Platform::New(env, static_cast(match)); - cleanupStrings.push_back(matchJni); - request.match = matchJni->charSpan(); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -5207,13 +4737,13 @@ JNI_METHOD(void, ChannelCluster, changeChannelRequest) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -5237,213 +4767,382 @@ JNI_METHOD(void, ChannelCluster, changeChannelRequest) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ChannelCluster, skipChannelRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject count, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, ContentLauncherCluster, launchURLRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring contentURL, jstring displayString, + jobject brandingInformation, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ChannelCluster * cppCluster; + ContentLauncherCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::Channel::Commands::SkipChannelRequest::Type request; + chip::app::Clusters::ContentLauncher::Commands::LaunchURLRequest::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.count = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(count)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ChannelCluster, subscribeChannelListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ChannelCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Channel::Attributes::ChannelList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPChannelChannelListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ChannelCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ChannelCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Channel::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPChannelAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ChannelCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + auto contentURLJni = chip::Platform::New(env, static_cast(contentURL)); + cleanupStrings.push_back(contentURLJni); + request.contentURL = contentURLJni->charSpan(); + auto displayStringJni = chip::Platform::New(env, static_cast(displayString)); + cleanupStrings.push_back(displayStringJni); + request.displayString = displayStringJni->charSpan(); + jobject brandingInformation_providerNameItem_0; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation, "providerName", "Ljava/lang/String;", + brandingInformation_providerNameItem_0); + auto brandingInformation_providerNameItem_0Jni = + chip::Platform::New(env, static_cast(brandingInformation_providerNameItem_0)); + cleanupStrings.push_back(brandingInformation_providerNameItem_0Jni); + request.brandingInformation.providerName = brandingInformation_providerNameItem_0Jni->charSpan(); + jobject brandingInformation_backgroundItem_0; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation, "background", + "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterStyleInformation;", + brandingInformation_backgroundItem_0); + jobject brandingInformation_backgroundItem_0_imageUrlItem_1; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_backgroundItem_0, "imageUrl", "Ljava/lang/String;", + brandingInformation_backgroundItem_0_imageUrlItem_1); + auto brandingInformation_backgroundItem_0_imageUrlItem_1Jni = + chip::Platform::New(env, static_cast(brandingInformation_backgroundItem_0_imageUrlItem_1)); + cleanupStrings.push_back(brandingInformation_backgroundItem_0_imageUrlItem_1Jni); + request.brandingInformation.background.imageUrl = brandingInformation_backgroundItem_0_imageUrlItem_1Jni->charSpan(); + jobject brandingInformation_backgroundItem_0_colorItem_1; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_backgroundItem_0, "color", "Ljava/lang/String;", + brandingInformation_backgroundItem_0_colorItem_1); + auto brandingInformation_backgroundItem_0_colorItem_1Jni = + chip::Platform::New(env, static_cast(brandingInformation_backgroundItem_0_colorItem_1)); + cleanupStrings.push_back(brandingInformation_backgroundItem_0_colorItem_1Jni); + request.brandingInformation.background.color = brandingInformation_backgroundItem_0_colorItem_1Jni->charSpan(); + jobject brandingInformation_backgroundItem_0_sizeItem_1; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_backgroundItem_0, "size", + "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterDimension;", + brandingInformation_backgroundItem_0_sizeItem_1); + jobject brandingInformation_backgroundItem_0_sizeItem_1_widthItem_2; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_backgroundItem_0_sizeItem_1, "width", + "Ljava/lang/Double;", + brandingInformation_backgroundItem_0_sizeItem_1_widthItem_2); + request.brandingInformation.background.size.width = + static_cast>( + chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_backgroundItem_0_sizeItem_1_widthItem_2)); + jobject brandingInformation_backgroundItem_0_sizeItem_1_heightItem_2; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_backgroundItem_0_sizeItem_1, "height", + "Ljava/lang/Double;", + brandingInformation_backgroundItem_0_sizeItem_1_heightItem_2); + request.brandingInformation.background.size.height = + static_cast>( + chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_backgroundItem_0_sizeItem_1_heightItem_2)); + jobject brandingInformation_backgroundItem_0_sizeItem_1_metricItem_2; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_backgroundItem_0_sizeItem_1, "metric", + "Ljava/lang/Integer;", + brandingInformation_backgroundItem_0_sizeItem_1_metricItem_2); + request.brandingInformation.background.size.metric = + static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(brandingInformation_backgroundItem_0_sizeItem_1_metricItem_2)); + jobject brandingInformation_logoItem_0; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation, "logo", + "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterStyleInformation;", + brandingInformation_logoItem_0); + jobject brandingInformation_logoItem_0_imageUrlItem_1; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_logoItem_0, "imageUrl", "Ljava/lang/String;", + brandingInformation_logoItem_0_imageUrlItem_1); + auto brandingInformation_logoItem_0_imageUrlItem_1Jni = + chip::Platform::New(env, static_cast(brandingInformation_logoItem_0_imageUrlItem_1)); + cleanupStrings.push_back(brandingInformation_logoItem_0_imageUrlItem_1Jni); + request.brandingInformation.logo.imageUrl = brandingInformation_logoItem_0_imageUrlItem_1Jni->charSpan(); + jobject brandingInformation_logoItem_0_colorItem_1; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_logoItem_0, "color", "Ljava/lang/String;", + brandingInformation_logoItem_0_colorItem_1); + auto brandingInformation_logoItem_0_colorItem_1Jni = + chip::Platform::New(env, static_cast(brandingInformation_logoItem_0_colorItem_1)); + cleanupStrings.push_back(brandingInformation_logoItem_0_colorItem_1Jni); + request.brandingInformation.logo.color = brandingInformation_logoItem_0_colorItem_1Jni->charSpan(); + jobject brandingInformation_logoItem_0_sizeItem_1; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_logoItem_0, "size", + "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterDimension;", + brandingInformation_logoItem_0_sizeItem_1); + jobject brandingInformation_logoItem_0_sizeItem_1_widthItem_2; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_logoItem_0_sizeItem_1, "width", "Ljava/lang/Double;", + brandingInformation_logoItem_0_sizeItem_1_widthItem_2); + request.brandingInformation.logo.size.width = + static_cast>( + chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_logoItem_0_sizeItem_1_widthItem_2)); + jobject brandingInformation_logoItem_0_sizeItem_1_heightItem_2; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_logoItem_0_sizeItem_1, "height", "Ljava/lang/Double;", + brandingInformation_logoItem_0_sizeItem_1_heightItem_2); + request.brandingInformation.logo.size.height = + static_cast>( + chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_logoItem_0_sizeItem_1_heightItem_2)); + jobject brandingInformation_logoItem_0_sizeItem_1_metricItem_2; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_logoItem_0_sizeItem_1, "metric", "Ljava/lang/Integer;", + brandingInformation_logoItem_0_sizeItem_1_metricItem_2); + request.brandingInformation.logo.size.metric = + static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(brandingInformation_logoItem_0_sizeItem_1_metricItem_2)); + jobject brandingInformation_progressBarItem_0; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation, "progressBar", + "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterStyleInformation;", + brandingInformation_progressBarItem_0); + jobject brandingInformation_progressBarItem_0_imageUrlItem_1; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_progressBarItem_0, "imageUrl", "Ljava/lang/String;", + brandingInformation_progressBarItem_0_imageUrlItem_1); + auto brandingInformation_progressBarItem_0_imageUrlItem_1Jni = + chip::Platform::New(env, static_cast(brandingInformation_progressBarItem_0_imageUrlItem_1)); + cleanupStrings.push_back(brandingInformation_progressBarItem_0_imageUrlItem_1Jni); + request.brandingInformation.progressBar.imageUrl = brandingInformation_progressBarItem_0_imageUrlItem_1Jni->charSpan(); + jobject brandingInformation_progressBarItem_0_colorItem_1; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_progressBarItem_0, "color", "Ljava/lang/String;", + brandingInformation_progressBarItem_0_colorItem_1); + auto brandingInformation_progressBarItem_0_colorItem_1Jni = + chip::Platform::New(env, static_cast(brandingInformation_progressBarItem_0_colorItem_1)); + cleanupStrings.push_back(brandingInformation_progressBarItem_0_colorItem_1Jni); + request.brandingInformation.progressBar.color = brandingInformation_progressBarItem_0_colorItem_1Jni->charSpan(); + jobject brandingInformation_progressBarItem_0_sizeItem_1; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_progressBarItem_0, "size", + "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterDimension;", + brandingInformation_progressBarItem_0_sizeItem_1); + jobject brandingInformation_progressBarItem_0_sizeItem_1_widthItem_2; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_progressBarItem_0_sizeItem_1, "width", + "Ljava/lang/Double;", + brandingInformation_progressBarItem_0_sizeItem_1_widthItem_2); + request.brandingInformation.progressBar.size.width = + static_cast>( + chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_progressBarItem_0_sizeItem_1_widthItem_2)); + jobject brandingInformation_progressBarItem_0_sizeItem_1_heightItem_2; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_progressBarItem_0_sizeItem_1, "height", + "Ljava/lang/Double;", + brandingInformation_progressBarItem_0_sizeItem_1_heightItem_2); + request.brandingInformation.progressBar.size.height = + static_cast>( + chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_progressBarItem_0_sizeItem_1_heightItem_2)); + jobject brandingInformation_progressBarItem_0_sizeItem_1_metricItem_2; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_progressBarItem_0_sizeItem_1, "metric", + "Ljava/lang/Integer;", + brandingInformation_progressBarItem_0_sizeItem_1_metricItem_2); + request.brandingInformation.progressBar.size.metric = + static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(brandingInformation_progressBarItem_0_sizeItem_1_metricItem_2)); + jobject brandingInformation_splashItem_0; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation, "splash", + "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterStyleInformation;", + brandingInformation_splashItem_0); + jobject brandingInformation_splashItem_0_imageUrlItem_1; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_splashItem_0, "imageUrl", "Ljava/lang/String;", + brandingInformation_splashItem_0_imageUrlItem_1); + auto brandingInformation_splashItem_0_imageUrlItem_1Jni = + chip::Platform::New(env, static_cast(brandingInformation_splashItem_0_imageUrlItem_1)); + cleanupStrings.push_back(brandingInformation_splashItem_0_imageUrlItem_1Jni); + request.brandingInformation.splash.imageUrl = brandingInformation_splashItem_0_imageUrlItem_1Jni->charSpan(); + jobject brandingInformation_splashItem_0_colorItem_1; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_splashItem_0, "color", "Ljava/lang/String;", + brandingInformation_splashItem_0_colorItem_1); + auto brandingInformation_splashItem_0_colorItem_1Jni = + chip::Platform::New(env, static_cast(brandingInformation_splashItem_0_colorItem_1)); + cleanupStrings.push_back(brandingInformation_splashItem_0_colorItem_1Jni); + request.brandingInformation.splash.color = brandingInformation_splashItem_0_colorItem_1Jni->charSpan(); + jobject brandingInformation_splashItem_0_sizeItem_1; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_splashItem_0, "size", + "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterDimension;", + brandingInformation_splashItem_0_sizeItem_1); + jobject brandingInformation_splashItem_0_sizeItem_1_widthItem_2; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_splashItem_0_sizeItem_1, "width", "Ljava/lang/Double;", + brandingInformation_splashItem_0_sizeItem_1_widthItem_2); + request.brandingInformation.splash.size.width = + static_cast>( + chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_splashItem_0_sizeItem_1_widthItem_2)); + jobject brandingInformation_splashItem_0_sizeItem_1_heightItem_2; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_splashItem_0_sizeItem_1, "height", "Ljava/lang/Double;", + brandingInformation_splashItem_0_sizeItem_1_heightItem_2); + request.brandingInformation.splash.size.height = + static_cast>( + chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_splashItem_0_sizeItem_1_heightItem_2)); + jobject brandingInformation_splashItem_0_sizeItem_1_metricItem_2; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_splashItem_0_sizeItem_1, "metric", "Ljava/lang/Integer;", + brandingInformation_splashItem_0_sizeItem_1_metricItem_2); + request.brandingInformation.splash.size.metric = + static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(brandingInformation_splashItem_0_sizeItem_1_metricItem_2)); + jobject brandingInformation_waterMarkItem_0; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation, "waterMark", + "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterStyleInformation;", + brandingInformation_waterMarkItem_0); + jobject brandingInformation_waterMarkItem_0_imageUrlItem_1; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_waterMarkItem_0, "imageUrl", "Ljava/lang/String;", + brandingInformation_waterMarkItem_0_imageUrlItem_1); + auto brandingInformation_waterMarkItem_0_imageUrlItem_1Jni = + chip::Platform::New(env, static_cast(brandingInformation_waterMarkItem_0_imageUrlItem_1)); + cleanupStrings.push_back(brandingInformation_waterMarkItem_0_imageUrlItem_1Jni); + request.brandingInformation.waterMark.imageUrl = brandingInformation_waterMarkItem_0_imageUrlItem_1Jni->charSpan(); + jobject brandingInformation_waterMarkItem_0_colorItem_1; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_waterMarkItem_0, "color", "Ljava/lang/String;", + brandingInformation_waterMarkItem_0_colorItem_1); + auto brandingInformation_waterMarkItem_0_colorItem_1Jni = + chip::Platform::New(env, static_cast(brandingInformation_waterMarkItem_0_colorItem_1)); + cleanupStrings.push_back(brandingInformation_waterMarkItem_0_colorItem_1Jni); + request.brandingInformation.waterMark.color = brandingInformation_waterMarkItem_0_colorItem_1Jni->charSpan(); + jobject brandingInformation_waterMarkItem_0_sizeItem_1; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_waterMarkItem_0, "size", + "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterDimension;", + brandingInformation_waterMarkItem_0_sizeItem_1); + jobject brandingInformation_waterMarkItem_0_sizeItem_1_widthItem_2; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_waterMarkItem_0_sizeItem_1, "width", "Ljava/lang/Double;", + brandingInformation_waterMarkItem_0_sizeItem_1_widthItem_2); + request.brandingInformation.waterMark.size.width = + static_cast>( + chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_waterMarkItem_0_sizeItem_1_widthItem_2)); + jobject brandingInformation_waterMarkItem_0_sizeItem_1_heightItem_2; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_waterMarkItem_0_sizeItem_1, "height", + "Ljava/lang/Double;", + brandingInformation_waterMarkItem_0_sizeItem_1_heightItem_2); + request.brandingInformation.waterMark.size.height = + static_cast>( + chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_waterMarkItem_0_sizeItem_1_heightItem_2)); + jobject brandingInformation_waterMarkItem_0_sizeItem_1_metricItem_2; + chip::JniReferences::GetInstance().GetObjectField(brandingInformation_waterMarkItem_0_sizeItem_1, "metric", + "Ljava/lang/Integer;", + brandingInformation_waterMarkItem_0_sizeItem_1_metricItem_2); + request.brandingInformation.waterMark.size.metric = + static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(brandingInformation_waterMarkItem_0_sizeItem_1_metricItem_2)); + + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); + std::unique_ptr onFailure( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + VerifyOrReturn(onFailure.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ChannelCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Channel::Attributes::ClusterRevision::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, ColorControlCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); + + onSuccess.release(); + onFailure.release(); +} + +JNI_METHOD(void, ContentLauncherCluster, writeSupportedStreamingProtocolsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - ColorControlCluster * cppCluster = new ColorControlCluster(); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + ContentLauncherCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(jlong, DescriptorCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + DescriptorCluster * cppCluster = new DescriptorCluster(); cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); return reinterpret_cast(cppCluster); } -JNI_METHOD(void, ColorControlCluster, colorLoopSet) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject updateFlags, jobject action, jobject direction, - jobject time, jobject startHue, jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) +JNI_METHOD(jlong, DiagnosticLogsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + DiagnosticLogsCluster * cppCluster = new DiagnosticLogsCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(void, DiagnosticLogsCluster, retrieveLogsRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject intent, jobject requestedProtocol, + jbyteArray transferFileDesignator, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; + DiagnosticLogsCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::ColorLoopSet::Type request; + chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsRequest::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.updateFlags = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(updateFlags)); - request.action = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(action)); - request.direction = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(direction)); - request.time = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(time)); - request.startHue = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(startHue)); - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + request.intent = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(intent)); + request.requestedProtocol = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(requestedProtocol)); + auto transferFileDesignatorJni = chip::Platform::New(env, static_cast(transferFileDesignator)); + cleanupByteArrays.push_back(transferFileDesignatorJni); + request.transferFileDesignator = transferFileDesignatorJni->byteSpan(); - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -5453,12 +5152,13 @@ JNI_METHOD(void, ColorControlCluster, colorLoopSet) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -5482,27 +5182,37 @@ JNI_METHOD(void, ColorControlCluster, colorLoopSet) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, enhancedMoveHue) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject moveMode, jobject rate, jobject optionsMask, - jobject optionsOverride, jobject timedInvokeTimeoutMs) +JNI_METHOD(jlong, DoorLockCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + DoorLockCluster * cppCluster = new DoorLockCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(void, DoorLockCluster, clearCredential) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject credential, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; + DoorLockCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::EnhancedMoveHue::Type request; + chip::app::Clusters::DoorLock::Commands::ClearCredential::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.moveMode = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(moveMode)); - request.rate = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(rate)); - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + jobject credential_credentialTypeItem_0; + chip::JniReferences::GetInstance().GetObjectField(credential, "credentialType", "Ljava/lang/Integer;", + credential_credentialTypeItem_0); + request.credential.credentialType = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(credential_credentialTypeItem_0)); + jobject credential_credentialIndexItem_0; + chip::JniReferences::GetInstance().GetObjectField(credential, "credentialIndex", "Ljava/lang/Integer;", + credential_credentialIndexItem_0); + request.credential.credentialIndex = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(credential_credentialIndexItem_0)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -5515,7 +5225,7 @@ JNI_METHOD(void, ColorControlCluster, enhancedMoveHue) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -5544,29 +5254,20 @@ JNI_METHOD(void, ColorControlCluster, enhancedMoveHue) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, enhancedMoveToHue) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject enhancedHue, jobject direction, jobject transitionTime, - jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, DoorLockCluster, clearUser) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject userIndex, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; + DoorLockCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::EnhancedMoveToHue::Type request; + chip::app::Clusters::DoorLock::Commands::ClearUser::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.enhancedHue = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(enhancedHue)); - request.direction = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(direction)); - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + request.userIndex = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(userIndex)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -5579,7 +5280,7 @@ JNI_METHOD(void, ColorControlCluster, enhancedMoveToHue) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -5608,32 +5309,33 @@ JNI_METHOD(void, ColorControlCluster, enhancedMoveToHue) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, enhancedMoveToHueAndSaturation) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject enhancedHue, jobject saturation, jobject transitionTime, - jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, DoorLockCluster, getCredentialStatus) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject credential, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; + DoorLockCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::EnhancedMoveToHueAndSaturation::Type request; + chip::app::Clusters::DoorLock::Commands::GetCredentialStatus::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.enhancedHue = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(enhancedHue)); - request.saturation = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(saturation)); - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + jobject credential_credentialTypeItem_0; + chip::JniReferences::GetInstance().GetObjectField(credential, "credentialType", "Ljava/lang/Integer;", + credential_credentialTypeItem_0); + request.credential.credentialType = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(credential_credentialTypeItem_0)); + jobject credential_credentialIndexItem_0; + chip::JniReferences::GetInstance().GetObjectField(credential, "credentialIndex", "Ljava/lang/Integer;", + credential_credentialIndexItem_0); + request.credential.credentialIndex = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(credential_credentialIndexItem_0)); - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -5643,12 +5345,13 @@ JNI_METHOD(void, ColorControlCluster, enhancedMoveToHueAndSaturation) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -5672,32 +5375,24 @@ JNI_METHOD(void, ColorControlCluster, enhancedMoveToHueAndSaturation) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, enhancedStepHue) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject stepMode, jobject stepSize, jobject transitionTime, - jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, DoorLockCluster, getUser) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject userIndex, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; + DoorLockCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::EnhancedStepHue::Type request; + chip::app::Clusters::DoorLock::Commands::GetUser::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.stepMode = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(stepMode)); - request.stepSize = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(stepSize)); - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + request.userIndex = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(userIndex)); - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -5707,12 +5402,12 @@ JNI_METHOD(void, ColorControlCluster, enhancedStepHue) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -5736,27 +5431,27 @@ JNI_METHOD(void, ColorControlCluster, enhancedStepHue) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, moveColor) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject rateX, jobject rateY, jobject optionsMask, - jobject optionsOverride, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, DoorLockCluster, lockDoor) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject pinCode, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; + DoorLockCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::MoveColor::Type request; + chip::app::Clusters::DoorLock::Commands::LockDoor::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.rateX = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(rateX)); - request.rateY = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(rateY)); - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + if (pinCode != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(pinCode, optionalValue_0); + auto & definedValue_0 = request.pinCode.Emplace(); + auto optionalValue_0Jni = chip::Platform::New(env, static_cast(optionalValue_0)); + cleanupByteArrays.push_back(optionalValue_0Jni); + definedValue_0 = optionalValue_0Jni->byteSpan(); + } std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -5769,7 +5464,7 @@ JNI_METHOD(void, ColorControlCluster, moveColor) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -5798,34 +5493,42 @@ JNI_METHOD(void, ColorControlCluster, moveColor) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, moveColorTemperature) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject moveMode, jobject rate, jobject colorTemperatureMinimum, - jobject colorTemperatureMaximum, jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, DoorLockCluster, setCredential) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject operationType, jobject credential, + jbyteArray credentialData, jobject userIndex, jobject userStatus, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; + DoorLockCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::MoveColorTemperature::Type request; + chip::app::Clusters::DoorLock::Commands::SetCredential::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.moveMode = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(moveMode)); - request.rate = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(rate)); - request.colorTemperatureMinimum = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(colorTemperatureMinimum)); - request.colorTemperatureMaximum = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(colorTemperatureMaximum)); - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + request.operationType = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(operationType)); + jobject credential_credentialTypeItem_0; + chip::JniReferences::GetInstance().GetObjectField(credential, "credentialType", "Ljava/lang/Integer;", + credential_credentialTypeItem_0); + request.credential.credentialType = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(credential_credentialTypeItem_0)); + jobject credential_credentialIndexItem_0; + chip::JniReferences::GetInstance().GetObjectField(credential, "credentialIndex", "Ljava/lang/Integer;", + credential_credentialIndexItem_0); + request.credential.credentialIndex = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(credential_credentialIndexItem_0)); + auto credentialDataJni = chip::Platform::New(env, static_cast(credentialData)); + cleanupByteArrays.push_back(credentialDataJni); + request.credentialData = credentialDataJni->byteSpan(); + request.userIndex = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(userIndex)); + request.userStatus = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(userStatus)); - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -5835,12 +5538,13 @@ JNI_METHOD(void, ColorControlCluster, moveColorTemperature) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -5864,27 +5568,50 @@ JNI_METHOD(void, ColorControlCluster, moveColorTemperature) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, moveHue) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject moveMode, jobject rate, jobject optionsMask, - jobject optionsOverride, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, DoorLockCluster, setUser) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject operationType, jobject userIndex, jstring userName, + jobject userUniqueId, jobject userStatus, jobject userType, jobject credentialRule, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; + DoorLockCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::MoveHue::Type request; + chip::app::Clusters::DoorLock::Commands::SetUser::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.moveMode = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(moveMode)); - request.rate = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(rate)); - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + request.operationType = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(operationType)); + request.userIndex = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(userIndex)); + if (userName == nullptr) + { + request.userName.SetNull(); + } + else + { + auto & nonNullValue_0 = request.userName.SetNonNull(); + auto userNameJni = chip::Platform::New(env, static_cast(userName)); + cleanupStrings.push_back(userNameJni); + nonNullValue_0 = userNameJni->charSpan(); + } + if (userUniqueId == nullptr) + { + request.userUniqueId.SetNull(); + } + else + { + auto & nonNullValue_0 = request.userUniqueId.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(userUniqueId)); + } + request.userStatus = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(userStatus)); + request.userType = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(userType)); + request.credentialRule = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(credentialRule)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -5897,7 +5624,7 @@ JNI_METHOD(void, ColorControlCluster, moveHue) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -5926,27 +5653,27 @@ JNI_METHOD(void, ColorControlCluster, moveHue) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, moveSaturation) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject moveMode, jobject rate, jobject optionsMask, - jobject optionsOverride, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, DoorLockCluster, unlockDoor) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject pinCode, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; + DoorLockCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::MoveSaturation::Type request; + chip::app::Clusters::DoorLock::Commands::UnlockDoor::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.moveMode = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(moveMode)); - request.rate = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(rate)); - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + if (pinCode != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(pinCode, optionalValue_0); + auto & definedValue_0 = request.pinCode.Emplace(); + auto optionalValue_0Jni = chip::Platform::New(env, static_cast(optionalValue_0)); + cleanupByteArrays.push_back(optionalValue_0Jni); + definedValue_0 = optionalValue_0Jni->byteSpan(); + } std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -5959,7 +5686,7 @@ JNI_METHOD(void, ColorControlCluster, moveSaturation) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -5988,61 +5715,55 @@ JNI_METHOD(void, ColorControlCluster, moveSaturation) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, moveToColor) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject colorX, jobject colorY, jobject transitionTime, - jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, DoorLockCluster, writeLanguageAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::MoveToColor::Type request; + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::Language::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.colorX = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(colorX)); - request.colorY = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(colorY)); - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + auto valueJni = chip::Platform::New(env, static_cast(value)); + cleanupStrings.push_back(valueJni); + cppValue = valueJni->charSpan(); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -6052,59 +5773,53 @@ JNI_METHOD(void, ColorControlCluster, moveToColor) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, moveToColorTemperature) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject colorTemperature, jobject transitionTime, - jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, DoorLockCluster, writeAutoRelockTimeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::MoveToColorTemperature::Type request; + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::AutoRelockTime::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.colorTemperature = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(colorTemperature)); - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -6114,61 +5829,54 @@ JNI_METHOD(void, ColorControlCluster, moveToColorTemperature) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, moveToHue) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject hue, jobject direction, jobject transitionTime, - jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, DoorLockCluster, writeSoundVolumeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::MoveToHue::Type request; + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::SoundVolume::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.hue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(hue)); - request.direction = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(direction)); - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -6178,61 +5886,54 @@ JNI_METHOD(void, ColorControlCluster, moveToHue) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, moveToHueAndSaturation) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject hue, jobject saturation, jobject transitionTime, - jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, DoorLockCluster, writeOperatingModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::MoveToHueAndSaturation::Type request; + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::OperatingMode::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.hue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(hue)); - request.saturation = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(saturation)); - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -6242,59 +5943,54 @@ JNI_METHOD(void, ColorControlCluster, moveToHueAndSaturation) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, moveToSaturation) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject saturation, jobject transitionTime, jobject optionsMask, - jobject optionsOverride, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, DoorLockCluster, writeEnableOneTouchLockingAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::MoveToSaturation::Type request; + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::EnableOneTouchLocking::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.saturation = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(saturation)); - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -6304,61 +6000,54 @@ JNI_METHOD(void, ColorControlCluster, moveToSaturation) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, stepColor) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject stepX, jobject stepY, jobject transitionTime, - jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, DoorLockCluster, writeEnablePrivacyModeButtonAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::StepColor::Type request; + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::EnablePrivacyModeButton::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.stepX = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(stepX)); - request.stepY = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(stepY)); - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -6368,34 +6057,93 @@ JNI_METHOD(void, ColorControlCluster, stepColor) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, stepColorTemperature) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject stepMode, jobject stepSize, jobject transitionTime, - jobject colorTemperatureMinimum, jobject colorTemperatureMaximum, jobject optionsMask, jobject optionsOverride, - jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, DoorLockCluster, writeWrongCodeEntryLimitAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) +{ + chip::DeviceLayer::StackLock lock; + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::WrongCodeEntryLimit::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(jlong, ElectricalMeasurementCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + ElectricalMeasurementCluster * cppCluster = new ElectricalMeasurementCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(jlong, EthernetNetworkDiagnosticsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + EthernetNetworkDiagnosticsCluster * cppCluster = new EthernetNetworkDiagnosticsCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, resetCounts) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; + EthernetNetworkDiagnosticsCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::StepColorTemperature::Type request; + chip::app::Clusters::EthernetNetworkDiagnostics::Commands::ResetCounts::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.stepMode = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(stepMode)); - request.stepSize = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(stepSize)); - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); - request.colorTemperatureMinimum = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(colorTemperatureMinimum)); - request.colorTemperatureMaximum = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(colorTemperatureMaximum)); - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -6408,7 +6156,7 @@ JNI_METHOD(void, ColorControlCluster, stepColorTemperature) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -6437,32 +6185,57 @@ JNI_METHOD(void, ColorControlCluster, stepColorTemperature) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, stepHue) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject stepMode, jobject stepSize, jobject transitionTime, - jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) +JNI_METHOD(jlong, FixedLabelCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + FixedLabelCluster * cppCluster = new FixedLabelCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(jlong, FlowMeasurementCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + FlowMeasurementCluster * cppCluster = new FlowMeasurementCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(jlong, GeneralCommissioningCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + GeneralCommissioningCluster * cppCluster = new GeneralCommissioningCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(void, GeneralCommissioningCluster, armFailSafe) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject expiryLengthSeconds, jobject breadcrumb, jobject timeoutMs, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; + GeneralCommissioningCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::StepHue::Type request; + chip::app::Clusters::GeneralCommissioning::Commands::ArmFailSafe::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.stepMode = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(stepMode)); - request.stepSize = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(stepSize)); - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + request.expiryLengthSeconds = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(expiryLengthSeconds)); + request.breadcrumb = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(breadcrumb)); + request.timeoutMs = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(timeoutMs)); - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -6472,12 +6245,13 @@ JNI_METHOD(void, ColorControlCluster, stepHue) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -6501,32 +6275,23 @@ JNI_METHOD(void, ColorControlCluster, stepHue) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, stepSaturation) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject stepMode, jobject stepSize, jobject transitionTime, - jobject optionsMask, jobject optionsOverride, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, GeneralCommissioningCluster, commissioningComplete) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; + GeneralCommissioningCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::StepSaturation::Type request; + chip::app::Clusters::GeneralCommissioning::Commands::CommissioningComplete::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.stepMode = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(stepMode)); - request.stepSize = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(stepSize)); - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -6536,12 +6301,14 @@ JNI_METHOD(void, ColorControlCluster, stepSaturation) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -6565,26 +6332,33 @@ JNI_METHOD(void, ColorControlCluster, stepSaturation) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, stopMoveStep) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject optionsMask, jobject optionsOverride, - jobject timedInvokeTimeoutMs) +JNI_METHOD(void, GeneralCommissioningCluster, setRegulatoryConfig) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject location, jstring countryCode, jobject breadcrumb, + jobject timeoutMs, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; + GeneralCommissioningCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::ColorControl::Commands::StopMoveStep::Type request; + chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfig::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.optionsMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsMask)); - request.optionsOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionsOverride)); + request.location = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(location)); + auto countryCodeJni = chip::Platform::New(env, static_cast(countryCode)); + cleanupStrings.push_back(countryCodeJni); + request.countryCode = countryCodeJni->charSpan(); + request.breadcrumb = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(breadcrumb)); + request.timeoutMs = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(timeoutMs)); - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -6594,12 +6368,14 @@ JNI_METHOD(void, ColorControlCluster, stopMoveStep) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -6623,387 +6399,487 @@ JNI_METHOD(void, ColorControlCluster, stopMoveStep) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeCurrentHueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, GeneralCommissioningCluster, writeBreadcrumbAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::GeneralCommissioning::Attributes::Breadcrumb::TypeInfo; + TypeInfo::Type cppValue; - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::CurrentHue::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ColorControlCluster, subscribeCurrentSaturationAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + GeneralCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::CurrentSaturation::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeRemainingTimeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, GeneralDiagnosticsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + GeneralDiagnosticsCluster * cppCluster = new GeneralDiagnosticsCluster(); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::RemainingTime::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); +JNI_METHOD(jlong, GroupKeyManagementCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + GroupKeyManagementCluster * cppCluster = new GroupKeyManagementCluster(); - onSuccess.release(); - onFailure.release(); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); } -JNI_METHOD(void, ColorControlCluster, subscribeCurrentXAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, GroupKeyManagementCluster, keySetRead) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupKeySetID, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + GroupKeyManagementCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.groupKeySetID = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(groupKeySetID)); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::CurrentX::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeCurrentYAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, GroupKeyManagementCluster, keySetReadAllIndices) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupKeySetIDs, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + GroupKeyManagementCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadAllIndices::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + jint groupKeySetIDsSize; + chip::JniReferences::GetInstance().GetArrayListSize(groupKeySetIDs, groupKeySetIDsSize); + if (groupKeySetIDsSize != 0) + { + auto * listHolder_0 = new ListHolder(groupKeySetIDsSize); + listFreer.add(listHolder_0); + + for (size_t i_0 = 0; i_0 < static_cast(groupKeySetIDsSize); ++i_0) + { + jobject element_0; + chip::JniReferences::GetInstance().GetArrayListItem(groupKeySetIDs, i_0, element_0); + listHolder_0->mList[i_0] = static_castmList[i_0])>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0)); + } + request.groupKeySetIDs = ListType_0(listHolder_0->mList, groupKeySetIDsSize); + } + else + { + request.groupKeySetIDs = ListType_0(); + } + } + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::CurrentY::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeDriftCompensationAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, GroupKeyManagementCluster, keySetRemove) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupKeySetID, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + GroupKeyManagementCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::GroupKeyManagement::Commands::KeySetRemove::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.groupKeySetID = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(groupKeySetID)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::DriftCompensation::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ColorControlCluster, subscribeCompensationTextAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::CompensationText::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeColorTemperatureAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, GroupKeyManagementCluster, keySetWrite) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupKeySet, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + GroupKeyManagementCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + jobject groupKeySet_groupKeySetIDItem_0; + chip::JniReferences::GetInstance().GetObjectField(groupKeySet, "groupKeySetID", "Ljava/lang/Integer;", + groupKeySet_groupKeySetIDItem_0); + request.groupKeySet.groupKeySetID = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(groupKeySet_groupKeySetIDItem_0)); + jobject groupKeySet_securityPolicyItem_0; + chip::JniReferences::GetInstance().GetObjectField(groupKeySet, "securityPolicy", "Ljava/lang/Integer;", + groupKeySet_securityPolicyItem_0); + request.groupKeySet.securityPolicy = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(groupKeySet_securityPolicyItem_0)); + jobject groupKeySet_epochKey0Item_0; + chip::JniReferences::GetInstance().GetObjectField(groupKeySet, "epochKey0", "[B", groupKeySet_epochKey0Item_0); + auto groupKeySet_epochKey0Item_0Jni = + chip::Platform::New(env, static_cast(groupKeySet_epochKey0Item_0)); + cleanupByteArrays.push_back(groupKeySet_epochKey0Item_0Jni); + request.groupKeySet.epochKey0 = groupKeySet_epochKey0Item_0Jni->byteSpan(); + jobject groupKeySet_epochStartTime0Item_0; + chip::JniReferences::GetInstance().GetObjectField(groupKeySet, "epochStartTime0", "Ljava/lang/Long;", + groupKeySet_epochStartTime0Item_0); + request.groupKeySet.epochStartTime0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(groupKeySet_epochStartTime0Item_0)); + jobject groupKeySet_epochKey1Item_0; + chip::JniReferences::GetInstance().GetObjectField(groupKeySet, "epochKey1", "[B", groupKeySet_epochKey1Item_0); + auto groupKeySet_epochKey1Item_0Jni = + chip::Platform::New(env, static_cast(groupKeySet_epochKey1Item_0)); + cleanupByteArrays.push_back(groupKeySet_epochKey1Item_0Jni); + request.groupKeySet.epochKey1 = groupKeySet_epochKey1Item_0Jni->byteSpan(); + jobject groupKeySet_epochStartTime1Item_0; + chip::JniReferences::GetInstance().GetObjectField(groupKeySet, "epochStartTime1", "Ljava/lang/Long;", + groupKeySet_epochStartTime1Item_0); + request.groupKeySet.epochStartTime1 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(groupKeySet_epochStartTime1Item_0)); + jobject groupKeySet_epochKey2Item_0; + chip::JniReferences::GetInstance().GetObjectField(groupKeySet, "epochKey2", "[B", groupKeySet_epochKey2Item_0); + auto groupKeySet_epochKey2Item_0Jni = + chip::Platform::New(env, static_cast(groupKeySet_epochKey2Item_0)); + cleanupByteArrays.push_back(groupKeySet_epochKey2Item_0Jni); + request.groupKeySet.epochKey2 = groupKeySet_epochKey2Item_0Jni->byteSpan(); + jobject groupKeySet_epochStartTime2Item_0; + chip::JniReferences::GetInstance().GetObjectField(groupKeySet, "epochStartTime2", "Ljava/lang/Long;", + groupKeySet_epochStartTime2Item_0); + request.groupKeySet.epochStartTime2 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(groupKeySet_epochStartTime2Item_0)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorTemperature::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeColorModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, GroupsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + GroupsCluster * cppCluster = new GroupsCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(void, GroupsCluster, addGroup) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jstring groupName, jobject timedInvokeTimeoutMs) +{ + chip::DeviceLayer::StackLock lock; + CHIP_ERROR err = CHIP_NO_ERROR; + GroupsCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::Groups::Commands::AddGroup::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.groupId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); + auto groupNameJni = chip::Platform::New(env, static_cast(groupName)); + cleanupStrings.push_back(groupNameJni); + request.groupName = groupNameJni->charSpan(); + std::unique_ptr onSuccess( + Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorMode::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } - -JNI_METHOD(void, ColorControlCluster, writeColorControlOptionsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) +JNI_METHOD(void, GroupsCluster, addGroupIfIdentifying) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jstring groupName, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorControlOptions::TypeInfo; - TypeInfo::Type cppValue; + CHIP_ERROR err = CHIP_NO_ERROR; + GroupsCluster * cppCluster; - std::vector cleanupByteArrays; - std::vector cleanupStrings; + ListFreer listFreer; + chip::app::Clusters::Groups::Commands::AddGroupIfIdentifying::Type request; - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + std::list cleanupByteArrays; + std::list cleanupStrings; + request.groupId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); + auto groupNameJni = chip::Platform::New(env, static_cast(groupName)); + cleanupStrings.push_back(groupNameJni); + request.groupName = groupNameJni->charSpan(); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedWriteTimeoutMs == nullptr) + if (timedInvokeTimeoutMs == nullptr) { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -7013,753 +6889,1051 @@ JNI_METHOD(void, ColorControlCluster, writeColorControlOptionsAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeColorControlOptionsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, GroupsCluster, getGroupMembership) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupList, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + GroupsCluster * cppCluster; - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + ListFreer listFreer; + chip::app::Clusters::Groups::Commands::GetGroupMembership::Type request; - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorControlOptions::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + std::list cleanupByteArrays; + std::list cleanupStrings; + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + jint groupListSize; + chip::JniReferences::GetInstance().GetArrayListSize(groupList, groupListSize); + if (groupListSize != 0) + { + auto * listHolder_0 = new ListHolder(groupListSize); + listFreer.add(listHolder_0); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ColorControlCluster, subscribeNumberOfPrimariesAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + for (size_t i_0 = 0; i_0 < static_cast(groupListSize); ++i_0) + { + jobject element_0; + chip::JniReferences::GetInstance().GetArrayListItem(groupList, i_0, element_0); + listHolder_0->mList[i_0] = static_castmList[i_0])>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0)); + } + request.groupList = ListType_0(listHolder_0->mList, groupListSize); + } + else + { + request.groupList = ListType_0(); + } + } + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::NumberOfPrimaries::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribePrimary1XAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, GroupsCluster, removeAllGroups) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + GroupsCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::Groups::Commands::RemoveAllGroups::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary1X::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribePrimary1YAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, GroupsCluster, removeGroup) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + GroupsCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::Groups::Commands::RemoveGroup::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.groupId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary1Y::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribePrimary1IntensityAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, GroupsCluster, viewGroup) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + GroupsCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::Groups::Commands::ViewGroup::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.groupId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); + std::unique_ptr onSuccess( + Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary1Intensity::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribePrimary2XAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, IdentifyCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + IdentifyCluster * cppCluster = new IdentifyCluster(); - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); +JNI_METHOD(void, IdentifyCluster, identify) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject identifyTime, jobject timedInvokeTimeoutMs) +{ + chip::DeviceLayer::StackLock lock; + CHIP_ERROR err = CHIP_NO_ERROR; + IdentifyCluster * cppCluster; - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary2X::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + ListFreer listFreer; + chip::app::Clusters::Identify::Commands::Identify::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.identifyTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(identifyTime)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); + std::unique_ptr onFailure( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + VerifyOrReturn(onFailure.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + + cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribePrimary2YAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, IdentifyCluster, identifyQuery) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + IdentifyCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::Identify::Commands::IdentifyQuery::Type request; + std::list cleanupByteArrays; + std::list cleanupStrings; + + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary2Y::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribePrimary2IntensityAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, IdentifyCluster, triggerEffect) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject effectIdentifier, jobject effectVariant, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + IdentifyCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::Identify::Commands::TriggerEffect::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.effectIdentifier = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(effectIdentifier)); + request.effectVariant = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(effectVariant)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary2Intensity::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribePrimary3XAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, IdentifyCluster, writeIdentifyTimeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::Identify::Attributes::IdentifyTime::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + IdentifyCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary3X::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribePrimary3YAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, IlluminanceMeasurementCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + IlluminanceMeasurementCluster * cppCluster = new IlluminanceMeasurementCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(jlong, KeypadInputCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + KeypadInputCluster * cppCluster = new KeypadInputCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(void, KeypadInputCluster, sendKeyRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject keyCode, jobject timedInvokeTimeoutMs) +{ + chip::DeviceLayer::StackLock lock; + CHIP_ERROR err = CHIP_NO_ERROR; + KeypadInputCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::KeypadInput::Commands::SendKeyRequest::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.keyCode = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(keyCode)); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary3Y::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribePrimary3IntensityAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, LevelControlCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary3Intensity::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + LevelControlCluster * cppCluster = new LevelControlCluster(); - onSuccess.release(); - onFailure.release(); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); } -JNI_METHOD(void, ColorControlCluster, subscribePrimary4XAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, LevelControlCluster, move) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject moveMode, jobject rate, jobject optionMask, + jobject optionOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + LevelControlCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::LevelControl::Commands::Move::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.moveMode = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(moveMode)); + request.rate = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(rate)); + request.optionMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionMask)); + request.optionOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionOverride)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary4X::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribePrimary4YAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, LevelControlCluster, moveToLevel) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject level, jobject transitionTime, jobject optionMask, + jobject optionOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + LevelControlCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::LevelControl::Commands::MoveToLevel::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.level = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(level)); + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + request.optionMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionMask)); + request.optionOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionOverride)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary4Y::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribePrimary4IntensityAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, LevelControlCluster, moveToLevelWithOnOff) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject level, jobject transitionTime, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + LevelControlCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::LevelControl::Commands::MoveToLevelWithOnOff::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.level = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(level)); + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary4Intensity::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribePrimary5XAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, LevelControlCluster, moveWithOnOff) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject moveMode, jobject rate, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + LevelControlCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::LevelControl::Commands::MoveWithOnOff::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.moveMode = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(moveMode)); + request.rate = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(rate)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary5X::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribePrimary5YAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, LevelControlCluster, step) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject stepMode, jobject stepSize, jobject transitionTime, + jobject optionMask, jobject optionOverride, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary5Y::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + CHIP_ERROR err = CHIP_NO_ERROR; + LevelControlCluster * cppCluster; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + ListFreer listFreer; + chip::app::Clusters::LevelControl::Commands::Step::Type request; - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ColorControlCluster, subscribePrimary5IntensityAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + request.stepMode = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(stepMode)); + request.stepSize = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(stepSize)); + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + request.optionMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionMask)); + request.optionOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionOverride)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary5Intensity::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribePrimary6XAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, LevelControlCluster, stepWithOnOff) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject stepMode, jobject stepSize, jobject transitionTime, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + LevelControlCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::LevelControl::Commands::StepWithOnOff::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.stepMode = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(stepMode)); + request.stepSize = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(stepSize)); + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary6X::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribePrimary6YAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, LevelControlCluster, stop) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject optionMask, jobject optionOverride, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + LevelControlCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::LevelControl::Commands::Stop::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.optionMask = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionMask)); + request.optionOverride = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionOverride)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary6Y::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribePrimary6IntensityAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, LevelControlCluster, stopWithOnOff) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + LevelControlCluster * cppCluster; + ListFreer listFreer; + chip::app::Clusters::LevelControl::Commands::StopWithOnOff::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary6Intensity::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, writeWhitePointXAttribute) +JNI_METHOD(void, LevelControlCluster, writeOptionsAttribute) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; ListFreer listFreer; - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::WhitePointX::TypeInfo; + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::Options::TypeInfo; TypeInfo::Type cppValue; std::vector cleanupByteArrays; @@ -7781,7 +7955,7 @@ JNI_METHOD(void, ColorControlCluster, writeWhitePointXAttribute) env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -7810,57 +7984,85 @@ JNI_METHOD(void, ColorControlCluster, writeWhitePointXAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeWhitePointXAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, LevelControlCluster, writeOnOffTransitionTimeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::OnOffTransitionTime::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::WhitePointX::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, writeWhitePointYAttribute) +JNI_METHOD(void, LevelControlCluster, writeOnLevelAttribute) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; ListFreer listFreer; - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::WhitePointY::TypeInfo; + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::OnLevel::TypeInfo; TypeInfo::Type cppValue; std::vector cleanupByteArrays; std::vector cleanupStrings; - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + } std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -7875,7 +8077,7 @@ JNI_METHOD(void, ColorControlCluster, writeWhitePointYAttribute) env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -7904,57 +8106,28 @@ JNI_METHOD(void, ColorControlCluster, writeWhitePointYAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeWhitePointYAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::WhitePointY::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ColorControlCluster, writeColorPointRXAttribute) +JNI_METHOD(void, LevelControlCluster, writeOnTransitionTimeAttribute) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; ListFreer listFreer; - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointRX::TypeInfo; + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::OnTransitionTime::TypeInfo; TypeInfo::Type cppValue; std::vector cleanupByteArrays; std::vector cleanupStrings; - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + } std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -7969,7 +8142,7 @@ JNI_METHOD(void, ColorControlCluster, writeColorPointRXAttribute) env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -7998,57 +8171,28 @@ JNI_METHOD(void, ColorControlCluster, writeColorPointRXAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeColorPointRXAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointRX::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ColorControlCluster, writeColorPointRYAttribute) +JNI_METHOD(void, LevelControlCluster, writeOffTransitionTimeAttribute) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; ListFreer listFreer; - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointRY::TypeInfo; + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::OffTransitionTime::TypeInfo; TypeInfo::Type cppValue; std::vector cleanupByteArrays; std::vector cleanupStrings; - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + } std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -8063,7 +8207,7 @@ JNI_METHOD(void, ColorControlCluster, writeColorPointRYAttribute) env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -8092,57 +8236,93 @@ JNI_METHOD(void, ColorControlCluster, writeColorPointRYAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeColorPointRYAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, LevelControlCluster, writeDefaultMoveRateAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::DefaultMoveRate::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointRY::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, writeColorPointRIntensityAttribute) +JNI_METHOD(void, LevelControlCluster, writeStartUpCurrentLevelAttribute) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; ListFreer listFreer; - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointRIntensity::TypeInfo; + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::StartUpCurrentLevel::TypeInfo; TypeInfo::Type cppValue; std::vector cleanupByteArrays; std::vector cleanupStrings; - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + } std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -8157,7 +8337,7 @@ JNI_METHOD(void, ColorControlCluster, writeColorPointRIntensityAttribute) env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -8186,57 +8366,29 @@ JNI_METHOD(void, ColorControlCluster, writeColorPointRIntensityAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeColorPointRIntensityAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, LocalizationConfigurationCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointRIntensity::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + LocalizationConfigurationCluster * cppCluster = new LocalizationConfigurationCluster(); - onSuccess.release(); - onFailure.release(); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); } -JNI_METHOD(void, ColorControlCluster, writeColorPointGXAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) +JNI_METHOD(void, LocalizationConfigurationCluster, writeActiveLocaleAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; ListFreer listFreer; - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointGX::TypeInfo; + using TypeInfo = chip::app::Clusters::LocalizationConfiguration::Attributes::ActiveLocale::TypeInfo; TypeInfo::Type cppValue; std::vector cleanupByteArrays; std::vector cleanupStrings; - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + auto valueJni = chip::Platform::New(env, static_cast(value)); + cleanupStrings.push_back(valueJni); + cppValue = valueJni->charSpan(); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -8250,8 +8402,8 @@ JNI_METHOD(void, ColorControlCluster, writeColorPointGXAttribute) chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + LocalizationConfigurationCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -8280,91 +8432,59 @@ JNI_METHOD(void, ColorControlCluster, writeColorPointGXAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeColorPointGXAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, LowPowerCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + LowPowerCluster * cppCluster = new LowPowerCluster(); - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointGX::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, ColorControlCluster, writeColorPointGYAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) +JNI_METHOD(void, LowPowerCluster, sleep) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointGY::TypeInfo; - TypeInfo::Type cppValue; + CHIP_ERROR err = CHIP_NO_ERROR; + LowPowerCluster * cppCluster; - std::vector cleanupByteArrays; - std::vector cleanupStrings; + ListFreer listFreer; + chip::app::Clusters::LowPower::Commands::Sleep::Type request; - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + std::list cleanupByteArrays; + std::list cleanupStrings; std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedWriteTimeoutMs == nullptr) + if (timedInvokeTimeoutMs == nullptr) { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -8374,91 +8494,59 @@ JNI_METHOD(void, ColorControlCluster, writeColorPointGYAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeColorPointGYAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, MediaInputCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointGY::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + MediaInputCluster * cppCluster = new MediaInputCluster(); - onSuccess.release(); - onFailure.release(); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); } -JNI_METHOD(void, ColorControlCluster, writeColorPointGIntensityAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) +JNI_METHOD(void, MediaInputCluster, hideInputStatusRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointGIntensity::TypeInfo; - TypeInfo::Type cppValue; + CHIP_ERROR err = CHIP_NO_ERROR; + MediaInputCluster * cppCluster; - std::vector cleanupByteArrays; - std::vector cleanupStrings; + ListFreer listFreer; + chip::app::Clusters::MediaInput::Commands::HideInputStatusRequest::Type request; - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + std::list cleanupByteArrays; + std::list cleanupStrings; std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedWriteTimeoutMs == nullptr) + if (timedInvokeTimeoutMs == nullptr) { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -8468,91 +8556,110 @@ JNI_METHOD(void, ColorControlCluster, writeColorPointGIntensityAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeColorPointGIntensityAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, MediaInputCluster, renameInputRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject index, jstring name, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + MediaInputCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::MediaInput::Commands::RenameInputRequest::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.index = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(index)); + auto nameJni = chip::Platform::New(env, static_cast(name)); + cleanupStrings.push_back(nameJni); + request.name = nameJni->charSpan(); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointGIntensity::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } - -JNI_METHOD(void, ColorControlCluster, writeColorPointBXAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) +JNI_METHOD(void, MediaInputCluster, selectInputRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject index, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointBX::TypeInfo; - TypeInfo::Type cppValue; + CHIP_ERROR err = CHIP_NO_ERROR; + MediaInputCluster * cppCluster; - std::vector cleanupByteArrays; - std::vector cleanupStrings; + ListFreer listFreer; + chip::app::Clusters::MediaInput::Commands::SelectInputRequest::Type request; - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + std::list cleanupByteArrays; + std::list cleanupStrings; + request.index = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(index)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedWriteTimeoutMs == nullptr) + if (timedInvokeTimeoutMs == nullptr) { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -8562,91 +8669,114 @@ JNI_METHOD(void, ColorControlCluster, writeColorPointBXAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeColorPointBXAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, MediaInputCluster, showInputStatusRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + MediaInputCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::MediaInput::Commands::ShowInputStatusRequest::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointBX::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } - -JNI_METHOD(void, ColorControlCluster, writeColorPointBYAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) +JNI_METHOD(jlong, MediaPlaybackCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointBY::TypeInfo; - TypeInfo::Type cppValue; + MediaPlaybackCluster * cppCluster = new MediaPlaybackCluster(); - std::vector cleanupByteArrays; - std::vector cleanupStrings; + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); +JNI_METHOD(void, MediaPlaybackCluster, fastForwardRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) +{ + chip::DeviceLayer::StackLock lock; + CHIP_ERROR err = CHIP_NO_ERROR; + MediaPlaybackCluster * cppCluster; - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + ListFreer listFreer; + chip::app::Clusters::MediaPlayback::Commands::FastForwardRequest::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedWriteTimeoutMs == nullptr) + if (timedInvokeTimeoutMs == nullptr) { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -8656,91 +8786,107 @@ JNI_METHOD(void, ColorControlCluster, writeColorPointBYAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeColorPointBYAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, MediaPlaybackCluster, nextRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + MediaPlaybackCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::MediaPlayback::Commands::NextRequest::Type request; + std::list cleanupByteArrays; + std::list cleanupStrings; + + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointBY::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } - -JNI_METHOD(void, ColorControlCluster, writeColorPointBIntensityAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) +JNI_METHOD(void, MediaPlaybackCluster, pauseRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointBIntensity::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; + CHIP_ERROR err = CHIP_NO_ERROR; + MediaPlaybackCluster * cppCluster; - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + ListFreer listFreer; + chip::app::Clusters::MediaPlayback::Commands::PauseRequest::Type request; - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedWriteTimeoutMs == nullptr) + if (timedInvokeTimeoutMs == nullptr) { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -8750,460 +8896,523 @@ JNI_METHOD(void, ColorControlCluster, writeColorPointBIntensityAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeColorPointBIntensityAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, MediaPlaybackCluster, playRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + MediaPlaybackCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::MediaPlayback::Commands::PlayRequest::Type request; + std::list cleanupByteArrays; + std::list cleanupStrings; + + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointBIntensity::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); + onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeEnhancedCurrentHueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, MediaPlaybackCluster, previousRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + MediaPlaybackCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::MediaPlayback::Commands::PreviousRequest::Type request; + std::list cleanupByteArrays; + std::list cleanupStrings; + + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::EnhancedCurrentHue::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeEnhancedColorModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, MediaPlaybackCluster, rewindRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + MediaPlaybackCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::MediaPlayback::Commands::RewindRequest::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::EnhancedColorMode::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeColorLoopActiveAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, MediaPlaybackCluster, seekRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject position, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + MediaPlaybackCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::MediaPlayback::Commands::SeekRequest::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.position = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(position)); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorLoopActive::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeColorLoopDirectionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, MediaPlaybackCluster, skipBackwardRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject deltaPositionMilliseconds, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + MediaPlaybackCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::MediaPlayback::Commands::SkipBackwardRequest::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.deltaPositionMilliseconds = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(deltaPositionMilliseconds)); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorLoopDirection::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeColorLoopTimeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, MediaPlaybackCluster, skipForwardRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject deltaPositionMilliseconds, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + MediaPlaybackCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::MediaPlayback::Commands::SkipForwardRequest::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.deltaPositionMilliseconds = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(deltaPositionMilliseconds)); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorLoopTime::TypeInfo; + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeColorLoopStartEnhancedHueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, MediaPlaybackCluster, startOverRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorLoopStartEnhancedHue::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + CHIP_ERROR err = CHIP_NO_ERROR; + MediaPlaybackCluster * cppCluster; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + ListFreer listFreer; + chip::app::Clusters::MediaPlayback::Commands::StartOverRequest::Type request; - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ColorControlCluster, subscribeColorLoopStoredEnhancedHueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorLoopStoredEnhancedHue::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeColorCapabilitiesAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, MediaPlaybackCluster, stopRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorCapabilities::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + CHIP_ERROR err = CHIP_NO_ERROR; + MediaPlaybackCluster * cppCluster; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + ListFreer listFreer; + chip::app::Clusters::MediaPlayback::Commands::StopRequest::Type request; - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ColorControlCluster, subscribeColorTempPhysicalMinAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorTempPhysicalMin::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeColorTempPhysicalMaxAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, ModeSelectCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorTempPhysicalMax::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + ModeSelectCluster * cppCluster = new ModeSelectCluster(); - onSuccess.release(); - onFailure.release(); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); } -JNI_METHOD(void, ColorControlCluster, subscribeCoupleColorTempToLevelMinMiredsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ModeSelectCluster, changeToMode) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject newMode, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ModeSelectCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::ModeSelect::Commands::ChangeToMode::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.newMode = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(newMode)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::CoupleColorTempToLevelMinMireds::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, writeStartUpColorTemperatureMiredsAttribute) +JNI_METHOD(void, ModeSelectCluster, writeOnModeAttribute) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; ListFreer listFreer; - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::StartUpColorTemperatureMireds::TypeInfo; + using TypeInfo = chip::app::Clusters::ModeSelect::Attributes::OnMode::TypeInfo; TypeInfo::Type cppValue; std::vector cleanupByteArrays; @@ -9224,8 +9433,8 @@ JNI_METHOD(void, ColorControlCluster, writeStartUpColorTemperatureMiredsAttribut chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ModeSelectCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -9254,253 +9463,103 @@ JNI_METHOD(void, ColorControlCluster, writeStartUpColorTemperatureMiredsAttribut onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ColorControlCluster, subscribeStartUpColorTemperatureMiredsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, NetworkCommissioningCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::StartUpColorTemperatureMireds::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + NetworkCommissioningCluster * cppCluster = new NetworkCommissioningCluster(); - onSuccess.release(); - onFailure.release(); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); } -JNI_METHOD(void, ColorControlCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, NetworkCommissioningCluster, addOrUpdateThreadNetwork) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray operationalDataset, jobject breadcrumb, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + CHIP_ERROR err = CHIP_NO_ERROR; + NetworkCommissioningCluster * cppCluster; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPColorControlAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + ListFreer listFreer; + chip::app::Clusters::NetworkCommissioning::Commands::AddOrUpdateThreadNetwork::Type request; - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ColorControlCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + auto operationalDatasetJni = chip::Platform::New(env, static_cast(operationalDataset)); + cleanupByteArrays.push_back(operationalDatasetJni); + request.operationalDataset = operationalDatasetJni->byteSpan(); + request.breadcrumb = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(breadcrumb)); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, ContentLauncherCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - ContentLauncherCluster * cppCluster = new ContentLauncherCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, ContentLauncherCluster, launchContentRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject autoPlay, jstring data, jobject search, +JNI_METHOD(void, NetworkCommissioningCluster, addOrUpdateWiFiNetwork) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray ssid, jbyteArray credentials, jobject breadcrumb, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ContentLauncherCluster * cppCluster; + NetworkCommissioningCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::ContentLauncher::Commands::LaunchContentRequest::Type request; + chip::app::Clusters::NetworkCommissioning::Commands::AddOrUpdateWiFiNetwork::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.autoPlay = static_cast>( - chip::JniReferences::GetInstance().BooleanToPrimitive(autoPlay)); - auto dataJni = chip::Platform::New(env, static_cast(data)); - cleanupStrings.push_back(dataJni); - request.data = dataJni->charSpan(); - { - using ListType_0 = std::remove_reference_t; - using ListMemberType_0 = ListMemberTypeGetter::Type; - jint searchSize; - chip::JniReferences::GetInstance().GetArrayListSize(search, searchSize); - if (searchSize != 0) - { - auto * listHolder_0 = new ListHolder(searchSize); - listFreer.add(listHolder_0); - - for (size_t i_0 = 0; i_0 < static_cast(searchSize); ++i_0) - { - jobject element_0; - chip::JniReferences::GetInstance().GetArrayListItem(search, i_0, element_0); - jobject element_0_parameterListItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "parameterList", "Ljava/util/ArrayList;", - element_0_parameterListItem_1); - { - using ListType_2 = std::remove_reference_tmList[i_0].parameterList)>; - using ListMemberType_2 = ListMemberTypeGetter::Type; - jint element_0_parameterListItem_1Size; - chip::JniReferences::GetInstance().GetArrayListSize(element_0_parameterListItem_1, - element_0_parameterListItem_1Size); - if (element_0_parameterListItem_1Size != 0) - { - auto * listHolder_2 = new ListHolder(element_0_parameterListItem_1Size); - listFreer.add(listHolder_2); - - for (size_t i_2 = 0; i_2 < static_cast(element_0_parameterListItem_1Size); ++i_2) - { - jobject element_2; - chip::JniReferences::GetInstance().GetArrayListItem(element_0_parameterListItem_1, i_2, element_2); - jobject element_2_typeItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_2, "type", "Ljava/lang/Integer;", - element_2_typeItem_3); - listHolder_2->mList[i_2].type = - static_castmList[i_2].type)>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_2_typeItem_3)); - jobject element_2_valueItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_2, "value", "Ljava/lang/String;", - element_2_valueItem_3); - auto element_2_valueItem_3Jni = - chip::Platform::New(env, static_cast(element_2_valueItem_3)); - cleanupStrings.push_back(element_2_valueItem_3Jni); - listHolder_2->mList[i_2].value = element_2_valueItem_3Jni->charSpan(); - jobject element_2_externalIDListItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_2, "externalIDList", "Ljava/util/ArrayList;", - element_2_externalIDListItem_3); - { - using ListType_4 = std::remove_reference_tmList[i_2].externalIDList)>; - using ListMemberType_4 = ListMemberTypeGetter::Type; - jint element_2_externalIDListItem_3Size; - chip::JniReferences::GetInstance().GetArrayListSize(element_2_externalIDListItem_3, - element_2_externalIDListItem_3Size); - if (element_2_externalIDListItem_3Size != 0) - { - auto * listHolder_4 = new ListHolder(element_2_externalIDListItem_3Size); - listFreer.add(listHolder_4); - - for (size_t i_4 = 0; i_4 < static_cast(element_2_externalIDListItem_3Size); ++i_4) - { - jobject element_4; - chip::JniReferences::GetInstance().GetArrayListItem(element_2_externalIDListItem_3, i_4, - element_4); - jobject element_4_nameItem_5; - chip::JniReferences::GetInstance().GetObjectField(element_4, "name", "Ljava/lang/String;", - element_4_nameItem_5); - auto element_4_nameItem_5Jni = chip::Platform::New( - env, static_cast(element_4_nameItem_5)); - cleanupStrings.push_back(element_4_nameItem_5Jni); - listHolder_4->mList[i_4].name = element_4_nameItem_5Jni->charSpan(); - jobject element_4_valueItem_5; - chip::JniReferences::GetInstance().GetObjectField(element_4, "value", "Ljava/lang/String;", - element_4_valueItem_5); - auto element_4_valueItem_5Jni = chip::Platform::New( - env, static_cast(element_4_valueItem_5)); - cleanupStrings.push_back(element_4_valueItem_5Jni); - listHolder_4->mList[i_4].value = element_4_valueItem_5Jni->charSpan(); - } - listHolder_2->mList[i_2].externalIDList = - ListType_4(listHolder_4->mList, element_2_externalIDListItem_3Size); - } - else - { - listHolder_2->mList[i_2].externalIDList = ListType_4(); - } - } - } - listHolder_0->mList[i_0].parameterList = ListType_2(listHolder_2->mList, element_0_parameterListItem_1Size); - } - else - { - listHolder_0->mList[i_0].parameterList = ListType_2(); - } - } - } - request.search = ListType_0(listHolder_0->mList, searchSize); - } - else - { - request.search = ListType_0(); - } - } + auto ssidJni = chip::Platform::New(env, static_cast(ssid)); + cleanupByteArrays.push_back(ssidJni); + request.ssid = ssidJni->byteSpan(); + auto credentialsJni = chip::Platform::New(env, static_cast(credentials)); + cleanupByteArrays.push_back(credentialsJni); + request.credentials = credentialsJni->byteSpan(); + request.breadcrumb = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(breadcrumb)); - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -9510,13 +9569,13 @@ JNI_METHOD(void, ContentLauncherCluster, launchContentRequest) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -9540,244 +9599,29 @@ JNI_METHOD(void, ContentLauncherCluster, launchContentRequest) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ContentLauncherCluster, launchURLRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring contentURL, jstring displayString, - jobject brandingInformation, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, NetworkCommissioningCluster, connectNetwork) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray networkID, jobject breadcrumb, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - ContentLauncherCluster * cppCluster; + NetworkCommissioningCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::ContentLauncher::Commands::LaunchURLRequest::Type request; + chip::app::Clusters::NetworkCommissioning::Commands::ConnectNetwork::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - auto contentURLJni = chip::Platform::New(env, static_cast(contentURL)); - cleanupStrings.push_back(contentURLJni); - request.contentURL = contentURLJni->charSpan(); - auto displayStringJni = chip::Platform::New(env, static_cast(displayString)); - cleanupStrings.push_back(displayStringJni); - request.displayString = displayStringJni->charSpan(); - jobject brandingInformation_providerNameItem_0; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation, "providerName", "Ljava/lang/String;", - brandingInformation_providerNameItem_0); - auto brandingInformation_providerNameItem_0Jni = - chip::Platform::New(env, static_cast(brandingInformation_providerNameItem_0)); - cleanupStrings.push_back(brandingInformation_providerNameItem_0Jni); - request.brandingInformation.providerName = brandingInformation_providerNameItem_0Jni->charSpan(); - jobject brandingInformation_backgroundItem_0; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation, "background", - "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterStyleInformation;", - brandingInformation_backgroundItem_0); - jobject brandingInformation_backgroundItem_0_imageUrlItem_1; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_backgroundItem_0, "imageUrl", "Ljava/lang/String;", - brandingInformation_backgroundItem_0_imageUrlItem_1); - auto brandingInformation_backgroundItem_0_imageUrlItem_1Jni = - chip::Platform::New(env, static_cast(brandingInformation_backgroundItem_0_imageUrlItem_1)); - cleanupStrings.push_back(brandingInformation_backgroundItem_0_imageUrlItem_1Jni); - request.brandingInformation.background.imageUrl = brandingInformation_backgroundItem_0_imageUrlItem_1Jni->charSpan(); - jobject brandingInformation_backgroundItem_0_colorItem_1; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_backgroundItem_0, "color", "Ljava/lang/String;", - brandingInformation_backgroundItem_0_colorItem_1); - auto brandingInformation_backgroundItem_0_colorItem_1Jni = - chip::Platform::New(env, static_cast(brandingInformation_backgroundItem_0_colorItem_1)); - cleanupStrings.push_back(brandingInformation_backgroundItem_0_colorItem_1Jni); - request.brandingInformation.background.color = brandingInformation_backgroundItem_0_colorItem_1Jni->charSpan(); - jobject brandingInformation_backgroundItem_0_sizeItem_1; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_backgroundItem_0, "size", - "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterDimension;", - brandingInformation_backgroundItem_0_sizeItem_1); - jobject brandingInformation_backgroundItem_0_sizeItem_1_widthItem_2; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_backgroundItem_0_sizeItem_1, "width", - "Ljava/lang/Double;", - brandingInformation_backgroundItem_0_sizeItem_1_widthItem_2); - request.brandingInformation.background.size.width = - static_cast>( - chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_backgroundItem_0_sizeItem_1_widthItem_2)); - jobject brandingInformation_backgroundItem_0_sizeItem_1_heightItem_2; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_backgroundItem_0_sizeItem_1, "height", - "Ljava/lang/Double;", - brandingInformation_backgroundItem_0_sizeItem_1_heightItem_2); - request.brandingInformation.background.size.height = - static_cast>( - chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_backgroundItem_0_sizeItem_1_heightItem_2)); - jobject brandingInformation_backgroundItem_0_sizeItem_1_metricItem_2; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_backgroundItem_0_sizeItem_1, "metric", - "Ljava/lang/Integer;", - brandingInformation_backgroundItem_0_sizeItem_1_metricItem_2); - request.brandingInformation.background.size.metric = - static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(brandingInformation_backgroundItem_0_sizeItem_1_metricItem_2)); - jobject brandingInformation_logoItem_0; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation, "logo", - "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterStyleInformation;", - brandingInformation_logoItem_0); - jobject brandingInformation_logoItem_0_imageUrlItem_1; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_logoItem_0, "imageUrl", "Ljava/lang/String;", - brandingInformation_logoItem_0_imageUrlItem_1); - auto brandingInformation_logoItem_0_imageUrlItem_1Jni = - chip::Platform::New(env, static_cast(brandingInformation_logoItem_0_imageUrlItem_1)); - cleanupStrings.push_back(brandingInformation_logoItem_0_imageUrlItem_1Jni); - request.brandingInformation.logo.imageUrl = brandingInformation_logoItem_0_imageUrlItem_1Jni->charSpan(); - jobject brandingInformation_logoItem_0_colorItem_1; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_logoItem_0, "color", "Ljava/lang/String;", - brandingInformation_logoItem_0_colorItem_1); - auto brandingInformation_logoItem_0_colorItem_1Jni = - chip::Platform::New(env, static_cast(brandingInformation_logoItem_0_colorItem_1)); - cleanupStrings.push_back(brandingInformation_logoItem_0_colorItem_1Jni); - request.brandingInformation.logo.color = brandingInformation_logoItem_0_colorItem_1Jni->charSpan(); - jobject brandingInformation_logoItem_0_sizeItem_1; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_logoItem_0, "size", - "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterDimension;", - brandingInformation_logoItem_0_sizeItem_1); - jobject brandingInformation_logoItem_0_sizeItem_1_widthItem_2; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_logoItem_0_sizeItem_1, "width", "Ljava/lang/Double;", - brandingInformation_logoItem_0_sizeItem_1_widthItem_2); - request.brandingInformation.logo.size.width = - static_cast>( - chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_logoItem_0_sizeItem_1_widthItem_2)); - jobject brandingInformation_logoItem_0_sizeItem_1_heightItem_2; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_logoItem_0_sizeItem_1, "height", "Ljava/lang/Double;", - brandingInformation_logoItem_0_sizeItem_1_heightItem_2); - request.brandingInformation.logo.size.height = - static_cast>( - chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_logoItem_0_sizeItem_1_heightItem_2)); - jobject brandingInformation_logoItem_0_sizeItem_1_metricItem_2; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_logoItem_0_sizeItem_1, "metric", "Ljava/lang/Integer;", - brandingInformation_logoItem_0_sizeItem_1_metricItem_2); - request.brandingInformation.logo.size.metric = - static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(brandingInformation_logoItem_0_sizeItem_1_metricItem_2)); - jobject brandingInformation_progressBarItem_0; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation, "progressBar", - "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterStyleInformation;", - brandingInformation_progressBarItem_0); - jobject brandingInformation_progressBarItem_0_imageUrlItem_1; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_progressBarItem_0, "imageUrl", "Ljava/lang/String;", - brandingInformation_progressBarItem_0_imageUrlItem_1); - auto brandingInformation_progressBarItem_0_imageUrlItem_1Jni = - chip::Platform::New(env, static_cast(brandingInformation_progressBarItem_0_imageUrlItem_1)); - cleanupStrings.push_back(brandingInformation_progressBarItem_0_imageUrlItem_1Jni); - request.brandingInformation.progressBar.imageUrl = brandingInformation_progressBarItem_0_imageUrlItem_1Jni->charSpan(); - jobject brandingInformation_progressBarItem_0_colorItem_1; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_progressBarItem_0, "color", "Ljava/lang/String;", - brandingInformation_progressBarItem_0_colorItem_1); - auto brandingInformation_progressBarItem_0_colorItem_1Jni = - chip::Platform::New(env, static_cast(brandingInformation_progressBarItem_0_colorItem_1)); - cleanupStrings.push_back(brandingInformation_progressBarItem_0_colorItem_1Jni); - request.brandingInformation.progressBar.color = brandingInformation_progressBarItem_0_colorItem_1Jni->charSpan(); - jobject brandingInformation_progressBarItem_0_sizeItem_1; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_progressBarItem_0, "size", - "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterDimension;", - brandingInformation_progressBarItem_0_sizeItem_1); - jobject brandingInformation_progressBarItem_0_sizeItem_1_widthItem_2; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_progressBarItem_0_sizeItem_1, "width", - "Ljava/lang/Double;", - brandingInformation_progressBarItem_0_sizeItem_1_widthItem_2); - request.brandingInformation.progressBar.size.width = - static_cast>( - chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_progressBarItem_0_sizeItem_1_widthItem_2)); - jobject brandingInformation_progressBarItem_0_sizeItem_1_heightItem_2; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_progressBarItem_0_sizeItem_1, "height", - "Ljava/lang/Double;", - brandingInformation_progressBarItem_0_sizeItem_1_heightItem_2); - request.brandingInformation.progressBar.size.height = - static_cast>( - chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_progressBarItem_0_sizeItem_1_heightItem_2)); - jobject brandingInformation_progressBarItem_0_sizeItem_1_metricItem_2; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_progressBarItem_0_sizeItem_1, "metric", - "Ljava/lang/Integer;", - brandingInformation_progressBarItem_0_sizeItem_1_metricItem_2); - request.brandingInformation.progressBar.size.metric = - static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(brandingInformation_progressBarItem_0_sizeItem_1_metricItem_2)); - jobject brandingInformation_splashItem_0; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation, "splash", - "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterStyleInformation;", - brandingInformation_splashItem_0); - jobject brandingInformation_splashItem_0_imageUrlItem_1; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_splashItem_0, "imageUrl", "Ljava/lang/String;", - brandingInformation_splashItem_0_imageUrlItem_1); - auto brandingInformation_splashItem_0_imageUrlItem_1Jni = - chip::Platform::New(env, static_cast(brandingInformation_splashItem_0_imageUrlItem_1)); - cleanupStrings.push_back(brandingInformation_splashItem_0_imageUrlItem_1Jni); - request.brandingInformation.splash.imageUrl = brandingInformation_splashItem_0_imageUrlItem_1Jni->charSpan(); - jobject brandingInformation_splashItem_0_colorItem_1; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_splashItem_0, "color", "Ljava/lang/String;", - brandingInformation_splashItem_0_colorItem_1); - auto brandingInformation_splashItem_0_colorItem_1Jni = - chip::Platform::New(env, static_cast(brandingInformation_splashItem_0_colorItem_1)); - cleanupStrings.push_back(brandingInformation_splashItem_0_colorItem_1Jni); - request.brandingInformation.splash.color = brandingInformation_splashItem_0_colorItem_1Jni->charSpan(); - jobject brandingInformation_splashItem_0_sizeItem_1; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_splashItem_0, "size", - "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterDimension;", - brandingInformation_splashItem_0_sizeItem_1); - jobject brandingInformation_splashItem_0_sizeItem_1_widthItem_2; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_splashItem_0_sizeItem_1, "width", "Ljava/lang/Double;", - brandingInformation_splashItem_0_sizeItem_1_widthItem_2); - request.brandingInformation.splash.size.width = - static_cast>( - chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_splashItem_0_sizeItem_1_widthItem_2)); - jobject brandingInformation_splashItem_0_sizeItem_1_heightItem_2; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_splashItem_0_sizeItem_1, "height", "Ljava/lang/Double;", - brandingInformation_splashItem_0_sizeItem_1_heightItem_2); - request.brandingInformation.splash.size.height = - static_cast>( - chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_splashItem_0_sizeItem_1_heightItem_2)); - jobject brandingInformation_splashItem_0_sizeItem_1_metricItem_2; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_splashItem_0_sizeItem_1, "metric", "Ljava/lang/Integer;", - brandingInformation_splashItem_0_sizeItem_1_metricItem_2); - request.brandingInformation.splash.size.metric = - static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(brandingInformation_splashItem_0_sizeItem_1_metricItem_2)); - jobject brandingInformation_waterMarkItem_0; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation, "waterMark", - "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterStyleInformation;", - brandingInformation_waterMarkItem_0); - jobject brandingInformation_waterMarkItem_0_imageUrlItem_1; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_waterMarkItem_0, "imageUrl", "Ljava/lang/String;", - brandingInformation_waterMarkItem_0_imageUrlItem_1); - auto brandingInformation_waterMarkItem_0_imageUrlItem_1Jni = - chip::Platform::New(env, static_cast(brandingInformation_waterMarkItem_0_imageUrlItem_1)); - cleanupStrings.push_back(brandingInformation_waterMarkItem_0_imageUrlItem_1Jni); - request.brandingInformation.waterMark.imageUrl = brandingInformation_waterMarkItem_0_imageUrlItem_1Jni->charSpan(); - jobject brandingInformation_waterMarkItem_0_colorItem_1; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_waterMarkItem_0, "color", "Ljava/lang/String;", - brandingInformation_waterMarkItem_0_colorItem_1); - auto brandingInformation_waterMarkItem_0_colorItem_1Jni = - chip::Platform::New(env, static_cast(brandingInformation_waterMarkItem_0_colorItem_1)); - cleanupStrings.push_back(brandingInformation_waterMarkItem_0_colorItem_1Jni); - request.brandingInformation.waterMark.color = brandingInformation_waterMarkItem_0_colorItem_1Jni->charSpan(); - jobject brandingInformation_waterMarkItem_0_sizeItem_1; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_waterMarkItem_0, "size", - "Lchip/devicecontroller/ChipStructs$ContentLauncherClusterDimension;", - brandingInformation_waterMarkItem_0_sizeItem_1); - jobject brandingInformation_waterMarkItem_0_sizeItem_1_widthItem_2; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_waterMarkItem_0_sizeItem_1, "width", "Ljava/lang/Double;", - brandingInformation_waterMarkItem_0_sizeItem_1_widthItem_2); - request.brandingInformation.waterMark.size.width = - static_cast>( - chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_waterMarkItem_0_sizeItem_1_widthItem_2)); - jobject brandingInformation_waterMarkItem_0_sizeItem_1_heightItem_2; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_waterMarkItem_0_sizeItem_1, "height", - "Ljava/lang/Double;", - brandingInformation_waterMarkItem_0_sizeItem_1_heightItem_2); - request.brandingInformation.waterMark.size.height = - static_cast>( - chip::JniReferences::GetInstance().DoubleToPrimitive(brandingInformation_waterMarkItem_0_sizeItem_1_heightItem_2)); - jobject brandingInformation_waterMarkItem_0_sizeItem_1_metricItem_2; - chip::JniReferences::GetInstance().GetObjectField(brandingInformation_waterMarkItem_0_sizeItem_1, "metric", - "Ljava/lang/Integer;", - brandingInformation_waterMarkItem_0_sizeItem_1_metricItem_2); - request.brandingInformation.waterMark.size.metric = - static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(brandingInformation_waterMarkItem_0_sizeItem_1_metricItem_2)); + auto networkIDJni = chip::Platform::New(env, static_cast(networkID)); + cleanupByteArrays.push_back(networkIDJni); + request.networkID = networkIDJni->byteSpan(); + request.breadcrumb = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(breadcrumb)); - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -9787,13 +9631,13 @@ JNI_METHOD(void, ContentLauncherCluster, launchURLRequest) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -9817,92 +9661,123 @@ JNI_METHOD(void, ContentLauncherCluster, launchURLRequest) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ContentLauncherCluster, subscribeAcceptHeaderListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, NetworkCommissioningCluster, removeNetwork) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray networkID, jobject breadcrumb, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + NetworkCommissioningCluster * cppCluster; - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + ListFreer listFreer; + chip::app::Clusters::NetworkCommissioning::Commands::RemoveNetwork::Type request; - CHIP_ERROR err = CHIP_NO_ERROR; - ContentLauncherCluster * cppCluster = reinterpret_cast(clusterPtr); + std::list cleanupByteArrays; + std::list cleanupStrings; + auto networkIDJni = chip::Platform::New(env, static_cast(networkID)); + cleanupByteArrays.push_back(networkIDJni); + request.networkID = networkIDJni->byteSpan(); + request.breadcrumb = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(breadcrumb)); + + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); + std::unique_ptr onFailure( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + VerifyOrReturn(onFailure.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ContentLauncher::Attributes::AcceptHeaderList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( + auto successFn = chip::Callback::Callback::FromCancelable( onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPContentLauncherAcceptHeaderListAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } - -JNI_METHOD(void, ContentLauncherCluster, writeSupportedStreamingProtocolsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) +JNI_METHOD(void, NetworkCommissioningCluster, reorderNetwork) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray networkID, jobject networkIndex, jobject breadcrumb, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; + CHIP_ERROR err = CHIP_NO_ERROR; + NetworkCommissioningCluster * cppCluster; - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); + ListFreer listFreer; + chip::app::Clusters::NetworkCommissioning::Commands::ReorderNetwork::Type request; - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + auto networkIDJni = chip::Platform::New(env, static_cast(networkID)); + cleanupByteArrays.push_back(networkIDJni); + request.networkID = networkIDJni->byteSpan(); + request.networkIndex = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(networkIndex)); + request.breadcrumb = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(breadcrumb)); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ContentLauncherCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedWriteTimeoutMs == nullptr) + if (timedInvokeTimeoutMs == nullptr) { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -9912,390 +9787,156 @@ JNI_METHOD(void, ContentLauncherCluster, writeSupportedStreamingProtocolsAttribu onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ContentLauncherCluster, subscribeSupportedStreamingProtocolsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, NetworkCommissioningCluster, scanNetworks) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray ssid, jobject breadcrumb, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + NetworkCommissioningCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::NetworkCommissioning::Commands::ScanNetworks::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + auto ssidJni = chip::Platform::New(env, static_cast(ssid)); + cleanupByteArrays.push_back(ssidJni); + request.ssid = ssidJni->byteSpan(); + request.breadcrumb = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(breadcrumb)); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ContentLauncherCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ContentLauncherCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, NetworkCommissioningCluster, writeInterfaceEnabledAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ContentLauncherCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::InterfaceEnabled::TypeInfo; + TypeInfo::Type cppValue; - using TypeInfo = chip::app::Clusters::ContentLauncher::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPContentLauncherAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + cppValue = + static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(value)); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ContentLauncherCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ContentLauncherCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + NetworkCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ContentLauncher::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, DescriptorCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +JNI_METHOD(jlong, OtaSoftwareUpdateProviderCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - DescriptorCluster * cppCluster = new DescriptorCluster(); + OtaSoftwareUpdateProviderCluster * cppCluster = new OtaSoftwareUpdateProviderCluster(); cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); return reinterpret_cast(cppCluster); } -JNI_METHOD(void, DescriptorCluster, subscribeDeviceListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, OtaSoftwareUpdateProviderCluster, applyUpdateRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray updateToken, jobject newVersion, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + OtaSoftwareUpdateProviderCluster * cppCluster; - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - DescriptorCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Descriptor::Attributes::DeviceList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPDescriptorDeviceListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, DescriptorCluster, subscribeServerListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - DescriptorCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Descriptor::Attributes::ServerList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPDescriptorServerListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, DescriptorCluster, subscribeClientListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - DescriptorCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Descriptor::Attributes::ClientList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPDescriptorClientListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, DescriptorCluster, subscribePartsListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - DescriptorCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Descriptor::Attributes::PartsList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPDescriptorPartsListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, DescriptorCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - DescriptorCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Descriptor::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPDescriptorAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, DescriptorCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - DescriptorCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Descriptor::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, DiagnosticLogsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - DiagnosticLogsCluster * cppCluster = new DiagnosticLogsCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, DiagnosticLogsCluster, retrieveLogsRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject intent, jobject requestedProtocol, - jbyteArray transferFileDesignator, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - DiagnosticLogsCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::DiagnosticLogs::Commands::RetrieveLogsRequest::Type request; + ListFreer listFreer; + chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::ApplyUpdateRequest::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.intent = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(intent)); - request.requestedProtocol = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(requestedProtocol)); - auto transferFileDesignatorJni = chip::Platform::New(env, static_cast(transferFileDesignator)); - cleanupByteArrays.push_back(transferFileDesignatorJni); - request.transferFileDesignator = transferFileDesignatorJni->byteSpan(); + auto updateTokenJni = chip::Platform::New(env, static_cast(updateToken)); + cleanupByteArrays.push_back(updateTokenJni); + request.updateToken = updateTokenJni->byteSpan(); + request.newVersion = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(newVersion)); - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -10305,13 +9946,13 @@ JNI_METHOD(void, DiagnosticLogsCluster, retrieveLogsRequest) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -10335,75 +9976,24 @@ JNI_METHOD(void, DiagnosticLogsCluster, retrieveLogsRequest) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DiagnosticLogsCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - DiagnosticLogsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::DiagnosticLogs::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPDiagnosticLogsAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, DoorLockCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - DoorLockCluster * cppCluster = new DoorLockCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, DoorLockCluster, clearCredential) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject credential, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, OtaSoftwareUpdateProviderCluster, notifyUpdateApplied) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray updateToken, jobject softwareVersion, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster; + OtaSoftwareUpdateProviderCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::ClearCredential::Type request; + chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::NotifyUpdateApplied::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - jobject credential_credentialTypeItem_0; - chip::JniReferences::GetInstance().GetObjectField(credential, "credentialType", "Ljava/lang/Integer;", - credential_credentialTypeItem_0); - request.credential.credentialType = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(credential_credentialTypeItem_0)); - jobject credential_credentialIndexItem_0; - chip::JniReferences::GetInstance().GetObjectField(credential, "credentialIndex", "Ljava/lang/Integer;", - credential_credentialIndexItem_0); - request.credential.credentialIndex = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(credential_credentialIndexItem_0)); + auto updateTokenJni = chip::Platform::New(env, static_cast(updateToken)); + cleanupByteArrays.push_back(updateTokenJni); + request.updateToken = updateTokenJni->byteSpan(); + request.softwareVersion = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(softwareVersion)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -10416,7 +10006,7 @@ JNI_METHOD(void, DoorLockCluster, clearCredential) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -10445,23 +10035,89 @@ JNI_METHOD(void, DoorLockCluster, clearCredential) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, clearUser) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject userIndex, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, OtaSoftwareUpdateProviderCluster, queryImage) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject vendorId, jobject productId, jobject softwareVersion, + jobject protocolsSupported, jobject hardwareVersion, jobject location, jobject requestorCanConsent, jobject metadataForProvider, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster; + OtaSoftwareUpdateProviderCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::ClearUser::Type request; + chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::QueryImage::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.userIndex = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(userIndex)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); + request.vendorId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(vendorId)); + request.productId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(productId)); + request.softwareVersion = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(softwareVersion)); + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + jint protocolsSupportedSize; + chip::JniReferences::GetInstance().GetArrayListSize(protocolsSupported, protocolsSupportedSize); + if (protocolsSupportedSize != 0) + { + auto * listHolder_0 = new ListHolder(protocolsSupportedSize); + listFreer.add(listHolder_0); + + for (size_t i_0 = 0; i_0 < static_cast(protocolsSupportedSize); ++i_0) + { + jobject element_0; + chip::JniReferences::GetInstance().GetArrayListItem(protocolsSupported, i_0, element_0); + listHolder_0->mList[i_0] = static_castmList[i_0])>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0)); + } + request.protocolsSupported = ListType_0(listHolder_0->mList, protocolsSupportedSize); + } + else + { + request.protocolsSupported = ListType_0(); + } + } + if (hardwareVersion != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(hardwareVersion, optionalValue_0); + auto & definedValue_0 = request.hardwareVersion.Emplace(); + definedValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_0)); + } + if (location != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(location, optionalValue_0); + auto & definedValue_0 = request.location.Emplace(); + auto optionalValue_0Jni = chip::Platform::New(env, static_cast(optionalValue_0)); + cleanupStrings.push_back(optionalValue_0Jni); + definedValue_0 = optionalValue_0Jni->charSpan(); + } + if (requestorCanConsent != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(requestorCanConsent, optionalValue_0); + auto & definedValue_0 = request.requestorCanConsent.Emplace(); + definedValue_0 = static_cast>( + chip::JniReferences::GetInstance().BooleanToPrimitive(optionalValue_0)); + } + if (metadataForProvider != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(metadataForProvider, optionalValue_0); + auto & definedValue_0 = request.metadataForProvider.Emplace(); + auto optionalValue_0Jni = chip::Platform::New(env, static_cast(optionalValue_0)); + cleanupByteArrays.push_back(optionalValue_0Jni); + definedValue_0 = optionalValue_0Jni->byteSpan(); + } + + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -10471,12 +10127,13 @@ JNI_METHOD(void, DoorLockCluster, clearUser) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -10500,33 +10157,48 @@ JNI_METHOD(void, DoorLockCluster, clearUser) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, getCredentialStatus) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject credential, jobject timedInvokeTimeoutMs) +JNI_METHOD(jlong, OtaSoftwareUpdateRequestorCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + OtaSoftwareUpdateRequestorCluster * cppCluster = new OtaSoftwareUpdateRequestorCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, announceOtaProvider) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject providerNodeId, jobject vendorId, + jobject announcementReason, jobject metadataForNode, jobject endpoint, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster; + OtaSoftwareUpdateRequestorCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::GetCredentialStatus::Type request; + chip::app::Clusters::OtaSoftwareUpdateRequestor::Commands::AnnounceOtaProvider::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - jobject credential_credentialTypeItem_0; - chip::JniReferences::GetInstance().GetObjectField(credential, "credentialType", "Ljava/lang/Integer;", - credential_credentialTypeItem_0); - request.credential.credentialType = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(credential_credentialTypeItem_0)); - jobject credential_credentialIndexItem_0; - chip::JniReferences::GetInstance().GetObjectField(credential, "credentialIndex", "Ljava/lang/Integer;", - credential_credentialIndexItem_0); - request.credential.credentialIndex = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(credential_credentialIndexItem_0)); + request.providerNodeId = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(providerNodeId)); + request.vendorId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(vendorId)); + request.announcementReason = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(announcementReason)); + if (metadataForNode != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(metadataForNode, optionalValue_0); + auto & definedValue_0 = request.metadataForNode.Emplace(); + auto optionalValue_0Jni = chip::Platform::New(env, static_cast(optionalValue_0)); + cleanupByteArrays.push_back(optionalValue_0Jni); + definedValue_0 = optionalValue_0Jni->byteSpan(); + } + request.endpoint = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(endpoint)); - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -10536,13 +10208,12 @@ JNI_METHOD(void, DoorLockCluster, getCredentialStatus) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -10566,53 +10237,92 @@ JNI_METHOD(void, DoorLockCluster, getCredentialStatus) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, getUser) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject userIndex, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, writeDefaultOtaProvidersAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::GetUser::Type request; + using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::DefaultOtaProviders::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.userIndex = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(userIndex)); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + jint valueSize; + chip::JniReferences::GetInstance().GetArrayListSize(value, valueSize); + if (valueSize != 0) + { + auto * listHolder_0 = new ListHolder(valueSize); + listFreer.add(listHolder_0); + + for (size_t i_0 = 0; i_0 < static_cast(valueSize); ++i_0) + { + jobject element_0; + chip::JniReferences::GetInstance().GetArrayListItem(value, i_0, element_0); + jobject element_0_fabricIndexItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "fabricIndex", "Ljava/lang/Integer;", + element_0_fabricIndexItem_1); + listHolder_0->mList[i_0].fabricIndex = + static_castmList[i_0].fabricIndex)>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_fabricIndexItem_1)); + jobject element_0_providerNodeIDItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "providerNodeID", "Ljava/lang/Long;", + element_0_providerNodeIDItem_1); + listHolder_0->mList[i_0].providerNodeID = + static_castmList[i_0].providerNodeID)>>( + chip::JniReferences::GetInstance().LongToPrimitive(element_0_providerNodeIDItem_1)); + jobject element_0_endpointItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "endpoint", "Ljava/lang/Integer;", + element_0_endpointItem_1); + listHolder_0->mList[i_0].endpoint = + static_castmList[i_0].endpoint)>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_endpointItem_1)); + } + cppValue = ListType_0(listHolder_0->mList, valueSize); + } + else + { + cppValue = ListType_0(); + } + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - std::unique_ptr onSuccess( - Platform::New(callback), - Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + OtaSoftwareUpdateRequestorCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -10622,27 +10332,35 @@ JNI_METHOD(void, DoorLockCluster, getUser) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, lockDoor) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject pinCode, jobject timedInvokeTimeoutMs) +JNI_METHOD(jlong, OccupancySensingCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + OccupancySensingCluster * cppCluster = new OccupancySensingCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(jlong, OnOffCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + OnOffCluster * cppCluster = new OnOffCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(void, OnOffCluster, off)(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster; + OnOffCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::LockDoor::Type request; + chip::app::Clusters::OnOff::Commands::Off::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - if (pinCode != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(pinCode, optionalValue_0); - auto & definedValue_0 = request.pinCode.Emplace(); - auto optionalValue_0Jni = chip::Platform::New(env, static_cast(optionalValue_0)); - cleanupByteArrays.push_back(optionalValue_0Jni); - definedValue_0 = optionalValue_0Jni->byteSpan(); - } std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -10655,7 +10373,7 @@ JNI_METHOD(void, DoorLockCluster, lockDoor) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -10684,42 +10402,26 @@ JNI_METHOD(void, DoorLockCluster, lockDoor) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, setCredential) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject operationType, jobject credential, - jbyteArray credentialData, jobject userIndex, jobject userStatus, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, OnOffCluster, offWithEffect) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject effectId, jobject effectVariant, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster; + OnOffCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::SetCredential::Type request; + chip::app::Clusters::OnOff::Commands::OffWithEffect::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.operationType = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(operationType)); - jobject credential_credentialTypeItem_0; - chip::JniReferences::GetInstance().GetObjectField(credential, "credentialType", "Ljava/lang/Integer;", - credential_credentialTypeItem_0); - request.credential.credentialType = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(credential_credentialTypeItem_0)); - jobject credential_credentialIndexItem_0; - chip::JniReferences::GetInstance().GetObjectField(credential, "credentialIndex", "Ljava/lang/Integer;", - credential_credentialIndexItem_0); - request.credential.credentialIndex = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(credential_credentialIndexItem_0)); - auto credentialDataJni = chip::Platform::New(env, static_cast(credentialData)); - cleanupByteArrays.push_back(credentialDataJni); - request.credentialData = credentialDataJni->byteSpan(); - request.userIndex = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(userIndex)); - request.userStatus = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(userStatus)); + request.effectId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(effectId)); + request.effectVariant = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(effectVariant)); - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -10729,13 +10431,12 @@ JNI_METHOD(void, DoorLockCluster, setCredential) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -10759,50 +10460,17 @@ JNI_METHOD(void, DoorLockCluster, setCredential) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, setUser) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject operationType, jobject userIndex, jstring userName, - jobject userUniqueId, jobject userStatus, jobject userType, jobject credentialRule, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, OnOffCluster, on)(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster; + OnOffCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::SetUser::Type request; + chip::app::Clusters::OnOff::Commands::On::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.operationType = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(operationType)); - request.userIndex = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(userIndex)); - if (userName == nullptr) - { - request.userName.SetNull(); - } - else - { - auto & nonNullValue_0 = request.userName.SetNonNull(); - auto userNameJni = chip::Platform::New(env, static_cast(userName)); - cleanupStrings.push_back(userNameJni); - nonNullValue_0 = userNameJni->charSpan(); - } - if (userUniqueId == nullptr) - { - request.userUniqueId.SetNull(); - } - else - { - auto & nonNullValue_0 = request.userUniqueId.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(userUniqueId)); - } - request.userStatus = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(userStatus)); - request.userType = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(userType)); - request.credentialRule = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(credentialRule)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -10815,7 +10483,7 @@ JNI_METHOD(void, DoorLockCluster, setUser) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -10844,27 +10512,18 @@ JNI_METHOD(void, DoorLockCluster, setUser) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, unlockDoor) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject pinCode, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, OnOffCluster, onWithRecallGlobalScene) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster; + OnOffCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnlockDoor::Type request; + chip::app::Clusters::OnOff::Commands::OnWithRecallGlobalScene::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - if (pinCode != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(pinCode, optionalValue_0); - auto & definedValue_0 = request.pinCode.Emplace(); - auto optionalValue_0Jni = chip::Platform::New(env, static_cast(optionalValue_0)); - cleanupByteArrays.push_back(optionalValue_0Jni); - definedValue_0 = optionalValue_0Jni->byteSpan(); - } std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -10877,7 +10536,7 @@ JNI_METHOD(void, DoorLockCluster, unlockDoor) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -10906,334 +10565,147 @@ JNI_METHOD(void, DoorLockCluster, unlockDoor) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, subscribeLockStateAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, OnOffCluster, onWithTimedOff) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject onOffControl, jobject onTime, jobject offWaitTime, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + OnOffCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::OnOff::Commands::OnWithTimedOff::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.onOffControl = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(onOffControl)); + request.onTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(onTime)); + request.offWaitTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(offWaitTime)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::LockState::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPDoorLockLockStateAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, subscribeLockTypeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, OnOffCluster, toggle)(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + OnOffCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::OnOff::Commands::Toggle::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::LockType::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, subscribeActuatorEnabledAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, OnOffCluster, writeOnTimeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::OnOff::Attributes::OnTime::TypeInfo; + TypeInfo::Type cppValue; - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::ActuatorEnabled::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, DoorLockCluster, subscribeDoorStateAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::DoorState::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPDoorLockDoorStateAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, DoorLockCluster, subscribeNumberOfTotalUsersSupportedAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::NumberOfTotalUsersSupported::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, DoorLockCluster, subscribeNumberOfPINUsersSupportedAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::NumberOfPINUsersSupported::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, DoorLockCluster, subscribeMaxPINCodeLengthAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::MaxPINCodeLength::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, DoorLockCluster, subscribeMinPINCodeLengthAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::MinPINCodeLength::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, DoorLockCluster, writeLanguageAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::Language::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - auto valueJni = chip::Platform::New(env, static_cast(value)); - cleanupStrings.push_back(valueJni); - cppValue = valueJni->charSpan(); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -11262,56 +10734,20 @@ JNI_METHOD(void, DoorLockCluster, writeLanguageAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, subscribeLanguageAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::Language::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, DoorLockCluster, writeAutoRelockTimeAttribute) +JNI_METHOD(void, OnOffCluster, writeOffWaitTimeAttribute) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; ListFreer listFreer; - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::AutoRelockTime::TypeInfo; + using TypeInfo = chip::app::Clusters::OnOff::Attributes::OffWaitTime::TypeInfo; TypeInfo::Type cppValue; std::vector cleanupByteArrays; std::vector cleanupStrings; - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -11325,8 +10761,8 @@ JNI_METHOD(void, DoorLockCluster, writeAutoRelockTimeAttribute) chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -11355,50 +10791,13 @@ JNI_METHOD(void, DoorLockCluster, writeAutoRelockTimeAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, subscribeAutoRelockTimeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::AutoRelockTime::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, DoorLockCluster, writeSoundVolumeAttribute) +JNI_METHOD(void, OnOffCluster, writeStartUpOnOffAttribute) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; ListFreer listFreer; - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::SoundVolume::TypeInfo; + using TypeInfo = chip::app::Clusters::OnOff::Attributes::StartUpOnOff::TypeInfo; TypeInfo::Type cppValue; std::vector cleanupByteArrays; @@ -11419,8 +10818,8 @@ JNI_METHOD(void, DoorLockCluster, writeSoundVolumeAttribute) chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -11449,50 +10848,21 @@ JNI_METHOD(void, DoorLockCluster, writeSoundVolumeAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, subscribeSoundVolumeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, OnOffSwitchConfigurationCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::SoundVolume::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + OnOffSwitchConfigurationCluster * cppCluster = new OnOffSwitchConfigurationCluster(); - onSuccess.release(); - onFailure.release(); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); } -JNI_METHOD(void, DoorLockCluster, writeOperatingModeAttribute) +JNI_METHOD(void, OnOffSwitchConfigurationCluster, writeSwitchActionsAttribute) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; ListFreer listFreer; - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::OperatingMode::TypeInfo; + using TypeInfo = chip::app::Clusters::OnOffSwitchConfiguration::Attributes::SwitchActions::TypeInfo; TypeInfo::Type cppValue; std::vector cleanupByteArrays; @@ -11513,8 +10883,8 @@ JNI_METHOD(void, DoorLockCluster, writeOperatingModeAttribute) chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + OnOffSwitchConfigurationCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -11543,128 +10913,138 @@ JNI_METHOD(void, DoorLockCluster, writeOperatingModeAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, subscribeOperatingModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, OperationalCredentialsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::OperatingMode::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + OperationalCredentialsCluster * cppCluster = new OperationalCredentialsCluster(); - onSuccess.release(); - onFailure.release(); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); } -JNI_METHOD(void, DoorLockCluster, subscribeSupportedOperatingModesAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, OperationalCredentialsCluster, addNOC) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray NOCValue, jobject ICACValue, jbyteArray IPKValue, + jobject caseAdminNode, jobject adminVendorId, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + OperationalCredentialsCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::OperationalCredentials::Commands::AddNOC::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + auto NOCValueJni = chip::Platform::New(env, static_cast(NOCValue)); + cleanupByteArrays.push_back(NOCValueJni); + request.NOCValue = NOCValueJni->byteSpan(); + if (ICACValue != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(ICACValue, optionalValue_0); + auto & definedValue_0 = request.ICACValue.Emplace(); + auto optionalValue_0Jni = chip::Platform::New(env, static_cast(optionalValue_0)); + cleanupByteArrays.push_back(optionalValue_0Jni); + definedValue_0 = optionalValue_0Jni->byteSpan(); + } + auto IPKValueJni = chip::Platform::New(env, static_cast(IPKValue)); + cleanupByteArrays.push_back(IPKValueJni); + request.IPKValue = IPKValueJni->byteSpan(); + request.caseAdminNode = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(caseAdminNode)); + request.adminVendorId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(adminVendorId)); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::SupportedOperatingModes::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } - -JNI_METHOD(void, DoorLockCluster, writeEnableOneTouchLockingAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) +JNI_METHOD(void, OperationalCredentialsCluster, addTrustedRootCertificate) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray rootCertificate, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::EnableOneTouchLocking::TypeInfo; - TypeInfo::Type cppValue; + CHIP_ERROR err = CHIP_NO_ERROR; + OperationalCredentialsCluster * cppCluster; - std::vector cleanupByteArrays; - std::vector cleanupStrings; + ListFreer listFreer; + chip::app::Clusters::OperationalCredentials::Commands::AddTrustedRootCertificate::Type request; - cppValue = - static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(value)); + std::list cleanupByteArrays; + std::list cleanupStrings; + auto rootCertificateJni = chip::Platform::New(env, static_cast(rootCertificate)); + cleanupByteArrays.push_back(rootCertificateJni); + request.rootCertificate = rootCertificateJni->byteSpan(); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedWriteTimeoutMs == nullptr) + if (timedInvokeTimeoutMs == nullptr) { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -11674,91 +11054,56 @@ JNI_METHOD(void, DoorLockCluster, writeEnableOneTouchLockingAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, subscribeEnableOneTouchLockingAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, OperationalCredentialsCluster, attestationRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray attestationNonce, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::EnableOneTouchLocking::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} + CHIP_ERROR err = CHIP_NO_ERROR; + OperationalCredentialsCluster * cppCluster; -JNI_METHOD(void, DoorLockCluster, writeEnablePrivacyModeButtonAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; ListFreer listFreer; - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::EnablePrivacyModeButton::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(value)); + chip::app::Clusters::OperationalCredentials::Commands::AttestationRequest::Type request; - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + auto attestationNonceJni = chip::Platform::New(env, static_cast(attestationNonce)); + cleanupByteArrays.push_back(attestationNonceJni); + request.attestationNonce = attestationNonceJni->byteSpan(); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedWriteTimeoutMs == nullptr) + if (timedInvokeTimeoutMs == nullptr) { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -11768,91 +11113,115 @@ JNI_METHOD(void, DoorLockCluster, writeEnablePrivacyModeButtonAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, subscribeEnablePrivacyModeButtonAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, OperationalCredentialsCluster, certificateChainRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject certificateType, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + OperationalCredentialsCluster * cppCluster; - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + ListFreer listFreer; + chip::app::Clusters::OperationalCredentials::Commands::CertificateChainRequest::Type request; - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + std::list cleanupByteArrays; + std::list cleanupStrings; + request.certificateType = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(certificateType)); + + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); + std::unique_ptr onFailure( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + VerifyOrReturn(onFailure.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::EnablePrivacyModeButton::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } - -JNI_METHOD(void, DoorLockCluster, writeWrongCodeEntryLimitAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) +JNI_METHOD(void, OperationalCredentialsCluster, opCSRRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray CSRNonce, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::WrongCodeEntryLimit::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; + CHIP_ERROR err = CHIP_NO_ERROR; + OperationalCredentialsCluster * cppCluster; - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + ListFreer listFreer; + chip::app::Clusters::OperationalCredentials::Commands::OpCSRRequest::Type request; - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + auto CSRNonceJni = chip::Platform::New(env, static_cast(CSRNonce)); + cleanupByteArrays.push_back(CSRNonceJni); + request.CSRNonce = CSRNonceJni->byteSpan(); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedWriteTimeoutMs == nullptr) + if (timedInvokeTimeoutMs == nullptr) { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -11862,635 +11231,841 @@ JNI_METHOD(void, DoorLockCluster, writeWrongCodeEntryLimitAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, subscribeWrongCodeEntryLimitAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, OperationalCredentialsCluster, removeFabric) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject fabricIndex, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + OperationalCredentialsCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::OperationalCredentials::Commands::RemoveFabric::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.fabricIndex = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(fabricIndex)); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::WrongCodeEntryLimit::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, OperationalCredentialsCluster, removeTrustedRootCertificate) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray trustedRootIdentifier, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + OperationalCredentialsCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::OperationalCredentials::Commands::RemoveTrustedRootCertificate::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + auto trustedRootIdentifierJni = chip::Platform::New(env, static_cast(trustedRootIdentifier)); + cleanupByteArrays.push_back(trustedRootIdentifierJni); + request.trustedRootIdentifier = trustedRootIdentifierJni->byteSpan(); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPDoorLockAttributeListAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, DoorLockCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, OperationalCredentialsCluster, updateFabricLabel) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring label, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + OperationalCredentialsCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::OperationalCredentials::Commands::UpdateFabricLabel::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + auto labelJni = chip::Platform::New(env, static_cast(label)); + cleanupStrings.push_back(labelJni); + request.label = labelJni->charSpan(); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::DoorLock::Attributes::ClusterRevision::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, ElectricalMeasurementCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - ElectricalMeasurementCluster * cppCluster = new ElectricalMeasurementCluster(); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); -JNI_METHOD(void, ElectricalMeasurementCluster, subscribeMeasurementTypeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OperationalCredentialsCluster, updateNOC) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray NOCValue, jobject ICACValue, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + OperationalCredentialsCluster * cppCluster; + ListFreer listFreer; + chip::app::Clusters::OperationalCredentials::Commands::UpdateNOC::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + auto NOCValueJni = chip::Platform::New(env, static_cast(NOCValue)); + cleanupByteArrays.push_back(NOCValueJni); + request.NOCValue = NOCValueJni->byteSpan(); + if (ICACValue != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(ICACValue, optionalValue_0); + auto & definedValue_0 = request.ICACValue.Emplace(); + auto optionalValue_0Jni = chip::Platform::New(env, static_cast(optionalValue_0)); + cleanupByteArrays.push_back(optionalValue_0Jni); + definedValue_0 = optionalValue_0Jni->byteSpan(); + } + + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ElectricalMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::MeasurementType::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ElectricalMeasurementCluster, subscribeTotalActivePowerAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, PowerSourceCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + PowerSourceCluster * cppCluster = new PowerSourceCluster(); - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} - CHIP_ERROR err = CHIP_NO_ERROR; - ElectricalMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); +JNI_METHOD(jlong, PowerSourceConfigurationCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + PowerSourceConfigurationCluster * cppCluster = new PowerSourceConfigurationCluster(); - using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::TotalActivePower::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); +JNI_METHOD(jlong, PressureMeasurementCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + PressureMeasurementCluster * cppCluster = new PressureMeasurementCluster(); - onSuccess.release(); - onFailure.release(); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(jlong, PumpConfigurationAndControlCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + PumpConfigurationAndControlCluster * cppCluster = new PumpConfigurationAndControlCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); } -JNI_METHOD(void, ElectricalMeasurementCluster, subscribeRmsVoltageAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, PumpConfigurationAndControlCluster, writeLifetimeRunningHoursAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::LifetimeRunningHours::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ElectricalMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::RmsVoltage::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ElectricalMeasurementCluster, subscribeRmsVoltageMinAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, PumpConfigurationAndControlCluster, writeLifetimeEnergyConsumedAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::LifetimeEnergyConsumed::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ElectricalMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::RmsVoltageMin::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ElectricalMeasurementCluster, subscribeRmsVoltageMaxAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, PumpConfigurationAndControlCluster, writeOperationModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::OperationMode::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ElectricalMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::RmsVoltageMax::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ElectricalMeasurementCluster, subscribeRmsCurrentAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ElectricalMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::RmsCurrent::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ElectricalMeasurementCluster, subscribeRmsCurrentMinAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, PumpConfigurationAndControlCluster, writeControlModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::ControlMode::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ElectricalMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::RmsCurrentMin::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ElectricalMeasurementCluster, subscribeRmsCurrentMaxAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, RelativeHumidityMeasurementCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ElectricalMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + RelativeHumidityMeasurementCluster * cppCluster = new RelativeHumidityMeasurementCluster(); - using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::RmsCurrentMax::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); +JNI_METHOD(jlong, ScenesCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + ScenesCluster * cppCluster = new ScenesCluster(); - onSuccess.release(); - onFailure.release(); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); } -JNI_METHOD(void, ElectricalMeasurementCluster, subscribeActivePowerAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ScenesCluster, addScene) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jobject sceneId, jobject transitionTime, + jstring sceneName, jobject extensionFieldSets, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ScenesCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::Scenes::Commands::AddScene::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.groupId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); + request.sceneId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(sceneId)); + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + auto sceneNameJni = chip::Platform::New(env, static_cast(sceneName)); + cleanupStrings.push_back(sceneNameJni); + request.sceneName = sceneNameJni->charSpan(); + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + jint extensionFieldSetsSize; + chip::JniReferences::GetInstance().GetArrayListSize(extensionFieldSets, extensionFieldSetsSize); + if (extensionFieldSetsSize != 0) + { + auto * listHolder_0 = new ListHolder(extensionFieldSetsSize); + listFreer.add(listHolder_0); + + for (size_t i_0 = 0; i_0 < static_cast(extensionFieldSetsSize); ++i_0) + { + jobject element_0; + chip::JniReferences::GetInstance().GetArrayListItem(extensionFieldSets, i_0, element_0); + jobject element_0_clusterIdItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "clusterId", "Ljava/lang/Long;", + element_0_clusterIdItem_1); + listHolder_0->mList[i_0].clusterId = + static_castmList[i_0].clusterId)>>( + chip::JniReferences::GetInstance().LongToPrimitive(element_0_clusterIdItem_1)); + jobject element_0_lengthItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "length", "Ljava/lang/Integer;", + element_0_lengthItem_1); + listHolder_0->mList[i_0].length = static_castmList[i_0].length)>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_lengthItem_1)); + jobject element_0_valueItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "value", "Ljava/lang/Integer;", element_0_valueItem_1); + listHolder_0->mList[i_0].value = static_castmList[i_0].value)>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_valueItem_1)); + } + request.extensionFieldSets = ListType_0(listHolder_0->mList, extensionFieldSetsSize); + } + else + { + request.extensionFieldSets = ListType_0(); + } + } + std::unique_ptr onSuccess( + Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ElectricalMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::ActivePower::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ElectricalMeasurementCluster, subscribeActivePowerMinAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, ScenesCluster, getSceneMembership) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ScenesCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::Scenes::Commands::GetSceneMembership::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.groupId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ElectricalMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::ActivePowerMin::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ElectricalMeasurementCluster, subscribeActivePowerMaxAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, ScenesCluster, recallScene) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jobject sceneId, jobject transitionTime, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ScenesCluster * cppCluster; - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ElectricalMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::ActivePowerMax::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + ListFreer listFreer; + chip::app::Clusters::Scenes::Commands::RecallScene::Type request; - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ElectricalMeasurementCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + request.groupId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); + request.sceneId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(sceneId)); + request.transitionTime = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ElectricalMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::AttributeList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPElectricalMeasurementAttributeListAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ElectricalMeasurementCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, ScenesCluster, removeAllScenes) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ScenesCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::Scenes::Commands::RemoveAllScenes::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.groupId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ElectricalMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, EthernetNetworkDiagnosticsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - EthernetNetworkDiagnosticsCluster * cppCluster = new EthernetNetworkDiagnosticsCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, resetCounts) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, ScenesCluster, removeScene) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jobject sceneId, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - EthernetNetworkDiagnosticsCluster * cppCluster; + ScenesCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::EthernetNetworkDiagnostics::Commands::ResetCounts::Type request; + chip::app::Clusters::Scenes::Commands::RemoveScene::Type request; std::list cleanupByteArrays; std::list cleanupStrings; + request.groupId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); + request.sceneId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(sceneId)); - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -12500,12 +12075,13 @@ JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, resetCounts) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -12529,865 +12105,1019 @@ JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, resetCounts) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribePHYRateAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, ScenesCluster, storeScene) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jobject sceneId, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ScenesCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::Scenes::Commands::StoreScene::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.groupId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); + request.sceneId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(sceneId)); + std::unique_ptr onSuccess( + Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - EthernetNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::PHYRate::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeFullDuplexAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, ScenesCluster, viewScene) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jobject sceneId, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + ScenesCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::Scenes::Commands::ViewScene::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.groupId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); + request.sceneId = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(sceneId)); + std::unique_ptr onSuccess( + Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - EthernetNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::FullDuplex::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribePacketRxCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, SoftwareDiagnosticsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + SoftwareDiagnosticsCluster * cppCluster = new SoftwareDiagnosticsCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(void, SoftwareDiagnosticsCluster, resetWatermarks) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) +{ + chip::DeviceLayer::StackLock lock; + CHIP_ERROR err = CHIP_NO_ERROR; + SoftwareDiagnosticsCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::SoftwareDiagnostics::Commands::ResetWatermarks::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - EthernetNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::PacketRxCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribePacketTxCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, SwitchCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + SwitchCluster * cppCluster = new SwitchCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(jlong, TargetNavigatorCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + TargetNavigatorCluster * cppCluster = new TargetNavigatorCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(void, TargetNavigatorCluster, navigateTargetRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject target, jstring data, jobject timedInvokeTimeoutMs) +{ + chip::DeviceLayer::StackLock lock; + CHIP_ERROR err = CHIP_NO_ERROR; + TargetNavigatorCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::TargetNavigator::Commands::NavigateTargetRequest::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.target = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(target)); + auto dataJni = chip::Platform::New(env, static_cast(data)); + cleanupStrings.push_back(dataJni); + request.data = dataJni->charSpan(); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - EthernetNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::PacketTxCount::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeTxErrCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, TemperatureMeasurementCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - EthernetNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + TemperatureMeasurementCluster * cppCluster = new TemperatureMeasurementCluster(); - using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::TxErrCount::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); +JNI_METHOD(jlong, TestClusterCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + TestClusterCluster * cppCluster = new TestClusterCluster(); - onSuccess.release(); - onFailure.release(); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); } -JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeCollisionCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, simpleStructEchoRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::TestCluster::Commands::SimpleStructEchoRequest::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + jobject arg1_aItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "a", "Ljava/lang/Integer;", arg1_aItem_0); + request.arg1.a = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_aItem_0)); + jobject arg1_bItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "b", "Ljava/lang/Boolean;", arg1_bItem_0); + request.arg1.b = static_cast>( + chip::JniReferences::GetInstance().BooleanToPrimitive(arg1_bItem_0)); + jobject arg1_cItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "c", "Ljava/lang/Integer;", arg1_cItem_0); + request.arg1.c = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_cItem_0)); + jobject arg1_dItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "d", "[B", arg1_dItem_0); + auto arg1_dItem_0Jni = chip::Platform::New(env, static_cast(arg1_dItem_0)); + cleanupByteArrays.push_back(arg1_dItem_0Jni); + request.arg1.d = arg1_dItem_0Jni->byteSpan(); + jobject arg1_eItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "e", "Ljava/lang/String;", arg1_eItem_0); + auto arg1_eItem_0Jni = chip::Platform::New(env, static_cast(arg1_eItem_0)); + cleanupStrings.push_back(arg1_eItem_0Jni); + request.arg1.e = arg1_eItem_0Jni->charSpan(); + jobject arg1_fItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "f", "Ljava/lang/Integer;", arg1_fItem_0); + request.arg1.f = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_fItem_0)); + jobject arg1_gItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "g", "Ljava/lang/Float;", arg1_gItem_0); + request.arg1.g = static_cast>( + chip::JniReferences::GetInstance().FloatToPrimitive(arg1_gItem_0)); + jobject arg1_hItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "h", "Ljava/lang/Double;", arg1_hItem_0); + request.arg1.h = static_cast>( + chip::JniReferences::GetInstance().DoubleToPrimitive(arg1_hItem_0)); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - EthernetNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::CollisionCount::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeOverrunCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, TestClusterCluster, test) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster; - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + ListFreer listFreer; + chip::app::Clusters::TestCluster::Commands::Test::Type request; - CHIP_ERROR err = CHIP_NO_ERROR; - EthernetNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::OverrunCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeCarrierDetectAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - EthernetNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::CarrierDetect::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeTimeSinceResetAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, TestClusterCluster, testAddArguments) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject arg2, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster; + ListFreer listFreer; + chip::app::Clusters::TestCluster::Commands::TestAddArguments::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.arg1 = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(arg1)); + request.arg2 = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(arg2)); + + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - EthernetNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::TimeSinceReset::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, TestClusterCluster, testEmitTestEventRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject arg2, jobject arg3, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::TestCluster::Commands::TestEmitTestEventRequest::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.arg1 = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(arg1)); + request.arg2 = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(arg2)); + request.arg3 = + static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(arg3)); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - EthernetNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::AttributeList::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPEthernetNetworkDiagnosticsAttributeListAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeFeatureMapAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, TestClusterCluster, testEnumsRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject arg2, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - EthernetNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::FeatureMap::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + ListFreer listFreer; + chip::app::Clusters::TestCluster::Commands::TestEnumsRequest::Type request; - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + request.arg1 = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(arg1)); + request.arg2 = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(arg2)); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - EthernetNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::ClusterRevision::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, FixedLabelCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +JNI_METHOD(void, TestClusterCluster, testListInt8UArgumentRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - FixedLabelCluster * cppCluster = new FixedLabelCluster(); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster; - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} + ListFreer listFreer; + chip::app::Clusters::TestCluster::Commands::TestListInt8UArgumentRequest::Type request; -JNI_METHOD(void, FixedLabelCluster, subscribeLabelListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - FixedLabelCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::FixedLabel::Attributes::LabelList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPFixedLabelLabelListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + std::list cleanupByteArrays; + std::list cleanupStrings; + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + jint arg1Size; + chip::JniReferences::GetInstance().GetArrayListSize(arg1, arg1Size); + if (arg1Size != 0) + { + auto * listHolder_0 = new ListHolder(arg1Size); + listFreer.add(listHolder_0); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, FixedLabelCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + for (size_t i_0 = 0; i_0 < static_cast(arg1Size); ++i_0) + { + jobject element_0; + chip::JniReferences::GetInstance().GetArrayListItem(arg1, i_0, element_0); + listHolder_0->mList[i_0] = static_castmList[i_0])>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0)); + } + request.arg1 = ListType_0(listHolder_0->mList, arg1Size); + } + else + { + request.arg1 = ListType_0(); + } + } + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - FixedLabelCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::FixedLabel::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPFixedLabelAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, FixedLabelCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - FixedLabelCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::FixedLabel::Attributes::ClusterRevision::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, FlowMeasurementCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - FlowMeasurementCluster * cppCluster = new FlowMeasurementCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, FlowMeasurementCluster, subscribeMeasuredValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - FlowMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::FlowMeasurement::Attributes::MeasuredValue::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, FlowMeasurementCluster, subscribeMinMeasuredValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, TestClusterCluster, testListInt8UReverseRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - FlowMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster; - using TypeInfo = chip::app::Clusters::FlowMeasurement::Attributes::MinMeasuredValue::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + ListFreer listFreer; + chip::app::Clusters::TestCluster::Commands::TestListInt8UReverseRequest::Type request; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + std::list cleanupByteArrays; + std::list cleanupStrings; + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + jint arg1Size; + chip::JniReferences::GetInstance().GetArrayListSize(arg1, arg1Size); + if (arg1Size != 0) + { + auto * listHolder_0 = new ListHolder(arg1Size); + listFreer.add(listHolder_0); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, FlowMeasurementCluster, subscribeMaxMeasuredValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + for (size_t i_0 = 0; i_0 < static_cast(arg1Size); ++i_0) + { + jobject element_0; + chip::JniReferences::GetInstance().GetArrayListItem(arg1, i_0, element_0); + listHolder_0->mList[i_0] = static_castmList[i_0])>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0)); + } + request.arg1 = ListType_0(listHolder_0->mList, arg1Size); + } + else + { + request.arg1 = ListType_0(); + } + } + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - FlowMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::FlowMeasurement::Attributes::MaxMeasuredValue::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( + auto successFn = chip::Callback::Callback::FromCancelable( onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, FlowMeasurementCluster, subscribeToleranceAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, TestClusterCluster, testListNestedStructListArgumentRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - FlowMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster; - using TypeInfo = chip::app::Clusters::FlowMeasurement::Attributes::Tolerance::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + ListFreer listFreer; + chip::app::Clusters::TestCluster::Commands::TestListNestedStructListArgumentRequest::Type request; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + std::list cleanupByteArrays; + std::list cleanupStrings; + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + jint arg1Size; + chip::JniReferences::GetInstance().GetArrayListSize(arg1, arg1Size); + if (arg1Size != 0) + { + auto * listHolder_0 = new ListHolder(arg1Size); + listFreer.add(listHolder_0); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, FlowMeasurementCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + for (size_t i_0 = 0; i_0 < static_cast(arg1Size); ++i_0) + { + jobject element_0; + chip::JniReferences::GetInstance().GetArrayListItem(arg1, i_0, element_0); + jobject element_0_aItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "a", "Ljava/lang/Integer;", element_0_aItem_1); + listHolder_0->mList[i_0].a = static_castmList[i_0].a)>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_aItem_1)); + jobject element_0_bItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "b", "Ljava/lang/Boolean;", element_0_bItem_1); + listHolder_0->mList[i_0].b = static_castmList[i_0].b)>>( + chip::JniReferences::GetInstance().BooleanToPrimitive(element_0_bItem_1)); + jobject element_0_cItem_1; + chip::JniReferences::GetInstance().GetObjectField( + element_0, "c", "Lchip/devicecontroller/ChipStructs$TestClusterClusterSimpleStruct;", element_0_cItem_1); + jobject element_0_cItem_1_aItem_2; + chip::JniReferences::GetInstance().GetObjectField(element_0_cItem_1, "a", "Ljava/lang/Integer;", + element_0_cItem_1_aItem_2); + listHolder_0->mList[i_0].c.a = static_castmList[i_0].c.a)>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_cItem_1_aItem_2)); + jobject element_0_cItem_1_bItem_2; + chip::JniReferences::GetInstance().GetObjectField(element_0_cItem_1, "b", "Ljava/lang/Boolean;", + element_0_cItem_1_bItem_2); + listHolder_0->mList[i_0].c.b = static_castmList[i_0].c.b)>>( + chip::JniReferences::GetInstance().BooleanToPrimitive(element_0_cItem_1_bItem_2)); + jobject element_0_cItem_1_cItem_2; + chip::JniReferences::GetInstance().GetObjectField(element_0_cItem_1, "c", "Ljava/lang/Integer;", + element_0_cItem_1_cItem_2); + listHolder_0->mList[i_0].c.c = static_castmList[i_0].c.c)>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_cItem_1_cItem_2)); + jobject element_0_cItem_1_dItem_2; + chip::JniReferences::GetInstance().GetObjectField(element_0_cItem_1, "d", "[B", element_0_cItem_1_dItem_2); + auto element_0_cItem_1_dItem_2Jni = + chip::Platform::New(env, static_cast(element_0_cItem_1_dItem_2)); + cleanupByteArrays.push_back(element_0_cItem_1_dItem_2Jni); + listHolder_0->mList[i_0].c.d = element_0_cItem_1_dItem_2Jni->byteSpan(); + jobject element_0_cItem_1_eItem_2; + chip::JniReferences::GetInstance().GetObjectField(element_0_cItem_1, "e", "Ljava/lang/String;", + element_0_cItem_1_eItem_2); + auto element_0_cItem_1_eItem_2Jni = + chip::Platform::New(env, static_cast(element_0_cItem_1_eItem_2)); + cleanupStrings.push_back(element_0_cItem_1_eItem_2Jni); + listHolder_0->mList[i_0].c.e = element_0_cItem_1_eItem_2Jni->charSpan(); + jobject element_0_cItem_1_fItem_2; + chip::JniReferences::GetInstance().GetObjectField(element_0_cItem_1, "f", "Ljava/lang/Integer;", + element_0_cItem_1_fItem_2); + listHolder_0->mList[i_0].c.f = static_castmList[i_0].c.f)>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_cItem_1_fItem_2)); + jobject element_0_cItem_1_gItem_2; + chip::JniReferences::GetInstance().GetObjectField(element_0_cItem_1, "g", "Ljava/lang/Float;", + element_0_cItem_1_gItem_2); + listHolder_0->mList[i_0].c.g = static_castmList[i_0].c.g)>>( + chip::JniReferences::GetInstance().FloatToPrimitive(element_0_cItem_1_gItem_2)); + jobject element_0_cItem_1_hItem_2; + chip::JniReferences::GetInstance().GetObjectField(element_0_cItem_1, "h", "Ljava/lang/Double;", + element_0_cItem_1_hItem_2); + listHolder_0->mList[i_0].c.h = static_castmList[i_0].c.h)>>( + chip::JniReferences::GetInstance().DoubleToPrimitive(element_0_cItem_1_hItem_2)); + jobject element_0_dItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "d", "Ljava/util/ArrayList;", element_0_dItem_1); + { + using ListType_2 = std::remove_reference_tmList[i_0].d)>; + using ListMemberType_2 = ListMemberTypeGetter::Type; + jint element_0_dItem_1Size; + chip::JniReferences::GetInstance().GetArrayListSize(element_0_dItem_1, element_0_dItem_1Size); + if (element_0_dItem_1Size != 0) + { + auto * listHolder_2 = new ListHolder(element_0_dItem_1Size); + listFreer.add(listHolder_2); + + for (size_t i_2 = 0; i_2 < static_cast(element_0_dItem_1Size); ++i_2) + { + jobject element_2; + chip::JniReferences::GetInstance().GetArrayListItem(element_0_dItem_1, i_2, element_2); + jobject element_2_aItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_2, "a", "Ljava/lang/Integer;", + element_2_aItem_3); + listHolder_2->mList[i_2].a = static_castmList[i_2].a)>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_2_aItem_3)); + jobject element_2_bItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_2, "b", "Ljava/lang/Boolean;", + element_2_bItem_3); + listHolder_2->mList[i_2].b = static_castmList[i_2].b)>>( + chip::JniReferences::GetInstance().BooleanToPrimitive(element_2_bItem_3)); + jobject element_2_cItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_2, "c", "Ljava/lang/Integer;", + element_2_cItem_3); + listHolder_2->mList[i_2].c = static_castmList[i_2].c)>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_2_cItem_3)); + jobject element_2_dItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_2, "d", "[B", element_2_dItem_3); + auto element_2_dItem_3Jni = + chip::Platform::New(env, static_cast(element_2_dItem_3)); + cleanupByteArrays.push_back(element_2_dItem_3Jni); + listHolder_2->mList[i_2].d = element_2_dItem_3Jni->byteSpan(); + jobject element_2_eItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_2, "e", "Ljava/lang/String;", + element_2_eItem_3); + auto element_2_eItem_3Jni = + chip::Platform::New(env, static_cast(element_2_eItem_3)); + cleanupStrings.push_back(element_2_eItem_3Jni); + listHolder_2->mList[i_2].e = element_2_eItem_3Jni->charSpan(); + jobject element_2_fItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_2, "f", "Ljava/lang/Integer;", + element_2_fItem_3); + listHolder_2->mList[i_2].f = static_castmList[i_2].f)>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_2_fItem_3)); + jobject element_2_gItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_2, "g", "Ljava/lang/Float;", + element_2_gItem_3); + listHolder_2->mList[i_2].g = static_castmList[i_2].g)>>( + chip::JniReferences::GetInstance().FloatToPrimitive(element_2_gItem_3)); + jobject element_2_hItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_2, "h", "Ljava/lang/Double;", + element_2_hItem_3); + listHolder_2->mList[i_2].h = static_castmList[i_2].h)>>( + chip::JniReferences::GetInstance().DoubleToPrimitive(element_2_hItem_3)); + } + listHolder_0->mList[i_0].d = ListType_2(listHolder_2->mList, element_0_dItem_1Size); + } + else + { + listHolder_0->mList[i_0].d = ListType_2(); + } + } + jobject element_0_eItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "e", "Ljava/util/ArrayList;", element_0_eItem_1); + { + using ListType_2 = std::remove_reference_tmList[i_0].e)>; + using ListMemberType_2 = ListMemberTypeGetter::Type; + jint element_0_eItem_1Size; + chip::JniReferences::GetInstance().GetArrayListSize(element_0_eItem_1, element_0_eItem_1Size); + if (element_0_eItem_1Size != 0) + { + auto * listHolder_2 = new ListHolder(element_0_eItem_1Size); + listFreer.add(listHolder_2); + + for (size_t i_2 = 0; i_2 < static_cast(element_0_eItem_1Size); ++i_2) + { + jobject element_2; + chip::JniReferences::GetInstance().GetArrayListItem(element_0_eItem_1, i_2, element_2); + listHolder_2->mList[i_2] = static_castmList[i_2])>>( + chip::JniReferences::GetInstance().LongToPrimitive(element_2)); + } + listHolder_0->mList[i_0].e = ListType_2(listHolder_2->mList, element_0_eItem_1Size); + } + else + { + listHolder_0->mList[i_0].e = ListType_2(); + } + } + jobject element_0_fItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "f", "Ljava/util/ArrayList;", element_0_fItem_1); + { + using ListType_2 = std::remove_reference_tmList[i_0].f)>; + using ListMemberType_2 = ListMemberTypeGetter::Type; + jint element_0_fItem_1Size; + chip::JniReferences::GetInstance().GetArrayListSize(element_0_fItem_1, element_0_fItem_1Size); + if (element_0_fItem_1Size != 0) + { + auto * listHolder_2 = new ListHolder(element_0_fItem_1Size); + listFreer.add(listHolder_2); + + for (size_t i_2 = 0; i_2 < static_cast(element_0_fItem_1Size); ++i_2) + { + jobject element_2; + chip::JniReferences::GetInstance().GetArrayListItem(element_0_fItem_1, i_2, element_2); + auto element_2Jni = chip::Platform::New(env, static_cast(element_2)); + cleanupByteArrays.push_back(element_2Jni); + listHolder_2->mList[i_2] = element_2Jni->byteSpan(); + } + listHolder_0->mList[i_0].f = ListType_2(listHolder_2->mList, element_0_fItem_1Size); + } + else + { + listHolder_0->mList[i_0].f = ListType_2(); + } + } + jobject element_0_gItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "g", "Ljava/util/ArrayList;", element_0_gItem_1); + { + using ListType_2 = std::remove_reference_tmList[i_0].g)>; + using ListMemberType_2 = ListMemberTypeGetter::Type; + jint element_0_gItem_1Size; + chip::JniReferences::GetInstance().GetArrayListSize(element_0_gItem_1, element_0_gItem_1Size); + if (element_0_gItem_1Size != 0) + { + auto * listHolder_2 = new ListHolder(element_0_gItem_1Size); + listFreer.add(listHolder_2); + + for (size_t i_2 = 0; i_2 < static_cast(element_0_gItem_1Size); ++i_2) + { + jobject element_2; + chip::JniReferences::GetInstance().GetArrayListItem(element_0_gItem_1, i_2, element_2); + listHolder_2->mList[i_2] = static_castmList[i_2])>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_2)); + } + listHolder_0->mList[i_0].g = ListType_2(listHolder_2->mList, element_0_gItem_1Size); + } + else + { + listHolder_0->mList[i_0].g = ListType_2(); + } + } + } + request.arg1 = ListType_0(listHolder_0->mList, arg1Size); + } + else + { + request.arg1 = ListType_0(); + } + } + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - FlowMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::FlowMeasurement::Attributes::AttributeList::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPFlowMeasurementAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, FlowMeasurementCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - FlowMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::FlowMeasurement::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, GeneralCommissioningCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - GeneralCommissioningCluster * cppCluster = new GeneralCommissioningCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, GeneralCommissioningCluster, armFailSafe) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject expiryLengthSeconds, jobject breadcrumb, jobject timeoutMs, - jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - GeneralCommissioningCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::GeneralCommissioning::Commands::ArmFailSafe::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.expiryLengthSeconds = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(expiryLengthSeconds)); - request.breadcrumb = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(breadcrumb)); - request.timeoutMs = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(timeoutMs)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -13411,23 +13141,79 @@ JNI_METHOD(void, GeneralCommissioningCluster, armFailSafe) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GeneralCommissioningCluster, commissioningComplete) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, TestClusterCluster, testListStructArgumentRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - GeneralCommissioningCluster * cppCluster; + TestClusterCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::GeneralCommissioning::Commands::CommissioningComplete::Type request; + chip::app::Clusters::TestCluster::Commands::TestListStructArgumentRequest::Type request; std::list cleanupByteArrays; std::list cleanupStrings; + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + jint arg1Size; + chip::JniReferences::GetInstance().GetArrayListSize(arg1, arg1Size); + if (arg1Size != 0) + { + auto * listHolder_0 = new ListHolder(arg1Size); + listFreer.add(listHolder_0); - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); + for (size_t i_0 = 0; i_0 < static_cast(arg1Size); ++i_0) + { + jobject element_0; + chip::JniReferences::GetInstance().GetArrayListItem(arg1, i_0, element_0); + jobject element_0_aItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "a", "Ljava/lang/Integer;", element_0_aItem_1); + listHolder_0->mList[i_0].a = static_castmList[i_0].a)>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_aItem_1)); + jobject element_0_bItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "b", "Ljava/lang/Boolean;", element_0_bItem_1); + listHolder_0->mList[i_0].b = static_castmList[i_0].b)>>( + chip::JniReferences::GetInstance().BooleanToPrimitive(element_0_bItem_1)); + jobject element_0_cItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "c", "Ljava/lang/Integer;", element_0_cItem_1); + listHolder_0->mList[i_0].c = static_castmList[i_0].c)>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_cItem_1)); + jobject element_0_dItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "d", "[B", element_0_dItem_1); + auto element_0_dItem_1Jni = + chip::Platform::New(env, static_cast(element_0_dItem_1)); + cleanupByteArrays.push_back(element_0_dItem_1Jni); + listHolder_0->mList[i_0].d = element_0_dItem_1Jni->byteSpan(); + jobject element_0_eItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "e", "Ljava/lang/String;", element_0_eItem_1); + auto element_0_eItem_1Jni = chip::Platform::New(env, static_cast(element_0_eItem_1)); + cleanupStrings.push_back(element_0_eItem_1Jni); + listHolder_0->mList[i_0].e = element_0_eItem_1Jni->charSpan(); + jobject element_0_fItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "f", "Ljava/lang/Integer;", element_0_fItem_1); + listHolder_0->mList[i_0].f = static_castmList[i_0].f)>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_fItem_1)); + jobject element_0_gItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "g", "Ljava/lang/Float;", element_0_gItem_1); + listHolder_0->mList[i_0].g = static_castmList[i_0].g)>>( + chip::JniReferences::GetInstance().FloatToPrimitive(element_0_gItem_1)); + jobject element_0_hItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "h", "Ljava/lang/Double;", element_0_hItem_1); + listHolder_0->mList[i_0].h = static_castmList[i_0].h)>>( + chip::JniReferences::GetInstance().DoubleToPrimitive(element_0_hItem_1)); + } + request.arg1 = ListType_0(listHolder_0->mList, arg1Size); + } + else + { + request.arg1 = ListType_0(); + } + } + + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -13437,14 +13223,13 @@ JNI_METHOD(void, GeneralCommissioningCluster, commissioningComplete) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -13468,33 +13253,67 @@ JNI_METHOD(void, GeneralCommissioningCluster, commissioningComplete) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GeneralCommissioningCluster, setRegulatoryConfig) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject location, jstring countryCode, jobject breadcrumb, - jobject timeoutMs, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, TestClusterCluster, testNestedStructArgumentRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - GeneralCommissioningCluster * cppCluster; + TestClusterCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfig::Type request; + chip::app::Clusters::TestCluster::Commands::TestNestedStructArgumentRequest::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.location = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(location)); - auto countryCodeJni = chip::Platform::New(env, static_cast(countryCode)); - cleanupStrings.push_back(countryCodeJni); - request.countryCode = countryCodeJni->charSpan(); - request.breadcrumb = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(breadcrumb)); - request.timeoutMs = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(timeoutMs)); + jobject arg1_aItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "a", "Ljava/lang/Integer;", arg1_aItem_0); + request.arg1.a = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_aItem_0)); + jobject arg1_bItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "b", "Ljava/lang/Boolean;", arg1_bItem_0); + request.arg1.b = static_cast>( + chip::JniReferences::GetInstance().BooleanToPrimitive(arg1_bItem_0)); + jobject arg1_cItem_0; + chip::JniReferences::GetInstance().GetObjectField( + arg1, "c", "Lchip/devicecontroller/ChipStructs$TestClusterClusterSimpleStruct;", arg1_cItem_0); + jobject arg1_cItem_0_aItem_1; + chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "a", "Ljava/lang/Integer;", arg1_cItem_0_aItem_1); + request.arg1.c.a = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_cItem_0_aItem_1)); + jobject arg1_cItem_0_bItem_1; + chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "b", "Ljava/lang/Boolean;", arg1_cItem_0_bItem_1); + request.arg1.c.b = static_cast>( + chip::JniReferences::GetInstance().BooleanToPrimitive(arg1_cItem_0_bItem_1)); + jobject arg1_cItem_0_cItem_1; + chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "c", "Ljava/lang/Integer;", arg1_cItem_0_cItem_1); + request.arg1.c.c = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_cItem_0_cItem_1)); + jobject arg1_cItem_0_dItem_1; + chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "d", "[B", arg1_cItem_0_dItem_1); + auto arg1_cItem_0_dItem_1Jni = chip::Platform::New(env, static_cast(arg1_cItem_0_dItem_1)); + cleanupByteArrays.push_back(arg1_cItem_0_dItem_1Jni); + request.arg1.c.d = arg1_cItem_0_dItem_1Jni->byteSpan(); + jobject arg1_cItem_0_eItem_1; + chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "e", "Ljava/lang/String;", arg1_cItem_0_eItem_1); + auto arg1_cItem_0_eItem_1Jni = chip::Platform::New(env, static_cast(arg1_cItem_0_eItem_1)); + cleanupStrings.push_back(arg1_cItem_0_eItem_1Jni); + request.arg1.c.e = arg1_cItem_0_eItem_1Jni->charSpan(); + jobject arg1_cItem_0_fItem_1; + chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "f", "Ljava/lang/Integer;", arg1_cItem_0_fItem_1); + request.arg1.c.f = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_cItem_0_fItem_1)); + jobject arg1_cItem_0_gItem_1; + chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "g", "Ljava/lang/Float;", arg1_cItem_0_gItem_1); + request.arg1.c.g = static_cast>( + chip::JniReferences::GetInstance().FloatToPrimitive(arg1_cItem_0_gItem_1)); + jobject arg1_cItem_0_hItem_1; + chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "h", "Ljava/lang/Double;", arg1_cItem_0_hItem_1); + request.arg1.c.h = static_cast>( + chip::JniReferences::GetInstance().DoubleToPrimitive(arg1_cItem_0_hItem_1)); - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -13504,14 +13323,13 @@ JNI_METHOD(void, GeneralCommissioningCluster, setRegulatoryConfig) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -13535,53 +13353,235 @@ JNI_METHOD(void, GeneralCommissioningCluster, setRegulatoryConfig) onSuccess.release(); onFailure.release(); } - -JNI_METHOD(void, GeneralCommissioningCluster, writeBreadcrumbAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) +JNI_METHOD(void, TestClusterCluster, testNestedStructListArgumentRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::GeneralCommissioning::Attributes::Breadcrumb::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster; - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + ListFreer listFreer; + chip::app::Clusters::TestCluster::Commands::TestNestedStructListArgumentRequest::Type request; - CHIP_ERROR err = CHIP_NO_ERROR; - GeneralCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); + std::list cleanupByteArrays; + std::list cleanupStrings; + jobject arg1_aItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "a", "Ljava/lang/Integer;", arg1_aItem_0); + request.arg1.a = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_aItem_0)); + jobject arg1_bItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "b", "Ljava/lang/Boolean;", arg1_bItem_0); + request.arg1.b = static_cast>( + chip::JniReferences::GetInstance().BooleanToPrimitive(arg1_bItem_0)); + jobject arg1_cItem_0; + chip::JniReferences::GetInstance().GetObjectField( + arg1, "c", "Lchip/devicecontroller/ChipStructs$TestClusterClusterSimpleStruct;", arg1_cItem_0); + jobject arg1_cItem_0_aItem_1; + chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "a", "Ljava/lang/Integer;", arg1_cItem_0_aItem_1); + request.arg1.c.a = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_cItem_0_aItem_1)); + jobject arg1_cItem_0_bItem_1; + chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "b", "Ljava/lang/Boolean;", arg1_cItem_0_bItem_1); + request.arg1.c.b = static_cast>( + chip::JniReferences::GetInstance().BooleanToPrimitive(arg1_cItem_0_bItem_1)); + jobject arg1_cItem_0_cItem_1; + chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "c", "Ljava/lang/Integer;", arg1_cItem_0_cItem_1); + request.arg1.c.c = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_cItem_0_cItem_1)); + jobject arg1_cItem_0_dItem_1; + chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "d", "[B", arg1_cItem_0_dItem_1); + auto arg1_cItem_0_dItem_1Jni = chip::Platform::New(env, static_cast(arg1_cItem_0_dItem_1)); + cleanupByteArrays.push_back(arg1_cItem_0_dItem_1Jni); + request.arg1.c.d = arg1_cItem_0_dItem_1Jni->byteSpan(); + jobject arg1_cItem_0_eItem_1; + chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "e", "Ljava/lang/String;", arg1_cItem_0_eItem_1); + auto arg1_cItem_0_eItem_1Jni = chip::Platform::New(env, static_cast(arg1_cItem_0_eItem_1)); + cleanupStrings.push_back(arg1_cItem_0_eItem_1Jni); + request.arg1.c.e = arg1_cItem_0_eItem_1Jni->charSpan(); + jobject arg1_cItem_0_fItem_1; + chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "f", "Ljava/lang/Integer;", arg1_cItem_0_fItem_1); + request.arg1.c.f = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_cItem_0_fItem_1)); + jobject arg1_cItem_0_gItem_1; + chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "g", "Ljava/lang/Float;", arg1_cItem_0_gItem_1); + request.arg1.c.g = static_cast>( + chip::JniReferences::GetInstance().FloatToPrimitive(arg1_cItem_0_gItem_1)); + jobject arg1_cItem_0_hItem_1; + chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "h", "Ljava/lang/Double;", arg1_cItem_0_hItem_1); + request.arg1.c.h = static_cast>( + chip::JniReferences::GetInstance().DoubleToPrimitive(arg1_cItem_0_hItem_1)); + jobject arg1_dItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "d", "Ljava/util/ArrayList;", arg1_dItem_0); + { + using ListType_1 = std::remove_reference_t; + using ListMemberType_1 = ListMemberTypeGetter::Type; + jint arg1_dItem_0Size; + chip::JniReferences::GetInstance().GetArrayListSize(arg1_dItem_0, arg1_dItem_0Size); + if (arg1_dItem_0Size != 0) + { + auto * listHolder_1 = new ListHolder(arg1_dItem_0Size); + listFreer.add(listHolder_1); + + for (size_t i_1 = 0; i_1 < static_cast(arg1_dItem_0Size); ++i_1) + { + jobject element_1; + chip::JniReferences::GetInstance().GetArrayListItem(arg1_dItem_0, i_1, element_1); + jobject element_1_aItem_2; + chip::JniReferences::GetInstance().GetObjectField(element_1, "a", "Ljava/lang/Integer;", element_1_aItem_2); + listHolder_1->mList[i_1].a = static_castmList[i_1].a)>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_1_aItem_2)); + jobject element_1_bItem_2; + chip::JniReferences::GetInstance().GetObjectField(element_1, "b", "Ljava/lang/Boolean;", element_1_bItem_2); + listHolder_1->mList[i_1].b = static_castmList[i_1].b)>>( + chip::JniReferences::GetInstance().BooleanToPrimitive(element_1_bItem_2)); + jobject element_1_cItem_2; + chip::JniReferences::GetInstance().GetObjectField(element_1, "c", "Ljava/lang/Integer;", element_1_cItem_2); + listHolder_1->mList[i_1].c = static_castmList[i_1].c)>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_1_cItem_2)); + jobject element_1_dItem_2; + chip::JniReferences::GetInstance().GetObjectField(element_1, "d", "[B", element_1_dItem_2); + auto element_1_dItem_2Jni = + chip::Platform::New(env, static_cast(element_1_dItem_2)); + cleanupByteArrays.push_back(element_1_dItem_2Jni); + listHolder_1->mList[i_1].d = element_1_dItem_2Jni->byteSpan(); + jobject element_1_eItem_2; + chip::JniReferences::GetInstance().GetObjectField(element_1, "e", "Ljava/lang/String;", element_1_eItem_2); + auto element_1_eItem_2Jni = chip::Platform::New(env, static_cast(element_1_eItem_2)); + cleanupStrings.push_back(element_1_eItem_2Jni); + listHolder_1->mList[i_1].e = element_1_eItem_2Jni->charSpan(); + jobject element_1_fItem_2; + chip::JniReferences::GetInstance().GetObjectField(element_1, "f", "Ljava/lang/Integer;", element_1_fItem_2); + listHolder_1->mList[i_1].f = static_castmList[i_1].f)>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_1_fItem_2)); + jobject element_1_gItem_2; + chip::JniReferences::GetInstance().GetObjectField(element_1, "g", "Ljava/lang/Float;", element_1_gItem_2); + listHolder_1->mList[i_1].g = static_castmList[i_1].g)>>( + chip::JniReferences::GetInstance().FloatToPrimitive(element_1_gItem_2)); + jobject element_1_hItem_2; + chip::JniReferences::GetInstance().GetObjectField(element_1, "h", "Ljava/lang/Double;", element_1_hItem_2); + listHolder_1->mList[i_1].h = static_castmList[i_1].h)>>( + chip::JniReferences::GetInstance().DoubleToPrimitive(element_1_hItem_2)); + } + request.arg1.d = ListType_1(listHolder_1->mList, arg1_dItem_0Size); + } + else + { + request.arg1.d = ListType_1(); + } + } + jobject arg1_eItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "e", "Ljava/util/ArrayList;", arg1_eItem_0); + { + using ListType_1 = std::remove_reference_t; + using ListMemberType_1 = ListMemberTypeGetter::Type; + jint arg1_eItem_0Size; + chip::JniReferences::GetInstance().GetArrayListSize(arg1_eItem_0, arg1_eItem_0Size); + if (arg1_eItem_0Size != 0) + { + auto * listHolder_1 = new ListHolder(arg1_eItem_0Size); + listFreer.add(listHolder_1); + + for (size_t i_1 = 0; i_1 < static_cast(arg1_eItem_0Size); ++i_1) + { + jobject element_1; + chip::JniReferences::GetInstance().GetArrayListItem(arg1_eItem_0, i_1, element_1); + listHolder_1->mList[i_1] = static_castmList[i_1])>>( + chip::JniReferences::GetInstance().LongToPrimitive(element_1)); + } + request.arg1.e = ListType_1(listHolder_1->mList, arg1_eItem_0Size); + } + else + { + request.arg1.e = ListType_1(); + } + } + jobject arg1_fItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "f", "Ljava/util/ArrayList;", arg1_fItem_0); + { + using ListType_1 = std::remove_reference_t; + using ListMemberType_1 = ListMemberTypeGetter::Type; + jint arg1_fItem_0Size; + chip::JniReferences::GetInstance().GetArrayListSize(arg1_fItem_0, arg1_fItem_0Size); + if (arg1_fItem_0Size != 0) + { + auto * listHolder_1 = new ListHolder(arg1_fItem_0Size); + listFreer.add(listHolder_1); + + for (size_t i_1 = 0; i_1 < static_cast(arg1_fItem_0Size); ++i_1) + { + jobject element_1; + chip::JniReferences::GetInstance().GetArrayListItem(arg1_fItem_0, i_1, element_1); + auto element_1Jni = chip::Platform::New(env, static_cast(element_1)); + cleanupByteArrays.push_back(element_1Jni); + listHolder_1->mList[i_1] = element_1Jni->byteSpan(); + } + request.arg1.f = ListType_1(listHolder_1->mList, arg1_fItem_0Size); + } + else + { + request.arg1.f = ListType_1(); + } + } + jobject arg1_gItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "g", "Ljava/util/ArrayList;", arg1_gItem_0); + { + using ListType_1 = std::remove_reference_t; + using ListMemberType_1 = ListMemberTypeGetter::Type; + jint arg1_gItem_0Size; + chip::JniReferences::GetInstance().GetArrayListSize(arg1_gItem_0, arg1_gItem_0Size); + if (arg1_gItem_0Size != 0) + { + auto * listHolder_1 = new ListHolder(arg1_gItem_0Size); + listFreer.add(listHolder_1); + + for (size_t i_1 = 0; i_1 < static_cast(arg1_gItem_0Size); ++i_1) + { + jobject element_1; + chip::JniReferences::GetInstance().GetArrayListItem(arg1_gItem_0, i_1, element_1); + listHolder_1->mList[i_1] = static_castmList[i_1])>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_1)); + } + request.arg1.g = ListType_1(listHolder_1->mList, arg1_gItem_0Size); + } + else + { + request.arg1.g = ListType_1(); + } + } + + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); + std::unique_ptr onFailure( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + VerifyOrReturn(onFailure.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedWriteTimeoutMs == nullptr) + if (timedInvokeTimeoutMs == nullptr) { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -13591,685 +13591,880 @@ JNI_METHOD(void, GeneralCommissioningCluster, writeBreadcrumbAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GeneralCommissioningCluster, subscribeBreadcrumbAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, TestClusterCluster, testNotHandled) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::TestCluster::Commands::TestNotHandled::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GeneralCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GeneralCommissioning::Attributes::Breadcrumb::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GeneralCommissioningCluster, subscribeBasicCommissioningInfoListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, TestClusterCluster, testNullableOptionalRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - GeneralCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::GeneralCommissioning::Attributes::BasicCommissioningInfoList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster; - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPGeneralCommissioningBasicCommissioningInfoListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + ListFreer listFreer; + chip::app::Clusters::TestCluster::Commands::TestNullableOptionalRequest::Type request; - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, GeneralCommissioningCluster, subscribeRegulatoryConfigAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + if (arg1 != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(arg1, optionalValue_0); + auto & definedValue_0 = request.arg1.Emplace(); + if (optionalValue_0 == nullptr) + { + definedValue_0.SetNull(); + } + else + { + auto & nonNullValue_1 = definedValue_0.SetNonNull(); + nonNullValue_1 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_0)); + } + } + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GeneralCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GeneralCommissioning::Attributes::RegulatoryConfig::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( + auto successFn = chip::Callback::Callback::FromCancelable( onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GeneralCommissioningCluster, subscribeLocationCapabilityAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, TestClusterCluster, testSimpleOptionalArgumentRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - GeneralCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::GeneralCommissioning::Attributes::LocationCapability::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + ListFreer listFreer; + chip::app::Clusters::TestCluster::Commands::TestSimpleOptionalArgumentRequest::Type request; - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, GeneralCommissioningCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::list cleanupByteArrays; + std::list cleanupStrings; + if (arg1 != nullptr) + { + jobject optionalValue_0; + chip::JniReferences::GetInstance().GetOptionalValue(arg1, optionalValue_0); + auto & definedValue_0 = request.arg1.Emplace(); + definedValue_0 = static_cast>( + chip::JniReferences::GetInstance().BooleanToPrimitive(optionalValue_0)); + } + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GeneralCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GeneralCommissioning::Attributes::AttributeList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPGeneralCommissioningAttributeListAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GeneralCommissioningCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, TestClusterCluster, testSpecific) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::TestCluster::Commands::TestSpecific::Type request; + std::list cleanupByteArrays; + std::list cleanupStrings; + + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GeneralCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GeneralCommissioning::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, GeneralDiagnosticsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +JNI_METHOD(void, TestClusterCluster, testStructArgumentRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - GeneralDiagnosticsCluster * cppCluster = new GeneralDiagnosticsCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster; -JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeNetworkInterfacesAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + ListFreer listFreer; + chip::app::Clusters::TestCluster::Commands::TestStructArgumentRequest::Type request; - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + std::list cleanupByteArrays; + std::list cleanupStrings; + jobject arg1_aItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "a", "Ljava/lang/Integer;", arg1_aItem_0); + request.arg1.a = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_aItem_0)); + jobject arg1_bItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "b", "Ljava/lang/Boolean;", arg1_bItem_0); + request.arg1.b = static_cast>( + chip::JniReferences::GetInstance().BooleanToPrimitive(arg1_bItem_0)); + jobject arg1_cItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "c", "Ljava/lang/Integer;", arg1_cItem_0); + request.arg1.c = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_cItem_0)); + jobject arg1_dItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "d", "[B", arg1_dItem_0); + auto arg1_dItem_0Jni = chip::Platform::New(env, static_cast(arg1_dItem_0)); + cleanupByteArrays.push_back(arg1_dItem_0Jni); + request.arg1.d = arg1_dItem_0Jni->byteSpan(); + jobject arg1_eItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "e", "Ljava/lang/String;", arg1_eItem_0); + auto arg1_eItem_0Jni = chip::Platform::New(env, static_cast(arg1_eItem_0)); + cleanupStrings.push_back(arg1_eItem_0Jni); + request.arg1.e = arg1_eItem_0Jni->charSpan(); + jobject arg1_fItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "f", "Ljava/lang/Integer;", arg1_fItem_0); + request.arg1.f = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_fItem_0)); + jobject arg1_gItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "g", "Ljava/lang/Float;", arg1_gItem_0); + request.arg1.g = static_cast>( + chip::JniReferences::GetInstance().FloatToPrimitive(arg1_gItem_0)); + jobject arg1_hItem_0; + chip::JniReferences::GetInstance().GetObjectField(arg1, "h", "Ljava/lang/Double;", arg1_hItem_0); + request.arg1.h = static_cast>( + chip::JniReferences::GetInstance().DoubleToPrimitive(arg1_hItem_0)); + + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); + std::unique_ptr onFailure( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GeneralDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::NetworkInterfaces::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPGeneralDiagnosticsNetworkInterfacesAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeRebootCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, TestClusterCluster, testUnknownCommand) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::TestCluster::Commands::TestUnknownCommand::Type request; + std::list cleanupByteArrays; + std::list cleanupStrings; + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GeneralDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::RebootCount::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeUpTimeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, TestClusterCluster, timedInvokeRequest) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster; + ListFreer listFreer; + chip::app::Clusters::TestCluster::Commands::TimedInvokeRequest::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GeneralDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::UpTime::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeTotalOperationalHoursAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeBooleanAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Boolean::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GeneralDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::TotalOperationalHours::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeBootReasonsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeBitmap8Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Bitmap8::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GeneralDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::BootReasons::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeActiveHardwareFaultsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeBitmap16Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Bitmap16::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GeneralDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::ActiveHardwareFaults::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPGeneralDiagnosticsActiveHardwareFaultsAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeActiveRadioFaultsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeBitmap32Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Bitmap32::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GeneralDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::ActiveRadioFaults::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPGeneralDiagnosticsActiveRadioFaultsAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeActiveNetworkFaultsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeBitmap64Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Bitmap64::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GeneralDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::ActiveNetworkFaults::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPGeneralDiagnosticsActiveNetworkFaultsAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeInt8uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int8u::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GeneralDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::AttributeList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPGeneralDiagnosticsAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeInt16uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int16u::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GeneralDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, GroupKeyManagementCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - GroupKeyManagementCluster * cppCluster = new GroupKeyManagementCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} -JNI_METHOD(void, GroupKeyManagementCluster, keySetRead) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupKeySetID, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, TestClusterCluster, writeInt24uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - GroupKeyManagementCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::Type request; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int24u::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.groupKeySetID = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(groupKeySetID)); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -14279,78 +14474,53 @@ JNI_METHOD(void, GroupKeyManagementCluster, keySetRead) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GroupKeyManagementCluster, keySetReadAllIndices) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupKeySetIDs, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, TestClusterCluster, writeInt32uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - GroupKeyManagementCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadAllIndices::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - { - using ListType_0 = std::remove_reference_t; - using ListMemberType_0 = ListMemberTypeGetter::Type; - jint groupKeySetIDsSize; - chip::JniReferences::GetInstance().GetArrayListSize(groupKeySetIDs, groupKeySetIDsSize); - if (groupKeySetIDsSize != 0) - { - auto * listHolder_0 = new ListHolder(groupKeySetIDsSize); - listFreer.add(listHolder_0); + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int32u::TypeInfo; + TypeInfo::Type cppValue; - for (size_t i_0 = 0; i_0 < static_cast(groupKeySetIDsSize); ++i_0) - { - jobject element_0; - chip::JniReferences::GetInstance().GetArrayListItem(groupKeySetIDs, i_0, element_0); - listHolder_0->mList[i_0] = static_castmList[i_0])>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0)); - } - request.groupKeySetIDs = ListType_0(listHolder_0->mList, groupKeySetIDsSize); - } - else - { - request.groupKeySetIDs = ListType_0(); - } - } + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -14360,52 +14530,53 @@ JNI_METHOD(void, GroupKeyManagementCluster, keySetReadAllIndices) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GroupKeyManagementCluster, keySetRemove) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupKeySetID, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, TestClusterCluster, writeInt40uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - GroupKeyManagementCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::GroupKeyManagement::Commands::KeySetRemove::Type request; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int40u::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.groupKeySetID = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(groupKeySetID)); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -14415,93 +14586,53 @@ JNI_METHOD(void, GroupKeyManagementCluster, keySetRemove) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GroupKeyManagementCluster, keySetWrite) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupKeySet, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, TestClusterCluster, writeInt48uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - GroupKeyManagementCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type request; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int48u::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - jobject groupKeySet_groupKeySetIDItem_0; - chip::JniReferences::GetInstance().GetObjectField(groupKeySet, "groupKeySetID", "Ljava/lang/Integer;", - groupKeySet_groupKeySetIDItem_0); - request.groupKeySet.groupKeySetID = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(groupKeySet_groupKeySetIDItem_0)); - jobject groupKeySet_securityPolicyItem_0; - chip::JniReferences::GetInstance().GetObjectField(groupKeySet, "securityPolicy", "Ljava/lang/Integer;", - groupKeySet_securityPolicyItem_0); - request.groupKeySet.securityPolicy = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(groupKeySet_securityPolicyItem_0)); - jobject groupKeySet_epochKey0Item_0; - chip::JniReferences::GetInstance().GetObjectField(groupKeySet, "epochKey0", "[B", groupKeySet_epochKey0Item_0); - auto groupKeySet_epochKey0Item_0Jni = - chip::Platform::New(env, static_cast(groupKeySet_epochKey0Item_0)); - cleanupByteArrays.push_back(groupKeySet_epochKey0Item_0Jni); - request.groupKeySet.epochKey0 = groupKeySet_epochKey0Item_0Jni->byteSpan(); - jobject groupKeySet_epochStartTime0Item_0; - chip::JniReferences::GetInstance().GetObjectField(groupKeySet, "epochStartTime0", "Ljava/lang/Long;", - groupKeySet_epochStartTime0Item_0); - request.groupKeySet.epochStartTime0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(groupKeySet_epochStartTime0Item_0)); - jobject groupKeySet_epochKey1Item_0; - chip::JniReferences::GetInstance().GetObjectField(groupKeySet, "epochKey1", "[B", groupKeySet_epochKey1Item_0); - auto groupKeySet_epochKey1Item_0Jni = - chip::Platform::New(env, static_cast(groupKeySet_epochKey1Item_0)); - cleanupByteArrays.push_back(groupKeySet_epochKey1Item_0Jni); - request.groupKeySet.epochKey1 = groupKeySet_epochKey1Item_0Jni->byteSpan(); - jobject groupKeySet_epochStartTime1Item_0; - chip::JniReferences::GetInstance().GetObjectField(groupKeySet, "epochStartTime1", "Ljava/lang/Long;", - groupKeySet_epochStartTime1Item_0); - request.groupKeySet.epochStartTime1 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(groupKeySet_epochStartTime1Item_0)); - jobject groupKeySet_epochKey2Item_0; - chip::JniReferences::GetInstance().GetObjectField(groupKeySet, "epochKey2", "[B", groupKeySet_epochKey2Item_0); - auto groupKeySet_epochKey2Item_0Jni = - chip::Platform::New(env, static_cast(groupKeySet_epochKey2Item_0)); - cleanupByteArrays.push_back(groupKeySet_epochKey2Item_0Jni); - request.groupKeySet.epochKey2 = groupKeySet_epochKey2Item_0Jni->byteSpan(); - jobject groupKeySet_epochStartTime2Item_0; - chip::JniReferences::GetInstance().GetObjectField(groupKeySet, "epochStartTime2", "Ljava/lang/Long;", - groupKeySet_epochStartTime2Item_0); - request.groupKeySet.epochStartTime2 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(groupKeySet_epochStartTime2Item_0)); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -14511,294 +14642,335 @@ JNI_METHOD(void, GroupKeyManagementCluster, keySetWrite) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GroupKeyManagementCluster, subscribeGroupKeyMapAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeInt56uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - GroupKeyManagementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int56u::TypeInfo; + TypeInfo::Type cppValue; - using TypeInfo = chip::app::Clusters::GroupKeyManagement::Attributes::GroupKeyMap::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPGroupKeyManagementGroupKeyMapAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, GroupKeyManagementCluster, subscribeGroupTableAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GroupKeyManagementCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GroupKeyManagement::Attributes::GroupTable::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPGroupKeyManagementGroupTableAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GroupKeyManagementCluster, subscribeMaxGroupsPerFabricAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeInt64uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int64u::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GroupKeyManagementCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GroupKeyManagement::Attributes::MaxGroupsPerFabric::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GroupKeyManagementCluster, subscribeMaxGroupKeysPerFabricAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeInt8sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int8s::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GroupKeyManagementCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GroupKeyManagement::Attributes::MaxGroupKeysPerFabric::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GroupKeyManagementCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeInt16sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int16s::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GroupKeyManagementCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GroupKeyManagement::Attributes::AttributeList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPGroupKeyManagementAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GroupKeyManagementCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeInt24sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int24s::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GroupKeyManagementCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::GroupKeyManagement::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, GroupsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - GroupsCluster * cppCluster = new GroupsCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} -JNI_METHOD(void, GroupsCluster, addGroup) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jstring groupName, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, TestClusterCluster, writeInt32sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - GroupsCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::Groups::Commands::AddGroup::Type request; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int32s::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.groupId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); - auto groupNameJni = chip::Platform::New(env, static_cast(groupName)); - cleanupStrings.push_back(groupNameJni); - request.groupName = groupNameJni->charSpan(); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - std::unique_ptr onSuccess( - Platform::New(callback), - Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -14808,55 +14980,53 @@ JNI_METHOD(void, GroupsCluster, addGroup) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GroupsCluster, addGroupIfIdentifying) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jstring groupName, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, TestClusterCluster, writeInt40sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - GroupsCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::Groups::Commands::AddGroupIfIdentifying::Type request; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int40s::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.groupId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); - auto groupNameJni = chip::Platform::New(env, static_cast(groupName)); - cleanupStrings.push_back(groupNameJni); - request.groupName = groupNameJni->charSpan(); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -14866,77 +15036,53 @@ JNI_METHOD(void, GroupsCluster, addGroupIfIdentifying) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GroupsCluster, getGroupMembership) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupList, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, TestClusterCluster, writeInt48sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - GroupsCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::Groups::Commands::GetGroupMembership::Type request; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int48s::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - { - using ListType_0 = std::remove_reference_t; - using ListMemberType_0 = ListMemberTypeGetter::Type; - jint groupListSize; - chip::JniReferences::GetInstance().GetArrayListSize(groupList, groupListSize); - if (groupListSize != 0) - { - auto * listHolder_0 = new ListHolder(groupListSize); - listFreer.add(listHolder_0); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - for (size_t i_0 = 0; i_0 < static_cast(groupListSize); ++i_0) - { - jobject element_0; - chip::JniReferences::GetInstance().GetArrayListItem(groupList, i_0, element_0); - listHolder_0->mList[i_0] = static_castmList[i_0])>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0)); - } - request.groupList = ListType_0(listHolder_0->mList, groupListSize); - } - else - { - request.groupList = ListType_0(); - } - } + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -14946,50 +15092,53 @@ JNI_METHOD(void, GroupsCluster, getGroupMembership) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GroupsCluster, removeAllGroups) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, TestClusterCluster, writeInt56sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - GroupsCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::Groups::Commands::RemoveAllGroups::Type request; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int56s::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -14999,54 +15148,53 @@ JNI_METHOD(void, GroupsCluster, removeAllGroups) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GroupsCluster, removeGroup) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, TestClusterCluster, writeInt64sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - GroupsCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::Groups::Commands::RemoveGroup::Type request; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int64s::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.groupId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -15056,53 +15204,54 @@ JNI_METHOD(void, GroupsCluster, removeGroup) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GroupsCluster, viewGroup) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, TestClusterCluster, writeEnum8Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - GroupsCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::Groups::Commands::ViewGroup::Type request; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Enum8::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.groupId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - std::unique_ptr onSuccess( - Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -15112,173 +15261,167 @@ JNI_METHOD(void, GroupsCluster, viewGroup) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GroupsCluster, subscribeNameSupportAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeEnum16Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - GroupsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Enum16::TypeInfo; + TypeInfo::Type cppValue; - using TypeInfo = chip::app::Clusters::Groups::Attributes::NameSupport::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, GroupsCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GroupsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Groups::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPGroupsAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, GroupsCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeFloatSingleAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::FloatSingle::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = static_cast>(chip::JniReferences::GetInstance().FloatToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - GroupsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Groups::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, IdentifyCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - IdentifyCluster * cppCluster = new IdentifyCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} -JNI_METHOD(void, IdentifyCluster, identify) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject identifyTime, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, TestClusterCluster, writeFloatDoubleAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - IdentifyCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::Identify::Commands::Identify::Type request; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::FloatDouble::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.identifyTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(identifyTime)); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().DoubleToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -15288,52 +15431,55 @@ JNI_METHOD(void, IdentifyCluster, identify) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, IdentifyCluster, identifyQuery) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, TestClusterCluster, writeOctetStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - IdentifyCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::Identify::Commands::IdentifyQuery::Type request; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::OctetString::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + auto valueJni = chip::Platform::New(env, static_cast(value)); + cleanupByteArrays.push_back(valueJni); + cppValue = valueJni->byteSpan(); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -15343,55 +15489,76 @@ JNI_METHOD(void, IdentifyCluster, identifyQuery) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, IdentifyCluster, triggerEffect) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject effectIdentifier, jobject effectVariant, - jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, TestClusterCluster, writeListInt8uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - IdentifyCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::Identify::Commands::TriggerEffect::Type request; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ListInt8u::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; - request.effectIdentifier = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(effectIdentifier)); - request.effectVariant = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(effectVariant)); + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + jint valueSize; + chip::JniReferences::GetInstance().GetArrayListSize(value, valueSize); + if (valueSize != 0) + { + auto * listHolder_0 = new ListHolder(valueSize); + listFreer.add(listHolder_0); + + for (size_t i_0 = 0; i_0 < static_cast(valueSize); ++i_0) + { + jobject element_0; + chip::JniReferences::GetInstance().GetArrayListItem(value, i_0, element_0); + listHolder_0->mList[i_0] = static_castmList[i_0])>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0)); + } + cppValue = ListType_0(listHolder_0->mList, valueSize); + } + else + { + cppValue = ListType_0(); + } + } std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -15402,19 +15569,42 @@ JNI_METHOD(void, IdentifyCluster, triggerEffect) onFailure.release(); } -JNI_METHOD(void, IdentifyCluster, writeIdentifyTimeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) +JNI_METHOD(void, TestClusterCluster, writeListOctetStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; ListFreer listFreer; - using TypeInfo = chip::app::Clusters::Identify::Attributes::IdentifyTime::TypeInfo; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ListOctetString::TypeInfo; TypeInfo::Type cppValue; std::vector cleanupByteArrays; std::vector cleanupStrings; - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + jint valueSize; + chip::JniReferences::GetInstance().GetArrayListSize(value, valueSize); + if (valueSize != 0) + { + auto * listHolder_0 = new ListHolder(valueSize); + listFreer.add(listHolder_0); + + for (size_t i_0 = 0; i_0 < static_cast(valueSize); ++i_0) + { + jobject element_0; + chip::JniReferences::GetInstance().GetArrayListItem(value, i_0, element_0); + auto element_0Jni = chip::Platform::New(env, static_cast(element_0)); + cleanupByteArrays.push_back(element_0Jni); + listHolder_0->mList[i_0] = element_0Jni->byteSpan(); + } + cppValue = ListType_0(listHolder_0->mList, valueSize); + } + else + { + cppValue = ListType_0(); + } + } std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -15428,8 +15618,8 @@ JNI_METHOD(void, IdentifyCluster, writeIdentifyTimeAttribute) chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - IdentifyCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -15458,25891 +15648,2079 @@ JNI_METHOD(void, IdentifyCluster, writeIdentifyTimeAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, IdentifyCluster, subscribeIdentifyTimeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeListStructOctetStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ListStructOctetString::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + jint valueSize; + chip::JniReferences::GetInstance().GetArrayListSize(value, valueSize); + if (valueSize != 0) + { + auto * listHolder_0 = new ListHolder(valueSize); + listFreer.add(listHolder_0); + + for (size_t i_0 = 0; i_0 < static_cast(valueSize); ++i_0) + { + jobject element_0; + chip::JniReferences::GetInstance().GetArrayListItem(value, i_0, element_0); + jobject element_0_fabricIndexItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "fabricIndex", "Ljava/lang/Long;", + element_0_fabricIndexItem_1); + listHolder_0->mList[i_0].fabricIndex = + static_castmList[i_0].fabricIndex)>>( + chip::JniReferences::GetInstance().LongToPrimitive(element_0_fabricIndexItem_1)); + jobject element_0_operationalCertItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "operationalCert", "[B", + element_0_operationalCertItem_1); + auto element_0_operationalCertItem_1Jni = + chip::Platform::New(env, static_cast(element_0_operationalCertItem_1)); + cleanupByteArrays.push_back(element_0_operationalCertItem_1Jni); + listHolder_0->mList[i_0].operationalCert = element_0_operationalCertItem_1Jni->byteSpan(); + } + cppValue = ListType_0(listHolder_0->mList, valueSize); + } + else + { + cppValue = ListType_0(); + } + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - IdentifyCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Identify::Attributes::IdentifyTime::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, IdentifyCluster, subscribeIdentifyTypeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeLongOctetStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::LongOctetString::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + auto valueJni = chip::Platform::New(env, static_cast(value)); + cleanupByteArrays.push_back(valueJni); + cppValue = valueJni->byteSpan(); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - IdentifyCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Identify::Attributes::IdentifyType::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, IdentifyCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeCharStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::CharString::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + auto valueJni = chip::Platform::New(env, static_cast(value)); + cleanupStrings.push_back(valueJni); + cppValue = valueJni->charSpan(); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - IdentifyCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Identify::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPIdentifyAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, IdentifyCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeLongCharStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::LongCharString::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + auto valueJni = chip::Platform::New(env, static_cast(value)); + cleanupStrings.push_back(valueJni); + cppValue = valueJni->charSpan(); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - IdentifyCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::Identify::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, IlluminanceMeasurementCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - IlluminanceMeasurementCluster * cppCluster = new IlluminanceMeasurementCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} -JNI_METHOD(void, IlluminanceMeasurementCluster, subscribeMeasuredValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, TestClusterCluster, writeEpochUsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - IlluminanceMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::EpochUs::TypeInfo; + TypeInfo::Type cppValue; - using TypeInfo = chip::app::Clusters::IlluminanceMeasurement::Attributes::MeasuredValue::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPIlluminanceMeasurementMeasuredValueAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, IlluminanceMeasurementCluster, subscribeMinMeasuredValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - IlluminanceMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::IlluminanceMeasurement::Attributes::MinMeasuredValue::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPIlluminanceMeasurementMinMeasuredValueAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, IlluminanceMeasurementCluster, subscribeMaxMeasuredValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeEpochSAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - IlluminanceMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::EpochS::TypeInfo; + TypeInfo::Type cppValue; - using TypeInfo = chip::app::Clusters::IlluminanceMeasurement::Attributes::MaxMeasuredValue::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPIlluminanceMeasurementMaxMeasuredValueAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, IlluminanceMeasurementCluster, subscribeToleranceAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - IlluminanceMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::IlluminanceMeasurement::Attributes::Tolerance::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, IlluminanceMeasurementCluster, subscribeLightSensorTypeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeVendorIdAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - IlluminanceMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::VendorId::TypeInfo; + TypeInfo::Type cppValue; - using TypeInfo = chip::app::Clusters::IlluminanceMeasurement::Attributes::LightSensorType::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPIlluminanceMeasurementLightSensorTypeAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, IlluminanceMeasurementCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - IlluminanceMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::IlluminanceMeasurement::Attributes::AttributeList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPIlluminanceMeasurementAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, IlluminanceMeasurementCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeListNullablesAndOptionalsStructAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ListNullablesAndOptionalsStruct::TypeInfo; + TypeInfo::Type cppValue; - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - CHIP_ERROR err = CHIP_NO_ERROR; - IlluminanceMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::IlluminanceMeasurement::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, KeypadInputCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - KeypadInputCluster * cppCluster = new KeypadInputCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, KeypadInputCluster, sendKeyRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject keyCode, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - KeypadInputCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::KeypadInput::Commands::SendKeyRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.keyCode = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(keyCode)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, KeypadInputCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - KeypadInputCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::KeypadInput::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPKeypadInputAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, KeypadInputCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - KeypadInputCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::KeypadInput::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, LevelControlCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - LevelControlCluster * cppCluster = new LevelControlCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, LevelControlCluster, move) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject moveMode, jobject rate, jobject optionMask, - jobject optionOverride, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::LevelControl::Commands::Move::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.moveMode = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(moveMode)); - request.rate = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(rate)); - request.optionMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionMask)); - request.optionOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionOverride)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, moveToLevel) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject level, jobject transitionTime, jobject optionMask, - jobject optionOverride, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::LevelControl::Commands::MoveToLevel::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.level = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(level)); - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); - request.optionMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionMask)); - request.optionOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionOverride)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + jint valueSize; + chip::JniReferences::GetInstance().GetArrayListSize(value, valueSize); + if (valueSize != 0) + { + auto * listHolder_0 = new ListHolder(valueSize); + listFreer.add(listHolder_0); - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, moveToLevelWithOnOff) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject level, jobject transitionTime, - jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::LevelControl::Commands::MoveToLevelWithOnOff::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.level = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(level)); - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, moveWithOnOff) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject moveMode, jobject rate, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::LevelControl::Commands::MoveWithOnOff::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.moveMode = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(moveMode)); - request.rate = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(rate)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, step) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject stepMode, jobject stepSize, jobject transitionTime, - jobject optionMask, jobject optionOverride, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::LevelControl::Commands::Step::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.stepMode = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(stepMode)); - request.stepSize = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(stepSize)); - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); - request.optionMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionMask)); - request.optionOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionOverride)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, stepWithOnOff) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject stepMode, jobject stepSize, jobject transitionTime, - jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::LevelControl::Commands::StepWithOnOff::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.stepMode = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(stepMode)); - request.stepSize = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(stepSize)); - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, stop) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject optionMask, jobject optionOverride, - jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::LevelControl::Commands::Stop::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.optionMask = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionMask)); - request.optionOverride = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionOverride)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, stopWithOnOff) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::LevelControl::Commands::StopWithOnOff::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, subscribeCurrentLevelAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::CurrentLevel::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, subscribeRemainingTimeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::RemainingTime::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, subscribeMinLevelAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::MinLevel::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, subscribeMaxLevelAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::MaxLevel::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, subscribeCurrentFrequencyAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::CurrentFrequency::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, subscribeMinFrequencyAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::MinFrequency::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, subscribeMaxFrequencyAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::MaxFrequency::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, LevelControlCluster, writeOptionsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::Options::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, subscribeOptionsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::Options::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, LevelControlCluster, writeOnOffTransitionTimeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::OnOffTransitionTime::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, subscribeOnOffTransitionTimeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::OnOffTransitionTime::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, LevelControlCluster, writeOnLevelAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::OnLevel::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, subscribeOnLevelAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::OnLevel::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPLevelControlOnLevelAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, LevelControlCluster, writeOnTransitionTimeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::OnTransitionTime::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, subscribeOnTransitionTimeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::OnTransitionTime::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPLevelControlOnTransitionTimeAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, LevelControlCluster, writeOffTransitionTimeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::OffTransitionTime::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, subscribeOffTransitionTimeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::OffTransitionTime::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPLevelControlOffTransitionTimeAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, LevelControlCluster, writeDefaultMoveRateAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::DefaultMoveRate::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, subscribeDefaultMoveRateAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::DefaultMoveRate::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPLevelControlDefaultMoveRateAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, LevelControlCluster, writeStartUpCurrentLevelAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::StartUpCurrentLevel::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, subscribeStartUpCurrentLevelAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::StartUpCurrentLevel::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPLevelControlStartUpCurrentLevelAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPLevelControlAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, subscribeFeatureMapAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::FeatureMap::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LevelControlCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LevelControl::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, LocalizationConfigurationCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - LocalizationConfigurationCluster * cppCluster = new LocalizationConfigurationCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, LocalizationConfigurationCluster, writeActiveLocaleAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::LocalizationConfiguration::Attributes::ActiveLocale::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - auto valueJni = chip::Platform::New(env, static_cast(value)); - cleanupStrings.push_back(valueJni); - cppValue = valueJni->charSpan(); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LocalizationConfigurationCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LocalizationConfigurationCluster, subscribeActiveLocaleAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LocalizationConfigurationCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LocalizationConfiguration::Attributes::ActiveLocale::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LocalizationConfigurationCluster, subscribeSupportedLocalesAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LocalizationConfigurationCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LocalizationConfiguration::Attributes::SupportedLocales::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPLocalizationConfigurationSupportedLocalesAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, LowPowerCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - LowPowerCluster * cppCluster = new LowPowerCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, LowPowerCluster, sleep) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - LowPowerCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::LowPower::Commands::Sleep::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LowPowerCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LowPowerCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LowPower::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPLowPowerAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, LowPowerCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - LowPowerCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::LowPower::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, MediaInputCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - MediaInputCluster * cppCluster = new MediaInputCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, MediaInputCluster, hideInputStatusRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - MediaInputCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::MediaInput::Commands::HideInputStatusRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaInputCluster, renameInputRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject index, jstring name, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - MediaInputCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::MediaInput::Commands::RenameInputRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.index = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(index)); - auto nameJni = chip::Platform::New(env, static_cast(name)); - cleanupStrings.push_back(nameJni); - request.name = nameJni->charSpan(); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaInputCluster, selectInputRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject index, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - MediaInputCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::MediaInput::Commands::SelectInputRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.index = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(index)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaInputCluster, showInputStatusRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - MediaInputCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::MediaInput::Commands::ShowInputStatusRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaInputCluster, subscribeMediaInputListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - MediaInputCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::MediaInput::Attributes::MediaInputList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPMediaInputMediaInputListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaInputCluster, subscribeCurrentMediaInputAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - MediaInputCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::MediaInput::Attributes::CurrentMediaInput::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaInputCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - MediaInputCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::MediaInput::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPMediaInputAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaInputCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - MediaInputCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::MediaInput::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, MediaPlaybackCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - MediaPlaybackCluster * cppCluster = new MediaPlaybackCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, MediaPlaybackCluster, fastForwardRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::MediaPlayback::Commands::FastForwardRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaPlaybackCluster, nextRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::MediaPlayback::Commands::NextRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaPlaybackCluster, pauseRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::MediaPlayback::Commands::PauseRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaPlaybackCluster, playRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::MediaPlayback::Commands::PlayRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaPlaybackCluster, previousRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::MediaPlayback::Commands::PreviousRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaPlaybackCluster, rewindRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::MediaPlayback::Commands::RewindRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaPlaybackCluster, seekRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject position, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::MediaPlayback::Commands::SeekRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.position = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(position)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaPlaybackCluster, skipBackwardRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject deltaPositionMilliseconds, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::MediaPlayback::Commands::SkipBackwardRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.deltaPositionMilliseconds = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(deltaPositionMilliseconds)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaPlaybackCluster, skipForwardRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject deltaPositionMilliseconds, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::MediaPlayback::Commands::SkipForwardRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.deltaPositionMilliseconds = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(deltaPositionMilliseconds)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaPlaybackCluster, startOverRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::MediaPlayback::Commands::StartOverRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaPlaybackCluster, stopRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::MediaPlayback::Commands::StopRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaPlaybackCluster, subscribePlaybackStateAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::MediaPlayback::Attributes::PlaybackState::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaPlaybackCluster, subscribeStartTimeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::MediaPlayback::Attributes::StartTime::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaPlaybackCluster, subscribeDurationAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::MediaPlayback::Attributes::Duration::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaPlaybackCluster, subscribePlaybackSpeedAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::MediaPlayback::Attributes::PlaybackSpeed::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPFloatAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaPlaybackCluster, subscribeSeekRangeEndAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::MediaPlayback::Attributes::SeekRangeEnd::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaPlaybackCluster, subscribeSeekRangeStartAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::MediaPlayback::Attributes::SeekRangeStart::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaPlaybackCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::MediaPlayback::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPMediaPlaybackAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, MediaPlaybackCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - MediaPlaybackCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::MediaPlayback::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, ModeSelectCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - ModeSelectCluster * cppCluster = new ModeSelectCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, ModeSelectCluster, changeToMode) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject newMode, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ModeSelectCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::ModeSelect::Commands::ChangeToMode::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.newMode = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(newMode)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ModeSelectCluster, subscribeCurrentModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ModeSelectCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ModeSelect::Attributes::CurrentMode::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ModeSelectCluster, subscribeSupportedModesAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ModeSelectCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ModeSelect::Attributes::SupportedModes::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPModeSelectSupportedModesAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, ModeSelectCluster, writeOnModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::ModeSelect::Attributes::OnMode::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ModeSelectCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ModeSelectCluster, subscribeOnModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ModeSelectCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ModeSelect::Attributes::OnMode::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ModeSelectCluster, subscribeStartUpModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ModeSelectCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ModeSelect::Attributes::StartUpMode::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ModeSelectCluster, subscribeDescriptionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ModeSelectCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ModeSelect::Attributes::Description::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ModeSelectCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ModeSelectCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ModeSelect::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPModeSelectAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ModeSelectCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ModeSelectCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ModeSelect::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, NetworkCommissioningCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - NetworkCommissioningCluster * cppCluster = new NetworkCommissioningCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, NetworkCommissioningCluster, addOrUpdateThreadNetwork) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray operationalDataset, jobject breadcrumb, - jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - NetworkCommissioningCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::NetworkCommissioning::Commands::AddOrUpdateThreadNetwork::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - auto operationalDatasetJni = chip::Platform::New(env, static_cast(operationalDataset)); - cleanupByteArrays.push_back(operationalDatasetJni); - request.operationalDataset = operationalDatasetJni->byteSpan(); - request.breadcrumb = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(breadcrumb)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, NetworkCommissioningCluster, addOrUpdateWiFiNetwork) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray ssid, jbyteArray credentials, jobject breadcrumb, - jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - NetworkCommissioningCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::NetworkCommissioning::Commands::AddOrUpdateWiFiNetwork::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - auto ssidJni = chip::Platform::New(env, static_cast(ssid)); - cleanupByteArrays.push_back(ssidJni); - request.ssid = ssidJni->byteSpan(); - auto credentialsJni = chip::Platform::New(env, static_cast(credentials)); - cleanupByteArrays.push_back(credentialsJni); - request.credentials = credentialsJni->byteSpan(); - request.breadcrumb = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(breadcrumb)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, NetworkCommissioningCluster, connectNetwork) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray networkID, jobject breadcrumb, - jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - NetworkCommissioningCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::NetworkCommissioning::Commands::ConnectNetwork::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - auto networkIDJni = chip::Platform::New(env, static_cast(networkID)); - cleanupByteArrays.push_back(networkIDJni); - request.networkID = networkIDJni->byteSpan(); - request.breadcrumb = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(breadcrumb)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, NetworkCommissioningCluster, removeNetwork) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray networkID, jobject breadcrumb, - jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - NetworkCommissioningCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::NetworkCommissioning::Commands::RemoveNetwork::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - auto networkIDJni = chip::Platform::New(env, static_cast(networkID)); - cleanupByteArrays.push_back(networkIDJni); - request.networkID = networkIDJni->byteSpan(); - request.breadcrumb = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(breadcrumb)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, NetworkCommissioningCluster, reorderNetwork) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray networkID, jobject networkIndex, jobject breadcrumb, - jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - NetworkCommissioningCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::NetworkCommissioning::Commands::ReorderNetwork::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - auto networkIDJni = chip::Platform::New(env, static_cast(networkID)); - cleanupByteArrays.push_back(networkIDJni); - request.networkID = networkIDJni->byteSpan(); - request.networkIndex = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(networkIndex)); - request.breadcrumb = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(breadcrumb)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, NetworkCommissioningCluster, scanNetworks) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray ssid, jobject breadcrumb, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - NetworkCommissioningCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::NetworkCommissioning::Commands::ScanNetworks::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - auto ssidJni = chip::Platform::New(env, static_cast(ssid)); - cleanupByteArrays.push_back(ssidJni); - request.ssid = ssidJni->byteSpan(); - request.breadcrumb = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(breadcrumb)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, NetworkCommissioningCluster, subscribeMaxNetworksAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - NetworkCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::MaxNetworks::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, NetworkCommissioningCluster, subscribeNetworksAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - NetworkCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::Networks::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPNetworkCommissioningNetworksAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, NetworkCommissioningCluster, subscribeScanMaxTimeSecondsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - NetworkCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::ScanMaxTimeSeconds::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, NetworkCommissioningCluster, subscribeConnectMaxTimeSecondsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - NetworkCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::ConnectMaxTimeSeconds::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, NetworkCommissioningCluster, writeInterfaceEnabledAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::InterfaceEnabled::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - NetworkCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, NetworkCommissioningCluster, subscribeInterfaceEnabledAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - NetworkCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::InterfaceEnabled::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, NetworkCommissioningCluster, subscribeLastNetworkingStatusAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - NetworkCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::LastNetworkingStatus::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, NetworkCommissioningCluster, subscribeLastNetworkIDAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - NetworkCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::LastNetworkID::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPOctetStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, NetworkCommissioningCluster, subscribeLastConnectErrorValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - NetworkCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::LastConnectErrorValue::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, NetworkCommissioningCluster, subscribeFeatureMapAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - NetworkCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::FeatureMap::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, NetworkCommissioningCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - NetworkCommissioningCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, OtaSoftwareUpdateProviderCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - OtaSoftwareUpdateProviderCluster * cppCluster = new OtaSoftwareUpdateProviderCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, OtaSoftwareUpdateProviderCluster, applyUpdateRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray updateToken, jobject newVersion, - jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OtaSoftwareUpdateProviderCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::ApplyUpdateRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - auto updateTokenJni = chip::Platform::New(env, static_cast(updateToken)); - cleanupByteArrays.push_back(updateTokenJni); - request.updateToken = updateTokenJni->byteSpan(); - request.newVersion = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(newVersion)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OtaSoftwareUpdateProviderCluster, notifyUpdateApplied) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray updateToken, jobject softwareVersion, - jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OtaSoftwareUpdateProviderCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::NotifyUpdateApplied::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - auto updateTokenJni = chip::Platform::New(env, static_cast(updateToken)); - cleanupByteArrays.push_back(updateTokenJni); - request.updateToken = updateTokenJni->byteSpan(); - request.softwareVersion = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(softwareVersion)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OtaSoftwareUpdateProviderCluster, queryImage) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject vendorId, jobject productId, jobject softwareVersion, - jobject protocolsSupported, jobject hardwareVersion, jobject location, jobject requestorCanConsent, jobject metadataForProvider, - jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OtaSoftwareUpdateProviderCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OtaSoftwareUpdateProvider::Commands::QueryImage::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.vendorId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(vendorId)); - request.productId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(productId)); - request.softwareVersion = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(softwareVersion)); - { - using ListType_0 = std::remove_reference_t; - using ListMemberType_0 = ListMemberTypeGetter::Type; - jint protocolsSupportedSize; - chip::JniReferences::GetInstance().GetArrayListSize(protocolsSupported, protocolsSupportedSize); - if (protocolsSupportedSize != 0) - { - auto * listHolder_0 = new ListHolder(protocolsSupportedSize); - listFreer.add(listHolder_0); - - for (size_t i_0 = 0; i_0 < static_cast(protocolsSupportedSize); ++i_0) - { - jobject element_0; - chip::JniReferences::GetInstance().GetArrayListItem(protocolsSupported, i_0, element_0); - listHolder_0->mList[i_0] = static_castmList[i_0])>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0)); - } - request.protocolsSupported = ListType_0(listHolder_0->mList, protocolsSupportedSize); - } - else - { - request.protocolsSupported = ListType_0(); - } - } - if (hardwareVersion != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(hardwareVersion, optionalValue_0); - auto & definedValue_0 = request.hardwareVersion.Emplace(); - definedValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_0)); - } - if (location != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(location, optionalValue_0); - auto & definedValue_0 = request.location.Emplace(); - auto optionalValue_0Jni = chip::Platform::New(env, static_cast(optionalValue_0)); - cleanupStrings.push_back(optionalValue_0Jni); - definedValue_0 = optionalValue_0Jni->charSpan(); - } - if (requestorCanConsent != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(requestorCanConsent, optionalValue_0); - auto & definedValue_0 = request.requestorCanConsent.Emplace(); - definedValue_0 = static_cast>( - chip::JniReferences::GetInstance().BooleanToPrimitive(optionalValue_0)); - } - if (metadataForProvider != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(metadataForProvider, optionalValue_0); - auto & definedValue_0 = request.metadataForProvider.Emplace(); - auto optionalValue_0Jni = chip::Platform::New(env, static_cast(optionalValue_0)); - cleanupByteArrays.push_back(optionalValue_0Jni); - definedValue_0 = optionalValue_0Jni->byteSpan(); - } - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OtaSoftwareUpdateProviderCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OtaSoftwareUpdateProviderCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateProvider::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPOtaSoftwareUpdateProviderAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OtaSoftwareUpdateProviderCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OtaSoftwareUpdateProviderCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateProvider::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, OtaSoftwareUpdateRequestorCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - OtaSoftwareUpdateRequestorCluster * cppCluster = new OtaSoftwareUpdateRequestorCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, announceOtaProvider) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject providerNodeId, jobject vendorId, - jobject announcementReason, jobject metadataForNode, jobject endpoint, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OtaSoftwareUpdateRequestorCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OtaSoftwareUpdateRequestor::Commands::AnnounceOtaProvider::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.providerNodeId = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(providerNodeId)); - request.vendorId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(vendorId)); - request.announcementReason = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(announcementReason)); - if (metadataForNode != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(metadataForNode, optionalValue_0); - auto & definedValue_0 = request.metadataForNode.Emplace(); - auto optionalValue_0Jni = chip::Platform::New(env, static_cast(optionalValue_0)); - cleanupByteArrays.push_back(optionalValue_0Jni); - definedValue_0 = optionalValue_0Jni->byteSpan(); - } - request.endpoint = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(endpoint)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, writeDefaultOtaProvidersAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::DefaultOtaProviders::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - { - using ListType_0 = std::remove_reference_t; - using ListMemberType_0 = ListMemberTypeGetter::Type; - jint valueSize; - chip::JniReferences::GetInstance().GetArrayListSize(value, valueSize); - if (valueSize != 0) - { - auto * listHolder_0 = new ListHolder(valueSize); - listFreer.add(listHolder_0); - - for (size_t i_0 = 0; i_0 < static_cast(valueSize); ++i_0) - { - jobject element_0; - chip::JniReferences::GetInstance().GetArrayListItem(value, i_0, element_0); - jobject element_0_fabricIndexItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "fabricIndex", "Ljava/lang/Integer;", - element_0_fabricIndexItem_1); - listHolder_0->mList[i_0].fabricIndex = - static_castmList[i_0].fabricIndex)>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_fabricIndexItem_1)); - jobject element_0_providerNodeIDItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "providerNodeID", "Ljava/lang/Long;", - element_0_providerNodeIDItem_1); - listHolder_0->mList[i_0].providerNodeID = - static_castmList[i_0].providerNodeID)>>( - chip::JniReferences::GetInstance().LongToPrimitive(element_0_providerNodeIDItem_1)); - jobject element_0_endpointItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "endpoint", "Ljava/lang/Integer;", - element_0_endpointItem_1); - listHolder_0->mList[i_0].endpoint = - static_castmList[i_0].endpoint)>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_endpointItem_1)); - } - cppValue = ListType_0(listHolder_0->mList, valueSize); - } - else - { - cppValue = ListType_0(); - } - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OtaSoftwareUpdateRequestorCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeDefaultOtaProvidersAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OtaSoftwareUpdateRequestorCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::DefaultOtaProviders::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeUpdatePossibleAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OtaSoftwareUpdateRequestorCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::UpdatePossible::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeUpdateStateAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OtaSoftwareUpdateRequestorCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::UpdateState::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeUpdateStateProgressAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OtaSoftwareUpdateRequestorCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::UpdateStateProgress::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPOtaSoftwareUpdateRequestorUpdateStateProgressAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OtaSoftwareUpdateRequestorCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPOtaSoftwareUpdateRequestorAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OtaSoftwareUpdateRequestorCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, OccupancySensingCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - OccupancySensingCluster * cppCluster = new OccupancySensingCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, OccupancySensingCluster, subscribeOccupancyAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OccupancySensingCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OccupancySensing::Attributes::Occupancy::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OccupancySensingCluster, subscribeOccupancySensorTypeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OccupancySensingCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OccupancySensing::Attributes::OccupancySensorType::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OccupancySensingCluster, subscribeOccupancySensorTypeBitmapAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OccupancySensingCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OccupancySensing::Attributes::OccupancySensorTypeBitmap::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OccupancySensingCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OccupancySensingCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OccupancySensing::Attributes::AttributeList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPOccupancySensingAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OccupancySensingCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OccupancySensingCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OccupancySensing::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, OnOffCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - OnOffCluster * cppCluster = new OnOffCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, OnOffCluster, off)(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OnOff::Commands::Off::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OnOffCluster, offWithEffect) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject effectId, jobject effectVariant, - jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OnOff::Commands::OffWithEffect::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.effectId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(effectId)); - request.effectVariant = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(effectVariant)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OnOffCluster, on)(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OnOff::Commands::On::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OnOffCluster, onWithRecallGlobalScene) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OnOff::Commands::OnWithRecallGlobalScene::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OnOffCluster, onWithTimedOff) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject onOffControl, jobject onTime, jobject offWaitTime, - jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OnOff::Commands::OnWithTimedOff::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.onOffControl = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(onOffControl)); - request.onTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(onTime)); - request.offWaitTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(offWaitTime)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OnOffCluster, toggle)(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OnOff::Commands::Toggle::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OnOffCluster, subscribeOnOffAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OnOff::Attributes::OnOff::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OnOffCluster, subscribeGlobalSceneControlAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OnOff::Attributes::GlobalSceneControl::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, OnOffCluster, writeOnTimeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::OnOff::Attributes::OnTime::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OnOffCluster, subscribeOnTimeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OnOff::Attributes::OnTime::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, OnOffCluster, writeOffWaitTimeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::OnOff::Attributes::OffWaitTime::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OnOffCluster, subscribeOffWaitTimeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OnOff::Attributes::OffWaitTime::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, OnOffCluster, writeStartUpOnOffAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::OnOff::Attributes::StartUpOnOff::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OnOffCluster, subscribeStartUpOnOffAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OnOff::Attributes::StartUpOnOff::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OnOffCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OnOff::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPOnOffAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OnOffCluster, subscribeFeatureMapAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OnOff::Attributes::FeatureMap::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OnOffCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OnOff::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, OnOffSwitchConfigurationCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - OnOffSwitchConfigurationCluster * cppCluster = new OnOffSwitchConfigurationCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, OnOffSwitchConfigurationCluster, subscribeSwitchTypeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffSwitchConfigurationCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OnOffSwitchConfiguration::Attributes::SwitchType::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, OnOffSwitchConfigurationCluster, writeSwitchActionsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::OnOffSwitchConfiguration::Attributes::SwitchActions::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffSwitchConfigurationCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OnOffSwitchConfigurationCluster, subscribeSwitchActionsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffSwitchConfigurationCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OnOffSwitchConfiguration::Attributes::SwitchActions::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OnOffSwitchConfigurationCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffSwitchConfigurationCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OnOffSwitchConfiguration::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPOnOffSwitchConfigurationAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OnOffSwitchConfigurationCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OnOffSwitchConfigurationCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OnOffSwitchConfiguration::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, OperationalCredentialsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - OperationalCredentialsCluster * cppCluster = new OperationalCredentialsCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, OperationalCredentialsCluster, addNOC) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray NOCValue, jobject ICACValue, jbyteArray IPKValue, - jobject caseAdminNode, jobject adminVendorId, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OperationalCredentialsCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OperationalCredentials::Commands::AddNOC::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - auto NOCValueJni = chip::Platform::New(env, static_cast(NOCValue)); - cleanupByteArrays.push_back(NOCValueJni); - request.NOCValue = NOCValueJni->byteSpan(); - if (ICACValue != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(ICACValue, optionalValue_0); - auto & definedValue_0 = request.ICACValue.Emplace(); - auto optionalValue_0Jni = chip::Platform::New(env, static_cast(optionalValue_0)); - cleanupByteArrays.push_back(optionalValue_0Jni); - definedValue_0 = optionalValue_0Jni->byteSpan(); - } - auto IPKValueJni = chip::Platform::New(env, static_cast(IPKValue)); - cleanupByteArrays.push_back(IPKValueJni); - request.IPKValue = IPKValueJni->byteSpan(); - request.caseAdminNode = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(caseAdminNode)); - request.adminVendorId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(adminVendorId)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OperationalCredentialsCluster, addTrustedRootCertificate) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray rootCertificate, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OperationalCredentialsCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OperationalCredentials::Commands::AddTrustedRootCertificate::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - auto rootCertificateJni = chip::Platform::New(env, static_cast(rootCertificate)); - cleanupByteArrays.push_back(rootCertificateJni); - request.rootCertificate = rootCertificateJni->byteSpan(); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OperationalCredentialsCluster, attestationRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray attestationNonce, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OperationalCredentialsCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OperationalCredentials::Commands::AttestationRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - auto attestationNonceJni = chip::Platform::New(env, static_cast(attestationNonce)); - cleanupByteArrays.push_back(attestationNonceJni); - request.attestationNonce = attestationNonceJni->byteSpan(); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OperationalCredentialsCluster, certificateChainRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject certificateType, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OperationalCredentialsCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OperationalCredentials::Commands::CertificateChainRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.certificateType = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(certificateType)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OperationalCredentialsCluster, opCSRRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray CSRNonce, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OperationalCredentialsCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OperationalCredentials::Commands::OpCSRRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - auto CSRNonceJni = chip::Platform::New(env, static_cast(CSRNonce)); - cleanupByteArrays.push_back(CSRNonceJni); - request.CSRNonce = CSRNonceJni->byteSpan(); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OperationalCredentialsCluster, removeFabric) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject fabricIndex, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OperationalCredentialsCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OperationalCredentials::Commands::RemoveFabric::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.fabricIndex = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(fabricIndex)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OperationalCredentialsCluster, removeTrustedRootCertificate) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray trustedRootIdentifier, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OperationalCredentialsCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OperationalCredentials::Commands::RemoveTrustedRootCertificate::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - auto trustedRootIdentifierJni = chip::Platform::New(env, static_cast(trustedRootIdentifier)); - cleanupByteArrays.push_back(trustedRootIdentifierJni); - request.trustedRootIdentifier = trustedRootIdentifierJni->byteSpan(); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OperationalCredentialsCluster, updateFabricLabel) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring label, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OperationalCredentialsCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OperationalCredentials::Commands::UpdateFabricLabel::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - auto labelJni = chip::Platform::New(env, static_cast(label)); - cleanupStrings.push_back(labelJni); - request.label = labelJni->charSpan(); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OperationalCredentialsCluster, updateNOC) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray NOCValue, jobject ICACValue, - jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - OperationalCredentialsCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::OperationalCredentials::Commands::UpdateNOC::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - auto NOCValueJni = chip::Platform::New(env, static_cast(NOCValue)); - cleanupByteArrays.push_back(NOCValueJni); - request.NOCValue = NOCValueJni->byteSpan(); - if (ICACValue != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(ICACValue, optionalValue_0); - auto & definedValue_0 = request.ICACValue.Emplace(); - auto optionalValue_0Jni = chip::Platform::New(env, static_cast(optionalValue_0)); - cleanupByteArrays.push_back(optionalValue_0Jni); - definedValue_0 = optionalValue_0Jni->byteSpan(); - } - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OperationalCredentialsCluster, subscribeFabricsListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OperationalCredentialsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OperationalCredentials::Attributes::FabricsList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPOperationalCredentialsFabricsListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OperationalCredentialsCluster, subscribeSupportedFabricsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OperationalCredentialsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OperationalCredentials::Attributes::SupportedFabrics::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OperationalCredentialsCluster, subscribeCommissionedFabricsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OperationalCredentialsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OperationalCredentials::Attributes::CommissionedFabrics::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OperationalCredentialsCluster, subscribeTrustedRootCertificatesAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OperationalCredentialsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OperationalCredentials::Attributes::TrustedRootCertificates::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPOperationalCredentialsTrustedRootCertificatesAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OperationalCredentialsCluster, subscribeCurrentFabricIndexAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OperationalCredentialsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OperationalCredentials::Attributes::CurrentFabricIndex::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPOperationalCredentialsCurrentFabricIndexAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OperationalCredentialsCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OperationalCredentialsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OperationalCredentials::Attributes::AttributeList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPOperationalCredentialsAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, OperationalCredentialsCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - OperationalCredentialsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::OperationalCredentials::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, PowerSourceCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - PowerSourceCluster * cppCluster = new PowerSourceCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, PowerSourceCluster, subscribeStatusAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PowerSource::Attributes::Status::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PowerSourceCluster, subscribeOrderAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PowerSource::Attributes::Order::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PowerSourceCluster, subscribeDescriptionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PowerSource::Attributes::Description::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PowerSourceCluster, subscribeBatteryVoltageAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PowerSource::Attributes::BatteryVoltage::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PowerSourceCluster, subscribeBatteryPercentRemainingAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PowerSource::Attributes::BatteryPercentRemaining::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PowerSourceCluster, subscribeBatteryTimeRemainingAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PowerSource::Attributes::BatteryTimeRemaining::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PowerSourceCluster, subscribeBatteryChargeLevelAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PowerSource::Attributes::BatteryChargeLevel::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PowerSourceCluster, subscribeActiveBatteryFaultsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PowerSource::Attributes::ActiveBatteryFaults::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPPowerSourceActiveBatteryFaultsAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PowerSourceCluster, subscribeBatteryChargeStateAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PowerSource::Attributes::BatteryChargeState::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PowerSourceCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PowerSource::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPPowerSourceAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PowerSourceCluster, subscribeFeatureMapAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PowerSource::Attributes::FeatureMap::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PowerSourceCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PowerSource::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, PowerSourceConfigurationCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - PowerSourceConfigurationCluster * cppCluster = new PowerSourceConfigurationCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, PowerSourceConfigurationCluster, subscribeSourcesAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PowerSourceConfigurationCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PowerSourceConfiguration::Attributes::Sources::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPPowerSourceConfigurationSourcesAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PowerSourceConfigurationCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PowerSourceConfigurationCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PowerSourceConfiguration::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPPowerSourceConfigurationAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PowerSourceConfigurationCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PowerSourceConfigurationCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PowerSourceConfiguration::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, PressureMeasurementCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - PressureMeasurementCluster * cppCluster = new PressureMeasurementCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, PressureMeasurementCluster, subscribeMeasuredValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PressureMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PressureMeasurement::Attributes::MeasuredValue::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PressureMeasurementCluster, subscribeMinMeasuredValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PressureMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PressureMeasurement::Attributes::MinMeasuredValue::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PressureMeasurementCluster, subscribeMaxMeasuredValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PressureMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PressureMeasurement::Attributes::MaxMeasuredValue::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PressureMeasurementCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PressureMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PressureMeasurement::Attributes::AttributeList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPPressureMeasurementAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PressureMeasurementCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PressureMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PressureMeasurement::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, PumpConfigurationAndControlCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - PumpConfigurationAndControlCluster * cppCluster = new PumpConfigurationAndControlCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMaxPressureAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MaxPressure::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMaxSpeedAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MaxSpeed::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMaxFlowAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MaxFlow::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMinConstPressureAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MinConstPressure::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMaxConstPressureAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MaxConstPressure::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMinCompPressureAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MinCompPressure::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMaxCompPressureAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MaxCompPressure::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMinConstSpeedAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MinConstSpeed::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMaxConstSpeedAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MaxConstSpeed::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMinConstFlowAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MinConstFlow::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMaxConstFlowAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MaxConstFlow::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMinConstTempAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MinConstTemp::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMaxConstTempAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MaxConstTemp::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribePumpStatusAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::PumpStatus::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeEffectiveOperationModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::EffectiveOperationMode::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeEffectiveControlModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::EffectiveControlMode::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeCapacityAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::Capacity::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeSpeedAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::Speed::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, PumpConfigurationAndControlCluster, writeLifetimeRunningHoursAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::LifetimeRunningHours::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeLifetimeRunningHoursAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::LifetimeRunningHours::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPPumpConfigurationAndControlLifetimeRunningHoursAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribePowerAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::Power::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, PumpConfigurationAndControlCluster, writeLifetimeEnergyConsumedAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::LifetimeEnergyConsumed::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeLifetimeEnergyConsumedAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::LifetimeEnergyConsumed::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPPumpConfigurationAndControlLifetimeEnergyConsumedAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, PumpConfigurationAndControlCluster, writeOperationModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::OperationMode::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeOperationModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::OperationMode::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, PumpConfigurationAndControlCluster, writeControlModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::ControlMode::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeControlModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::ControlMode::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeAlarmMaskAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::AlarmMask::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPPumpConfigurationAndControlAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeFeatureMapAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::FeatureMap::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - PumpConfigurationAndControlCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, RelativeHumidityMeasurementCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - RelativeHumidityMeasurementCluster * cppCluster = new RelativeHumidityMeasurementCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, RelativeHumidityMeasurementCluster, subscribeMeasuredValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - RelativeHumidityMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::RelativeHumidityMeasurement::Attributes::MeasuredValue::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, RelativeHumidityMeasurementCluster, subscribeMinMeasuredValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - RelativeHumidityMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::RelativeHumidityMeasurement::Attributes::MinMeasuredValue::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, RelativeHumidityMeasurementCluster, subscribeMaxMeasuredValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - RelativeHumidityMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::RelativeHumidityMeasurement::Attributes::MaxMeasuredValue::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, RelativeHumidityMeasurementCluster, subscribeToleranceAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - RelativeHumidityMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::RelativeHumidityMeasurement::Attributes::Tolerance::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, RelativeHumidityMeasurementCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - RelativeHumidityMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::RelativeHumidityMeasurement::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPRelativeHumidityMeasurementAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, RelativeHumidityMeasurementCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - RelativeHumidityMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::RelativeHumidityMeasurement::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, ScenesCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - ScenesCluster * cppCluster = new ScenesCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, ScenesCluster, addScene) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jobject sceneId, jobject transitionTime, - jstring sceneName, jobject extensionFieldSets, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ScenesCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::Scenes::Commands::AddScene::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.groupId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); - request.sceneId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(sceneId)); - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); - auto sceneNameJni = chip::Platform::New(env, static_cast(sceneName)); - cleanupStrings.push_back(sceneNameJni); - request.sceneName = sceneNameJni->charSpan(); - { - using ListType_0 = std::remove_reference_t; - using ListMemberType_0 = ListMemberTypeGetter::Type; - jint extensionFieldSetsSize; - chip::JniReferences::GetInstance().GetArrayListSize(extensionFieldSets, extensionFieldSetsSize); - if (extensionFieldSetsSize != 0) - { - auto * listHolder_0 = new ListHolder(extensionFieldSetsSize); - listFreer.add(listHolder_0); - - for (size_t i_0 = 0; i_0 < static_cast(extensionFieldSetsSize); ++i_0) - { - jobject element_0; - chip::JniReferences::GetInstance().GetArrayListItem(extensionFieldSets, i_0, element_0); - jobject element_0_clusterIdItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "clusterId", "Ljava/lang/Long;", - element_0_clusterIdItem_1); - listHolder_0->mList[i_0].clusterId = - static_castmList[i_0].clusterId)>>( - chip::JniReferences::GetInstance().LongToPrimitive(element_0_clusterIdItem_1)); - jobject element_0_lengthItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "length", "Ljava/lang/Integer;", - element_0_lengthItem_1); - listHolder_0->mList[i_0].length = static_castmList[i_0].length)>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_lengthItem_1)); - jobject element_0_valueItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "value", "Ljava/lang/Integer;", element_0_valueItem_1); - listHolder_0->mList[i_0].value = static_castmList[i_0].value)>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_valueItem_1)); - } - request.extensionFieldSets = ListType_0(listHolder_0->mList, extensionFieldSetsSize); - } - else - { - request.extensionFieldSets = ListType_0(); - } - } - - std::unique_ptr onSuccess( - Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ScenesCluster, getSceneMembership) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ScenesCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::Scenes::Commands::GetSceneMembership::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.groupId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ScenesCluster, recallScene) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jobject sceneId, jobject transitionTime, - jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ScenesCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::Scenes::Commands::RecallScene::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.groupId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); - request.sceneId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(sceneId)); - request.transitionTime = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(transitionTime)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ScenesCluster, removeAllScenes) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ScenesCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::Scenes::Commands::RemoveAllScenes::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.groupId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ScenesCluster, removeScene) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jobject sceneId, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ScenesCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::Scenes::Commands::RemoveScene::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.groupId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); - request.sceneId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(sceneId)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ScenesCluster, storeScene) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jobject sceneId, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ScenesCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::Scenes::Commands::StoreScene::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.groupId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); - request.sceneId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(sceneId)); - - std::unique_ptr onSuccess( - Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ScenesCluster, viewScene) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject groupId, jobject sceneId, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ScenesCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::Scenes::Commands::ViewScene::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.groupId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(groupId)); - request.sceneId = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(sceneId)); - - std::unique_ptr onSuccess( - Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ScenesCluster, subscribeSceneCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ScenesCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Scenes::Attributes::SceneCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ScenesCluster, subscribeCurrentSceneAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ScenesCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Scenes::Attributes::CurrentScene::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ScenesCluster, subscribeCurrentGroupAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ScenesCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Scenes::Attributes::CurrentGroup::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ScenesCluster, subscribeSceneValidAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ScenesCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Scenes::Attributes::SceneValid::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ScenesCluster, subscribeNameSupportAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ScenesCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Scenes::Attributes::NameSupport::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ScenesCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ScenesCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Scenes::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPScenesAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ScenesCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ScenesCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Scenes::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, SoftwareDiagnosticsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - SoftwareDiagnosticsCluster * cppCluster = new SoftwareDiagnosticsCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, SoftwareDiagnosticsCluster, resetWatermarks) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - SoftwareDiagnosticsCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::SoftwareDiagnostics::Commands::ResetWatermarks::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, SoftwareDiagnosticsCluster, subscribeThreadMetricsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - SoftwareDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::SoftwareDiagnostics::Attributes::ThreadMetrics::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPSoftwareDiagnosticsThreadMetricsAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, SoftwareDiagnosticsCluster, subscribeCurrentHeapFreeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - SoftwareDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::SoftwareDiagnostics::Attributes::CurrentHeapFree::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, SoftwareDiagnosticsCluster, subscribeCurrentHeapUsedAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - SoftwareDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::SoftwareDiagnostics::Attributes::CurrentHeapUsed::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, SoftwareDiagnosticsCluster, subscribeCurrentHeapHighWatermarkAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - SoftwareDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::SoftwareDiagnostics::Attributes::CurrentHeapHighWatermark::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, SoftwareDiagnosticsCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - SoftwareDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::SoftwareDiagnostics::Attributes::AttributeList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPSoftwareDiagnosticsAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, SoftwareDiagnosticsCluster, subscribeFeatureMapAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - SoftwareDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::SoftwareDiagnostics::Attributes::FeatureMap::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, SoftwareDiagnosticsCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - SoftwareDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::SoftwareDiagnostics::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, SwitchCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - SwitchCluster * cppCluster = new SwitchCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, SwitchCluster, subscribeNumberOfPositionsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - SwitchCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Switch::Attributes::NumberOfPositions::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, SwitchCluster, subscribeCurrentPositionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - SwitchCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Switch::Attributes::CurrentPosition::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, SwitchCluster, subscribeMultiPressMaxAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - SwitchCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Switch::Attributes::MultiPressMax::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, SwitchCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - SwitchCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Switch::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPSwitchAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, SwitchCluster, subscribeFeatureMapAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - SwitchCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Switch::Attributes::FeatureMap::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, SwitchCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - SwitchCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Switch::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, TargetNavigatorCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - TargetNavigatorCluster * cppCluster = new TargetNavigatorCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, TargetNavigatorCluster, navigateTargetRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject target, jstring data, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TargetNavigatorCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TargetNavigator::Commands::NavigateTargetRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.target = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(target)); - auto dataJni = chip::Platform::New(env, static_cast(data)); - cleanupStrings.push_back(dataJni); - request.data = dataJni->charSpan(); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TargetNavigatorCluster, subscribeTargetNavigatorListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TargetNavigatorCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TargetNavigator::Attributes::TargetNavigatorList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPTargetNavigatorTargetNavigatorListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TargetNavigatorCluster, subscribeCurrentNavigatorTargetAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TargetNavigatorCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TargetNavigator::Attributes::CurrentNavigatorTarget::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TargetNavigatorCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TargetNavigatorCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TargetNavigator::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTargetNavigatorAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TargetNavigatorCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TargetNavigatorCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TargetNavigator::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, TemperatureMeasurementCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - TemperatureMeasurementCluster * cppCluster = new TemperatureMeasurementCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, TemperatureMeasurementCluster, subscribeMeasuredValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TemperatureMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TemperatureMeasurement::Attributes::MeasuredValue::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TemperatureMeasurementCluster, subscribeMinMeasuredValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TemperatureMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TemperatureMeasurement::Attributes::MinMeasuredValue::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TemperatureMeasurementCluster, subscribeMaxMeasuredValueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TemperatureMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TemperatureMeasurement::Attributes::MaxMeasuredValue::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TemperatureMeasurementCluster, subscribeToleranceAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TemperatureMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TemperatureMeasurement::Attributes::Tolerance::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TemperatureMeasurementCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TemperatureMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TemperatureMeasurement::Attributes::AttributeList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPTemperatureMeasurementAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TemperatureMeasurementCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TemperatureMeasurementCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TemperatureMeasurement::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, TestClusterCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - TestClusterCluster * cppCluster = new TestClusterCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, TestClusterCluster, simpleStructEchoRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TestCluster::Commands::SimpleStructEchoRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - jobject arg1_aItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "a", "Ljava/lang/Integer;", arg1_aItem_0); - request.arg1.a = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_aItem_0)); - jobject arg1_bItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "b", "Ljava/lang/Boolean;", arg1_bItem_0); - request.arg1.b = static_cast>( - chip::JniReferences::GetInstance().BooleanToPrimitive(arg1_bItem_0)); - jobject arg1_cItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "c", "Ljava/lang/Integer;", arg1_cItem_0); - request.arg1.c = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_cItem_0)); - jobject arg1_dItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "d", "[B", arg1_dItem_0); - auto arg1_dItem_0Jni = chip::Platform::New(env, static_cast(arg1_dItem_0)); - cleanupByteArrays.push_back(arg1_dItem_0Jni); - request.arg1.d = arg1_dItem_0Jni->byteSpan(); - jobject arg1_eItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "e", "Ljava/lang/String;", arg1_eItem_0); - auto arg1_eItem_0Jni = chip::Platform::New(env, static_cast(arg1_eItem_0)); - cleanupStrings.push_back(arg1_eItem_0Jni); - request.arg1.e = arg1_eItem_0Jni->charSpan(); - jobject arg1_fItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "f", "Ljava/lang/Integer;", arg1_fItem_0); - request.arg1.f = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_fItem_0)); - jobject arg1_gItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "g", "Ljava/lang/Float;", arg1_gItem_0); - request.arg1.g = static_cast>( - chip::JniReferences::GetInstance().FloatToPrimitive(arg1_gItem_0)); - jobject arg1_hItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "h", "Ljava/lang/Double;", arg1_hItem_0); - request.arg1.h = static_cast>( - chip::JniReferences::GetInstance().DoubleToPrimitive(arg1_hItem_0)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, test) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TestCluster::Commands::Test::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, testAddArguments) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject arg2, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TestCluster::Commands::TestAddArguments::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.arg1 = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(arg1)); - request.arg2 = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(arg2)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, testEmitTestEventRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject arg2, jobject arg3, - jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TestCluster::Commands::TestEmitTestEventRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.arg1 = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(arg1)); - request.arg2 = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(arg2)); - request.arg3 = - static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(arg3)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, testEnumsRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject arg2, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TestCluster::Commands::TestEnumsRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.arg1 = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(arg1)); - request.arg2 = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(arg2)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, testListInt8UArgumentRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TestCluster::Commands::TestListInt8UArgumentRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - { - using ListType_0 = std::remove_reference_t; - using ListMemberType_0 = ListMemberTypeGetter::Type; - jint arg1Size; - chip::JniReferences::GetInstance().GetArrayListSize(arg1, arg1Size); - if (arg1Size != 0) - { - auto * listHolder_0 = new ListHolder(arg1Size); - listFreer.add(listHolder_0); - - for (size_t i_0 = 0; i_0 < static_cast(arg1Size); ++i_0) - { - jobject element_0; - chip::JniReferences::GetInstance().GetArrayListItem(arg1, i_0, element_0); - listHolder_0->mList[i_0] = static_castmList[i_0])>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0)); - } - request.arg1 = ListType_0(listHolder_0->mList, arg1Size); - } - else - { - request.arg1 = ListType_0(); - } - } - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, testListInt8UReverseRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TestCluster::Commands::TestListInt8UReverseRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - { - using ListType_0 = std::remove_reference_t; - using ListMemberType_0 = ListMemberTypeGetter::Type; - jint arg1Size; - chip::JniReferences::GetInstance().GetArrayListSize(arg1, arg1Size); - if (arg1Size != 0) - { - auto * listHolder_0 = new ListHolder(arg1Size); - listFreer.add(listHolder_0); - - for (size_t i_0 = 0; i_0 < static_cast(arg1Size); ++i_0) - { - jobject element_0; - chip::JniReferences::GetInstance().GetArrayListItem(arg1, i_0, element_0); - listHolder_0->mList[i_0] = static_castmList[i_0])>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0)); - } - request.arg1 = ListType_0(listHolder_0->mList, arg1Size); - } - else - { - request.arg1 = ListType_0(); - } - } - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, testListNestedStructListArgumentRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TestCluster::Commands::TestListNestedStructListArgumentRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - { - using ListType_0 = std::remove_reference_t; - using ListMemberType_0 = ListMemberTypeGetter::Type; - jint arg1Size; - chip::JniReferences::GetInstance().GetArrayListSize(arg1, arg1Size); - if (arg1Size != 0) - { - auto * listHolder_0 = new ListHolder(arg1Size); - listFreer.add(listHolder_0); - - for (size_t i_0 = 0; i_0 < static_cast(arg1Size); ++i_0) - { - jobject element_0; - chip::JniReferences::GetInstance().GetArrayListItem(arg1, i_0, element_0); - jobject element_0_aItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "a", "Ljava/lang/Integer;", element_0_aItem_1); - listHolder_0->mList[i_0].a = static_castmList[i_0].a)>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_aItem_1)); - jobject element_0_bItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "b", "Ljava/lang/Boolean;", element_0_bItem_1); - listHolder_0->mList[i_0].b = static_castmList[i_0].b)>>( - chip::JniReferences::GetInstance().BooleanToPrimitive(element_0_bItem_1)); - jobject element_0_cItem_1; - chip::JniReferences::GetInstance().GetObjectField( - element_0, "c", "Lchip/devicecontroller/ChipStructs$TestClusterClusterSimpleStruct;", element_0_cItem_1); - jobject element_0_cItem_1_aItem_2; - chip::JniReferences::GetInstance().GetObjectField(element_0_cItem_1, "a", "Ljava/lang/Integer;", - element_0_cItem_1_aItem_2); - listHolder_0->mList[i_0].c.a = static_castmList[i_0].c.a)>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_cItem_1_aItem_2)); - jobject element_0_cItem_1_bItem_2; - chip::JniReferences::GetInstance().GetObjectField(element_0_cItem_1, "b", "Ljava/lang/Boolean;", - element_0_cItem_1_bItem_2); - listHolder_0->mList[i_0].c.b = static_castmList[i_0].c.b)>>( - chip::JniReferences::GetInstance().BooleanToPrimitive(element_0_cItem_1_bItem_2)); - jobject element_0_cItem_1_cItem_2; - chip::JniReferences::GetInstance().GetObjectField(element_0_cItem_1, "c", "Ljava/lang/Integer;", - element_0_cItem_1_cItem_2); - listHolder_0->mList[i_0].c.c = static_castmList[i_0].c.c)>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_cItem_1_cItem_2)); - jobject element_0_cItem_1_dItem_2; - chip::JniReferences::GetInstance().GetObjectField(element_0_cItem_1, "d", "[B", element_0_cItem_1_dItem_2); - auto element_0_cItem_1_dItem_2Jni = - chip::Platform::New(env, static_cast(element_0_cItem_1_dItem_2)); - cleanupByteArrays.push_back(element_0_cItem_1_dItem_2Jni); - listHolder_0->mList[i_0].c.d = element_0_cItem_1_dItem_2Jni->byteSpan(); - jobject element_0_cItem_1_eItem_2; - chip::JniReferences::GetInstance().GetObjectField(element_0_cItem_1, "e", "Ljava/lang/String;", - element_0_cItem_1_eItem_2); - auto element_0_cItem_1_eItem_2Jni = - chip::Platform::New(env, static_cast(element_0_cItem_1_eItem_2)); - cleanupStrings.push_back(element_0_cItem_1_eItem_2Jni); - listHolder_0->mList[i_0].c.e = element_0_cItem_1_eItem_2Jni->charSpan(); - jobject element_0_cItem_1_fItem_2; - chip::JniReferences::GetInstance().GetObjectField(element_0_cItem_1, "f", "Ljava/lang/Integer;", - element_0_cItem_1_fItem_2); - listHolder_0->mList[i_0].c.f = static_castmList[i_0].c.f)>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_cItem_1_fItem_2)); - jobject element_0_cItem_1_gItem_2; - chip::JniReferences::GetInstance().GetObjectField(element_0_cItem_1, "g", "Ljava/lang/Float;", - element_0_cItem_1_gItem_2); - listHolder_0->mList[i_0].c.g = static_castmList[i_0].c.g)>>( - chip::JniReferences::GetInstance().FloatToPrimitive(element_0_cItem_1_gItem_2)); - jobject element_0_cItem_1_hItem_2; - chip::JniReferences::GetInstance().GetObjectField(element_0_cItem_1, "h", "Ljava/lang/Double;", - element_0_cItem_1_hItem_2); - listHolder_0->mList[i_0].c.h = static_castmList[i_0].c.h)>>( - chip::JniReferences::GetInstance().DoubleToPrimitive(element_0_cItem_1_hItem_2)); - jobject element_0_dItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "d", "Ljava/util/ArrayList;", element_0_dItem_1); - { - using ListType_2 = std::remove_reference_tmList[i_0].d)>; - using ListMemberType_2 = ListMemberTypeGetter::Type; - jint element_0_dItem_1Size; - chip::JniReferences::GetInstance().GetArrayListSize(element_0_dItem_1, element_0_dItem_1Size); - if (element_0_dItem_1Size != 0) - { - auto * listHolder_2 = new ListHolder(element_0_dItem_1Size); - listFreer.add(listHolder_2); - - for (size_t i_2 = 0; i_2 < static_cast(element_0_dItem_1Size); ++i_2) - { - jobject element_2; - chip::JniReferences::GetInstance().GetArrayListItem(element_0_dItem_1, i_2, element_2); - jobject element_2_aItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_2, "a", "Ljava/lang/Integer;", - element_2_aItem_3); - listHolder_2->mList[i_2].a = static_castmList[i_2].a)>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_2_aItem_3)); - jobject element_2_bItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_2, "b", "Ljava/lang/Boolean;", - element_2_bItem_3); - listHolder_2->mList[i_2].b = static_castmList[i_2].b)>>( - chip::JniReferences::GetInstance().BooleanToPrimitive(element_2_bItem_3)); - jobject element_2_cItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_2, "c", "Ljava/lang/Integer;", - element_2_cItem_3); - listHolder_2->mList[i_2].c = static_castmList[i_2].c)>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_2_cItem_3)); - jobject element_2_dItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_2, "d", "[B", element_2_dItem_3); - auto element_2_dItem_3Jni = - chip::Platform::New(env, static_cast(element_2_dItem_3)); - cleanupByteArrays.push_back(element_2_dItem_3Jni); - listHolder_2->mList[i_2].d = element_2_dItem_3Jni->byteSpan(); - jobject element_2_eItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_2, "e", "Ljava/lang/String;", - element_2_eItem_3); - auto element_2_eItem_3Jni = - chip::Platform::New(env, static_cast(element_2_eItem_3)); - cleanupStrings.push_back(element_2_eItem_3Jni); - listHolder_2->mList[i_2].e = element_2_eItem_3Jni->charSpan(); - jobject element_2_fItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_2, "f", "Ljava/lang/Integer;", - element_2_fItem_3); - listHolder_2->mList[i_2].f = static_castmList[i_2].f)>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_2_fItem_3)); - jobject element_2_gItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_2, "g", "Ljava/lang/Float;", - element_2_gItem_3); - listHolder_2->mList[i_2].g = static_castmList[i_2].g)>>( - chip::JniReferences::GetInstance().FloatToPrimitive(element_2_gItem_3)); - jobject element_2_hItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_2, "h", "Ljava/lang/Double;", - element_2_hItem_3); - listHolder_2->mList[i_2].h = static_castmList[i_2].h)>>( - chip::JniReferences::GetInstance().DoubleToPrimitive(element_2_hItem_3)); - } - listHolder_0->mList[i_0].d = ListType_2(listHolder_2->mList, element_0_dItem_1Size); - } - else - { - listHolder_0->mList[i_0].d = ListType_2(); - } - } - jobject element_0_eItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "e", "Ljava/util/ArrayList;", element_0_eItem_1); - { - using ListType_2 = std::remove_reference_tmList[i_0].e)>; - using ListMemberType_2 = ListMemberTypeGetter::Type; - jint element_0_eItem_1Size; - chip::JniReferences::GetInstance().GetArrayListSize(element_0_eItem_1, element_0_eItem_1Size); - if (element_0_eItem_1Size != 0) - { - auto * listHolder_2 = new ListHolder(element_0_eItem_1Size); - listFreer.add(listHolder_2); - - for (size_t i_2 = 0; i_2 < static_cast(element_0_eItem_1Size); ++i_2) - { - jobject element_2; - chip::JniReferences::GetInstance().GetArrayListItem(element_0_eItem_1, i_2, element_2); - listHolder_2->mList[i_2] = static_castmList[i_2])>>( - chip::JniReferences::GetInstance().LongToPrimitive(element_2)); - } - listHolder_0->mList[i_0].e = ListType_2(listHolder_2->mList, element_0_eItem_1Size); - } - else - { - listHolder_0->mList[i_0].e = ListType_2(); - } - } - jobject element_0_fItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "f", "Ljava/util/ArrayList;", element_0_fItem_1); - { - using ListType_2 = std::remove_reference_tmList[i_0].f)>; - using ListMemberType_2 = ListMemberTypeGetter::Type; - jint element_0_fItem_1Size; - chip::JniReferences::GetInstance().GetArrayListSize(element_0_fItem_1, element_0_fItem_1Size); - if (element_0_fItem_1Size != 0) - { - auto * listHolder_2 = new ListHolder(element_0_fItem_1Size); - listFreer.add(listHolder_2); - - for (size_t i_2 = 0; i_2 < static_cast(element_0_fItem_1Size); ++i_2) - { - jobject element_2; - chip::JniReferences::GetInstance().GetArrayListItem(element_0_fItem_1, i_2, element_2); - auto element_2Jni = chip::Platform::New(env, static_cast(element_2)); - cleanupByteArrays.push_back(element_2Jni); - listHolder_2->mList[i_2] = element_2Jni->byteSpan(); - } - listHolder_0->mList[i_0].f = ListType_2(listHolder_2->mList, element_0_fItem_1Size); - } - else - { - listHolder_0->mList[i_0].f = ListType_2(); - } - } - jobject element_0_gItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "g", "Ljava/util/ArrayList;", element_0_gItem_1); - { - using ListType_2 = std::remove_reference_tmList[i_0].g)>; - using ListMemberType_2 = ListMemberTypeGetter::Type; - jint element_0_gItem_1Size; - chip::JniReferences::GetInstance().GetArrayListSize(element_0_gItem_1, element_0_gItem_1Size); - if (element_0_gItem_1Size != 0) - { - auto * listHolder_2 = new ListHolder(element_0_gItem_1Size); - listFreer.add(listHolder_2); - - for (size_t i_2 = 0; i_2 < static_cast(element_0_gItem_1Size); ++i_2) - { - jobject element_2; - chip::JniReferences::GetInstance().GetArrayListItem(element_0_gItem_1, i_2, element_2); - listHolder_2->mList[i_2] = static_castmList[i_2])>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_2)); - } - listHolder_0->mList[i_0].g = ListType_2(listHolder_2->mList, element_0_gItem_1Size); - } - else - { - listHolder_0->mList[i_0].g = ListType_2(); - } - } - } - request.arg1 = ListType_0(listHolder_0->mList, arg1Size); - } - else - { - request.arg1 = ListType_0(); - } - } - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, testListStructArgumentRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TestCluster::Commands::TestListStructArgumentRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - { - using ListType_0 = std::remove_reference_t; - using ListMemberType_0 = ListMemberTypeGetter::Type; - jint arg1Size; - chip::JniReferences::GetInstance().GetArrayListSize(arg1, arg1Size); - if (arg1Size != 0) - { - auto * listHolder_0 = new ListHolder(arg1Size); - listFreer.add(listHolder_0); - - for (size_t i_0 = 0; i_0 < static_cast(arg1Size); ++i_0) - { - jobject element_0; - chip::JniReferences::GetInstance().GetArrayListItem(arg1, i_0, element_0); - jobject element_0_aItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "a", "Ljava/lang/Integer;", element_0_aItem_1); - listHolder_0->mList[i_0].a = static_castmList[i_0].a)>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_aItem_1)); - jobject element_0_bItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "b", "Ljava/lang/Boolean;", element_0_bItem_1); - listHolder_0->mList[i_0].b = static_castmList[i_0].b)>>( - chip::JniReferences::GetInstance().BooleanToPrimitive(element_0_bItem_1)); - jobject element_0_cItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "c", "Ljava/lang/Integer;", element_0_cItem_1); - listHolder_0->mList[i_0].c = static_castmList[i_0].c)>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_cItem_1)); - jobject element_0_dItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "d", "[B", element_0_dItem_1); - auto element_0_dItem_1Jni = - chip::Platform::New(env, static_cast(element_0_dItem_1)); - cleanupByteArrays.push_back(element_0_dItem_1Jni); - listHolder_0->mList[i_0].d = element_0_dItem_1Jni->byteSpan(); - jobject element_0_eItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "e", "Ljava/lang/String;", element_0_eItem_1); - auto element_0_eItem_1Jni = chip::Platform::New(env, static_cast(element_0_eItem_1)); - cleanupStrings.push_back(element_0_eItem_1Jni); - listHolder_0->mList[i_0].e = element_0_eItem_1Jni->charSpan(); - jobject element_0_fItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "f", "Ljava/lang/Integer;", element_0_fItem_1); - listHolder_0->mList[i_0].f = static_castmList[i_0].f)>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_fItem_1)); - jobject element_0_gItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "g", "Ljava/lang/Float;", element_0_gItem_1); - listHolder_0->mList[i_0].g = static_castmList[i_0].g)>>( - chip::JniReferences::GetInstance().FloatToPrimitive(element_0_gItem_1)); - jobject element_0_hItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "h", "Ljava/lang/Double;", element_0_hItem_1); - listHolder_0->mList[i_0].h = static_castmList[i_0].h)>>( - chip::JniReferences::GetInstance().DoubleToPrimitive(element_0_hItem_1)); - } - request.arg1 = ListType_0(listHolder_0->mList, arg1Size); - } - else - { - request.arg1 = ListType_0(); - } - } - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, testNestedStructArgumentRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TestCluster::Commands::TestNestedStructArgumentRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - jobject arg1_aItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "a", "Ljava/lang/Integer;", arg1_aItem_0); - request.arg1.a = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_aItem_0)); - jobject arg1_bItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "b", "Ljava/lang/Boolean;", arg1_bItem_0); - request.arg1.b = static_cast>( - chip::JniReferences::GetInstance().BooleanToPrimitive(arg1_bItem_0)); - jobject arg1_cItem_0; - chip::JniReferences::GetInstance().GetObjectField( - arg1, "c", "Lchip/devicecontroller/ChipStructs$TestClusterClusterSimpleStruct;", arg1_cItem_0); - jobject arg1_cItem_0_aItem_1; - chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "a", "Ljava/lang/Integer;", arg1_cItem_0_aItem_1); - request.arg1.c.a = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_cItem_0_aItem_1)); - jobject arg1_cItem_0_bItem_1; - chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "b", "Ljava/lang/Boolean;", arg1_cItem_0_bItem_1); - request.arg1.c.b = static_cast>( - chip::JniReferences::GetInstance().BooleanToPrimitive(arg1_cItem_0_bItem_1)); - jobject arg1_cItem_0_cItem_1; - chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "c", "Ljava/lang/Integer;", arg1_cItem_0_cItem_1); - request.arg1.c.c = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_cItem_0_cItem_1)); - jobject arg1_cItem_0_dItem_1; - chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "d", "[B", arg1_cItem_0_dItem_1); - auto arg1_cItem_0_dItem_1Jni = chip::Platform::New(env, static_cast(arg1_cItem_0_dItem_1)); - cleanupByteArrays.push_back(arg1_cItem_0_dItem_1Jni); - request.arg1.c.d = arg1_cItem_0_dItem_1Jni->byteSpan(); - jobject arg1_cItem_0_eItem_1; - chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "e", "Ljava/lang/String;", arg1_cItem_0_eItem_1); - auto arg1_cItem_0_eItem_1Jni = chip::Platform::New(env, static_cast(arg1_cItem_0_eItem_1)); - cleanupStrings.push_back(arg1_cItem_0_eItem_1Jni); - request.arg1.c.e = arg1_cItem_0_eItem_1Jni->charSpan(); - jobject arg1_cItem_0_fItem_1; - chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "f", "Ljava/lang/Integer;", arg1_cItem_0_fItem_1); - request.arg1.c.f = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_cItem_0_fItem_1)); - jobject arg1_cItem_0_gItem_1; - chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "g", "Ljava/lang/Float;", arg1_cItem_0_gItem_1); - request.arg1.c.g = static_cast>( - chip::JniReferences::GetInstance().FloatToPrimitive(arg1_cItem_0_gItem_1)); - jobject arg1_cItem_0_hItem_1; - chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "h", "Ljava/lang/Double;", arg1_cItem_0_hItem_1); - request.arg1.c.h = static_cast>( - chip::JniReferences::GetInstance().DoubleToPrimitive(arg1_cItem_0_hItem_1)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, testNestedStructListArgumentRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TestCluster::Commands::TestNestedStructListArgumentRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - jobject arg1_aItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "a", "Ljava/lang/Integer;", arg1_aItem_0); - request.arg1.a = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_aItem_0)); - jobject arg1_bItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "b", "Ljava/lang/Boolean;", arg1_bItem_0); - request.arg1.b = static_cast>( - chip::JniReferences::GetInstance().BooleanToPrimitive(arg1_bItem_0)); - jobject arg1_cItem_0; - chip::JniReferences::GetInstance().GetObjectField( - arg1, "c", "Lchip/devicecontroller/ChipStructs$TestClusterClusterSimpleStruct;", arg1_cItem_0); - jobject arg1_cItem_0_aItem_1; - chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "a", "Ljava/lang/Integer;", arg1_cItem_0_aItem_1); - request.arg1.c.a = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_cItem_0_aItem_1)); - jobject arg1_cItem_0_bItem_1; - chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "b", "Ljava/lang/Boolean;", arg1_cItem_0_bItem_1); - request.arg1.c.b = static_cast>( - chip::JniReferences::GetInstance().BooleanToPrimitive(arg1_cItem_0_bItem_1)); - jobject arg1_cItem_0_cItem_1; - chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "c", "Ljava/lang/Integer;", arg1_cItem_0_cItem_1); - request.arg1.c.c = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_cItem_0_cItem_1)); - jobject arg1_cItem_0_dItem_1; - chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "d", "[B", arg1_cItem_0_dItem_1); - auto arg1_cItem_0_dItem_1Jni = chip::Platform::New(env, static_cast(arg1_cItem_0_dItem_1)); - cleanupByteArrays.push_back(arg1_cItem_0_dItem_1Jni); - request.arg1.c.d = arg1_cItem_0_dItem_1Jni->byteSpan(); - jobject arg1_cItem_0_eItem_1; - chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "e", "Ljava/lang/String;", arg1_cItem_0_eItem_1); - auto arg1_cItem_0_eItem_1Jni = chip::Platform::New(env, static_cast(arg1_cItem_0_eItem_1)); - cleanupStrings.push_back(arg1_cItem_0_eItem_1Jni); - request.arg1.c.e = arg1_cItem_0_eItem_1Jni->charSpan(); - jobject arg1_cItem_0_fItem_1; - chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "f", "Ljava/lang/Integer;", arg1_cItem_0_fItem_1); - request.arg1.c.f = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_cItem_0_fItem_1)); - jobject arg1_cItem_0_gItem_1; - chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "g", "Ljava/lang/Float;", arg1_cItem_0_gItem_1); - request.arg1.c.g = static_cast>( - chip::JniReferences::GetInstance().FloatToPrimitive(arg1_cItem_0_gItem_1)); - jobject arg1_cItem_0_hItem_1; - chip::JniReferences::GetInstance().GetObjectField(arg1_cItem_0, "h", "Ljava/lang/Double;", arg1_cItem_0_hItem_1); - request.arg1.c.h = static_cast>( - chip::JniReferences::GetInstance().DoubleToPrimitive(arg1_cItem_0_hItem_1)); - jobject arg1_dItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "d", "Ljava/util/ArrayList;", arg1_dItem_0); - { - using ListType_1 = std::remove_reference_t; - using ListMemberType_1 = ListMemberTypeGetter::Type; - jint arg1_dItem_0Size; - chip::JniReferences::GetInstance().GetArrayListSize(arg1_dItem_0, arg1_dItem_0Size); - if (arg1_dItem_0Size != 0) - { - auto * listHolder_1 = new ListHolder(arg1_dItem_0Size); - listFreer.add(listHolder_1); - - for (size_t i_1 = 0; i_1 < static_cast(arg1_dItem_0Size); ++i_1) - { - jobject element_1; - chip::JniReferences::GetInstance().GetArrayListItem(arg1_dItem_0, i_1, element_1); - jobject element_1_aItem_2; - chip::JniReferences::GetInstance().GetObjectField(element_1, "a", "Ljava/lang/Integer;", element_1_aItem_2); - listHolder_1->mList[i_1].a = static_castmList[i_1].a)>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_1_aItem_2)); - jobject element_1_bItem_2; - chip::JniReferences::GetInstance().GetObjectField(element_1, "b", "Ljava/lang/Boolean;", element_1_bItem_2); - listHolder_1->mList[i_1].b = static_castmList[i_1].b)>>( - chip::JniReferences::GetInstance().BooleanToPrimitive(element_1_bItem_2)); - jobject element_1_cItem_2; - chip::JniReferences::GetInstance().GetObjectField(element_1, "c", "Ljava/lang/Integer;", element_1_cItem_2); - listHolder_1->mList[i_1].c = static_castmList[i_1].c)>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_1_cItem_2)); - jobject element_1_dItem_2; - chip::JniReferences::GetInstance().GetObjectField(element_1, "d", "[B", element_1_dItem_2); - auto element_1_dItem_2Jni = - chip::Platform::New(env, static_cast(element_1_dItem_2)); - cleanupByteArrays.push_back(element_1_dItem_2Jni); - listHolder_1->mList[i_1].d = element_1_dItem_2Jni->byteSpan(); - jobject element_1_eItem_2; - chip::JniReferences::GetInstance().GetObjectField(element_1, "e", "Ljava/lang/String;", element_1_eItem_2); - auto element_1_eItem_2Jni = chip::Platform::New(env, static_cast(element_1_eItem_2)); - cleanupStrings.push_back(element_1_eItem_2Jni); - listHolder_1->mList[i_1].e = element_1_eItem_2Jni->charSpan(); - jobject element_1_fItem_2; - chip::JniReferences::GetInstance().GetObjectField(element_1, "f", "Ljava/lang/Integer;", element_1_fItem_2); - listHolder_1->mList[i_1].f = static_castmList[i_1].f)>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_1_fItem_2)); - jobject element_1_gItem_2; - chip::JniReferences::GetInstance().GetObjectField(element_1, "g", "Ljava/lang/Float;", element_1_gItem_2); - listHolder_1->mList[i_1].g = static_castmList[i_1].g)>>( - chip::JniReferences::GetInstance().FloatToPrimitive(element_1_gItem_2)); - jobject element_1_hItem_2; - chip::JniReferences::GetInstance().GetObjectField(element_1, "h", "Ljava/lang/Double;", element_1_hItem_2); - listHolder_1->mList[i_1].h = static_castmList[i_1].h)>>( - chip::JniReferences::GetInstance().DoubleToPrimitive(element_1_hItem_2)); - } - request.arg1.d = ListType_1(listHolder_1->mList, arg1_dItem_0Size); - } - else - { - request.arg1.d = ListType_1(); - } - } - jobject arg1_eItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "e", "Ljava/util/ArrayList;", arg1_eItem_0); - { - using ListType_1 = std::remove_reference_t; - using ListMemberType_1 = ListMemberTypeGetter::Type; - jint arg1_eItem_0Size; - chip::JniReferences::GetInstance().GetArrayListSize(arg1_eItem_0, arg1_eItem_0Size); - if (arg1_eItem_0Size != 0) - { - auto * listHolder_1 = new ListHolder(arg1_eItem_0Size); - listFreer.add(listHolder_1); - - for (size_t i_1 = 0; i_1 < static_cast(arg1_eItem_0Size); ++i_1) - { - jobject element_1; - chip::JniReferences::GetInstance().GetArrayListItem(arg1_eItem_0, i_1, element_1); - listHolder_1->mList[i_1] = static_castmList[i_1])>>( - chip::JniReferences::GetInstance().LongToPrimitive(element_1)); - } - request.arg1.e = ListType_1(listHolder_1->mList, arg1_eItem_0Size); - } - else - { - request.arg1.e = ListType_1(); - } - } - jobject arg1_fItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "f", "Ljava/util/ArrayList;", arg1_fItem_0); - { - using ListType_1 = std::remove_reference_t; - using ListMemberType_1 = ListMemberTypeGetter::Type; - jint arg1_fItem_0Size; - chip::JniReferences::GetInstance().GetArrayListSize(arg1_fItem_0, arg1_fItem_0Size); - if (arg1_fItem_0Size != 0) - { - auto * listHolder_1 = new ListHolder(arg1_fItem_0Size); - listFreer.add(listHolder_1); - - for (size_t i_1 = 0; i_1 < static_cast(arg1_fItem_0Size); ++i_1) - { - jobject element_1; - chip::JniReferences::GetInstance().GetArrayListItem(arg1_fItem_0, i_1, element_1); - auto element_1Jni = chip::Platform::New(env, static_cast(element_1)); - cleanupByteArrays.push_back(element_1Jni); - listHolder_1->mList[i_1] = element_1Jni->byteSpan(); - } - request.arg1.f = ListType_1(listHolder_1->mList, arg1_fItem_0Size); - } - else - { - request.arg1.f = ListType_1(); - } - } - jobject arg1_gItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "g", "Ljava/util/ArrayList;", arg1_gItem_0); - { - using ListType_1 = std::remove_reference_t; - using ListMemberType_1 = ListMemberTypeGetter::Type; - jint arg1_gItem_0Size; - chip::JniReferences::GetInstance().GetArrayListSize(arg1_gItem_0, arg1_gItem_0Size); - if (arg1_gItem_0Size != 0) - { - auto * listHolder_1 = new ListHolder(arg1_gItem_0Size); - listFreer.add(listHolder_1); - - for (size_t i_1 = 0; i_1 < static_cast(arg1_gItem_0Size); ++i_1) - { - jobject element_1; - chip::JniReferences::GetInstance().GetArrayListItem(arg1_gItem_0, i_1, element_1); - listHolder_1->mList[i_1] = static_castmList[i_1])>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_1)); - } - request.arg1.g = ListType_1(listHolder_1->mList, arg1_gItem_0Size); - } - else - { - request.arg1.g = ListType_1(); - } - } - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, testNotHandled) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TestCluster::Commands::TestNotHandled::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, testNullableOptionalRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TestCluster::Commands::TestNullableOptionalRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - if (arg1 != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(arg1, optionalValue_0); - auto & definedValue_0 = request.arg1.Emplace(); - if (optionalValue_0 == nullptr) - { - definedValue_0.SetNull(); - } - else - { - auto & nonNullValue_1 = definedValue_0.SetNonNull(); - nonNullValue_1 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_0)); - } - } - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, testSimpleOptionalArgumentRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TestCluster::Commands::TestSimpleOptionalArgumentRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - if (arg1 != nullptr) - { - jobject optionalValue_0; - chip::JniReferences::GetInstance().GetOptionalValue(arg1, optionalValue_0); - auto & definedValue_0 = request.arg1.Emplace(); - definedValue_0 = static_cast>( - chip::JniReferences::GetInstance().BooleanToPrimitive(optionalValue_0)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, testSpecific) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TestCluster::Commands::TestSpecific::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, testStructArgumentRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject arg1, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TestCluster::Commands::TestStructArgumentRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - jobject arg1_aItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "a", "Ljava/lang/Integer;", arg1_aItem_0); - request.arg1.a = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_aItem_0)); - jobject arg1_bItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "b", "Ljava/lang/Boolean;", arg1_bItem_0); - request.arg1.b = static_cast>( - chip::JniReferences::GetInstance().BooleanToPrimitive(arg1_bItem_0)); - jobject arg1_cItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "c", "Ljava/lang/Integer;", arg1_cItem_0); - request.arg1.c = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_cItem_0)); - jobject arg1_dItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "d", "[B", arg1_dItem_0); - auto arg1_dItem_0Jni = chip::Platform::New(env, static_cast(arg1_dItem_0)); - cleanupByteArrays.push_back(arg1_dItem_0Jni); - request.arg1.d = arg1_dItem_0Jni->byteSpan(); - jobject arg1_eItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "e", "Ljava/lang/String;", arg1_eItem_0); - auto arg1_eItem_0Jni = chip::Platform::New(env, static_cast(arg1_eItem_0)); - cleanupStrings.push_back(arg1_eItem_0Jni); - request.arg1.e = arg1_eItem_0Jni->charSpan(); - jobject arg1_fItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "f", "Ljava/lang/Integer;", arg1_fItem_0); - request.arg1.f = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(arg1_fItem_0)); - jobject arg1_gItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "g", "Ljava/lang/Float;", arg1_gItem_0); - request.arg1.g = static_cast>( - chip::JniReferences::GetInstance().FloatToPrimitive(arg1_gItem_0)); - jobject arg1_hItem_0; - chip::JniReferences::GetInstance().GetObjectField(arg1, "h", "Ljava/lang/Double;", arg1_hItem_0); - request.arg1.h = static_cast>( - chip::JniReferences::GetInstance().DoubleToPrimitive(arg1_hItem_0)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, testUnknownCommand) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TestCluster::Commands::TestUnknownCommand::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, timedInvokeRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::TestCluster::Commands::TimedInvokeRequest::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeBooleanAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Boolean::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeBooleanAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Boolean::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeBitmap8Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Bitmap8::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeBitmap8Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Bitmap8::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeBitmap16Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Bitmap16::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeBitmap16Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Bitmap16::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeBitmap32Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Bitmap32::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeBitmap32Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Bitmap32::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeBitmap64Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Bitmap64::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeBitmap64Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Bitmap64::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeInt8uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int8u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeInt8uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int8u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeInt16uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int16u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeInt16uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int16u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeInt24uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int24u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeInt24uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int24u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeInt32uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int32u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeInt32uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int32u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeInt40uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int40u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeInt40uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int40u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeInt48uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int48u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeInt48uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int48u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeInt56uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int56u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeInt56uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int56u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeInt64uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int64u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeInt64uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int64u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeInt8sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int8s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeInt8sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int8s::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeInt16sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int16s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeInt16sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int16s::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeInt24sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int24s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeInt24sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int24s::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeInt32sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int32s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeInt32sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int32s::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeInt40sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int40s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeInt40sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int40s::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeInt48sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int48s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeInt48sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int48s::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeInt56sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int56s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeInt56sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int56s::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeInt64sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int64s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeInt64sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int64s::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeEnum8Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Enum8::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeEnum8Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Enum8::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeEnum16Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Enum16::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeEnum16Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Enum16::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeFloatSingleAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::FloatSingle::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = static_cast>(chip::JniReferences::GetInstance().FloatToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeFloatSingleAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::FloatSingle::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPFloatAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeFloatDoubleAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::FloatDouble::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().DoubleToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeFloatDoubleAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::FloatDouble::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPDoubleAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeOctetStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::OctetString::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - auto valueJni = chip::Platform::New(env, static_cast(value)); - cleanupByteArrays.push_back(valueJni); - cppValue = valueJni->byteSpan(); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeOctetStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::OctetString::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPOctetStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeListInt8uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ListInt8u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - { - using ListType_0 = std::remove_reference_t; - using ListMemberType_0 = ListMemberTypeGetter::Type; - jint valueSize; - chip::JniReferences::GetInstance().GetArrayListSize(value, valueSize); - if (valueSize != 0) - { - auto * listHolder_0 = new ListHolder(valueSize); - listFreer.add(listHolder_0); - - for (size_t i_0 = 0; i_0 < static_cast(valueSize); ++i_0) - { - jobject element_0; - chip::JniReferences::GetInstance().GetArrayListItem(value, i_0, element_0); - listHolder_0->mList[i_0] = static_castmList[i_0])>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0)); - } - cppValue = ListType_0(listHolder_0->mList, valueSize); - } - else - { - cppValue = ListType_0(); - } - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeListInt8uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ListInt8u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterListInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeListOctetStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ListOctetString::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - { - using ListType_0 = std::remove_reference_t; - using ListMemberType_0 = ListMemberTypeGetter::Type; - jint valueSize; - chip::JniReferences::GetInstance().GetArrayListSize(value, valueSize); - if (valueSize != 0) - { - auto * listHolder_0 = new ListHolder(valueSize); - listFreer.add(listHolder_0); - - for (size_t i_0 = 0; i_0 < static_cast(valueSize); ++i_0) - { - jobject element_0; - chip::JniReferences::GetInstance().GetArrayListItem(value, i_0, element_0); - auto element_0Jni = chip::Platform::New(env, static_cast(element_0)); - cleanupByteArrays.push_back(element_0Jni); - listHolder_0->mList[i_0] = element_0Jni->byteSpan(); - } - cppValue = ListType_0(listHolder_0->mList, valueSize); - } - else - { - cppValue = ListType_0(); - } - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeListOctetStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ListOctetString::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterListOctetStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeListStructOctetStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ListStructOctetString::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - { - using ListType_0 = std::remove_reference_t; - using ListMemberType_0 = ListMemberTypeGetter::Type; - jint valueSize; - chip::JniReferences::GetInstance().GetArrayListSize(value, valueSize); - if (valueSize != 0) - { - auto * listHolder_0 = new ListHolder(valueSize); - listFreer.add(listHolder_0); - - for (size_t i_0 = 0; i_0 < static_cast(valueSize); ++i_0) - { - jobject element_0; - chip::JniReferences::GetInstance().GetArrayListItem(value, i_0, element_0); - jobject element_0_fabricIndexItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "fabricIndex", "Ljava/lang/Long;", - element_0_fabricIndexItem_1); - listHolder_0->mList[i_0].fabricIndex = - static_castmList[i_0].fabricIndex)>>( - chip::JniReferences::GetInstance().LongToPrimitive(element_0_fabricIndexItem_1)); - jobject element_0_operationalCertItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "operationalCert", "[B", - element_0_operationalCertItem_1); - auto element_0_operationalCertItem_1Jni = - chip::Platform::New(env, static_cast(element_0_operationalCertItem_1)); - cleanupByteArrays.push_back(element_0_operationalCertItem_1Jni); - listHolder_0->mList[i_0].operationalCert = element_0_operationalCertItem_1Jni->byteSpan(); - } - cppValue = ListType_0(listHolder_0->mList, valueSize); - } - else - { - cppValue = ListType_0(); - } - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeListStructOctetStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ListStructOctetString::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPTestClusterListStructOctetStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeLongOctetStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::LongOctetString::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - auto valueJni = chip::Platform::New(env, static_cast(value)); - cleanupByteArrays.push_back(valueJni); - cppValue = valueJni->byteSpan(); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeLongOctetStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::LongOctetString::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPOctetStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeCharStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::CharString::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - auto valueJni = chip::Platform::New(env, static_cast(value)); - cleanupStrings.push_back(valueJni); - cppValue = valueJni->charSpan(); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeCharStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::CharString::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeLongCharStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::LongCharString::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - auto valueJni = chip::Platform::New(env, static_cast(value)); - cleanupStrings.push_back(valueJni); - cppValue = valueJni->charSpan(); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeLongCharStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::LongCharString::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeEpochUsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::EpochUs::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeEpochUsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::EpochUs::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeEpochSAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::EpochS::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = static_cast>(chip::JniReferences::GetInstance().LongToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeEpochSAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::EpochS::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeVendorIdAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::VendorId::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeVendorIdAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::VendorId::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterVendorIdAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeListNullablesAndOptionalsStructAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ListNullablesAndOptionalsStruct::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - { - using ListType_0 = std::remove_reference_t; - using ListMemberType_0 = ListMemberTypeGetter::Type; - jint valueSize; - chip::JniReferences::GetInstance().GetArrayListSize(value, valueSize); - if (valueSize != 0) - { - auto * listHolder_0 = new ListHolder(valueSize); - listFreer.add(listHolder_0); - - for (size_t i_0 = 0; i_0 < static_cast(valueSize); ++i_0) - { - jobject element_0; - chip::JniReferences::GetInstance().GetArrayListItem(value, i_0, element_0); - jobject element_0_nullableIntItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "nullableInt", "Ljava/lang/Integer;", - element_0_nullableIntItem_1); - if (element_0_nullableIntItem_1 == nullptr) - { - listHolder_0->mList[i_0].nullableInt.SetNull(); - } - else - { - auto & nonNullValue_2 = listHolder_0->mList[i_0].nullableInt.SetNonNull(); - nonNullValue_2 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_nullableIntItem_1)); - } - jobject element_0_optionalIntItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "optionalInt", "Ljava/util/Optional;", - element_0_optionalIntItem_1); - if (element_0_optionalIntItem_1 != nullptr) - { - jobject optionalValue_2; - chip::JniReferences::GetInstance().GetOptionalValue(element_0_optionalIntItem_1, optionalValue_2); - auto & definedValue_2 = listHolder_0->mList[i_0].optionalInt.Emplace(); - definedValue_2 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_2)); - } - jobject element_0_nullableOptionalIntItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "nullableOptionalInt", "Ljava/util/Optional;", - element_0_nullableOptionalIntItem_1); - if (element_0_nullableOptionalIntItem_1 != nullptr) - { - jobject optionalValue_2; - chip::JniReferences::GetInstance().GetOptionalValue(element_0_nullableOptionalIntItem_1, optionalValue_2); - auto & definedValue_2 = listHolder_0->mList[i_0].nullableOptionalInt.Emplace(); - if (optionalValue_2 == nullptr) - { - definedValue_2.SetNull(); - } - else - { - auto & nonNullValue_3 = definedValue_2.SetNonNull(); - nonNullValue_3 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_2)); - } - } - jobject element_0_nullableStringItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "nullableString", "Ljava/lang/String;", - element_0_nullableStringItem_1); - if (element_0_nullableStringItem_1 == nullptr) - { - listHolder_0->mList[i_0].nullableString.SetNull(); - } - else - { - auto & nonNullValue_2 = listHolder_0->mList[i_0].nullableString.SetNonNull(); - auto element_0_nullableStringItem_1Jni = - chip::Platform::New(env, static_cast(element_0_nullableStringItem_1)); - cleanupStrings.push_back(element_0_nullableStringItem_1Jni); - nonNullValue_2 = element_0_nullableStringItem_1Jni->charSpan(); - } - jobject element_0_optionalStringItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "optionalString", "Ljava/util/Optional;", - element_0_optionalStringItem_1); - if (element_0_optionalStringItem_1 != nullptr) - { - jobject optionalValue_2; - chip::JniReferences::GetInstance().GetOptionalValue(element_0_optionalStringItem_1, optionalValue_2); - auto & definedValue_2 = listHolder_0->mList[i_0].optionalString.Emplace(); - auto optionalValue_2Jni = chip::Platform::New(env, static_cast(optionalValue_2)); - cleanupStrings.push_back(optionalValue_2Jni); - definedValue_2 = optionalValue_2Jni->charSpan(); - } - jobject element_0_nullableOptionalStringItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "nullableOptionalString", "Ljava/util/Optional;", - element_0_nullableOptionalStringItem_1); - if (element_0_nullableOptionalStringItem_1 != nullptr) - { - jobject optionalValue_2; - chip::JniReferences::GetInstance().GetOptionalValue(element_0_nullableOptionalStringItem_1, optionalValue_2); - auto & definedValue_2 = listHolder_0->mList[i_0].nullableOptionalString.Emplace(); - if (optionalValue_2 == nullptr) - { - definedValue_2.SetNull(); - } - else - { - auto & nonNullValue_3 = definedValue_2.SetNonNull(); - auto optionalValue_2Jni = - chip::Platform::New(env, static_cast(optionalValue_2)); - cleanupStrings.push_back(optionalValue_2Jni); - nonNullValue_3 = optionalValue_2Jni->charSpan(); - } - } - jobject element_0_nullableStructItem_1; - chip::JniReferences::GetInstance().GetObjectField( - element_0, "nullableStruct", "Lchip/devicecontroller/ChipStructs$TestClusterClusterSimpleStruct;", - element_0_nullableStructItem_1); - if (element_0_nullableStructItem_1 == nullptr) - { - listHolder_0->mList[i_0].nullableStruct.SetNull(); - } - else - { - auto & nonNullValue_2 = listHolder_0->mList[i_0].nullableStruct.SetNonNull(); - jobject element_0_nullableStructItem_1_aItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_0_nullableStructItem_1, "a", "Ljava/lang/Integer;", - element_0_nullableStructItem_1_aItem_3); - nonNullValue_2.a = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_nullableStructItem_1_aItem_3)); - jobject element_0_nullableStructItem_1_bItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_0_nullableStructItem_1, "b", "Ljava/lang/Boolean;", - element_0_nullableStructItem_1_bItem_3); - nonNullValue_2.b = static_cast>( - chip::JniReferences::GetInstance().BooleanToPrimitive(element_0_nullableStructItem_1_bItem_3)); - jobject element_0_nullableStructItem_1_cItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_0_nullableStructItem_1, "c", "Ljava/lang/Integer;", - element_0_nullableStructItem_1_cItem_3); - nonNullValue_2.c = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_nullableStructItem_1_cItem_3)); - jobject element_0_nullableStructItem_1_dItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_0_nullableStructItem_1, "d", "[B", - element_0_nullableStructItem_1_dItem_3); - auto element_0_nullableStructItem_1_dItem_3Jni = chip::Platform::New( - env, static_cast(element_0_nullableStructItem_1_dItem_3)); - cleanupByteArrays.push_back(element_0_nullableStructItem_1_dItem_3Jni); - nonNullValue_2.d = element_0_nullableStructItem_1_dItem_3Jni->byteSpan(); - jobject element_0_nullableStructItem_1_eItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_0_nullableStructItem_1, "e", "Ljava/lang/String;", - element_0_nullableStructItem_1_eItem_3); - auto element_0_nullableStructItem_1_eItem_3Jni = - chip::Platform::New(env, static_cast(element_0_nullableStructItem_1_eItem_3)); - cleanupStrings.push_back(element_0_nullableStructItem_1_eItem_3Jni); - nonNullValue_2.e = element_0_nullableStructItem_1_eItem_3Jni->charSpan(); - jobject element_0_nullableStructItem_1_fItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_0_nullableStructItem_1, "f", "Ljava/lang/Integer;", - element_0_nullableStructItem_1_fItem_3); - nonNullValue_2.f = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_nullableStructItem_1_fItem_3)); - jobject element_0_nullableStructItem_1_gItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_0_nullableStructItem_1, "g", "Ljava/lang/Float;", - element_0_nullableStructItem_1_gItem_3); - nonNullValue_2.g = static_cast>( - chip::JniReferences::GetInstance().FloatToPrimitive(element_0_nullableStructItem_1_gItem_3)); - jobject element_0_nullableStructItem_1_hItem_3; - chip::JniReferences::GetInstance().GetObjectField(element_0_nullableStructItem_1, "h", "Ljava/lang/Double;", - element_0_nullableStructItem_1_hItem_3); - nonNullValue_2.h = static_cast>( - chip::JniReferences::GetInstance().DoubleToPrimitive(element_0_nullableStructItem_1_hItem_3)); - } - jobject element_0_optionalStructItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "optionalStruct", "Ljava/util/Optional;", - element_0_optionalStructItem_1); - if (element_0_optionalStructItem_1 != nullptr) - { - jobject optionalValue_2; - chip::JniReferences::GetInstance().GetOptionalValue(element_0_optionalStructItem_1, optionalValue_2); - auto & definedValue_2 = listHolder_0->mList[i_0].optionalStruct.Emplace(); - jobject optionalValue_2_aItem_3; - chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "a", "Ljava/lang/Integer;", - optionalValue_2_aItem_3); - definedValue_2.a = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_2_aItem_3)); - jobject optionalValue_2_bItem_3; - chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "b", "Ljava/lang/Boolean;", - optionalValue_2_bItem_3); - definedValue_2.b = static_cast>( - chip::JniReferences::GetInstance().BooleanToPrimitive(optionalValue_2_bItem_3)); - jobject optionalValue_2_cItem_3; - chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "c", "Ljava/lang/Integer;", - optionalValue_2_cItem_3); - definedValue_2.c = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_2_cItem_3)); - jobject optionalValue_2_dItem_3; - chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "d", "[B", optionalValue_2_dItem_3); - auto optionalValue_2_dItem_3Jni = - chip::Platform::New(env, static_cast(optionalValue_2_dItem_3)); - cleanupByteArrays.push_back(optionalValue_2_dItem_3Jni); - definedValue_2.d = optionalValue_2_dItem_3Jni->byteSpan(); - jobject optionalValue_2_eItem_3; - chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "e", "Ljava/lang/String;", - optionalValue_2_eItem_3); - auto optionalValue_2_eItem_3Jni = - chip::Platform::New(env, static_cast(optionalValue_2_eItem_3)); - cleanupStrings.push_back(optionalValue_2_eItem_3Jni); - definedValue_2.e = optionalValue_2_eItem_3Jni->charSpan(); - jobject optionalValue_2_fItem_3; - chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "f", "Ljava/lang/Integer;", - optionalValue_2_fItem_3); - definedValue_2.f = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_2_fItem_3)); - jobject optionalValue_2_gItem_3; - chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "g", "Ljava/lang/Float;", - optionalValue_2_gItem_3); - definedValue_2.g = static_cast>( - chip::JniReferences::GetInstance().FloatToPrimitive(optionalValue_2_gItem_3)); - jobject optionalValue_2_hItem_3; - chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "h", "Ljava/lang/Double;", - optionalValue_2_hItem_3); - definedValue_2.h = static_cast>( - chip::JniReferences::GetInstance().DoubleToPrimitive(optionalValue_2_hItem_3)); - } - jobject element_0_nullableOptionalStructItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "nullableOptionalStruct", "Ljava/util/Optional;", - element_0_nullableOptionalStructItem_1); - if (element_0_nullableOptionalStructItem_1 != nullptr) - { - jobject optionalValue_2; - chip::JniReferences::GetInstance().GetOptionalValue(element_0_nullableOptionalStructItem_1, optionalValue_2); - auto & definedValue_2 = listHolder_0->mList[i_0].nullableOptionalStruct.Emplace(); - if (optionalValue_2 == nullptr) - { - definedValue_2.SetNull(); - } - else - { - auto & nonNullValue_3 = definedValue_2.SetNonNull(); - jobject optionalValue_2_aItem_4; - chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "a", "Ljava/lang/Integer;", - optionalValue_2_aItem_4); - nonNullValue_3.a = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_2_aItem_4)); - jobject optionalValue_2_bItem_4; - chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "b", "Ljava/lang/Boolean;", - optionalValue_2_bItem_4); - nonNullValue_3.b = static_cast>( - chip::JniReferences::GetInstance().BooleanToPrimitive(optionalValue_2_bItem_4)); - jobject optionalValue_2_cItem_4; - chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "c", "Ljava/lang/Integer;", - optionalValue_2_cItem_4); - nonNullValue_3.c = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_2_cItem_4)); - jobject optionalValue_2_dItem_4; - chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "d", "[B", optionalValue_2_dItem_4); - auto optionalValue_2_dItem_4Jni = - chip::Platform::New(env, static_cast(optionalValue_2_dItem_4)); - cleanupByteArrays.push_back(optionalValue_2_dItem_4Jni); - nonNullValue_3.d = optionalValue_2_dItem_4Jni->byteSpan(); - jobject optionalValue_2_eItem_4; - chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "e", "Ljava/lang/String;", - optionalValue_2_eItem_4); - auto optionalValue_2_eItem_4Jni = - chip::Platform::New(env, static_cast(optionalValue_2_eItem_4)); - cleanupStrings.push_back(optionalValue_2_eItem_4Jni); - nonNullValue_3.e = optionalValue_2_eItem_4Jni->charSpan(); - jobject optionalValue_2_fItem_4; - chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "f", "Ljava/lang/Integer;", - optionalValue_2_fItem_4); - nonNullValue_3.f = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_2_fItem_4)); - jobject optionalValue_2_gItem_4; - chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "g", "Ljava/lang/Float;", - optionalValue_2_gItem_4); - nonNullValue_3.g = static_cast>( - chip::JniReferences::GetInstance().FloatToPrimitive(optionalValue_2_gItem_4)); - jobject optionalValue_2_hItem_4; - chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "h", "Ljava/lang/Double;", - optionalValue_2_hItem_4); - nonNullValue_3.h = static_cast>( - chip::JniReferences::GetInstance().DoubleToPrimitive(optionalValue_2_hItem_4)); - } - } - jobject element_0_nullableListItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "nullableList", "Ljava/util/ArrayList;", - element_0_nullableListItem_1); - if (element_0_nullableListItem_1 == nullptr) - { - listHolder_0->mList[i_0].nullableList.SetNull(); - } - else - { - auto & nonNullValue_2 = listHolder_0->mList[i_0].nullableList.SetNonNull(); - { - using ListType_3 = std::remove_reference_t; - using ListMemberType_3 = ListMemberTypeGetter::Type; - jint element_0_nullableListItem_1Size; - chip::JniReferences::GetInstance().GetArrayListSize(element_0_nullableListItem_1, - element_0_nullableListItem_1Size); - if (element_0_nullableListItem_1Size != 0) - { - auto * listHolder_3 = new ListHolder(element_0_nullableListItem_1Size); - listFreer.add(listHolder_3); - - for (size_t i_3 = 0; i_3 < static_cast(element_0_nullableListItem_1Size); ++i_3) - { - jobject element_3; - chip::JniReferences::GetInstance().GetArrayListItem(element_0_nullableListItem_1, i_3, element_3); - listHolder_3->mList[i_3] = static_castmList[i_3])>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_3)); - } - nonNullValue_2 = ListType_3(listHolder_3->mList, element_0_nullableListItem_1Size); - } - else - { - nonNullValue_2 = ListType_3(); - } - } - } - jobject element_0_optionalListItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "optionalList", "Ljava/util/Optional;", - element_0_optionalListItem_1); - if (element_0_optionalListItem_1 != nullptr) - { - jobject optionalValue_2; - chip::JniReferences::GetInstance().GetOptionalValue(element_0_optionalListItem_1, optionalValue_2); - auto & definedValue_2 = listHolder_0->mList[i_0].optionalList.Emplace(); - { - using ListType_3 = std::remove_reference_t; - using ListMemberType_3 = ListMemberTypeGetter::Type; - jint optionalValue_2Size; - chip::JniReferences::GetInstance().GetArrayListSize(optionalValue_2, optionalValue_2Size); - if (optionalValue_2Size != 0) - { - auto * listHolder_3 = new ListHolder(optionalValue_2Size); - listFreer.add(listHolder_3); - - for (size_t i_3 = 0; i_3 < static_cast(optionalValue_2Size); ++i_3) - { - jobject element_3; - chip::JniReferences::GetInstance().GetArrayListItem(optionalValue_2, i_3, element_3); - listHolder_3->mList[i_3] = static_castmList[i_3])>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_3)); - } - definedValue_2 = ListType_3(listHolder_3->mList, optionalValue_2Size); - } - else - { - definedValue_2 = ListType_3(); - } - } - } - jobject element_0_nullableOptionalListItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "nullableOptionalList", "Ljava/util/Optional;", - element_0_nullableOptionalListItem_1); - if (element_0_nullableOptionalListItem_1 != nullptr) - { - jobject optionalValue_2; - chip::JniReferences::GetInstance().GetOptionalValue(element_0_nullableOptionalListItem_1, optionalValue_2); - auto & definedValue_2 = listHolder_0->mList[i_0].nullableOptionalList.Emplace(); - if (optionalValue_2 == nullptr) - { - definedValue_2.SetNull(); - } - else - { - auto & nonNullValue_3 = definedValue_2.SetNonNull(); - { - using ListType_4 = std::remove_reference_t; - using ListMemberType_4 = ListMemberTypeGetter::Type; - jint optionalValue_2Size; - chip::JniReferences::GetInstance().GetArrayListSize(optionalValue_2, optionalValue_2Size); - if (optionalValue_2Size != 0) - { - auto * listHolder_4 = new ListHolder(optionalValue_2Size); - listFreer.add(listHolder_4); - - for (size_t i_4 = 0; i_4 < static_cast(optionalValue_2Size); ++i_4) - { - jobject element_4; - chip::JniReferences::GetInstance().GetArrayListItem(optionalValue_2, i_4, element_4); - listHolder_4->mList[i_4] = - static_castmList[i_4])>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_4)); - } - nonNullValue_3 = ListType_4(listHolder_4->mList, optionalValue_2Size); - } - else - { - nonNullValue_3 = ListType_4(); - } - } - } - } - } - cppValue = ListType_0(listHolder_0->mList, valueSize); - } - else - { - cppValue = ListType_0(); - } - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeListNullablesAndOptionalsStructAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ListNullablesAndOptionalsStruct::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPTestClusterListNullablesAndOptionalsStructAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeEnumAttrAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::EnumAttr::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeEnumAttrAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::EnumAttr::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeRangeRestrictedInt8uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::RangeRestrictedInt8u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeRangeRestrictedInt8uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::RangeRestrictedInt8u::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeRangeRestrictedInt8sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::RangeRestrictedInt8s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeRangeRestrictedInt8sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::RangeRestrictedInt8s::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeRangeRestrictedInt16uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::RangeRestrictedInt16u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeRangeRestrictedInt16uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::RangeRestrictedInt16u::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeRangeRestrictedInt16sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::RangeRestrictedInt16s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeRangeRestrictedInt16sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::RangeRestrictedInt16s::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeListLongOctetStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ListLongOctetString::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterListLongOctetStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeTimedWriteBooleanAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::TimedWriteBoolean::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeTimedWriteBooleanAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::TimedWriteBoolean::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeUnsupportedAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Unsupported::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeUnsupportedAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Unsupported::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableBooleanAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBoolean::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().BooleanToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableBooleanAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBoolean::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableBooleanAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableBitmap8Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBitmap8::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableBitmap8Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBitmap8::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableBitmap8AttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableBitmap16Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBitmap16::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableBitmap16Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBitmap16::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableBitmap16AttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableBitmap32Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBitmap32::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableBitmap32Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBitmap32::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableBitmap32AttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableBitmap64Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBitmap64::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableBitmap64Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBitmap64::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableBitmap64AttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableInt8uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt8u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableInt8uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt8u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableInt16uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt16u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableInt16uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt16u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableInt24uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt24u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableInt24uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt24u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableInt24uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableInt32uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt32u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableInt32uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt32u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableInt40uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt40u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableInt40uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt40u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableInt40uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableInt48uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt48u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableInt48uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt48u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableInt48uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableInt56uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt56u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableInt56uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt56u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableInt56uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableInt64uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt64u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableInt64uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt64u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableInt8sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt8s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableInt8sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt8s::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableInt8sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableInt16sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt16s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableInt16sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt16s::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableInt24sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt24s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableInt24sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt24s::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableInt24sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableInt32sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt32s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableInt32sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt32s::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableInt32sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableInt40sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt40s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableInt40sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt40s::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableInt40sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableInt48sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt48s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableInt48sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt48s::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableInt48sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableInt56sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt56s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableInt56sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt56s::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableInt56sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableInt64sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt64s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().LongToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableInt64sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt64s::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableInt64sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableEnum8Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableEnum8::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableEnum8Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableEnum8::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableEnum8AttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableEnum16Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableEnum16::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableEnum16Attribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableEnum16::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableEnum16AttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableFloatSingleAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableFloatSingle::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().FloatToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableFloatSingleAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableFloatSingle::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableFloatSingleAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableFloatDoubleAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableFloatDouble::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().DoubleToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableFloatDoubleAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableFloatDouble::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableFloatDoubleAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableOctetStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableOctetString::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - auto valueJni = chip::Platform::New(env, static_cast(value)); - cleanupByteArrays.push_back(valueJni); - nonNullValue_0 = valueJni->byteSpan(); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableOctetStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableOctetString::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableOctetStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableCharStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableCharString::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - auto valueJni = chip::Platform::New(env, static_cast(value)); - cleanupStrings.push_back(valueJni); - nonNullValue_0 = valueJni->charSpan(); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableCharStringAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableCharString::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableCharStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableEnumAttrAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableEnumAttr::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableEnumAttrAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableEnumAttr::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterNullableEnumAttrAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableRangeRestrictedInt8uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableRangeRestrictedInt8u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableRangeRestrictedInt8uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableRangeRestrictedInt8u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPTestClusterNullableRangeRestrictedInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableRangeRestrictedInt8sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableRangeRestrictedInt8s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableRangeRestrictedInt8sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableRangeRestrictedInt8s::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPTestClusterNullableRangeRestrictedInt8sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableRangeRestrictedInt16uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableRangeRestrictedInt16u::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableRangeRestrictedInt16uAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableRangeRestrictedInt16u::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPTestClusterNullableRangeRestrictedInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, TestClusterCluster, writeNullableRangeRestrictedInt16sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableRangeRestrictedInt16s::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - if (value == nullptr) - { - cppValue.SetNull(); - } - else - { - auto & nonNullValue_0 = cppValue.SetNonNull(); - nonNullValue_0 = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeNullableRangeRestrictedInt16sAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableRangeRestrictedInt16s::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPTestClusterNullableRangeRestrictedInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPTestClusterAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, TestClusterCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, ThermostatCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - ThermostatCluster * cppCluster = new ThermostatCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, ThermostatCluster, clearWeeklySchedule) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::Thermostat::Commands::ClearWeeklySchedule::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, getRelayStatusLog) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::Thermostat::Commands::GetRelayStatusLog::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, getWeeklySchedule) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject daysToReturn, jobject modeToReturn, - jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::Thermostat::Commands::GetWeeklySchedule::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.daysToReturn = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(daysToReturn)); - request.modeToReturn = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(modeToReturn)); - - std::unique_ptr - onSuccess(Platform::New(callback), - Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, setWeeklySchedule) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject numberOfTransitionsForSequence, - jobject dayOfWeekForSequence, jobject modeForSequence, jobject payload, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::Thermostat::Commands::SetWeeklySchedule::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.numberOfTransitionsForSequence = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(numberOfTransitionsForSequence)); - request.dayOfWeekForSequence = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(dayOfWeekForSequence)); - request.modeForSequence = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(modeForSequence)); - { - using ListType_0 = std::remove_reference_t; - using ListMemberType_0 = ListMemberTypeGetter::Type; - jint payloadSize; - chip::JniReferences::GetInstance().GetArrayListSize(payload, payloadSize); - if (payloadSize != 0) - { - auto * listHolder_0 = new ListHolder(payloadSize); - listFreer.add(listHolder_0); - - for (size_t i_0 = 0; i_0 < static_cast(payloadSize); ++i_0) - { - jobject element_0; - chip::JniReferences::GetInstance().GetArrayListItem(payload, i_0, element_0); - listHolder_0->mList[i_0] = static_castmList[i_0])>>( - chip::JniReferences::GetInstance().IntegerToPrimitive(element_0)); - } - request.payload = ListType_0(listHolder_0->mList, payloadSize); - } - else - { - request.payload = ListType_0(); - } - } - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, setpointRaiseLower) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject mode, jobject amount, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::Thermostat::Commands::SetpointRaiseLower::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - request.mode = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(mode)); - request.amount = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(amount)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeLocalTemperatureAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::LocalTemperature::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeAbsMinHeatSetpointLimitAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::AbsMinHeatSetpointLimit::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeAbsMaxHeatSetpointLimitAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::AbsMaxHeatSetpointLimit::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeAbsMinCoolSetpointLimitAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::AbsMinCoolSetpointLimit::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeAbsMaxCoolSetpointLimitAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::AbsMaxCoolSetpointLimit::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, ThermostatCluster, writeOccupiedCoolingSetpointAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::OccupiedCoolingSetpoint::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeOccupiedCoolingSetpointAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::OccupiedCoolingSetpoint::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, ThermostatCluster, writeOccupiedHeatingSetpointAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::OccupiedHeatingSetpoint::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeOccupiedHeatingSetpointAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::OccupiedHeatingSetpoint::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, ThermostatCluster, writeMinHeatSetpointLimitAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MinHeatSetpointLimit::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeMinHeatSetpointLimitAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MinHeatSetpointLimit::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, ThermostatCluster, writeMaxHeatSetpointLimitAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MaxHeatSetpointLimit::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeMaxHeatSetpointLimitAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MaxHeatSetpointLimit::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, ThermostatCluster, writeMinCoolSetpointLimitAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MinCoolSetpointLimit::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeMinCoolSetpointLimitAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MinCoolSetpointLimit::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, ThermostatCluster, writeMaxCoolSetpointLimitAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MaxCoolSetpointLimit::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeMaxCoolSetpointLimitAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MaxCoolSetpointLimit::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, ThermostatCluster, writeMinSetpointDeadBandAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MinSetpointDeadBand::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeMinSetpointDeadBandAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MinSetpointDeadBand::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, ThermostatCluster, writeControlSequenceOfOperationAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::ControlSequenceOfOperation::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeControlSequenceOfOperationAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::ControlSequenceOfOperation::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, ThermostatCluster, writeSystemModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::SystemMode::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeSystemModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::SystemMode::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeStartOfWeekAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::StartOfWeek::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeNumberOfWeeklyTransitionsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::NumberOfWeeklyTransitions::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeNumberOfDailyTransitionsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::NumberOfDailyTransitions::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPThermostatAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeFeatureMapAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::FeatureMap::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::Thermostat::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, ThermostatUserInterfaceConfigurationCluster, initWithDevice) -(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - ThermostatUserInterfaceConfigurationCluster * cppCluster = new ThermostatUserInterfaceConfigurationCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, ThermostatUserInterfaceConfigurationCluster, writeTemperatureDisplayModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::ThermostatUserInterfaceConfiguration::Attributes::TemperatureDisplayMode::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatUserInterfaceConfigurationCluster * cppCluster = - reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatUserInterfaceConfigurationCluster, subscribeTemperatureDisplayModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatUserInterfaceConfigurationCluster * cppCluster = - reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThermostatUserInterfaceConfiguration::Attributes::TemperatureDisplayMode::TypeInfo; - auto successFn = - chip::Callback::Callback:: - FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, ThermostatUserInterfaceConfigurationCluster, writeKeypadLockoutAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::ThermostatUserInterfaceConfiguration::Attributes::KeypadLockout::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatUserInterfaceConfigurationCluster * cppCluster = - reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatUserInterfaceConfigurationCluster, subscribeKeypadLockoutAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatUserInterfaceConfigurationCluster * cppCluster = - reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThermostatUserInterfaceConfiguration::Attributes::KeypadLockout::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} - -JNI_METHOD(void, ThermostatUserInterfaceConfigurationCluster, writeScheduleProgrammingVisibilityAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::ThermostatUserInterfaceConfiguration::Attributes::ScheduleProgrammingVisibility::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatUserInterfaceConfigurationCluster * cppCluster = - reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedWriteTimeoutMs == nullptr) - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); - } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatUserInterfaceConfigurationCluster, subscribeScheduleProgrammingVisibilityAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatUserInterfaceConfigurationCluster * cppCluster = - reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThermostatUserInterfaceConfiguration::Attributes::ScheduleProgrammingVisibility::TypeInfo; - auto successFn = chip::Callback:: - Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatUserInterfaceConfigurationCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatUserInterfaceConfigurationCluster * cppCluster = - reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThermostatUserInterfaceConfiguration::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPThermostatUserInterfaceConfigurationAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThermostatUserInterfaceConfigurationCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThermostatUserInterfaceConfigurationCluster * cppCluster = - reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThermostatUserInterfaceConfiguration::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback< - CHIPThermostatUserInterfaceConfigurationClusterClusterRevisionAttributeCallbackType>::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(jlong, ThreadNetworkDiagnosticsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - ThreadNetworkDiagnosticsCluster * cppCluster = new ThreadNetworkDiagnosticsCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} - -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, resetCounts) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) -{ - chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster; - - ListFreer listFreer; - chip::app::Clusters::ThreadNetworkDiagnostics::Commands::ResetCounts::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - if (timedInvokeTimeoutMs == nullptr) - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); - } - else - { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); - } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeChannelAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::Channel::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRoutingRoleAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RoutingRole::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeNetworkNameAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::NetworkName::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPOctetStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribePanIdAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::PanId::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeExtendedPanIdAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::ExtendedPanId::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeMeshLocalPrefixAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::MeshLocalPrefix::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPOctetStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeOverrunCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::OverrunCount::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeNeighborTableListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::NeighborTableList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPThreadNetworkDiagnosticsNeighborTableListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRouteTableListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RouteTableList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPThreadNetworkDiagnosticsRouteTableListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribePartitionIdAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::PartitionId::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeWeightingAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::Weighting::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeDataVersionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::DataVersion::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeStableDataVersionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::StableDataVersion::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeLeaderRouterIdAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::LeaderRouterId::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeDetachedRoleCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::DetachedRoleCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeChildRoleCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::ChildRoleCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRouterRoleCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RouterRoleCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeLeaderRoleCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::LeaderRoleCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeAttachAttemptCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::AttachAttemptCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribePartitionIdChangeCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::PartitionIdChangeCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeBetterPartitionAttachAttemptCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::BetterPartitionAttachAttemptCount::TypeInfo; - auto successFn = - chip::Callback::Callback:: - FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeParentChangeCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::ParentChangeCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxTotalCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxTotalCount::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxUnicastCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxUnicastCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxBroadcastCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxBroadcastCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxAckRequestedCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxAckRequestedCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxAckedCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxAckedCount::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxNoAckRequestedCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxNoAckRequestedCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxDataCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxDataCount::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxDataPollCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxDataPollCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxBeaconCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxBeaconCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxBeaconRequestCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxBeaconRequestCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxOtherCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxOtherCount::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxRetryCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxRetryCount::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxDirectMaxRetryExpiryCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxDirectMaxRetryExpiryCount::TypeInfo; - auto successFn = chip::Callback::Callback< - CHIPThreadNetworkDiagnosticsClusterTxDirectMaxRetryExpiryCountAttributeCallbackType>::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxIndirectMaxRetryExpiryCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxIndirectMaxRetryExpiryCount::TypeInfo; - auto successFn = chip::Callback::Callback< - CHIPThreadNetworkDiagnosticsClusterTxIndirectMaxRetryExpiryCountAttributeCallbackType>::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxErrCcaCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxErrCcaCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxErrAbortCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxErrAbortCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxErrBusyChannelCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxErrBusyChannelCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxTotalCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxTotalCount::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxUnicastCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxUnicastCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxBroadcastCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + for (size_t i_0 = 0; i_0 < static_cast(valueSize); ++i_0) + { + jobject element_0; + chip::JniReferences::GetInstance().GetArrayListItem(value, i_0, element_0); + jobject element_0_nullableIntItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "nullableInt", "Ljava/lang/Integer;", + element_0_nullableIntItem_1); + if (element_0_nullableIntItem_1 == nullptr) + { + listHolder_0->mList[i_0].nullableInt.SetNull(); + } + else + { + auto & nonNullValue_2 = listHolder_0->mList[i_0].nullableInt.SetNonNull(); + nonNullValue_2 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_nullableIntItem_1)); + } + jobject element_0_optionalIntItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "optionalInt", "Ljava/util/Optional;", + element_0_optionalIntItem_1); + if (element_0_optionalIntItem_1 != nullptr) + { + jobject optionalValue_2; + chip::JniReferences::GetInstance().GetOptionalValue(element_0_optionalIntItem_1, optionalValue_2); + auto & definedValue_2 = listHolder_0->mList[i_0].optionalInt.Emplace(); + definedValue_2 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_2)); + } + jobject element_0_nullableOptionalIntItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "nullableOptionalInt", "Ljava/util/Optional;", + element_0_nullableOptionalIntItem_1); + if (element_0_nullableOptionalIntItem_1 != nullptr) + { + jobject optionalValue_2; + chip::JniReferences::GetInstance().GetOptionalValue(element_0_nullableOptionalIntItem_1, optionalValue_2); + auto & definedValue_2 = listHolder_0->mList[i_0].nullableOptionalInt.Emplace(); + if (optionalValue_2 == nullptr) + { + definedValue_2.SetNull(); + } + else + { + auto & nonNullValue_3 = definedValue_2.SetNonNull(); + nonNullValue_3 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_2)); + } + } + jobject element_0_nullableStringItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "nullableString", "Ljava/lang/String;", + element_0_nullableStringItem_1); + if (element_0_nullableStringItem_1 == nullptr) + { + listHolder_0->mList[i_0].nullableString.SetNull(); + } + else + { + auto & nonNullValue_2 = listHolder_0->mList[i_0].nullableString.SetNonNull(); + auto element_0_nullableStringItem_1Jni = + chip::Platform::New(env, static_cast(element_0_nullableStringItem_1)); + cleanupStrings.push_back(element_0_nullableStringItem_1Jni); + nonNullValue_2 = element_0_nullableStringItem_1Jni->charSpan(); + } + jobject element_0_optionalStringItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "optionalString", "Ljava/util/Optional;", + element_0_optionalStringItem_1); + if (element_0_optionalStringItem_1 != nullptr) + { + jobject optionalValue_2; + chip::JniReferences::GetInstance().GetOptionalValue(element_0_optionalStringItem_1, optionalValue_2); + auto & definedValue_2 = listHolder_0->mList[i_0].optionalString.Emplace(); + auto optionalValue_2Jni = chip::Platform::New(env, static_cast(optionalValue_2)); + cleanupStrings.push_back(optionalValue_2Jni); + definedValue_2 = optionalValue_2Jni->charSpan(); + } + jobject element_0_nullableOptionalStringItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "nullableOptionalString", "Ljava/util/Optional;", + element_0_nullableOptionalStringItem_1); + if (element_0_nullableOptionalStringItem_1 != nullptr) + { + jobject optionalValue_2; + chip::JniReferences::GetInstance().GetOptionalValue(element_0_nullableOptionalStringItem_1, optionalValue_2); + auto & definedValue_2 = listHolder_0->mList[i_0].nullableOptionalString.Emplace(); + if (optionalValue_2 == nullptr) + { + definedValue_2.SetNull(); + } + else + { + auto & nonNullValue_3 = definedValue_2.SetNonNull(); + auto optionalValue_2Jni = + chip::Platform::New(env, static_cast(optionalValue_2)); + cleanupStrings.push_back(optionalValue_2Jni); + nonNullValue_3 = optionalValue_2Jni->charSpan(); + } + } + jobject element_0_nullableStructItem_1; + chip::JniReferences::GetInstance().GetObjectField( + element_0, "nullableStruct", "Lchip/devicecontroller/ChipStructs$TestClusterClusterSimpleStruct;", + element_0_nullableStructItem_1); + if (element_0_nullableStructItem_1 == nullptr) + { + listHolder_0->mList[i_0].nullableStruct.SetNull(); + } + else + { + auto & nonNullValue_2 = listHolder_0->mList[i_0].nullableStruct.SetNonNull(); + jobject element_0_nullableStructItem_1_aItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_0_nullableStructItem_1, "a", "Ljava/lang/Integer;", + element_0_nullableStructItem_1_aItem_3); + nonNullValue_2.a = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_nullableStructItem_1_aItem_3)); + jobject element_0_nullableStructItem_1_bItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_0_nullableStructItem_1, "b", "Ljava/lang/Boolean;", + element_0_nullableStructItem_1_bItem_3); + nonNullValue_2.b = static_cast>( + chip::JniReferences::GetInstance().BooleanToPrimitive(element_0_nullableStructItem_1_bItem_3)); + jobject element_0_nullableStructItem_1_cItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_0_nullableStructItem_1, "c", "Ljava/lang/Integer;", + element_0_nullableStructItem_1_cItem_3); + nonNullValue_2.c = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_nullableStructItem_1_cItem_3)); + jobject element_0_nullableStructItem_1_dItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_0_nullableStructItem_1, "d", "[B", + element_0_nullableStructItem_1_dItem_3); + auto element_0_nullableStructItem_1_dItem_3Jni = chip::Platform::New( + env, static_cast(element_0_nullableStructItem_1_dItem_3)); + cleanupByteArrays.push_back(element_0_nullableStructItem_1_dItem_3Jni); + nonNullValue_2.d = element_0_nullableStructItem_1_dItem_3Jni->byteSpan(); + jobject element_0_nullableStructItem_1_eItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_0_nullableStructItem_1, "e", "Ljava/lang/String;", + element_0_nullableStructItem_1_eItem_3); + auto element_0_nullableStructItem_1_eItem_3Jni = + chip::Platform::New(env, static_cast(element_0_nullableStructItem_1_eItem_3)); + cleanupStrings.push_back(element_0_nullableStructItem_1_eItem_3Jni); + nonNullValue_2.e = element_0_nullableStructItem_1_eItem_3Jni->charSpan(); + jobject element_0_nullableStructItem_1_fItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_0_nullableStructItem_1, "f", "Ljava/lang/Integer;", + element_0_nullableStructItem_1_fItem_3); + nonNullValue_2.f = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0_nullableStructItem_1_fItem_3)); + jobject element_0_nullableStructItem_1_gItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_0_nullableStructItem_1, "g", "Ljava/lang/Float;", + element_0_nullableStructItem_1_gItem_3); + nonNullValue_2.g = static_cast>( + chip::JniReferences::GetInstance().FloatToPrimitive(element_0_nullableStructItem_1_gItem_3)); + jobject element_0_nullableStructItem_1_hItem_3; + chip::JniReferences::GetInstance().GetObjectField(element_0_nullableStructItem_1, "h", "Ljava/lang/Double;", + element_0_nullableStructItem_1_hItem_3); + nonNullValue_2.h = static_cast>( + chip::JniReferences::GetInstance().DoubleToPrimitive(element_0_nullableStructItem_1_hItem_3)); + } + jobject element_0_optionalStructItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "optionalStruct", "Ljava/util/Optional;", + element_0_optionalStructItem_1); + if (element_0_optionalStructItem_1 != nullptr) + { + jobject optionalValue_2; + chip::JniReferences::GetInstance().GetOptionalValue(element_0_optionalStructItem_1, optionalValue_2); + auto & definedValue_2 = listHolder_0->mList[i_0].optionalStruct.Emplace(); + jobject optionalValue_2_aItem_3; + chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "a", "Ljava/lang/Integer;", + optionalValue_2_aItem_3); + definedValue_2.a = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_2_aItem_3)); + jobject optionalValue_2_bItem_3; + chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "b", "Ljava/lang/Boolean;", + optionalValue_2_bItem_3); + definedValue_2.b = static_cast>( + chip::JniReferences::GetInstance().BooleanToPrimitive(optionalValue_2_bItem_3)); + jobject optionalValue_2_cItem_3; + chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "c", "Ljava/lang/Integer;", + optionalValue_2_cItem_3); + definedValue_2.c = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_2_cItem_3)); + jobject optionalValue_2_dItem_3; + chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "d", "[B", optionalValue_2_dItem_3); + auto optionalValue_2_dItem_3Jni = + chip::Platform::New(env, static_cast(optionalValue_2_dItem_3)); + cleanupByteArrays.push_back(optionalValue_2_dItem_3Jni); + definedValue_2.d = optionalValue_2_dItem_3Jni->byteSpan(); + jobject optionalValue_2_eItem_3; + chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "e", "Ljava/lang/String;", + optionalValue_2_eItem_3); + auto optionalValue_2_eItem_3Jni = + chip::Platform::New(env, static_cast(optionalValue_2_eItem_3)); + cleanupStrings.push_back(optionalValue_2_eItem_3Jni); + definedValue_2.e = optionalValue_2_eItem_3Jni->charSpan(); + jobject optionalValue_2_fItem_3; + chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "f", "Ljava/lang/Integer;", + optionalValue_2_fItem_3); + definedValue_2.f = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_2_fItem_3)); + jobject optionalValue_2_gItem_3; + chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "g", "Ljava/lang/Float;", + optionalValue_2_gItem_3); + definedValue_2.g = static_cast>( + chip::JniReferences::GetInstance().FloatToPrimitive(optionalValue_2_gItem_3)); + jobject optionalValue_2_hItem_3; + chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "h", "Ljava/lang/Double;", + optionalValue_2_hItem_3); + definedValue_2.h = static_cast>( + chip::JniReferences::GetInstance().DoubleToPrimitive(optionalValue_2_hItem_3)); + } + jobject element_0_nullableOptionalStructItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "nullableOptionalStruct", "Ljava/util/Optional;", + element_0_nullableOptionalStructItem_1); + if (element_0_nullableOptionalStructItem_1 != nullptr) + { + jobject optionalValue_2; + chip::JniReferences::GetInstance().GetOptionalValue(element_0_nullableOptionalStructItem_1, optionalValue_2); + auto & definedValue_2 = listHolder_0->mList[i_0].nullableOptionalStruct.Emplace(); + if (optionalValue_2 == nullptr) + { + definedValue_2.SetNull(); + } + else + { + auto & nonNullValue_3 = definedValue_2.SetNonNull(); + jobject optionalValue_2_aItem_4; + chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "a", "Ljava/lang/Integer;", + optionalValue_2_aItem_4); + nonNullValue_3.a = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_2_aItem_4)); + jobject optionalValue_2_bItem_4; + chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "b", "Ljava/lang/Boolean;", + optionalValue_2_bItem_4); + nonNullValue_3.b = static_cast>( + chip::JniReferences::GetInstance().BooleanToPrimitive(optionalValue_2_bItem_4)); + jobject optionalValue_2_cItem_4; + chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "c", "Ljava/lang/Integer;", + optionalValue_2_cItem_4); + nonNullValue_3.c = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_2_cItem_4)); + jobject optionalValue_2_dItem_4; + chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "d", "[B", optionalValue_2_dItem_4); + auto optionalValue_2_dItem_4Jni = + chip::Platform::New(env, static_cast(optionalValue_2_dItem_4)); + cleanupByteArrays.push_back(optionalValue_2_dItem_4Jni); + nonNullValue_3.d = optionalValue_2_dItem_4Jni->byteSpan(); + jobject optionalValue_2_eItem_4; + chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "e", "Ljava/lang/String;", + optionalValue_2_eItem_4); + auto optionalValue_2_eItem_4Jni = + chip::Platform::New(env, static_cast(optionalValue_2_eItem_4)); + cleanupStrings.push_back(optionalValue_2_eItem_4Jni); + nonNullValue_3.e = optionalValue_2_eItem_4Jni->charSpan(); + jobject optionalValue_2_fItem_4; + chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "f", "Ljava/lang/Integer;", + optionalValue_2_fItem_4); + nonNullValue_3.f = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(optionalValue_2_fItem_4)); + jobject optionalValue_2_gItem_4; + chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "g", "Ljava/lang/Float;", + optionalValue_2_gItem_4); + nonNullValue_3.g = static_cast>( + chip::JniReferences::GetInstance().FloatToPrimitive(optionalValue_2_gItem_4)); + jobject optionalValue_2_hItem_4; + chip::JniReferences::GetInstance().GetObjectField(optionalValue_2, "h", "Ljava/lang/Double;", + optionalValue_2_hItem_4); + nonNullValue_3.h = static_cast>( + chip::JniReferences::GetInstance().DoubleToPrimitive(optionalValue_2_hItem_4)); + } + } + jobject element_0_nullableListItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "nullableList", "Ljava/util/ArrayList;", + element_0_nullableListItem_1); + if (element_0_nullableListItem_1 == nullptr) + { + listHolder_0->mList[i_0].nullableList.SetNull(); + } + else + { + auto & nonNullValue_2 = listHolder_0->mList[i_0].nullableList.SetNonNull(); + { + using ListType_3 = std::remove_reference_t; + using ListMemberType_3 = ListMemberTypeGetter::Type; + jint element_0_nullableListItem_1Size; + chip::JniReferences::GetInstance().GetArrayListSize(element_0_nullableListItem_1, + element_0_nullableListItem_1Size); + if (element_0_nullableListItem_1Size != 0) + { + auto * listHolder_3 = new ListHolder(element_0_nullableListItem_1Size); + listFreer.add(listHolder_3); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxBroadcastCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + for (size_t i_3 = 0; i_3 < static_cast(element_0_nullableListItem_1Size); ++i_3) + { + jobject element_3; + chip::JniReferences::GetInstance().GetArrayListItem(element_0_nullableListItem_1, i_3, element_3); + listHolder_3->mList[i_3] = static_castmList[i_3])>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_3)); + } + nonNullValue_2 = ListType_3(listHolder_3->mList, element_0_nullableListItem_1Size); + } + else + { + nonNullValue_2 = ListType_3(); + } + } + } + jobject element_0_optionalListItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "optionalList", "Ljava/util/Optional;", + element_0_optionalListItem_1); + if (element_0_optionalListItem_1 != nullptr) + { + jobject optionalValue_2; + chip::JniReferences::GetInstance().GetOptionalValue(element_0_optionalListItem_1, optionalValue_2); + auto & definedValue_2 = listHolder_0->mList[i_0].optionalList.Emplace(); + { + using ListType_3 = std::remove_reference_t; + using ListMemberType_3 = ListMemberTypeGetter::Type; + jint optionalValue_2Size; + chip::JniReferences::GetInstance().GetArrayListSize(optionalValue_2, optionalValue_2Size); + if (optionalValue_2Size != 0) + { + auto * listHolder_3 = new ListHolder(optionalValue_2Size); + listFreer.add(listHolder_3); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + for (size_t i_3 = 0; i_3 < static_cast(optionalValue_2Size); ++i_3) + { + jobject element_3; + chip::JniReferences::GetInstance().GetArrayListItem(optionalValue_2, i_3, element_3); + listHolder_3->mList[i_3] = static_castmList[i_3])>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_3)); + } + definedValue_2 = ListType_3(listHolder_3->mList, optionalValue_2Size); + } + else + { + definedValue_2 = ListType_3(); + } + } + } + jobject element_0_nullableOptionalListItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "nullableOptionalList", "Ljava/util/Optional;", + element_0_nullableOptionalListItem_1); + if (element_0_nullableOptionalListItem_1 != nullptr) + { + jobject optionalValue_2; + chip::JniReferences::GetInstance().GetOptionalValue(element_0_nullableOptionalListItem_1, optionalValue_2); + auto & definedValue_2 = listHolder_0->mList[i_0].nullableOptionalList.Emplace(); + if (optionalValue_2 == nullptr) + { + definedValue_2.SetNull(); + } + else + { + auto & nonNullValue_3 = definedValue_2.SetNonNull(); + { + using ListType_4 = std::remove_reference_t; + using ListMemberType_4 = ListMemberTypeGetter::Type; + jint optionalValue_2Size; + chip::JniReferences::GetInstance().GetArrayListSize(optionalValue_2, optionalValue_2Size); + if (optionalValue_2Size != 0) + { + auto * listHolder_4 = new ListHolder(optionalValue_2Size); + listFreer.add(listHolder_4); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxDataCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + for (size_t i_4 = 0; i_4 < static_cast(optionalValue_2Size); ++i_4) + { + jobject element_4; + chip::JniReferences::GetInstance().GetArrayListItem(optionalValue_2, i_4, element_4); + listHolder_4->mList[i_4] = + static_castmList[i_4])>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_4)); + } + nonNullValue_3 = ListType_4(listHolder_4->mList, optionalValue_2Size); + } + else + { + nonNullValue_3 = ListType_4(); + } + } + } + } + } + cppValue = ListType_0(listHolder_0->mList, valueSize); + } + else + { + cppValue = ListType_0(); + } + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxDataCount::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxDataPollCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeEnumAttrAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::EnumAttr::TypeInfo; + TypeInfo::Type cppValue; - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxDataPollCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxBeaconCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxBeaconCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxBeaconRequestCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeRangeRestrictedInt8uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::RangeRestrictedInt8u::TypeInfo; + TypeInfo::Type cppValue; - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxBeaconRequestCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxOtherCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxOtherCount::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxAddressFilteredCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeRangeRestrictedInt8sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::RangeRestrictedInt8s::TypeInfo; + TypeInfo::Type cppValue; - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxAddressFilteredCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxDestAddrFilteredCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxDestAddrFilteredCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxDuplicatedCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeRangeRestrictedInt16uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::RangeRestrictedInt16u::TypeInfo; + TypeInfo::Type cppValue; - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxDuplicatedCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxErrNoFrameCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrNoFrameCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxErrUnknownNeighborCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeRangeRestrictedInt16sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::RangeRestrictedInt16s::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrUnknownNeighborCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxErrInvalidSrcAddrCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeTimedWriteBooleanAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::TimedWriteBoolean::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrInvalidSrcAddrCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxErrSecCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeUnsupportedAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Unsupported::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().BooleanToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrSecCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxErrFcsCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableBooleanAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBoolean::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().BooleanToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrFcsCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxErrOtherCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableBitmap8Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBitmap8::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrOtherCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeActiveTimestampAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableBitmap16Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBitmap16::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::ActiveTimestamp::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribePendingTimestampAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableBitmap32Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBitmap32::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::PendingTimestamp::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeDelayAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableBitmap64Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBitmap64::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::Delay::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeSecurityPolicyAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableInt8uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt8u::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::SecurityPolicy::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPThreadNetworkDiagnosticsSecurityPolicyAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeChannelMaskAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableInt16uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt16u::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::ChannelMask::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPOctetStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeOperationalDatasetComponentsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableInt24uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt24u::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::OperationalDatasetComponents::TypeInfo; - auto successFn = chip::Callback::Callback< - CHIPThreadNetworkDiagnosticsClusterOperationalDatasetComponentsAttributeCallbackType>::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPThreadNetworkDiagnosticsOperationalDatasetComponentsAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeActiveNetworkFaultsListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableInt32uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt32u::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::ActiveNetworkFaultsList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPThreadNetworkDiagnosticsActiveNetworkFaultsListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableInt40uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt40u::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPThreadNetworkDiagnosticsAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeFeatureMapAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableInt48uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt48u::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::FeatureMap::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableInt56uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt56u::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - ThreadNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, UserLabelCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - UserLabelCluster * cppCluster = new UserLabelCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} -JNI_METHOD(void, UserLabelCluster, writeLabelListAttribute) +JNI_METHOD(void, TestClusterCluster, writeNullableInt64uAttribute) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { - chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::UserLabel::Attributes::LabelList::TypeInfo; - TypeInfo::Type cppValue; - - std::vector cleanupByteArrays; - std::vector cleanupStrings; - - { - using ListType_0 = std::remove_reference_t; - using ListMemberType_0 = ListMemberTypeGetter::Type; - jint valueSize; - chip::JniReferences::GetInstance().GetArrayListSize(value, valueSize); - if (valueSize != 0) - { - auto * listHolder_0 = new ListHolder(valueSize); - listFreer.add(listHolder_0); - - for (size_t i_0 = 0; i_0 < static_cast(valueSize); ++i_0) - { - jobject element_0; - chip::JniReferences::GetInstance().GetArrayListItem(value, i_0, element_0); - jobject element_0_labelItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "label", "Ljava/lang/String;", element_0_labelItem_1); - auto element_0_labelItem_1Jni = - chip::Platform::New(env, static_cast(element_0_labelItem_1)); - cleanupStrings.push_back(element_0_labelItem_1Jni); - listHolder_0->mList[i_0].label = element_0_labelItem_1Jni->charSpan(); - jobject element_0_valueItem_1; - chip::JniReferences::GetInstance().GetObjectField(element_0, "value", "Ljava/lang/String;", element_0_valueItem_1); - auto element_0_valueItem_1Jni = - chip::Platform::New(env, static_cast(element_0_valueItem_1)); - cleanupStrings.push_back(element_0_valueItem_1Jni); - listHolder_0->mList[i_0].value = element_0_valueItem_1Jni->charSpan(); - } - cppValue = ListType_0(listHolder_0->mList, valueSize); - } - else - { - cppValue = ListType_0(); - } + chip::DeviceLayer::StackLock lock; + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt64u::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(value)); } std::unique_ptr onSuccess( @@ -41357,8 +17735,8 @@ JNI_METHOD(void, UserLabelCluster, writeLabelListAttribute) chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - UserLabelCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -41387,882 +17765,1261 @@ JNI_METHOD(void, UserLabelCluster, writeLabelListAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, UserLabelCluster, subscribeLabelListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableInt8sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - UserLabelCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt8s::TypeInfo; + TypeInfo::Type cppValue; - using TypeInfo = chip::app::Clusters::UserLabel::Attributes::LabelList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPUserLabelLabelListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + } - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, UserLabelCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - UserLabelCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::UserLabel::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, WakeOnLanCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) + +JNI_METHOD(void, TestClusterCluster, writeNullableInt16sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - WakeOnLanCluster * cppCluster = new WakeOnLanCluster(); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt16s::TypeInfo; + TypeInfo::Type cppValue; - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} + std::vector cleanupByteArrays; + std::vector cleanupStrings; -JNI_METHOD(void, WakeOnLanCluster, subscribeWakeOnLanMacAddressAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WakeOnLanCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WakeOnLan::Attributes::WakeOnLanMacAddress::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPCharStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WakeOnLanCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableInt24sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - - CHIP_ERROR err = CHIP_NO_ERROR; - WakeOnLanCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt24s::TypeInfo; + TypeInfo::Type cppValue; - using TypeInfo = chip::app::Clusters::WakeOnLan::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPWakeOnLanAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(value)); + } - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, WakeOnLanCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WakeOnLanCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WakeOnLan::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, WiFiNetworkDiagnosticsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) -{ - chip::DeviceLayer::StackLock lock; - WiFiNetworkDiagnosticsCluster * cppCluster = new WiFiNetworkDiagnosticsCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); - return reinterpret_cast(cppCluster); -} -JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, resetCounts) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, TestClusterCluster, writeNullableInt32sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - WiFiNetworkDiagnosticsCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::WiFiNetworkDiagnostics::Commands::ResetCounts::Type request; - - std::list cleanupByteArrays; - std::list cleanupStrings; - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); - std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt32s::TypeInfo; + TypeInfo::Type cppValue; - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - if (timedInvokeTimeoutMs == nullptr) + if (value == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + cppValue.SetNull(); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(value)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); - std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), - [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); - std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), - [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); - - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeBssidAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WiFiNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::Bssid::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPOctetStringAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeSecurityTypeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableInt40sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt40s::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WiFiNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::SecurityType::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeWiFiVersionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableInt48sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt48s::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WiFiNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::WiFiVersion::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeChannelNumberAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableInt56sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt56s::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WiFiNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::ChannelNumber::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeRssiAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableInt64sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt64s::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().LongToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WiFiNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::Rssi::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8sAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeBeaconLostCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableEnum8Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableEnum8::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WiFiNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::BeaconLostCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeBeaconRxCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableEnum16Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableEnum16::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WiFiNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::BeaconRxCount::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribePacketMulticastRxCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableFloatSingleAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableFloatSingle::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().FloatToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WiFiNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::PacketMulticastRxCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribePacketMulticastTxCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableFloatDoubleAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableFloatDouble::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().DoubleToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WiFiNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::PacketMulticastTxCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribePacketUnicastRxCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableOctetStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableOctetString::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + auto valueJni = chip::Platform::New(env, static_cast(value)); + cleanupByteArrays.push_back(valueJni); + nonNullValue_0 = valueJni->byteSpan(); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WiFiNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::PacketUnicastRxCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribePacketUnicastTxCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableCharStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableCharString::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + auto valueJni = chip::Platform::New(env, static_cast(value)); + cleanupStrings.push_back(valueJni); + nonNullValue_0 = valueJni->charSpan(); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WiFiNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::PacketUnicastTxCount::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeCurrentMaxRateAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableEnumAttrAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableEnumAttr::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WiFiNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::CurrentMaxRate::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeOverrunCountAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableRangeRestrictedInt8uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableRangeRestrictedInt8u::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WiFiNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::OverrunCount::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt64uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableRangeRestrictedInt8sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableRangeRestrictedInt8s::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WiFiNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::AttributeList::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPWiFiNetworkDiagnosticsAttributeListAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeFeatureMapAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableRangeRestrictedInt16uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableRangeRestrictedInt16u::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WiFiNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::FeatureMap::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, TestClusterCluster, writeNullableRangeRestrictedInt16sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableRangeRestrictedInt16s::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + if (value == nullptr) + { + cppValue.SetNull(); + } + else + { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + } + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WiFiNetworkDiagnosticsCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::ClusterRevision::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(jlong, WindowCoveringCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +JNI_METHOD(jlong, ThermostatCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - WindowCoveringCluster * cppCluster = new WindowCoveringCluster(); + ThermostatCluster * cppCluster = new ThermostatCluster(); cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); return reinterpret_cast(cppCluster); } -JNI_METHOD(void, WindowCoveringCluster, downOrClose) +JNI_METHOD(void, ThermostatCluster, clearWeeklySchedule) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster; + ThermostatCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::WindowCovering::Commands::DownOrClose::Type request; + chip::app::Clusters::Thermostat::Commands::ClearWeeklySchedule::Type request; std::list cleanupByteArrays; std::list cleanupStrings; @@ -42278,7 +19035,7 @@ JNI_METHOD(void, WindowCoveringCluster, downOrClose) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -42307,26 +19064,23 @@ JNI_METHOD(void, WindowCoveringCluster, downOrClose) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, goToLiftPercentage) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject liftPercentageValue, jobject liftPercent100thsValue, - jobject timedInvokeTimeoutMs) +JNI_METHOD(void, ThermostatCluster, getRelayStatusLog) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster; + ThermostatCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::WindowCovering::Commands::GoToLiftPercentage::Type request; + chip::app::Clusters::Thermostat::Commands::GetRelayStatusLog::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.liftPercentageValue = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(liftPercentageValue)); - request.liftPercent100thsValue = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(liftPercent100thsValue)); - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -42336,12 +19090,13 @@ JNI_METHOD(void, WindowCoveringCluster, goToLiftPercentage) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -42365,23 +19120,28 @@ JNI_METHOD(void, WindowCoveringCluster, goToLiftPercentage) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, goToLiftValue) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject liftValue, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, ThermostatCluster, getWeeklySchedule) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject daysToReturn, jobject modeToReturn, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster; + ThermostatCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::WindowCovering::Commands::GoToLiftValue::Type request; + chip::app::Clusters::Thermostat::Commands::GetWeeklySchedule::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.liftValue = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(liftValue)); + request.daysToReturn = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(daysToReturn)); + request.modeToReturn = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(modeToReturn)); - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, @@ -42391,12 +19151,13 @@ JNI_METHOD(void, WindowCoveringCluster, goToLiftValue) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); if (timedInvokeTimeoutMs == nullptr) @@ -42420,23 +19181,49 @@ JNI_METHOD(void, WindowCoveringCluster, goToLiftValue) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, goToTiltPercentage) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject tiltPercentageValue, jobject tiltPercent100thsValue, - jobject timedInvokeTimeoutMs) +JNI_METHOD(void, ThermostatCluster, setWeeklySchedule) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject numberOfTransitionsForSequence, + jobject dayOfWeekForSequence, jobject modeForSequence, jobject payload, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster; + ThermostatCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::WindowCovering::Commands::GoToTiltPercentage::Type request; + chip::app::Clusters::Thermostat::Commands::SetWeeklySchedule::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.tiltPercentageValue = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(tiltPercentageValue)); - request.tiltPercent100thsValue = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(tiltPercent100thsValue)); + request.numberOfTransitionsForSequence = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(numberOfTransitionsForSequence)); + request.dayOfWeekForSequence = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(dayOfWeekForSequence)); + request.modeForSequence = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(modeForSequence)); + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + jint payloadSize; + chip::JniReferences::GetInstance().GetArrayListSize(payload, payloadSize); + if (payloadSize != 0) + { + auto * listHolder_0 = new ListHolder(payloadSize); + listFreer.add(listHolder_0); + + for (size_t i_0 = 0; i_0 < static_cast(payloadSize); ++i_0) + { + jobject element_0; + chip::JniReferences::GetInstance().GetArrayListItem(payload, i_0, element_0); + listHolder_0->mList[i_0] = static_castmList[i_0])>>( + chip::JniReferences::GetInstance().IntegerToPrimitive(element_0)); + } + request.payload = ListType_0(listHolder_0->mList, payloadSize); + } + else + { + request.payload = ListType_0(); + } + } std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -42449,7 +19236,7 @@ JNI_METHOD(void, WindowCoveringCluster, goToTiltPercentage) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -42478,20 +19265,22 @@ JNI_METHOD(void, WindowCoveringCluster, goToTiltPercentage) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, goToTiltValue) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject tiltValue, jobject timedInvokeTimeoutMs) +JNI_METHOD(void, ThermostatCluster, setpointRaiseLower) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject mode, jobject amount, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster; + ThermostatCluster * cppCluster; ListFreer listFreer; - chip::app::Clusters::WindowCovering::Commands::GoToTiltValue::Type request; + chip::app::Clusters::Thermostat::Commands::SetpointRaiseLower::Type request; std::list cleanupByteArrays; std::list cleanupStrings; - request.tiltValue = static_cast>( - chip::JniReferences::GetInstance().IntegerToPrimitive(tiltValue)); + request.mode = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(mode)); + request.amount = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(amount)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -42504,7 +19293,7 @@ JNI_METHOD(void, WindowCoveringCluster, goToTiltValue) AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); @@ -42533,50 +19322,54 @@ JNI_METHOD(void, WindowCoveringCluster, goToTiltValue) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, stopMotion) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, ThermostatCluster, writeOccupiedCoolingSetpointAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::WindowCovering::Commands::StopMotion::Type request; + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::OccupiedCoolingSetpoint::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -42586,50 +19379,54 @@ JNI_METHOD(void, WindowCoveringCluster, stopMotion) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, upOrOpen) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) + +JNI_METHOD(void, ThermostatCluster, writeOccupiedHeatingSetpointAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster; - ListFreer listFreer; - chip::app::Clusters::WindowCovering::Commands::UpOrOpen::Type request; + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::OccupiedHeatingSetpoint::TypeInfo; + TypeInfo::Type cppValue; - std::list cleanupByteArrays; - std::list cleanupStrings; + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedInvokeTimeoutMs == nullptr) + if (timedWriteTimeoutMs == nullptr) { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); } - VerifyOrReturn(err == CHIP_NO_ERROR, - AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", - CHIP_ERROR_INCORRECT_STATE)); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -42639,676 +19436,984 @@ JNI_METHOD(void, WindowCoveringCluster, upOrOpen) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeTypeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ThermostatCluster, writeMinHeatSetpointLimitAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MinHeatSetpointLimit::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::Type::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeCurrentPositionLiftAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ThermostatCluster, writeMaxHeatSetpointLimitAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MaxHeatSetpointLimit::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::CurrentPositionLift::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPWindowCoveringCurrentPositionLiftAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeCurrentPositionTiltAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ThermostatCluster, writeMinCoolSetpointLimitAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MinCoolSetpointLimit::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::CurrentPositionTilt::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), CHIPWindowCoveringCurrentPositionTiltAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeConfigStatusAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ThermostatCluster, writeMaxCoolSetpointLimitAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MaxCoolSetpointLimit::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::ConfigStatus::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeCurrentPositionLiftPercentageAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ThermostatCluster, writeMinSetpointDeadBandAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MinSetpointDeadBand::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::CurrentPositionLiftPercentage::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPWindowCoveringCurrentPositionLiftPercentageAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeCurrentPositionTiltPercentageAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ThermostatCluster, writeControlSequenceOfOperationAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::ControlSequenceOfOperation::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::CurrentPositionTiltPercentage::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPWindowCoveringCurrentPositionTiltPercentageAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeOperationalStatusAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ThermostatCluster, writeSystemModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::SystemMode::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::OperationalStatus::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(jlong, ThermostatUserInterfaceConfigurationCluster, initWithDevice) +(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + ThermostatUserInterfaceConfigurationCluster * cppCluster = new ThermostatUserInterfaceConfigurationCluster(); - onSuccess.release(); - onFailure.release(); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); } -JNI_METHOD(void, WindowCoveringCluster, subscribeTargetPositionLiftPercent100thsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ThermostatUserInterfaceConfigurationCluster, writeTemperatureDisplayModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::ThermostatUserInterfaceConfiguration::Attributes::TemperatureDisplayMode::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ThermostatUserInterfaceConfigurationCluster * cppCluster = + reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::TargetPositionLiftPercent100ths::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPWindowCoveringTargetPositionLiftPercent100thsAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeTargetPositionTiltPercent100thsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ThermostatUserInterfaceConfigurationCluster, writeKeypadLockoutAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::ThermostatUserInterfaceConfiguration::Attributes::KeypadLockout::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ThermostatUserInterfaceConfigurationCluster * cppCluster = + reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::TargetPositionTiltPercent100ths::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPWindowCoveringTargetPositionTiltPercent100thsAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeEndProductTypeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, ThermostatUserInterfaceConfigurationCluster, writeScheduleProgrammingVisibilityAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::ThermostatUserInterfaceConfiguration::Attributes::ScheduleProgrammingVisibility::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + ThermostatUserInterfaceConfigurationCluster * cppCluster = + reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::EndProductType::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeCurrentPositionLiftPercent100thsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, ThreadNetworkDiagnosticsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + ThreadNetworkDiagnosticsCluster * cppCluster = new ThreadNetworkDiagnosticsCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, resetCounts) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) +{ + chip::DeviceLayer::StackLock lock; + CHIP_ERROR err = CHIP_NO_ERROR; + ThreadNetworkDiagnosticsCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::ThreadNetworkDiagnostics::Commands::ResetCounts::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::CurrentPositionLiftPercent100ths::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPWindowCoveringCurrentPositionLiftPercent100thsAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeCurrentPositionTiltPercent100thsAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, UserLabelCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + UserLabelCluster * cppCluster = new UserLabelCluster(); - std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); - VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); - VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); +JNI_METHOD(void, UserLabelCluster, writeLabelListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) +{ + chip::DeviceLayer::StackLock lock; + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::UserLabel::Attributes::LabelList::TypeInfo; + TypeInfo::Type cppValue; - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::CurrentPositionTiltPercent100ths::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); - auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + std::vector cleanupByteArrays; + std::vector cleanupStrings; - err = cppCluster->SubscribeAttribute( - onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), - static_cast(maxInterval), - CHIPWindowCoveringCurrentPositionTiltPercent100thsAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + jint valueSize; + chip::JniReferences::GetInstance().GetArrayListSize(value, valueSize); + if (valueSize != 0) + { + auto * listHolder_0 = new ListHolder(valueSize); + listFreer.add(listHolder_0); + + for (size_t i_0 = 0; i_0 < static_cast(valueSize); ++i_0) + { + jobject element_0; + chip::JniReferences::GetInstance().GetArrayListItem(value, i_0, element_0); + jobject element_0_labelItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "label", "Ljava/lang/String;", element_0_labelItem_1); + auto element_0_labelItem_1Jni = + chip::Platform::New(env, static_cast(element_0_labelItem_1)); + cleanupStrings.push_back(element_0_labelItem_1Jni); + listHolder_0->mList[i_0].label = element_0_labelItem_1Jni->charSpan(); + jobject element_0_valueItem_1; + chip::JniReferences::GetInstance().GetObjectField(element_0, "value", "Ljava/lang/String;", element_0_valueItem_1); + auto element_0_valueItem_1Jni = + chip::Platform::New(env, static_cast(element_0_valueItem_1)); + cleanupStrings.push_back(element_0_valueItem_1Jni); + listHolder_0->mList[i_0].value = element_0_valueItem_1Jni->charSpan(); + } + cppValue = ListType_0(listHolder_0->mList, valueSize); + } + else + { + cppValue = ListType_0(); + } + } - onSuccess.release(); - onFailure.release(); -} -JNI_METHOD(void, WindowCoveringCluster, subscribeInstalledOpenLimitLiftAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) -{ - chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + CHIP_ERROR err = CHIP_NO_ERROR; + UserLabelCluster * cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::InstalledOpenLimitLift::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeInstalledClosedLimitLiftAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, WakeOnLanCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + WakeOnLanCluster * cppCluster = new WakeOnLanCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(jlong, WiFiNetworkDiagnosticsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + chip::DeviceLayer::StackLock lock; + WiFiNetworkDiagnosticsCluster * cppCluster = new WiFiNetworkDiagnosticsCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, resetCounts) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) +{ + chip::DeviceLayer::StackLock lock; + CHIP_ERROR err = CHIP_NO_ERROR; + WiFiNetworkDiagnosticsCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::WiFiNetworkDiagnostics::Commands::ResetCounts::Type request; + std::list cleanupByteArrays; + std::list cleanupStrings; + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::InstalledClosedLimitLift::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeInstalledOpenLimitTiltAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(jlong, WindowCoveringCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + WindowCoveringCluster * cppCluster = new WindowCoveringCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + +JNI_METHOD(void, WindowCoveringCluster, downOrClose) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) +{ + chip::DeviceLayer::StackLock lock; + CHIP_ERROR err = CHIP_NO_ERROR; + WindowCoveringCluster * cppCluster; + ListFreer listFreer; + chip::app::Clusters::WindowCovering::Commands::DownOrClose::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::InstalledOpenLimitTilt::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeInstalledClosedLimitTiltAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, WindowCoveringCluster, goToLiftPercentage) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject liftPercentageValue, jobject liftPercent100thsValue, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + WindowCoveringCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::WindowCovering::Commands::GoToLiftPercentage::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.liftPercentageValue = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(liftPercentageValue)); + request.liftPercent100thsValue = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(liftPercent100thsValue)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::InstalledClosedLimitTilt::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } - -JNI_METHOD(void, WindowCoveringCluster, writeModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) +JNI_METHOD(void, WindowCoveringCluster, goToLiftValue) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject liftValue, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - ListFreer listFreer; - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::Mode::TypeInfo; - TypeInfo::Type cppValue; + CHIP_ERROR err = CHIP_NO_ERROR; + WindowCoveringCluster * cppCluster; - std::vector cleanupByteArrays; - std::vector cleanupStrings; + ListFreer listFreer; + chip::app::Clusters::WindowCovering::Commands::GoToLiftValue::Type request; - cppValue = - static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + std::list cleanupByteArrays; + std::list cleanupStrings; + request.liftValue = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(liftValue)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); - std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - if (timedWriteTimeoutMs == nullptr) + if (timedInvokeTimeoutMs == nullptr) { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); } else { - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, - chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); } - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + VerifyOrReturn(err == CHIP_NO_ERROR, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); @@ -43318,167 +20423,248 @@ JNI_METHOD(void, WindowCoveringCluster, writeModeAttribute) onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, WindowCoveringCluster, goToTiltPercentage) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject tiltPercentageValue, jobject tiltPercent100thsValue, + jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + WindowCoveringCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::WindowCovering::Commands::GoToTiltPercentage::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + request.tiltPercentageValue = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(tiltPercentageValue)); + request.tiltPercent100thsValue = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(tiltPercent100thsValue)); + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::Mode::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeSafetyStatusAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, WindowCoveringCluster, goToTiltValue) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject tiltValue, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + WindowCoveringCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::WindowCovering::Commands::GoToTiltValue::Type request; + std::list cleanupByteArrays; + std::list cleanupStrings; + request.tiltValue = static_cast>( + chip::JniReferences::GetInstance().IntegerToPrimitive(tiltValue)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::SafetyStatus::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeAttributeListAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, WindowCoveringCluster, stopMotion) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr - onSuccess(Platform::New(callback, true), - chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + WindowCoveringCluster * cppCluster; + ListFreer listFreer; + chip::app::Clusters::WindowCovering::Commands::StopMotion::Type request; + + std::list cleanupByteArrays; + std::list cleanupStrings; + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::AttributeList::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPWindowCoveringAttributeListAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeFeatureMapAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +JNI_METHOD(void, WindowCoveringCluster, upOrOpen) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); - VerifyOrReturn(onSuccess.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + CHIP_ERROR err = CHIP_NO_ERROR; + WindowCoveringCluster * cppCluster; + + ListFreer listFreer; + chip::app::Clusters::WindowCovering::Commands::UpOrOpen::Type request; + std::list cleanupByteArrays; + std::list cleanupStrings; + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); VerifyOrReturn(onFailure.get() != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY)); - CHIP_ERROR err = CHIP_NO_ERROR; - WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + cppCluster = reinterpret_cast(clusterPtr); VerifyOrReturn(cppCluster != nullptr, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::FeatureMap::TypeInfo; - auto successFn = - chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + if (timedInvokeTimeoutMs == nullptr) + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->InvokeCommand(request, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedInvokeTimeoutMs)); + } VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error invoking command", + CHIP_ERROR_INCORRECT_STATE)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, WindowCoveringCluster, subscribeClusterRevisionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) + +JNI_METHOD(void, WindowCoveringCluster, writeModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject value, jobject timedWriteTimeoutMs) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + ListFreer listFreer; + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::Mode::TypeInfo; + TypeInfo::Type cppValue; + + std::vector cleanupByteArrays; + std::vector cleanupStrings; + + cppValue = + static_cast>(chip::JniReferences::GetInstance().IntegerToPrimitive(value)); + + std::unique_ptr onSuccess( + Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), chip::Platform::Delete); + Platform::New(callback), Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); @@ -43489,17 +20675,26 @@ JNI_METHOD(void, WindowCoveringCluster, subscribeClusterRevisionAttribute) chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::ClusterRevision::TypeInfo; - auto successFn = chip::Callback::Callback::FromCancelable( - onSuccess->Cancel()); + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt16uAttributeCallback::OnSubscriptionEstablished); - VerifyOrReturn(err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( - env, callback, "Error subscribing to attribute", err)); + if (timedWriteTimeoutMs == nullptr) + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); + } + else + { + err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall, + chip::JniReferences::GetInstance().IntegerToPrimitive(timedWriteTimeoutMs)); + } + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + std::for_each(cleanupByteArrays.cbegin(), cleanupByteArrays.cend(), + [](chip::JniByteArray * jniByteArray) { chip::Platform::Delete(jniByteArray); }); + std::for_each(cleanupStrings.cbegin(), cleanupStrings.cend(), + [](chip::JniUtfString * jniString) { chip::Platform::Delete(jniString); }); onSuccess.release(); onFailure.release(); diff --git a/src/controller/java/zap-generated/CHIPClustersSubscribe-JNI.cpp b/src/controller/java/zap-generated/CHIPClustersSubscribe-JNI.cpp new file mode 100644 index 00000000000000..7c7b6c186eb296 --- /dev/null +++ b/src/controller/java/zap-generated/CHIPClustersSubscribe-JNI.cpp @@ -0,0 +1,23130 @@ +/* + * + * 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. + */ + +// THIS FILE IS GENERATED BY ZAP +#include "CHIPReadCallbacks.h" + +#include +#include + +#include +#include +#include +#include +#include + +#define JNI_METHOD(RETURN, CLASS_NAME, METHOD_NAME) \ + extern "C" JNIEXPORT RETURN JNICALL Java_chip_devicecontroller_ChipClusters_00024##CLASS_NAME##_##METHOD_NAME + +JNI_METHOD(void, AccessControlCluster, subscribeAclAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::AccessControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::AccessControl::Attributes::Acl::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPAccessControlAclAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, AccessControlCluster, subscribeExtensionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::AccessControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::AccessControl::Attributes::Extension::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPAccessControlExtensionAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, AccessControlCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::AccessControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::AccessControl::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPAccessControlAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, AccessControlCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::AccessControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::AccessControl::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, AccountLoginCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::AccountLoginCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::AccountLogin::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPAccountLoginAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, AccountLoginCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::AccountLoginCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::AccountLogin::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, AdministratorCommissioningCluster, subscribeWindowStatusAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::AdministratorCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::AdministratorCommissioning::Attributes::WindowStatus::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, AdministratorCommissioningCluster, subscribeAdminFabricIndexAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::AdministratorCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::AdministratorCommissioning::Attributes::AdminFabricIndex::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPAdministratorCommissioningAdminFabricIndexAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, AdministratorCommissioningCluster, subscribeAdminVendorIdAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::AdministratorCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::AdministratorCommissioning::Attributes::AdminVendorId::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, AdministratorCommissioningCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::AdministratorCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::AdministratorCommissioning::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPAdministratorCommissioningAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, AdministratorCommissioningCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::AdministratorCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::AdministratorCommissioning::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ApplicationBasicCluster, subscribeVendorNameAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ApplicationBasicCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ApplicationBasic::Attributes::VendorName::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ApplicationBasicCluster, subscribeVendorIdAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ApplicationBasicCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ApplicationBasic::Attributes::VendorId::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ApplicationBasicCluster, subscribeApplicationNameAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ApplicationBasicCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ApplicationBasic::Attributes::ApplicationName::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ApplicationBasicCluster, subscribeProductIdAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ApplicationBasicCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ApplicationBasic::Attributes::ProductId::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ApplicationBasicCluster, subscribeApplicationStatusAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ApplicationBasicCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ApplicationBasic::Attributes::ApplicationStatus::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ApplicationBasicCluster, subscribeApplicationVersionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ApplicationBasicCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ApplicationBasic::Attributes::ApplicationVersion::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ApplicationBasicCluster, subscribeAllowedVendorListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ApplicationBasicCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ApplicationBasic::Attributes::AllowedVendorList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPApplicationBasicAllowedVendorListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ApplicationBasicCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ApplicationBasicCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ApplicationBasic::Attributes::AttributeList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPApplicationBasicAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ApplicationBasicCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ApplicationBasicCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ApplicationBasic::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ApplicationLauncherCluster, subscribeApplicationLauncherListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ApplicationLauncherCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ApplicationLauncher::Attributes::ApplicationLauncherList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPApplicationLauncherApplicationLauncherListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ApplicationLauncherCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ApplicationLauncherCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ApplicationLauncher::Attributes::AttributeList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPApplicationLauncherAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ApplicationLauncherCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ApplicationLauncherCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ApplicationLauncher::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, AudioOutputCluster, subscribeAudioOutputListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::AudioOutputCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::AudioOutput::Attributes::AudioOutputList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPAudioOutputAudioOutputListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, AudioOutputCluster, subscribeCurrentAudioOutputAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::AudioOutputCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::AudioOutput::Attributes::CurrentAudioOutput::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, AudioOutputCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::AudioOutputCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::AudioOutput::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPAudioOutputAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, AudioOutputCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::AudioOutputCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::AudioOutput::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BarrierControlCluster, subscribeBarrierMovingStateAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BarrierControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BarrierControl::Attributes::BarrierMovingState::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BarrierControlCluster, subscribeBarrierSafetyStatusAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BarrierControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BarrierControl::Attributes::BarrierSafetyStatus::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BarrierControlCluster, subscribeBarrierCapabilitiesAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BarrierControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BarrierControl::Attributes::BarrierCapabilities::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BarrierControlCluster, subscribeBarrierPositionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BarrierControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BarrierControl::Attributes::BarrierPosition::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BarrierControlCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BarrierControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BarrierControl::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBarrierControlAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BarrierControlCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BarrierControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BarrierControl::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeInteractionModelVersionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::InteractionModelVersion::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeVendorNameAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::VendorName::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeVendorIDAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::VendorID::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBasicVendorIDAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeProductNameAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::ProductName::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeProductIDAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::ProductID::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeNodeLabelAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::NodeLabel::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeLocationAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::Location::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeHardwareVersionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::HardwareVersion::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeHardwareVersionStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::HardwareVersionString::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeSoftwareVersionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::SoftwareVersion::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeSoftwareVersionStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::SoftwareVersionString::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeManufacturingDateAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::ManufacturingDate::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribePartNumberAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::PartNumber::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeProductURLAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::ProductURL::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeProductLabelAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::ProductLabel::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeSerialNumberAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::SerialNumber::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeLocalConfigDisabledAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::LocalConfigDisabled::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeReachableAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::Reachable::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeUniqueIDAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::UniqueID::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBasicAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BasicCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BasicCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Basic::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BinaryInputBasicCluster, subscribeOutOfServiceAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BinaryInputBasicCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BinaryInputBasic::Attributes::OutOfService::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BinaryInputBasicCluster, subscribePresentValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BinaryInputBasicCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BinaryInputBasic::Attributes::PresentValue::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BinaryInputBasicCluster, subscribeStatusFlagsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BinaryInputBasicCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BinaryInputBasic::Attributes::StatusFlags::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BinaryInputBasicCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BinaryInputBasicCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BinaryInputBasic::Attributes::AttributeList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBinaryInputBasicAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BinaryInputBasicCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BinaryInputBasicCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BinaryInputBasic::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BindingCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BindingCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Binding::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBindingAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BindingCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BindingCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Binding::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BooleanStateCluster, subscribeStateValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BooleanStateCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BooleanState::Attributes::StateValue::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BooleanStateCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BooleanStateCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BooleanState::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanStateAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BooleanStateCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BooleanStateCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BooleanState::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BridgedActionsCluster, subscribeActionListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BridgedActionsCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BridgedActions::Attributes::ActionList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBridgedActionsActionListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BridgedActionsCluster, subscribeEndpointListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BridgedActionsCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BridgedActions::Attributes::EndpointList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBridgedActionsEndpointListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BridgedActionsCluster, subscribeSetupUrlAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BridgedActionsCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BridgedActions::Attributes::SetupUrl::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BridgedActionsCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BridgedActionsCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BridgedActions::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBridgedActionsAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BridgedActionsCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BridgedActionsCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BridgedActions::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BridgedDeviceBasicCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BridgedDeviceBasicCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BridgedDeviceBasic::Attributes::AttributeList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBridgedDeviceBasicAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, BridgedDeviceBasicCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::BridgedDeviceBasicCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::BridgedDeviceBasic::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ChannelCluster, subscribeChannelListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ChannelCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Channel::Attributes::ChannelList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPChannelChannelListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ChannelCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ChannelCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Channel::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPChannelAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ChannelCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ChannelCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Channel::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeCurrentHueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::CurrentHue::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeCurrentSaturationAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::CurrentSaturation::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeRemainingTimeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::RemainingTime::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeCurrentXAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::CurrentX::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeCurrentYAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::CurrentY::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeDriftCompensationAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::DriftCompensation::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeCompensationTextAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::CompensationText::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorTemperatureAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorTemperature::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorMode::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorControlOptionsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorControlOptions::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeNumberOfPrimariesAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::NumberOfPrimaries::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribePrimary1XAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary1X::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribePrimary1YAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary1Y::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribePrimary1IntensityAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary1Intensity::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribePrimary2XAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary2X::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribePrimary2YAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary2Y::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribePrimary2IntensityAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary2Intensity::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribePrimary3XAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary3X::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribePrimary3YAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary3Y::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribePrimary3IntensityAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary3Intensity::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribePrimary4XAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary4X::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribePrimary4YAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary4Y::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribePrimary4IntensityAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary4Intensity::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribePrimary5XAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary5X::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribePrimary5YAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary5Y::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribePrimary5IntensityAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary5Intensity::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribePrimary6XAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary6X::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribePrimary6YAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary6Y::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribePrimary6IntensityAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::Primary6Intensity::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeWhitePointXAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::WhitePointX::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeWhitePointYAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::WhitePointY::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorPointRXAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointRX::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorPointRYAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointRY::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorPointRIntensityAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointRIntensity::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorPointGXAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointGX::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorPointGYAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointGY::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorPointGIntensityAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointGIntensity::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorPointBXAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointBX::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorPointBYAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointBY::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorPointBIntensityAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorPointBIntensity::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeEnhancedCurrentHueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::EnhancedCurrentHue::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeEnhancedColorModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::EnhancedColorMode::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorLoopActiveAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorLoopActive::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorLoopDirectionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorLoopDirection::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorLoopTimeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorLoopTime::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorLoopStartEnhancedHueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorLoopStartEnhancedHue::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorLoopStoredEnhancedHueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorLoopStoredEnhancedHue::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorCapabilitiesAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorCapabilities::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorTempPhysicalMinAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorTempPhysicalMin::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeColorTempPhysicalMaxAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ColorTempPhysicalMax::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeCoupleColorTempToLevelMinMiredsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::CoupleColorTempToLevelMinMireds::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeStartUpColorTemperatureMiredsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::StartUpColorTemperatureMireds::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPColorControlAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ColorControlCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ColorControl::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ContentLauncherCluster, subscribeAcceptHeaderListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ContentLauncherCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ContentLauncher::Attributes::AcceptHeaderList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPContentLauncherAcceptHeaderListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ContentLauncherCluster, subscribeSupportedStreamingProtocolsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ContentLauncherCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ContentLauncherCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ContentLauncherCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ContentLauncher::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPContentLauncherAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ContentLauncherCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ContentLauncherCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ContentLauncher::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DescriptorCluster, subscribeDeviceListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DescriptorCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Descriptor::Attributes::DeviceList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPDescriptorDeviceListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DescriptorCluster, subscribeServerListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DescriptorCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Descriptor::Attributes::ServerList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPDescriptorServerListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DescriptorCluster, subscribeClientListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DescriptorCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Descriptor::Attributes::ClientList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPDescriptorClientListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DescriptorCluster, subscribePartsListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DescriptorCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Descriptor::Attributes::PartsList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPDescriptorPartsListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DescriptorCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DescriptorCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Descriptor::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPDescriptorAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DescriptorCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DescriptorCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Descriptor::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DiagnosticLogsCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DiagnosticLogsCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DiagnosticLogs::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPDiagnosticLogsAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DoorLockCluster, subscribeLockStateAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::LockState::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPDoorLockLockStateAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DoorLockCluster, subscribeLockTypeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::LockType::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DoorLockCluster, subscribeActuatorEnabledAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::ActuatorEnabled::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DoorLockCluster, subscribeDoorStateAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::DoorState::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPDoorLockDoorStateAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DoorLockCluster, subscribeNumberOfTotalUsersSupportedAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::NumberOfTotalUsersSupported::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DoorLockCluster, subscribeNumberOfPINUsersSupportedAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::NumberOfPINUsersSupported::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DoorLockCluster, subscribeMaxPINCodeLengthAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::MaxPINCodeLength::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DoorLockCluster, subscribeMinPINCodeLengthAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::MinPINCodeLength::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DoorLockCluster, subscribeLanguageAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::Language::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DoorLockCluster, subscribeAutoRelockTimeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::AutoRelockTime::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DoorLockCluster, subscribeSoundVolumeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::SoundVolume::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DoorLockCluster, subscribeOperatingModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::OperatingMode::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DoorLockCluster, subscribeSupportedOperatingModesAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::SupportedOperatingModes::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DoorLockCluster, subscribeEnableOneTouchLockingAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::EnableOneTouchLocking::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DoorLockCluster, subscribeEnablePrivacyModeButtonAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::EnablePrivacyModeButton::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DoorLockCluster, subscribeWrongCodeEntryLimitAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::WrongCodeEntryLimit::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DoorLockCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPDoorLockAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, DoorLockCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::DoorLockCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::DoorLock::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ElectricalMeasurementCluster, subscribeMeasurementTypeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ElectricalMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::MeasurementType::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ElectricalMeasurementCluster, subscribeTotalActivePowerAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ElectricalMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::TotalActivePower::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ElectricalMeasurementCluster, subscribeRmsVoltageAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ElectricalMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::RmsVoltage::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ElectricalMeasurementCluster, subscribeRmsVoltageMinAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ElectricalMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::RmsVoltageMin::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ElectricalMeasurementCluster, subscribeRmsVoltageMaxAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ElectricalMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::RmsVoltageMax::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ElectricalMeasurementCluster, subscribeRmsCurrentAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ElectricalMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::RmsCurrent::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ElectricalMeasurementCluster, subscribeRmsCurrentMinAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ElectricalMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::RmsCurrentMin::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ElectricalMeasurementCluster, subscribeRmsCurrentMaxAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ElectricalMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::RmsCurrentMax::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ElectricalMeasurementCluster, subscribeActivePowerAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ElectricalMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::ActivePower::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ElectricalMeasurementCluster, subscribeActivePowerMinAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ElectricalMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::ActivePowerMin::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ElectricalMeasurementCluster, subscribeActivePowerMaxAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ElectricalMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::ActivePowerMax::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ElectricalMeasurementCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ElectricalMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::AttributeList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPElectricalMeasurementAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ElectricalMeasurementCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ElectricalMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ElectricalMeasurement::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribePHYRateAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::EthernetNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::PHYRate::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeFullDuplexAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::EthernetNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::FullDuplex::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribePacketRxCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::EthernetNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::PacketRxCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribePacketTxCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::EthernetNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::PacketTxCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeTxErrCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::EthernetNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::TxErrCount::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeCollisionCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::EthernetNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::CollisionCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeOverrunCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::EthernetNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::OverrunCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeCarrierDetectAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::EthernetNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::CarrierDetect::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeTimeSinceResetAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::EthernetNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::TimeSinceReset::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::EthernetNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPEthernetNetworkDiagnosticsAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeFeatureMapAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::EthernetNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::FeatureMap::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::EthernetNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::EthernetNetworkDiagnostics::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, FixedLabelCluster, subscribeLabelListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::FixedLabelCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::FixedLabel::Attributes::LabelList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPFixedLabelLabelListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, FixedLabelCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::FixedLabelCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::FixedLabel::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPFixedLabelAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, FixedLabelCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::FixedLabelCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::FixedLabel::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, FlowMeasurementCluster, subscribeMeasuredValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::FlowMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::FlowMeasurement::Attributes::MeasuredValue::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, FlowMeasurementCluster, subscribeMinMeasuredValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::FlowMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::FlowMeasurement::Attributes::MinMeasuredValue::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, FlowMeasurementCluster, subscribeMaxMeasuredValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::FlowMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::FlowMeasurement::Attributes::MaxMeasuredValue::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, FlowMeasurementCluster, subscribeToleranceAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::FlowMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::FlowMeasurement::Attributes::Tolerance::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, FlowMeasurementCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::FlowMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::FlowMeasurement::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPFlowMeasurementAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, FlowMeasurementCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::FlowMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::FlowMeasurement::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GeneralCommissioningCluster, subscribeBreadcrumbAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GeneralCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GeneralCommissioning::Attributes::Breadcrumb::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GeneralCommissioningCluster, subscribeBasicCommissioningInfoListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GeneralCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GeneralCommissioning::Attributes::BasicCommissioningInfoList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPGeneralCommissioningBasicCommissioningInfoListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GeneralCommissioningCluster, subscribeRegulatoryConfigAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GeneralCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GeneralCommissioning::Attributes::RegulatoryConfig::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GeneralCommissioningCluster, subscribeLocationCapabilityAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GeneralCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GeneralCommissioning::Attributes::LocationCapability::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GeneralCommissioningCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GeneralCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GeneralCommissioning::Attributes::AttributeList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPGeneralCommissioningAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GeneralCommissioningCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GeneralCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GeneralCommissioning::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeNetworkInterfacesAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GeneralDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::NetworkInterfaces::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPGeneralDiagnosticsNetworkInterfacesAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeRebootCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GeneralDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::RebootCount::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeUpTimeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GeneralDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::UpTime::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeTotalOperationalHoursAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GeneralDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::TotalOperationalHours::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeBootReasonsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GeneralDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::BootReasons::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeActiveHardwareFaultsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GeneralDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::ActiveHardwareFaults::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPGeneralDiagnosticsActiveHardwareFaultsAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeActiveRadioFaultsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GeneralDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::ActiveRadioFaults::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPGeneralDiagnosticsActiveRadioFaultsAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeActiveNetworkFaultsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GeneralDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::ActiveNetworkFaults::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPGeneralDiagnosticsActiveNetworkFaultsAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GeneralDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::AttributeList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPGeneralDiagnosticsAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GeneralDiagnosticsCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GeneralDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GeneralDiagnostics::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GroupKeyManagementCluster, subscribeGroupKeyMapAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GroupKeyManagementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GroupKeyManagement::Attributes::GroupKeyMap::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPGroupKeyManagementGroupKeyMapAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GroupKeyManagementCluster, subscribeGroupTableAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GroupKeyManagementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GroupKeyManagement::Attributes::GroupTable::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPGroupKeyManagementGroupTableAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GroupKeyManagementCluster, subscribeMaxGroupsPerFabricAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GroupKeyManagementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GroupKeyManagement::Attributes::MaxGroupsPerFabric::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GroupKeyManagementCluster, subscribeMaxGroupKeysPerFabricAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GroupKeyManagementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GroupKeyManagement::Attributes::MaxGroupKeysPerFabric::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GroupKeyManagementCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GroupKeyManagementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GroupKeyManagement::Attributes::AttributeList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPGroupKeyManagementAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GroupKeyManagementCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GroupKeyManagementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::GroupKeyManagement::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GroupsCluster, subscribeNameSupportAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GroupsCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Groups::Attributes::NameSupport::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GroupsCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GroupsCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Groups::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPGroupsAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, GroupsCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::GroupsCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Groups::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, IdentifyCluster, subscribeIdentifyTimeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::IdentifyCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Identify::Attributes::IdentifyTime::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, IdentifyCluster, subscribeIdentifyTypeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::IdentifyCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Identify::Attributes::IdentifyType::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, IdentifyCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::IdentifyCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Identify::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPIdentifyAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, IdentifyCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::IdentifyCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Identify::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, IlluminanceMeasurementCluster, subscribeMeasuredValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::IlluminanceMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::IlluminanceMeasurement::Attributes::MeasuredValue::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPIlluminanceMeasurementMeasuredValueAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, IlluminanceMeasurementCluster, subscribeMinMeasuredValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::IlluminanceMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::IlluminanceMeasurement::Attributes::MinMeasuredValue::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPIlluminanceMeasurementMinMeasuredValueAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, IlluminanceMeasurementCluster, subscribeMaxMeasuredValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::IlluminanceMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::IlluminanceMeasurement::Attributes::MaxMeasuredValue::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPIlluminanceMeasurementMaxMeasuredValueAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, IlluminanceMeasurementCluster, subscribeToleranceAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::IlluminanceMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::IlluminanceMeasurement::Attributes::Tolerance::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, IlluminanceMeasurementCluster, subscribeLightSensorTypeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::IlluminanceMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::IlluminanceMeasurement::Attributes::LightSensorType::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPIlluminanceMeasurementLightSensorTypeAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, IlluminanceMeasurementCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::IlluminanceMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::IlluminanceMeasurement::Attributes::AttributeList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPIlluminanceMeasurementAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, IlluminanceMeasurementCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::IlluminanceMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::IlluminanceMeasurement::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, KeypadInputCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::KeypadInputCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::KeypadInput::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPKeypadInputAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, KeypadInputCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::KeypadInputCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::KeypadInput::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LevelControlCluster, subscribeCurrentLevelAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::CurrentLevel::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LevelControlCluster, subscribeRemainingTimeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::RemainingTime::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LevelControlCluster, subscribeMinLevelAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::MinLevel::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LevelControlCluster, subscribeMaxLevelAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::MaxLevel::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LevelControlCluster, subscribeCurrentFrequencyAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::CurrentFrequency::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LevelControlCluster, subscribeMinFrequencyAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::MinFrequency::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LevelControlCluster, subscribeMaxFrequencyAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::MaxFrequency::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LevelControlCluster, subscribeOptionsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::Options::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LevelControlCluster, subscribeOnOffTransitionTimeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::OnOffTransitionTime::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LevelControlCluster, subscribeOnLevelAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::OnLevel::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPLevelControlOnLevelAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LevelControlCluster, subscribeOnTransitionTimeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::OnTransitionTime::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPLevelControlOnTransitionTimeAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LevelControlCluster, subscribeOffTransitionTimeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::OffTransitionTime::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPLevelControlOffTransitionTimeAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LevelControlCluster, subscribeDefaultMoveRateAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::DefaultMoveRate::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPLevelControlDefaultMoveRateAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LevelControlCluster, subscribeStartUpCurrentLevelAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::StartUpCurrentLevel::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPLevelControlStartUpCurrentLevelAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LevelControlCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPLevelControlAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LevelControlCluster, subscribeFeatureMapAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::FeatureMap::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LevelControlCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LevelControlCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LevelControl::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LocalizationConfigurationCluster, subscribeActiveLocaleAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LocalizationConfigurationCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LocalizationConfiguration::Attributes::ActiveLocale::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LocalizationConfigurationCluster, subscribeSupportedLocalesAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LocalizationConfigurationCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LocalizationConfiguration::Attributes::SupportedLocales::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPLocalizationConfigurationSupportedLocalesAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LowPowerCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LowPowerCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LowPower::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPLowPowerAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, LowPowerCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::LowPowerCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::LowPower::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, MediaInputCluster, subscribeMediaInputListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::MediaInputCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::MediaInput::Attributes::MediaInputList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPMediaInputMediaInputListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, MediaInputCluster, subscribeCurrentMediaInputAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::MediaInputCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::MediaInput::Attributes::CurrentMediaInput::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, MediaInputCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::MediaInputCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::MediaInput::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPMediaInputAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, MediaInputCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::MediaInputCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::MediaInput::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, MediaPlaybackCluster, subscribePlaybackStateAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::MediaPlaybackCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::MediaPlayback::Attributes::PlaybackState::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, MediaPlaybackCluster, subscribeStartTimeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::MediaPlaybackCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::MediaPlayback::Attributes::StartTime::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, MediaPlaybackCluster, subscribeDurationAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::MediaPlaybackCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::MediaPlayback::Attributes::Duration::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, MediaPlaybackCluster, subscribePlaybackSpeedAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::MediaPlaybackCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::MediaPlayback::Attributes::PlaybackSpeed::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPFloatAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, MediaPlaybackCluster, subscribeSeekRangeEndAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::MediaPlaybackCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::MediaPlayback::Attributes::SeekRangeEnd::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, MediaPlaybackCluster, subscribeSeekRangeStartAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::MediaPlaybackCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::MediaPlayback::Attributes::SeekRangeStart::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, MediaPlaybackCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::MediaPlaybackCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::MediaPlayback::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPMediaPlaybackAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, MediaPlaybackCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::MediaPlaybackCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::MediaPlayback::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ModeSelectCluster, subscribeCurrentModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ModeSelectCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ModeSelect::Attributes::CurrentMode::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ModeSelectCluster, subscribeSupportedModesAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ModeSelectCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ModeSelect::Attributes::SupportedModes::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPModeSelectSupportedModesAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ModeSelectCluster, subscribeOnModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ModeSelectCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ModeSelect::Attributes::OnMode::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ModeSelectCluster, subscribeStartUpModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ModeSelectCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ModeSelect::Attributes::StartUpMode::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ModeSelectCluster, subscribeDescriptionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ModeSelectCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ModeSelect::Attributes::Description::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ModeSelectCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ModeSelectCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ModeSelect::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPModeSelectAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ModeSelectCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ModeSelectCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ModeSelect::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, NetworkCommissioningCluster, subscribeMaxNetworksAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::NetworkCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::MaxNetworks::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, NetworkCommissioningCluster, subscribeNetworksAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::NetworkCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::Networks::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPNetworkCommissioningNetworksAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, NetworkCommissioningCluster, subscribeScanMaxTimeSecondsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::NetworkCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::ScanMaxTimeSeconds::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, NetworkCommissioningCluster, subscribeConnectMaxTimeSecondsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::NetworkCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::ConnectMaxTimeSeconds::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, NetworkCommissioningCluster, subscribeInterfaceEnabledAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::NetworkCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::InterfaceEnabled::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, NetworkCommissioningCluster, subscribeLastNetworkingStatusAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::NetworkCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::LastNetworkingStatus::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, NetworkCommissioningCluster, subscribeLastNetworkIDAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::NetworkCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::LastNetworkID::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPOctetStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, NetworkCommissioningCluster, subscribeLastConnectErrorValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::NetworkCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::LastConnectErrorValue::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, NetworkCommissioningCluster, subscribeFeatureMapAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::NetworkCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::FeatureMap::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, NetworkCommissioningCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::NetworkCommissioningCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::NetworkCommissioning::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OtaSoftwareUpdateProviderCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OtaSoftwareUpdateProviderCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateProvider::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPOtaSoftwareUpdateProviderAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OtaSoftwareUpdateProviderCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OtaSoftwareUpdateProviderCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateProvider::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeDefaultOtaProvidersAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OtaSoftwareUpdateRequestorCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::DefaultOtaProviders::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeUpdatePossibleAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OtaSoftwareUpdateRequestorCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::UpdatePossible::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeUpdateStateAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OtaSoftwareUpdateRequestorCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::UpdateState::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeUpdateStateProgressAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OtaSoftwareUpdateRequestorCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::UpdateStateProgress::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPOtaSoftwareUpdateRequestorUpdateStateProgressAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OtaSoftwareUpdateRequestorCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPOtaSoftwareUpdateRequestorAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OtaSoftwareUpdateRequestorCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OccupancySensingCluster, subscribeOccupancyAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OccupancySensingCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OccupancySensing::Attributes::Occupancy::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OccupancySensingCluster, subscribeOccupancySensorTypeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OccupancySensingCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OccupancySensing::Attributes::OccupancySensorType::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OccupancySensingCluster, subscribeOccupancySensorTypeBitmapAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OccupancySensingCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OccupancySensing::Attributes::OccupancySensorTypeBitmap::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OccupancySensingCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OccupancySensingCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OccupancySensing::Attributes::AttributeList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPOccupancySensingAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OccupancySensingCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OccupancySensingCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OccupancySensing::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OnOffCluster, subscribeOnOffAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OnOff::Attributes::OnOff::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OnOffCluster, subscribeGlobalSceneControlAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OnOff::Attributes::GlobalSceneControl::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OnOffCluster, subscribeOnTimeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OnOff::Attributes::OnTime::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OnOffCluster, subscribeOffWaitTimeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OnOff::Attributes::OffWaitTime::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OnOffCluster, subscribeStartUpOnOffAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OnOff::Attributes::StartUpOnOff::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OnOffCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OnOff::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPOnOffAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OnOffCluster, subscribeFeatureMapAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OnOff::Attributes::FeatureMap::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OnOffCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OnOffCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OnOff::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OnOffSwitchConfigurationCluster, subscribeSwitchTypeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OnOffSwitchConfigurationCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OnOffSwitchConfiguration::Attributes::SwitchType::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OnOffSwitchConfigurationCluster, subscribeSwitchActionsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OnOffSwitchConfigurationCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OnOffSwitchConfiguration::Attributes::SwitchActions::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OnOffSwitchConfigurationCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OnOffSwitchConfigurationCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OnOffSwitchConfiguration::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPOnOffSwitchConfigurationAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OnOffSwitchConfigurationCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OnOffSwitchConfigurationCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OnOffSwitchConfiguration::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OperationalCredentialsCluster, subscribeFabricsListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OperationalCredentialsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OperationalCredentials::Attributes::FabricsList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPOperationalCredentialsFabricsListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OperationalCredentialsCluster, subscribeSupportedFabricsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OperationalCredentialsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OperationalCredentials::Attributes::SupportedFabrics::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OperationalCredentialsCluster, subscribeCommissionedFabricsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OperationalCredentialsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OperationalCredentials::Attributes::CommissionedFabrics::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OperationalCredentialsCluster, subscribeTrustedRootCertificatesAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OperationalCredentialsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OperationalCredentials::Attributes::TrustedRootCertificates::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPOperationalCredentialsTrustedRootCertificatesAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OperationalCredentialsCluster, subscribeCurrentFabricIndexAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OperationalCredentialsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OperationalCredentials::Attributes::CurrentFabricIndex::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPOperationalCredentialsCurrentFabricIndexAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OperationalCredentialsCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OperationalCredentialsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OperationalCredentials::Attributes::AttributeList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPOperationalCredentialsAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, OperationalCredentialsCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OperationalCredentialsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::OperationalCredentials::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PowerSourceCluster, subscribeStatusAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PowerSource::Attributes::Status::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PowerSourceCluster, subscribeOrderAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PowerSource::Attributes::Order::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PowerSourceCluster, subscribeDescriptionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PowerSource::Attributes::Description::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PowerSourceCluster, subscribeBatteryVoltageAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PowerSource::Attributes::BatteryVoltage::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PowerSourceCluster, subscribeBatteryPercentRemainingAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PowerSource::Attributes::BatteryPercentRemaining::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PowerSourceCluster, subscribeBatteryTimeRemainingAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PowerSource::Attributes::BatteryTimeRemaining::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PowerSourceCluster, subscribeBatteryChargeLevelAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PowerSource::Attributes::BatteryChargeLevel::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PowerSourceCluster, subscribeActiveBatteryFaultsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PowerSource::Attributes::ActiveBatteryFaults::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPPowerSourceActiveBatteryFaultsAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PowerSourceCluster, subscribeBatteryChargeStateAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PowerSource::Attributes::BatteryChargeState::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PowerSourceCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PowerSource::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPPowerSourceAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PowerSourceCluster, subscribeFeatureMapAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PowerSource::Attributes::FeatureMap::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PowerSourceCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PowerSourceCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PowerSource::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PowerSourceConfigurationCluster, subscribeSourcesAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PowerSourceConfigurationCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PowerSourceConfiguration::Attributes::Sources::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPPowerSourceConfigurationSourcesAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PowerSourceConfigurationCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PowerSourceConfigurationCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PowerSourceConfiguration::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPPowerSourceConfigurationAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PowerSourceConfigurationCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PowerSourceConfigurationCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PowerSourceConfiguration::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PressureMeasurementCluster, subscribeMeasuredValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PressureMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PressureMeasurement::Attributes::MeasuredValue::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PressureMeasurementCluster, subscribeMinMeasuredValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PressureMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PressureMeasurement::Attributes::MinMeasuredValue::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PressureMeasurementCluster, subscribeMaxMeasuredValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PressureMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PressureMeasurement::Attributes::MaxMeasuredValue::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PressureMeasurementCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PressureMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PressureMeasurement::Attributes::AttributeList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPPressureMeasurementAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PressureMeasurementCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PressureMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PressureMeasurement::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMaxPressureAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MaxPressure::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMaxSpeedAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MaxSpeed::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMaxFlowAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MaxFlow::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMinConstPressureAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MinConstPressure::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMaxConstPressureAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MaxConstPressure::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMinCompPressureAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MinCompPressure::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMaxCompPressureAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MaxCompPressure::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMinConstSpeedAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MinConstSpeed::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMaxConstSpeedAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MaxConstSpeed::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMinConstFlowAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MinConstFlow::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMaxConstFlowAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MaxConstFlow::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMinConstTempAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MinConstTemp::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeMaxConstTempAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::MaxConstTemp::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribePumpStatusAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::PumpStatus::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeEffectiveOperationModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::EffectiveOperationMode::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeEffectiveControlModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::EffectiveControlMode::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeCapacityAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::Capacity::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeSpeedAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::Speed::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeLifetimeRunningHoursAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::LifetimeRunningHours::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPPumpConfigurationAndControlLifetimeRunningHoursAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribePowerAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::Power::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeLifetimeEnergyConsumedAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::LifetimeEnergyConsumed::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPPumpConfigurationAndControlLifetimeEnergyConsumedAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeOperationModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::OperationMode::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeControlModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::ControlMode::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeAlarmMaskAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::AlarmMask::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPPumpConfigurationAndControlAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeFeatureMapAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::FeatureMap::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, PumpConfigurationAndControlCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::PumpConfigurationAndControlCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::PumpConfigurationAndControl::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, RelativeHumidityMeasurementCluster, subscribeMeasuredValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::RelativeHumidityMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::RelativeHumidityMeasurement::Attributes::MeasuredValue::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, RelativeHumidityMeasurementCluster, subscribeMinMeasuredValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::RelativeHumidityMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::RelativeHumidityMeasurement::Attributes::MinMeasuredValue::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, RelativeHumidityMeasurementCluster, subscribeMaxMeasuredValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::RelativeHumidityMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::RelativeHumidityMeasurement::Attributes::MaxMeasuredValue::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, RelativeHumidityMeasurementCluster, subscribeToleranceAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::RelativeHumidityMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::RelativeHumidityMeasurement::Attributes::Tolerance::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, RelativeHumidityMeasurementCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::RelativeHumidityMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::RelativeHumidityMeasurement::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPRelativeHumidityMeasurementAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, RelativeHumidityMeasurementCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::RelativeHumidityMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::RelativeHumidityMeasurement::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ScenesCluster, subscribeSceneCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ScenesCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Scenes::Attributes::SceneCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ScenesCluster, subscribeCurrentSceneAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ScenesCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Scenes::Attributes::CurrentScene::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ScenesCluster, subscribeCurrentGroupAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ScenesCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Scenes::Attributes::CurrentGroup::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ScenesCluster, subscribeSceneValidAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ScenesCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Scenes::Attributes::SceneValid::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ScenesCluster, subscribeNameSupportAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ScenesCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Scenes::Attributes::NameSupport::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ScenesCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ScenesCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Scenes::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPScenesAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ScenesCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ScenesCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Scenes::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, SoftwareDiagnosticsCluster, subscribeThreadMetricsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::SoftwareDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::SoftwareDiagnostics::Attributes::ThreadMetrics::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPSoftwareDiagnosticsThreadMetricsAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, SoftwareDiagnosticsCluster, subscribeCurrentHeapFreeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::SoftwareDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::SoftwareDiagnostics::Attributes::CurrentHeapFree::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, SoftwareDiagnosticsCluster, subscribeCurrentHeapUsedAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::SoftwareDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::SoftwareDiagnostics::Attributes::CurrentHeapUsed::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, SoftwareDiagnosticsCluster, subscribeCurrentHeapHighWatermarkAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::SoftwareDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::SoftwareDiagnostics::Attributes::CurrentHeapHighWatermark::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, SoftwareDiagnosticsCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::SoftwareDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::SoftwareDiagnostics::Attributes::AttributeList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPSoftwareDiagnosticsAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, SoftwareDiagnosticsCluster, subscribeFeatureMapAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::SoftwareDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::SoftwareDiagnostics::Attributes::FeatureMap::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, SoftwareDiagnosticsCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::SoftwareDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::SoftwareDiagnostics::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, SwitchCluster, subscribeNumberOfPositionsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::SwitchCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Switch::Attributes::NumberOfPositions::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, SwitchCluster, subscribeCurrentPositionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::SwitchCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Switch::Attributes::CurrentPosition::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, SwitchCluster, subscribeMultiPressMaxAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::SwitchCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Switch::Attributes::MultiPressMax::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, SwitchCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::SwitchCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Switch::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPSwitchAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, SwitchCluster, subscribeFeatureMapAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::SwitchCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Switch::Attributes::FeatureMap::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, SwitchCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::SwitchCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Switch::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TargetNavigatorCluster, subscribeTargetNavigatorListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TargetNavigatorCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TargetNavigator::Attributes::TargetNavigatorList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPTargetNavigatorTargetNavigatorListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TargetNavigatorCluster, subscribeCurrentNavigatorTargetAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TargetNavigatorCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TargetNavigator::Attributes::CurrentNavigatorTarget::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TargetNavigatorCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TargetNavigatorCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TargetNavigator::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTargetNavigatorAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TargetNavigatorCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TargetNavigatorCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TargetNavigator::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TemperatureMeasurementCluster, subscribeMeasuredValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TemperatureMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TemperatureMeasurement::Attributes::MeasuredValue::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TemperatureMeasurementCluster, subscribeMinMeasuredValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TemperatureMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TemperatureMeasurement::Attributes::MinMeasuredValue::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TemperatureMeasurementCluster, subscribeMaxMeasuredValueAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TemperatureMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TemperatureMeasurement::Attributes::MaxMeasuredValue::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TemperatureMeasurementCluster, subscribeToleranceAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TemperatureMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TemperatureMeasurement::Attributes::Tolerance::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TemperatureMeasurementCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TemperatureMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TemperatureMeasurement::Attributes::AttributeList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPTemperatureMeasurementAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TemperatureMeasurementCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TemperatureMeasurementCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TemperatureMeasurement::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeBooleanAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Boolean::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeBitmap8Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Bitmap8::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeBitmap16Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Bitmap16::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeBitmap32Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Bitmap32::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeBitmap64Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Bitmap64::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeInt8uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int8u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeInt16uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int16u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeInt24uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int24u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeInt32uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int32u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeInt40uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int40u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeInt48uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int48u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeInt56uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int56u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeInt64uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int64u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeInt8sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int8s::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeInt16sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int16s::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeInt24sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int24s::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeInt32sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int32s::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeInt40sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int40s::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeInt48sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int48s::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeInt56sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int56s::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeInt64sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Int64s::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeEnum8Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Enum8::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeEnum16Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Enum16::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeFloatSingleAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::FloatSingle::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPFloatAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeFloatDoubleAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::FloatDouble::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPDoubleAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeOctetStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::OctetString::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPOctetStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeListInt8uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ListInt8u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterListInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeListOctetStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ListOctetString::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterListOctetStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeListStructOctetStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ListStructOctetString::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPTestClusterListStructOctetStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeLongOctetStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::LongOctetString::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPOctetStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeCharStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::CharString::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeLongCharStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::LongCharString::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeEpochUsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::EpochUs::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeEpochSAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::EpochS::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeVendorIdAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::VendorId::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterVendorIdAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeListNullablesAndOptionalsStructAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ListNullablesAndOptionalsStruct::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPTestClusterListNullablesAndOptionalsStructAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeEnumAttrAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::EnumAttr::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeRangeRestrictedInt8uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::RangeRestrictedInt8u::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeRangeRestrictedInt8sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::RangeRestrictedInt8s::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeRangeRestrictedInt16uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::RangeRestrictedInt16u::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeRangeRestrictedInt16sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::RangeRestrictedInt16s::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeListLongOctetStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ListLongOctetString::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterListLongOctetStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeTimedWriteBooleanAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::TimedWriteBoolean::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeUnsupportedAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::Unsupported::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableBooleanAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBoolean::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableBitmap8Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBitmap8::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableBitmap8AttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableBitmap16Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBitmap16::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableBitmap16AttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableBitmap32Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBitmap32::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableBitmap32AttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableBitmap64Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableBitmap64::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableBitmap64AttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableInt8uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt8u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableInt16uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt16u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableInt24uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt24u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableInt24uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableInt32uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt32u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableInt40uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt40u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableInt40uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableInt48uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt48u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableInt48uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableInt56uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt56u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableInt56uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableInt64uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt64u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableInt8sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt8s::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableInt8sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableInt16sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt16s::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableInt24sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt24s::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableInt24sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableInt32sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt32s::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableInt32sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableInt40sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt40s::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableInt40sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableInt48sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt48s::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableInt48sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableInt56sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt56s::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableInt56sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableInt64sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableInt64s::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableInt64sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableEnum8Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableEnum8::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableEnum8AttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableEnum16Attribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableEnum16::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableEnum16AttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableFloatSingleAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableFloatSingle::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableFloatSingleAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableFloatDoubleAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableFloatDouble::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableFloatDoubleAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableOctetStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableOctetString::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableOctetStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableCharStringAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableCharString::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableEnumAttrAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableEnumAttr::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterNullableEnumAttrAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableRangeRestrictedInt8uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableRangeRestrictedInt8u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPTestClusterNullableRangeRestrictedInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableRangeRestrictedInt8sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableRangeRestrictedInt8s::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPTestClusterNullableRangeRestrictedInt8sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableRangeRestrictedInt16uAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableRangeRestrictedInt16u::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPTestClusterNullableRangeRestrictedInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeNullableRangeRestrictedInt16sAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::NullableRangeRestrictedInt16s::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPTestClusterNullableRangeRestrictedInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPTestClusterAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, TestClusterCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::TestCluster::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeLocalTemperatureAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::LocalTemperature::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeAbsMinHeatSetpointLimitAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::AbsMinHeatSetpointLimit::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeAbsMaxHeatSetpointLimitAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::AbsMaxHeatSetpointLimit::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeAbsMinCoolSetpointLimitAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::AbsMinCoolSetpointLimit::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeAbsMaxCoolSetpointLimitAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::AbsMaxCoolSetpointLimit::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeOccupiedCoolingSetpointAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::OccupiedCoolingSetpoint::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeOccupiedHeatingSetpointAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::OccupiedHeatingSetpoint::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeMinHeatSetpointLimitAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MinHeatSetpointLimit::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeMaxHeatSetpointLimitAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MaxHeatSetpointLimit::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeMinCoolSetpointLimitAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MinCoolSetpointLimit::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeMaxCoolSetpointLimitAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MaxCoolSetpointLimit::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeMinSetpointDeadBandAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::MinSetpointDeadBand::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeControlSequenceOfOperationAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::ControlSequenceOfOperation::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeSystemModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::SystemMode::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeStartOfWeekAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::StartOfWeek::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeNumberOfWeeklyTransitionsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::NumberOfWeeklyTransitions::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeNumberOfDailyTransitionsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::NumberOfDailyTransitions::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPThermostatAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeFeatureMapAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::FeatureMap::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::Thermostat::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatUserInterfaceConfigurationCluster, subscribeTemperatureDisplayModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatUserInterfaceConfigurationCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThermostatUserInterfaceConfiguration::Attributes::TemperatureDisplayMode::TypeInfo; + auto successFn = + chip::Callback::Callback:: + FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatUserInterfaceConfigurationCluster, subscribeKeypadLockoutAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatUserInterfaceConfigurationCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThermostatUserInterfaceConfiguration::Attributes::KeypadLockout::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatUserInterfaceConfigurationCluster, subscribeScheduleProgrammingVisibilityAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatUserInterfaceConfigurationCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThermostatUserInterfaceConfiguration::Attributes::ScheduleProgrammingVisibility::TypeInfo; + auto successFn = chip::Callback:: + Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatUserInterfaceConfigurationCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatUserInterfaceConfigurationCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThermostatUserInterfaceConfiguration::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPThermostatUserInterfaceConfigurationAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThermostatUserInterfaceConfigurationCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThermostatUserInterfaceConfigurationCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThermostatUserInterfaceConfiguration::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback< + CHIPThermostatUserInterfaceConfigurationClusterClusterRevisionAttributeCallbackType>::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeChannelAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::Channel::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRoutingRoleAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RoutingRole::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeNetworkNameAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::NetworkName::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPOctetStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribePanIdAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::PanId::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeExtendedPanIdAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::ExtendedPanId::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeMeshLocalPrefixAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::MeshLocalPrefix::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPOctetStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeOverrunCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::OverrunCount::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeNeighborTableListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::NeighborTableList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPThreadNetworkDiagnosticsNeighborTableListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRouteTableListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RouteTableList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPThreadNetworkDiagnosticsRouteTableListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribePartitionIdAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::PartitionId::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeWeightingAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::Weighting::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeDataVersionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::DataVersion::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeStableDataVersionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::StableDataVersion::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeLeaderRouterIdAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::LeaderRouterId::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeDetachedRoleCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::DetachedRoleCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeChildRoleCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::ChildRoleCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRouterRoleCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RouterRoleCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeLeaderRoleCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::LeaderRoleCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeAttachAttemptCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::AttachAttemptCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribePartitionIdChangeCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::PartitionIdChangeCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeBetterPartitionAttachAttemptCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::BetterPartitionAttachAttemptCount::TypeInfo; + auto successFn = + chip::Callback::Callback:: + FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeParentChangeCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::ParentChangeCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxTotalCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxTotalCount::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxUnicastCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxUnicastCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxBroadcastCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxBroadcastCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxAckRequestedCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxAckRequestedCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxAckedCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxAckedCount::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxNoAckRequestedCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxNoAckRequestedCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxDataCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxDataCount::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxDataPollCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxDataPollCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxBeaconCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxBeaconCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxBeaconRequestCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxBeaconRequestCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxOtherCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxOtherCount::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxRetryCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxRetryCount::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxDirectMaxRetryExpiryCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxDirectMaxRetryExpiryCount::TypeInfo; + auto successFn = chip::Callback::Callback< + CHIPThreadNetworkDiagnosticsClusterTxDirectMaxRetryExpiryCountAttributeCallbackType>::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxIndirectMaxRetryExpiryCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxIndirectMaxRetryExpiryCount::TypeInfo; + auto successFn = chip::Callback::Callback< + CHIPThreadNetworkDiagnosticsClusterTxIndirectMaxRetryExpiryCountAttributeCallbackType>::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxErrCcaCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxErrCcaCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxErrAbortCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxErrAbortCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeTxErrBusyChannelCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::TxErrBusyChannelCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxTotalCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxTotalCount::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxUnicastCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxUnicastCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxBroadcastCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxBroadcastCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxDataCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxDataCount::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxDataPollCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxDataPollCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxBeaconCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxBeaconCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxBeaconRequestCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxBeaconRequestCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxOtherCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxOtherCount::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxAddressFilteredCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxAddressFilteredCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxDestAddrFilteredCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxDestAddrFilteredCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxDuplicatedCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxDuplicatedCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxErrNoFrameCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrNoFrameCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxErrUnknownNeighborCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrUnknownNeighborCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxErrInvalidSrcAddrCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrInvalidSrcAddrCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxErrSecCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrSecCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxErrFcsCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrFcsCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeRxErrOtherCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::RxErrOtherCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeActiveTimestampAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::ActiveTimestamp::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribePendingTimestampAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::PendingTimestamp::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeDelayAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::Delay::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeSecurityPolicyAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::SecurityPolicy::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPThreadNetworkDiagnosticsSecurityPolicyAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeChannelMaskAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::ChannelMask::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPOctetStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeOperationalDatasetComponentsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::OperationalDatasetComponents::TypeInfo; + auto successFn = chip::Callback::Callback< + CHIPThreadNetworkDiagnosticsClusterOperationalDatasetComponentsAttributeCallbackType>::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPThreadNetworkDiagnosticsOperationalDatasetComponentsAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeActiveNetworkFaultsListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::ActiveNetworkFaultsList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPThreadNetworkDiagnosticsActiveNetworkFaultsListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPThreadNetworkDiagnosticsAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeFeatureMapAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::FeatureMap::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, ThreadNetworkDiagnosticsCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::ThreadNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::ThreadNetworkDiagnostics::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, UserLabelCluster, subscribeLabelListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::UserLabelCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::UserLabel::Attributes::LabelList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPUserLabelLabelListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, UserLabelCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::UserLabelCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::UserLabel::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WakeOnLanCluster, subscribeWakeOnLanMacAddressAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WakeOnLanCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WakeOnLan::Attributes::WakeOnLanMacAddress::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPCharStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WakeOnLanCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WakeOnLanCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WakeOnLan::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPWakeOnLanAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WakeOnLanCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WakeOnLanCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WakeOnLan::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeBssidAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::Bssid::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPOctetStringAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeSecurityTypeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::SecurityType::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeWiFiVersionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::WiFiVersion::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeChannelNumberAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::ChannelNumber::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeRssiAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::Rssi::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8sAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeBeaconLostCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::BeaconLostCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeBeaconRxCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::BeaconRxCount::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribePacketMulticastRxCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::PacketMulticastRxCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribePacketMulticastTxCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::PacketMulticastTxCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribePacketUnicastRxCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::PacketUnicastRxCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribePacketUnicastTxCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::PacketUnicastTxCount::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeCurrentMaxRateAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::CurrentMaxRate::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeOverrunCountAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::OverrunCount::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt64uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::AttributeList::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPWiFiNetworkDiagnosticsAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeFeatureMapAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::FeatureMap::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WiFiNetworkDiagnosticsCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WiFiNetworkDiagnosticsCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WiFiNetworkDiagnostics::Attributes::ClusterRevision::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeTypeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::Type::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeCurrentPositionLiftAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::CurrentPositionLift::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPWindowCoveringCurrentPositionLiftAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeCurrentPositionTiltAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::CurrentPositionTilt::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPWindowCoveringCurrentPositionTiltAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeConfigStatusAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::ConfigStatus::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeCurrentPositionLiftPercentageAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::CurrentPositionLiftPercentage::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPWindowCoveringCurrentPositionLiftPercentageAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeCurrentPositionTiltPercentageAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::CurrentPositionTiltPercentage::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPWindowCoveringCurrentPositionTiltPercentageAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeOperationalStatusAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::OperationalStatus::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeTargetPositionLiftPercent100thsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::TargetPositionLiftPercent100ths::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPWindowCoveringTargetPositionLiftPercent100thsAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeTargetPositionTiltPercent100thsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::TargetPositionTiltPercent100ths::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPWindowCoveringTargetPositionTiltPercent100thsAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeEndProductTypeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::EndProductType::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeCurrentPositionLiftPercent100thsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::CurrentPositionLiftPercent100ths::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPWindowCoveringCurrentPositionLiftPercent100thsAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeCurrentPositionTiltPercent100thsAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::CurrentPositionTiltPercent100ths::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPWindowCoveringCurrentPositionTiltPercent100thsAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeInstalledOpenLimitLiftAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::InstalledOpenLimitLift::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeInstalledClosedLimitLiftAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::InstalledClosedLimitLift::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeInstalledOpenLimitTiltAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::InstalledOpenLimitTilt::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeInstalledClosedLimitTiltAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::InstalledClosedLimitTilt::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeModeAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::Mode::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeSafetyStatusAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::SafetyStatus::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeAttributeListAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(chip::Platform::New(callback, true), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::AttributeList::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPWindowCoveringAttributeListAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeFeatureMapAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::FeatureMap::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt32uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +} +JNI_METHOD(void, WindowCoveringCluster, subscribeClusterRevisionAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr onSuccess( + chip::Platform::New(callback, true), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::WindowCoveringCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + using TypeInfo = chip::app::Clusters::WindowCovering::Attributes::ClusterRevision::TypeInfo; + auto successFn = chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPInt16uAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); + + onSuccess.release(); + onFailure.release(); +}