Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecating chip_server_cluster_attributes and if_basic_global_response #25693

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integrations/docker/images/chip-cert-bins/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG COMMITHASH=7b99e6399c6069037c613782d78132c69b9dcabb
# ZAP Development install, so that it runs on both x64 and arm64
# Generally this should match with the ZAP version that is used for codegen within the
# specified SHA
ARG ZAP_VERSION=v2023.03.17-nightly
ARG ZAP_VERSION=v2023.03.22-nightly

# Ensure TARGETPLATFORM is set
RUN case ${TARGETPLATFORM} in \
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup/zap.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"mac-arm64",
"windows-amd64"
],
"tags": ["version:[email protected].17-nightly.1"]
"tags": ["version:[email protected].22-nightly.1"]
}
]
}
2 changes: 1 addition & 1 deletion scripts/tools/zap/zap_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# Use scripts/tools/zap/version_update.py to manage ZAP versioning as many
# files may need updating for versions
#
MIN_ZAP_VERSION = '2023.3.16'
MIN_ZAP_VERSION = '2023.3.22'


class ZapTool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR
using namespace app::Clusters::{{asUpperCamelCase name}};
switch (aPath.mAttributeId)
{
{{#chip_server_cluster_attributes}}
{{#zcl_attributes_server removeKeys='isOptional'}}
case Attributes::{{asUpperCamelCase name}}::Id: {
using TypeInfo = Attributes::{{asUpperCamelCase name}}::TypeInfo;
TypeInfo::DecodableType cppValue;
Expand All @@ -54,7 +54,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR
{{>decode_value target="value" source="cppValue" cluster=(asUpperCamelCase parent.name) depth=0 earlyReturn="nullptr"}}
return value;
}
{{/chip_server_cluster_attributes}}
{{/zcl_attributes_server}}
default:
*aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB;
break;
Expand Down
4 changes: 2 additions & 2 deletions src/controller/java/templates/CHIPCallbackTypes.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ typedef void (*CHIP{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase nam

{{! TODO: global response types?}}

{{#chip_server_cluster_attributes}}
{{#zcl_attributes_server}}
{{#if isArray}}
typedef void (*CHIP{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}AttributeCallbackType)(void *, const chip::app::Clusters::{{asUpperCamelCase parent.name}}::Attributes::{{asUpperCamelCase name}}::TypeInfo::DecodableType &);
{{else}}
typedef void (*CHIP{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}AttributeCallbackType)(void *, chip::app::Clusters::{{asUpperCamelCase parent.name}}::Attributes::{{asUpperCamelCase name}}::TypeInfo::DecodableArgType);
{{/if}}
{{/chip_server_cluster_attributes}}
{{/zcl_attributes_server}}
{{/chip_client_clusters}}
{{/if}}
9 changes: 5 additions & 4 deletions src/controller/java/templates/CHIPClustersWrite-JNI.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ using namespace chip;
using namespace chip::Controller;

{{#chip_client_clusters}}
{{#chip_server_cluster_attributes}}
{{#unless (isStrEqual chipCallback.name "Unsupported")}}
{{#zcl_attributes_server removeKeys='isOptional'}}
{{#if_unsupported_attribute_callback type isArray ../id}}
{{else}}
{{#if isWritableAttribute}}

JNI_METHOD(void, {{asUpperCamelCase ../name}}Cluster, write{{asUpperCamelCase name}}Attribute)(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, {{asJniBasicType type true}} value, jobject timedWriteTimeoutMs)
Expand Down Expand Up @@ -74,8 +75,8 @@ JNI_METHOD(void, {{asUpperCamelCase ../name}}Cluster, write{{asUpperCamelCase na
onFailure.release();
}
{{/if}}
{{/unless}}
{{/chip_server_cluster_attributes}}
{{/if_unsupported_attribute_callback}}
{{/zcl_attributes_server}}
{{/chip_client_clusters}}
{{/if}}

Expand Down
17 changes: 9 additions & 8 deletions src/controller/java/templates/CHIPReadCallbacks-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@ void CHIP{{chipCallback.name}}AttributeCallback::CallbackFn(void * context, {{ch
{{/chip_server_global_responses}}

{{#chip_client_clusters}}
{{#chip_server_cluster_attributes}}
{{#zcl_attributes_server removeKeys='isOptional'}}
{{! TODO: Add support for struct-typed attributes }}
{{#unless (isStrEqual chipCallback.name "Unsupported")}}
{{#if_unsupported_attribute_callback type isArray ../id}}
{{else}}

{{#if_basic_global_response}}
{{#if_basic_attribute type ../id}}
{{else}}
CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCallback::CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCallback(jobject javaCallback, bool keepAlive) :
chip::Callback::Callback<CHIP{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}AttributeCallbackType>(CallbackFn, this), keepAlive(keepAlive)
Expand All @@ -116,7 +117,7 @@ CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCallback::
}
env->DeleteGlobalRef(javaCallbackRef);
}
{{/if_basic_global_response}}
{{/if_basic_attribute}}

{{#if isArray}}
void CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCallback::CallbackFn(void * context, {{zapTypeToDecodableClusterObjectType type ns=parent.name isArgument=true}} list)
Expand Down Expand Up @@ -144,7 +145,7 @@ void CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCallb
env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj);
}
{{else}}
{{#if_basic_global_response}}
{{#if_basic_attribute type ../id}}
{{else}}
void CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCallback::CallbackFn(void * context, {{zapTypeToDecodableClusterObjectType type ns=parent.name isArgument=true}} value)
{
Expand All @@ -168,10 +169,10 @@ void CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCallb

env->CallVoidMethod(javaCallbackRef, javaMethod, javaValue);
}
{{/if_basic_global_response}}
{{/if_basic_attribute}}
{{/if}}
{{/unless}}
{{/chip_server_cluster_attributes}}
{{/if_unsupported_attribute_callback}}
{{/zcl_attributes_server}}
{{/chip_client_clusters}}

{{/if}}
13 changes: 7 additions & 6 deletions src/controller/java/templates/CHIPReadCallbacks.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ private:
{{/chip_server_global_responses}}

{{#chip_client_clusters}}
{{#chip_server_cluster_attributes}}
{{#unless (isStrEqual chipCallback.name "Unsupported")}}
{{#if_basic_global_response}}
{{#zcl_attributes_server removeKeys='isOptional'}}
{{#if_unsupported_attribute_callback type isArray ../id}}
{{else}}
{{#if_basic_attribute type ../id}}
{{else}}
class CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCallback : public chip::Callback::Callback<CHIP{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}AttributeCallbackType>
{
Expand All @@ -65,10 +66,10 @@ private:
jobject javaCallbackRef;
bool keepAlive;
};
{{/if_basic_global_response}}
{{/if_basic_attribute}}

{{/unless}}
{{/chip_server_cluster_attributes}}
{{/if_unsupported_attribute_callback}}
{{/zcl_attributes_server}}
{{/chip_client_clusters}}

{{/if}}
55 changes: 29 additions & 26 deletions src/controller/java/templates/ChipClusters-java.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@ public class ChipClusters {

{{/chip_cluster_responses}}

{{#chip_server_cluster_attributes}}
{{#unless (isStrEqual chipCallback.name "Unsupported")}}
{{#if_basic_global_response}}
{{#zcl_attributes_server removeKeys='isOptional'}}
{{#if_unsupported_attribute_callback type isArray ../id}}
{{else}}
{{#if_basic_attribute type ../id}}
{{else}}
{{! NOTE: asJavaType ends up sniffing for isArray on the context. Since we want the type of our _entry_, force isArray to
brdandu marked this conversation as resolved.
Show resolved Hide resolved
false. }}
Expand All @@ -161,19 +162,20 @@ public class ChipClusters {
default void onSubscriptionEstablished(long subscriptionId) {}
}
{{/if}}
{{/if_basic_global_response}}
{{/unless}}
{{/chip_server_cluster_attributes}}
{{#chip_server_cluster_attributes}}
{{/if_basic_attribute}}
{{/if_unsupported_attribute_callback}}
{{/zcl_attributes_server}}
{{#zcl_attributes_server removeKeys='isOptional'}}
{{! TODO: Add support for struct-typed attributes }}
{{#unless (isStrEqual chipCallback.name "Unsupported")}}
{{#if_unsupported_attribute_callback type isArray ../id}}
{{else}}

public void read{{asUpperCamelCase name}}Attribute(
{{#if_basic_global_response}}
{{convertAttributeCallbackTypeToJavaName chipCallback.type}}AttributeCallback callback
{{#if_basic_attribute type ../id}}
{{as_underlying_java_zcl_type type ../id boolean="Boolean"}}AttributeCallback callback
{{else}}
{{asUpperCamelCase name}}AttributeCallback callback
{{/if_basic_global_response}}
{{/if_basic_attribute}}
) {
read{{asUpperCamelCase name}}Attribute(chipClusterPtr, callback);
}
Expand All @@ -190,42 +192,43 @@ public class ChipClusters {
{{/if}}
{{#if isReportableAttribute}}
public void subscribe{{asCamelCased name false}}Attribute(
{{#if_basic_global_response}}
{{convertAttributeCallbackTypeToJavaName chipCallback.type}}AttributeCallback callback
{{#if_basic_attribute type ../id}}
{{as_underlying_java_zcl_type type ../id boolean="Boolean"}}AttributeCallback callback
{{else}}
{{asUpperCamelCase name}}AttributeCallback callback
{{/if_basic_global_response}},
{{/if_basic_attribute}},
int minInterval, int maxInterval) {
subscribe{{asCamelCased name false}}Attribute(chipClusterPtr, callback, minInterval, maxInterval);
}
{{/if}}
{{/unless}}
{{/chip_server_cluster_attributes}}
{{#chip_server_cluster_attributes}}
{{/if_unsupported_attribute_callback}}
{{/zcl_attributes_server}}
{{#zcl_attributes_server removeKeys='isOptional'}}
{{! TODO: Add support for struct-typed attributes }}
{{#unless (isStrEqual chipCallback.name "Unsupported")}}
{{#if_unsupported_attribute_callback type isArray ../id }}
{{else}}

private native void read{{asUpperCamelCase name}}Attribute(long chipClusterPtr,
{{#if_basic_global_response}}
{{convertAttributeCallbackTypeToJavaName chipCallback.type}}AttributeCallback callback
{{#if_basic_attribute type ../id}}
{{as_underlying_java_zcl_type type ../id boolean="Boolean"}}AttributeCallback callback
{{else}}
{{asUpperCamelCase name}}AttributeCallback callback
{{/if_basic_global_response}}
{{/if_basic_attribute}}
);
{{#if isWritableAttribute}}

private native void write{{asUpperCamelCase name}}Attribute(long chipClusterPtr, DefaultClusterCallback callback, {{asJavaType type chipType parent.name}} value, @Nullable Integer timedWriteTimeoutMs);
{{/if}}
{{#if isReportableAttribute}}
private native void subscribe{{asCamelCased name false}}Attribute(long chipClusterPtr,
{{#if_basic_global_response}}
{{convertAttributeCallbackTypeToJavaName chipCallback.type}}AttributeCallback callback
{{#if_basic_attribute type ../id}}
{{as_underlying_java_zcl_type type ../id boolean="Boolean"}}AttributeCallback callback
{{else}}
{{asUpperCamelCase name}}AttributeCallback callback
{{/if_basic_global_response}}, int minInterval, int maxInterval);
{{/if_basic_attribute}}, int minInterval, int maxInterval);
{{/if}}
{{/unless}}
{{/chip_server_cluster_attributes}}
{{/if_unsupported_attribute_callback}}
{{/zcl_attributes_server}}
}
{{#not_last}}

Expand Down
4 changes: 2 additions & 2 deletions src/controller/java/templates/ChipIdLookup-java.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public final class ChipIdLookup {
public static String attributeIdToName(long clusterId, long attributeId) {
{{#chip_client_clusters}}
if (clusterId == {{code}}L) {
{{#chip_server_cluster_attributes}}
{{#zcl_attributes_server}}
if (attributeId == {{code}}L) {
return "{{asUpperCamelCase name}}";
}
{{/chip_server_cluster_attributes}}
{{/zcl_attributes_server}}
return "";
}
{{/chip_client_clusters}}
Expand Down
13 changes: 7 additions & 6 deletions src/controller/java/templates/ClusterInfo-java.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,10 @@ public class ClusterInfoMapping {
}

{{/chip_cluster_responses}}
{{#chip_server_cluster_attributes}}
{{#unless (isStrEqual chipCallback.name "Unsupported")}}
{{#if_basic_global_response}}
{{#zcl_attributes_server removeKeys='isOptional'}}
{{#if_unsupported_attribute_callback type isArray ../id}}
{{else}}
{{#if_basic_attribute type ../id}}
{{else}}
public static class Delegated{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}AttributeCallback implements ChipClusters.{{asUpperCamelCase ../name}}Cluster.{{asUpperCamelCase name}}AttributeCallback, DelegatedClusterCallback {
brdandu marked this conversation as resolved.
Show resolved Hide resolved
private ClusterCommandCallback callback;
Expand Down Expand Up @@ -270,9 +271,9 @@ public class ClusterInfoMapping {
callback.onFailure(ex);
}
}
{{/if_basic_global_response}}
{{/unless}}
{{/chip_server_cluster_attributes}}
{{/if_basic_attribute}}
{{/if_unsupported_attribute_callback}}
{{/zcl_attributes_server}}

{{/chip_client_clusters}}

Expand Down
21 changes: 11 additions & 10 deletions src/controller/java/templates/ClusterInfo-read-interaction.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,31 @@ public class ClusterReadMapping {
Map<String, Map<String, InteractionInfo>> readAttributeMap = new HashMap<>();
{{#chip_client_clusters}}
Map<String, InteractionInfo> read{{asUpperCamelCase name}}InteractionInfo = new LinkedHashMap<>();
{{#chip_server_cluster_attributes}}
{{#zcl_attributes_server removeKeys='isOptional'}}
{{! TODO: Add support for struct-typed attributes }}
{{#unless (isStrEqual chipCallback.name "Unsupported")}}
{{#if_unsupported_attribute_callback type isArray ../id}}
{{else}}
Map<String, CommandParameterInfo> read{{asUpperCamelCase ../name}}{{asUpperCamelCase name}}CommandParams = new LinkedHashMap<String, CommandParameterInfo>();
InteractionInfo read{{asUpperCamelCase ../name}}{{asUpperCamelCase name}}AttributeInteractionInfo = new InteractionInfo(
(cluster, callback, commandArguments) -> {
((ChipClusters.{{asUpperCamelCase ../name}}Cluster) cluster).read{{asUpperCamelCase name}}Attribute(
({{#if_basic_global_response}}
ChipClusters.{{convertAttributeCallbackTypeToJavaName chipCallback.type}}AttributeCallback
({{#if_basic_attribute type ../id}}
ChipClusters.{{as_underlying_java_zcl_type type ../id boolean="Boolean"}}AttributeCallback
{{else}}
ChipClusters.{{asUpperCamelCase ../name}}Cluster.{{asUpperCamelCase name}}AttributeCallback
{{/if_basic_global_response}}) callback
{{/if_basic_attribute}}) callback
);
},
{{#if_basic_global_response}}
() -> new ClusterInfoMapping.Delegated{{convertAttributeCallbackTypeToJavaName chipCallback.type}}AttributeCallback(),
{{#if_basic_attribute type ../id}}
() -> new ClusterInfoMapping.Delegated{{as_underlying_java_zcl_type type ../id boolean="Boolean"}}AttributeCallback(),
{{else}}
() -> new ClusterInfoMapping.Delegated{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}AttributeCallback(),
{{/if_basic_global_response}}
{{/if_basic_attribute}}
read{{asUpperCamelCase ../name}}{{asUpperCamelCase name}}CommandParams
);
read{{asUpperCamelCase ../name}}InteractionInfo.put("read{{asUpperCamelCase name}}Attribute", read{{asUpperCamelCase ../name}}{{asUpperCamelCase name}}AttributeInteractionInfo);
{{/unless}}
{{/chip_server_cluster_attributes}}
{{/if_unsupported_attribute_callback}}
{{/zcl_attributes_server}}
readAttributeMap.put("{{asLowerCamelCase name}}", read{{asUpperCamelCase name}}InteractionInfo);
{{/chip_client_clusters}}
return readAttributeMap;
Expand Down
Loading