Skip to content

Commit 3911107

Browse files
andy31415andreilitvin
authored andcommitted
Use zcl_clusters to loop over clusters for controller_clusters.zap (#26617)
* split out client cluster generation for IDL client and server * Update to use client-side codegen and correct loop definition for matter_idl_client * make generation work * Fix typo * Update spacing to match what we had before * Ran zap_regen_all * regen all again ... to get java changes * Regen java files for devicecontroller * update dependencies in chip_codegen.cmake * Application templates do not actually depend on IDL anymore - IDL codegen is separate * Fix up the expected java output files * Update java to not use CHIPClusters and only use ClusterBase * Move callbacks to zcl_clusters as well * remove conditional from callbacks src * Switch one more file to use zcl_clusters * Switch to zcl_clusters for a LOT of java templates * unit test update --------- Co-authored-by: Andrei Litvin <[email protected]>
1 parent 9f7b583 commit 3911107

File tree

49 files changed

+9513
-2729
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+9513
-2729
lines changed

build/chip/chip_codegen.cmake

-6
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,13 @@ function(chip_zapgen TARGET_NAME)
162162
# out links of template files and zap files and such
163163
SET(EXTRA_DEPENDENCIES
164164
"${CHIP_ROOT}/src/app/zap-templates/partials/header.zapt"
165-
"${CHIP_ROOT}/src/app/zap-templates/partials/idl/command_request_response.zapt"
166-
"${CHIP_ROOT}/src/app/zap-templates/partials/idl/command_request_struct.zapt"
167-
"${CHIP_ROOT}/src/app/zap-templates/partials/idl/command_response_struct.zapt"
168-
"${CHIP_ROOT}/src/app/zap-templates/partials/idl/structure_definition.zapt"
169-
"${CHIP_ROOT}/src/app/zap-templates/partials/idl/structure_member.zapt"
170165
"${CHIP_ROOT}/src/app/zap-templates/partials/im_command_handler_cluster_commands.zapt"
171166
"${CHIP_ROOT}/src/app/zap-templates/templates/app/access.zapt"
172167
"${CHIP_ROOT}/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt"
173168
"${CHIP_ROOT}/src/app/zap-templates/templates/app/CHIPClusters.zapt"
174169
"${CHIP_ROOT}/src/app/zap-templates/templates/app/endpoint_config.zapt"
175170
"${CHIP_ROOT}/src/app/zap-templates/templates/app/gen_config.zapt"
176171
"${CHIP_ROOT}/src/app/zap-templates/templates/app/im-cluster-command-handler.zapt"
177-
"${CHIP_ROOT}/src/app/zap-templates/templates/app/MatterIDL.zapt"
178172
)
179173
SET(OUTPUT_SUBDIR "zap-generated")
180174
else()

scripts/py_matter_idl/matter_idl/generators/java/ChipClustersCpp.jinja

+11-9
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@
8686

8787
#include <jni/CHIPCallbackTypes.h>
8888
#include <jni/CHIPReadCallbacks.h>
89+
#include <controller/CHIPCluster.h>
8990
#include <controller/java/zap-generated/CHIPInvokeCallbacks.h>
9091

9192
#include <app-common/zap-generated/cluster-objects.h>
9293
#include <zap-generated/CHIPClientCallbacks.h>
93-
#include <zap-generated/CHIPClusters.h>
9494

9595
#include <controller/java/AndroidCallbacks.h>
9696
#include <controller/java/AndroidClusterExceptions.h>
@@ -104,17 +104,19 @@
104104
#include <platform/PlatformManager.h>
105105
#include <vector>
106106

107+
#include <jni/CHIPCallbackTypes.h>
108+
107109
#define JNI_METHOD(RETURN, CLASS_NAME, METHOD_NAME) \
108110
extern "C" JNIEXPORT RETURN JNICALL Java_chip_devicecontroller_ChipClusters_00024##CLASS_NAME##_##METHOD_NAME
109111

110112
using namespace chip;
111-
using namespace chip::Controller;
113+
using chip::Controller::ClusterBase;
112114

113115
JNI_METHOD(jlong, {{cluster.name | capitalcase}}Cluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId)
114116
{
115117
chip::DeviceLayer::StackLock lock;
116118
DeviceProxy * device = reinterpret_cast<DeviceProxy *>(devicePtr);
117-
{{cluster.name | capitalcase}}Cluster * cppCluster = new {{cluster.name | capitalcase}}Cluster(*device->GetExchangeManager(), device->GetSecureSession().Value(), endpointId);
119+
ClusterBase * cppCluster = new ClusterBase(*device->GetExchangeManager(), device->GetSecureSession().Value(), endpointId);
118120
return reinterpret_cast<jlong>(cppCluster);
119121
}
120122

@@ -131,8 +133,8 @@ JNI_METHOD(void, {{cluster.name | capitalcase}}Cluster,
131133
{
132134
chip::DeviceLayer::StackLock lock;
133135
CHIP_ERROR err = CHIP_NO_ERROR;
134-
{{cluster.name | capitalcase}}Cluster * cppCluster;
135-
136+
ClusterBase * cppCluster;
137+
136138
ListFreer listFreer;
137139
chip::app::Clusters::{{cluster.name | capitalcase}}::Commands::{{command.name | capitalcase}}::Type request;
138140

@@ -142,8 +144,8 @@ JNI_METHOD(void, {{cluster.name | capitalcase}}Cluster,
142144
{%- for field in (cluster.structs | named(command.input_param)).fields -%}
143145
{{ encode_value(
144146
"request." + (field.name | lowercaseFirst),
145-
(field.name | lowercaseFirst),
146-
0,
147+
(field.name | lowercaseFirst),
148+
0,
147149
field | asEncodable(typeLookup)
148150
)}}
149151
{%- endfor -%}
@@ -156,7 +158,7 @@ JNI_METHOD(void, {{cluster.name | capitalcase}}Cluster,
156158
VerifyOrReturn(onSuccess.get() != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY));
157159
VerifyOrReturn(onFailure.get() != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY));
158160

159-
cppCluster = reinterpret_cast<{{cluster.name | capitalcase}}Cluster *>(clusterPtr);
161+
cppCluster = reinterpret_cast<ClusterBase *>(clusterPtr);
160162
VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE));
161163

162164
auto successFn = chip::Callback::Callback<CHIP{{callbackName}}CallbackType>::FromCancelable(onSuccess->Cancel());
@@ -194,7 +196,7 @@ JNI_METHOD(void, {{cluster.name}}Cluster, subscribe{{attr.definition.name | capi
194196
VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY));
195197

196198
CHIP_ERROR err = CHIP_NO_ERROR;
197-
{{cluster.name}}Cluster * cppCluster = reinterpret_cast<{{cluster.name}}Cluster *>(clusterPtr);
199+
ClusterBase * cppCluster = reinterpret_cast<ClusterBase *>(clusterPtr);
198200
VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE));
199201

200202
using TypeInfo = chip::app::Clusters::{{cluster.name}}::Attributes::{{attr.definition.name | capitalcase}}::TypeInfo;

scripts/py_matter_idl/matter_idl/generators/java/ChipClustersRead.jinja

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <jni/CHIPReadCallbacks.h>
1616

1717
#include <app-common/zap-generated/cluster-objects.h>
18-
#include <zap-generated/CHIPClusters.h>
18+
#include <controller/CHIPCluster.h>
1919

2020
#include <controller/java/AndroidClusterExceptions.h>
2121
#include <controller/java/CHIPDefaultCallbacks.h>
@@ -39,7 +39,7 @@ JNI_METHOD(void, {{cluster.name | capitalcase}}Cluster, read{{attr.definition.na
3939
VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY));
4040

4141
CHIP_ERROR err = CHIP_NO_ERROR;
42-
chip::Controller::{{cluster.name | capitalcase}}Cluster * cppCluster = reinterpret_cast<chip::Controller::{{cluster.name | capitalcase }}Cluster *>(clusterPtr);
42+
chip::Controller::ClusterBase * cppCluster = reinterpret_cast<chip::Controller::ClusterBase *>(clusterPtr);
4343
VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE));
4444

4545
auto successFn = chip::Callback::Callback<CHIP{{cluster.name | capitalcase}}Cluster{{attr.definition.name | capitalcase}}AttributeCallbackType>::FromCancelable(onSuccess->Cancel());

scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include <jni/CHIPCallbackTypes.h>
22
#include <jni/CHIPReadCallbacks.h>
3+
#include <controller/CHIPCluster.h>
34
#include <controller/java/zap-generated/CHIPInvokeCallbacks.h>
45

56
#include <app-common/zap-generated/cluster-objects.h>
67
#include <zap-generated/CHIPClientCallbacks.h>
7-
#include <zap-generated/CHIPClusters.h>
88

99
#include <controller/java/AndroidCallbacks.h>
1010
#include <controller/java/AndroidClusterExceptions.h>
@@ -18,17 +18,19 @@
1818
#include <platform/PlatformManager.h>
1919
#include <vector>
2020

21+
#include <jni/CHIPCallbackTypes.h>
22+
2123
#define JNI_METHOD(RETURN, CLASS_NAME, METHOD_NAME) \
2224
extern "C" JNIEXPORT RETURN JNICALL Java_chip_devicecontroller_ChipClusters_00024##CLASS_NAME##_##METHOD_NAME
2325

2426
using namespace chip;
25-
using namespace chip::Controller;
27+
using chip::Controller::ClusterBase;
2628

2729
JNI_METHOD(jlong, DemoClusterCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId)
2830
{
2931
chip::DeviceLayer::StackLock lock;
3032
DeviceProxy * device = reinterpret_cast<DeviceProxy *>(devicePtr);
31-
DemoClusterCluster * cppCluster = new DemoClusterCluster(*device->GetExchangeManager(), device->GetSecureSession().Value(), endpointId);
33+
ClusterBase * cppCluster = new ClusterBase(*device->GetExchangeManager(), device->GetSecureSession().Value(), endpointId);
3234
return reinterpret_cast<jlong>(cppCluster);
3335
}
3436

@@ -41,7 +43,7 @@ JNI_METHOD(void, DemoClusterCluster, subscribeArmFailsafesAttribute)(JNIEnv * en
4143
VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY));
4244

4345
CHIP_ERROR err = CHIP_NO_ERROR;
44-
DemoClusterCluster * cppCluster = reinterpret_cast<DemoClusterCluster *>(clusterPtr);
46+
ClusterBase * cppCluster = reinterpret_cast<ClusterBase *>(clusterPtr);
4547
VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE));
4648

4749
using TypeInfo = chip::app::Clusters::DemoCluster::Attributes::ArmFailsafes::TypeInfo;

scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <jni/CHIPReadCallbacks.h>
33

44
#include <app-common/zap-generated/cluster-objects.h>
5-
#include <zap-generated/CHIPClusters.h>
5+
#include <controller/CHIPCluster.h>
66

77
#include <controller/java/AndroidClusterExceptions.h>
88
#include <controller/java/CHIPDefaultCallbacks.h>
@@ -23,7 +23,7 @@ JNI_METHOD(void, DemoClusterCluster, readArmFailsafesAttribute)(JNIEnv * env, jo
2323
VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY));
2424

2525
CHIP_ERROR err = CHIP_NO_ERROR;
26-
chip::Controller::DemoClusterCluster * cppCluster = reinterpret_cast<chip::Controller::DemoClusterCluster *>(clusterPtr);
26+
chip::Controller::ClusterBase * cppCluster = reinterpret_cast<chip::Controller::ClusterBase *>(clusterPtr);
2727
VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE));
2828

2929
auto successFn = chip::Callback::Callback<CHIPDemoClusterClusterArmFailsafesAttributeCallbackType>::FromCancelable(onSuccess->Cancel());

scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include <jni/CHIPCallbackTypes.h>
22
#include <jni/CHIPReadCallbacks.h>
3+
#include <controller/CHIPCluster.h>
34
#include <controller/java/zap-generated/CHIPInvokeCallbacks.h>
45

56
#include <app-common/zap-generated/cluster-objects.h>
67
#include <zap-generated/CHIPClientCallbacks.h>
7-
#include <zap-generated/CHIPClusters.h>
88

99
#include <controller/java/AndroidCallbacks.h>
1010
#include <controller/java/AndroidClusterExceptions.h>
@@ -18,17 +18,19 @@
1818
#include <platform/PlatformManager.h>
1919
#include <vector>
2020

21+
#include <jni/CHIPCallbackTypes.h>
22+
2123
#define JNI_METHOD(RETURN, CLASS_NAME, METHOD_NAME) \
2224
extern "C" JNIEXPORT RETURN JNICALL Java_chip_devicecontroller_ChipClusters_00024##CLASS_NAME##_##METHOD_NAME
2325

2426
using namespace chip;
25-
using namespace chip::Controller;
27+
using chip::Controller::ClusterBase;
2628

2729
JNI_METHOD(jlong, DemoClusterCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId)
2830
{
2931
chip::DeviceLayer::StackLock lock;
3032
DeviceProxy * device = reinterpret_cast<DeviceProxy *>(devicePtr);
31-
DemoClusterCluster * cppCluster = new DemoClusterCluster(*device->GetExchangeManager(), device->GetSecureSession().Value(), endpointId);
33+
ClusterBase * cppCluster = new ClusterBase(*device->GetExchangeManager(), device->GetSecureSession().Value(), endpointId);
3234
return reinterpret_cast<jlong>(cppCluster);
3335
}
3436

@@ -41,7 +43,7 @@ JNI_METHOD(void, DemoClusterCluster, subscribeSomeLabelsAttribute)(JNIEnv * env,
4143
VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY));
4244

4345
CHIP_ERROR err = CHIP_NO_ERROR;
44-
DemoClusterCluster * cppCluster = reinterpret_cast<DemoClusterCluster *>(clusterPtr);
46+
ClusterBase * cppCluster = reinterpret_cast<ClusterBase *>(clusterPtr);
4547
VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE));
4648

4749
using TypeInfo = chip::app::Clusters::DemoCluster::Attributes::SomeLabels::TypeInfo;

scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <jni/CHIPReadCallbacks.h>
33

44
#include <app-common/zap-generated/cluster-objects.h>
5-
#include <zap-generated/CHIPClusters.h>
5+
#include <controller/CHIPCluster.h>
66

77
#include <controller/java/AndroidClusterExceptions.h>
88
#include <controller/java/CHIPDefaultCallbacks.h>
@@ -23,7 +23,7 @@ JNI_METHOD(void, DemoClusterCluster, readSomeLabelsAttribute)(JNIEnv * env, jobj
2323
VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY));
2424

2525
CHIP_ERROR err = CHIP_NO_ERROR;
26-
chip::Controller::DemoClusterCluster * cppCluster = reinterpret_cast<chip::Controller::DemoClusterCluster *>(clusterPtr);
26+
chip::Controller::ClusterBase * cppCluster = reinterpret_cast<chip::Controller::ClusterBase *>(clusterPtr);
2727
VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE));
2828

2929
auto successFn = chip::Callback::Callback<CHIPDemoClusterClusterSomeLabelsAttributeCallbackType>::FromCancelable(onSuccess->Cancel());

scripts/py_matter_idl/matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include <jni/CHIPCallbackTypes.h>
22
#include <jni/CHIPReadCallbacks.h>
3+
#include <controller/CHIPCluster.h>
34
#include <controller/java/zap-generated/CHIPInvokeCallbacks.h>
45

56
#include <app-common/zap-generated/cluster-objects.h>
67
#include <zap-generated/CHIPClientCallbacks.h>
7-
#include <zap-generated/CHIPClusters.h>
88

99
#include <controller/java/AndroidCallbacks.h>
1010
#include <controller/java/AndroidClusterExceptions.h>
@@ -18,17 +18,19 @@
1818
#include <platform/PlatformManager.h>
1919
#include <vector>
2020

21+
#include <jni/CHIPCallbackTypes.h>
22+
2123
#define JNI_METHOD(RETURN, CLASS_NAME, METHOD_NAME) \
2224
extern "C" JNIEXPORT RETURN JNICALL Java_chip_devicecontroller_ChipClusters_00024##CLASS_NAME##_##METHOD_NAME
2325

2426
using namespace chip;
25-
using namespace chip::Controller;
27+
using chip::Controller::ClusterBase;
2628

2729
JNI_METHOD(jlong, MyClusterCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId)
2830
{
2931
chip::DeviceLayer::StackLock lock;
3032
DeviceProxy * device = reinterpret_cast<DeviceProxy *>(devicePtr);
31-
MyClusterCluster * cppCluster = new MyClusterCluster(*device->GetExchangeManager(), device->GetSecureSession().Value(), endpointId);
33+
ClusterBase * cppCluster = new ClusterBase(*device->GetExchangeManager(), device->GetSecureSession().Value(), endpointId);
3234
return reinterpret_cast<jlong>(cppCluster);
3335
}
3436

@@ -37,8 +39,8 @@ JNI_METHOD(void, MyClusterCluster,
3739
{
3840
chip::DeviceLayer::StackLock lock;
3941
CHIP_ERROR err = CHIP_NO_ERROR;
40-
MyClusterCluster * cppCluster;
41-
42+
ClusterBase * cppCluster;
43+
4244
ListFreer listFreer;
4345
chip::app::Clusters::MyCluster::Commands::Foo::Type request;
4446

@@ -60,7 +62,7 @@ JNI_METHOD(void, MyClusterCluster,
6062
VerifyOrReturn(onSuccess.get() != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY));
6163
VerifyOrReturn(onFailure.get() != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native callback", CHIP_ERROR_NO_MEMORY));
6264

63-
cppCluster = reinterpret_cast<MyClusterCluster *>(clusterPtr);
65+
cppCluster = reinterpret_cast<ClusterBase *>(clusterPtr);
6466
VerifyOrReturn(cppCluster != nullptr, AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error getting native cluster", CHIP_ERROR_INCORRECT_STATE));
6567

6668
auto successFn = chip::Callback::Callback<CHIPDefaultSuccessCallbackType>::FromCancelable(onSuccess->Cancel());

scripts/py_matter_idl/matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <jni/CHIPReadCallbacks.h>
33

44
#include <app-common/zap-generated/cluster-objects.h>
5-
#include <zap-generated/CHIPClusters.h>
5+
#include <controller/CHIPCluster.h>
66

77
#include <controller/java/AndroidClusterExceptions.h>
88
#include <controller/java/CHIPDefaultCallbacks.h>

scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include <jni/CHIPCallbackTypes.h>
22
#include <jni/CHIPReadCallbacks.h>
3+
#include <controller/CHIPCluster.h>
34
#include <controller/java/zap-generated/CHIPInvokeCallbacks.h>
45

56
#include <app-common/zap-generated/cluster-objects.h>
67
#include <zap-generated/CHIPClientCallbacks.h>
7-
#include <zap-generated/CHIPClusters.h>
88

99
#include <controller/java/AndroidCallbacks.h>
1010
#include <controller/java/AndroidClusterExceptions.h>
@@ -18,17 +18,19 @@
1818
#include <platform/PlatformManager.h>
1919
#include <vector>
2020

21+
#include <jni/CHIPCallbackTypes.h>
22+
2123
#define JNI_METHOD(RETURN, CLASS_NAME, METHOD_NAME) \
2224
extern "C" JNIEXPORT RETURN JNICALL Java_chip_devicecontroller_ChipClusters_00024##CLASS_NAME##_##METHOD_NAME
2325

2426
using namespace chip;
25-
using namespace chip::Controller;
27+
using chip::Controller::ClusterBase;
2628

2729
JNI_METHOD(jlong, FirstCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId)
2830
{
2931
chip::DeviceLayer::StackLock lock;
3032
DeviceProxy * device = reinterpret_cast<DeviceProxy *>(devicePtr);
31-
FirstCluster * cppCluster = new FirstCluster(*device->GetExchangeManager(), device->GetSecureSession().Value(), endpointId);
33+
ClusterBase * cppCluster = new ClusterBase(*device->GetExchangeManager(), device->GetSecureSession().Value(), endpointId);
3234
return reinterpret_cast<jlong>(cppCluster);
3335
}
3436

@@ -41,7 +43,7 @@ JNI_METHOD(void, FirstCluster, subscribeSomeIntegerAttribute)(JNIEnv * env, jobj
4143
VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY));
4244

4345
CHIP_ERROR err = CHIP_NO_ERROR;
44-
FirstCluster * cppCluster = reinterpret_cast<FirstCluster *>(clusterPtr);
46+
ClusterBase * cppCluster = reinterpret_cast<ClusterBase *>(clusterPtr);
4547
VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE));
4648

4749
using TypeInfo = chip::app::Clusters::First::Attributes::SomeInteger::TypeInfo;

scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <jni/CHIPReadCallbacks.h>
33

44
#include <app-common/zap-generated/cluster-objects.h>
5-
#include <zap-generated/CHIPClusters.h>
5+
#include <controller/CHIPCluster.h>
66

77
#include <controller/java/AndroidClusterExceptions.h>
88
#include <controller/java/CHIPDefaultCallbacks.h>
@@ -23,7 +23,7 @@ JNI_METHOD(void, FirstCluster, readSomeIntegerAttribute)(JNIEnv * env, jobject s
2323
VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY));
2424

2525
CHIP_ERROR err = CHIP_NO_ERROR;
26-
chip::Controller::FirstCluster * cppCluster = reinterpret_cast<chip::Controller::FirstCluster *>(clusterPtr);
26+
chip::Controller::ClusterBase * cppCluster = reinterpret_cast<chip::Controller::ClusterBase *>(clusterPtr);
2727
VerifyOrReturn(cppCluster != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE));
2828

2929
auto successFn = chip::Callback::Callback<CHIPFirstClusterSomeIntegerAttributeCallbackType>::FromCancelable(onSuccess->Cancel());

0 commit comments

Comments
 (0)