Skip to content

Commit

Permalink
Modify ClusterInfo Mapping (#25098)
Browse files Browse the repository at this point in the history
  • Loading branch information
joonhaengHeo authored and pull[bot] committed Feb 1, 2024
1 parent b798559 commit 2210660
Show file tree
Hide file tree
Showing 5 changed files with 5,578 additions and 1,396 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,9 @@ class ClusterDetailFragment : Fragment() {
val clusterCallbackTypeTv: TextView = callbackItem.findViewById(R.id.clusterCallbackTypeTv)

clusterCallbackNameTv.text = variableNameType.name
clusterCallbackDataTv.text = if (response.javaClass == ByteArray::class.java) {
clusterCallbackDataTv.text = if (response == null) {
"null"
} else if (response.javaClass == ByteArray::class.java) {
(response as ByteArray).decodeToString()
} else {
response.toString()
Expand Down
20 changes: 14 additions & 6 deletions src/controller/java/templates/ClusterInfo-java.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,9 @@ public class ClusterInfoMapping {

{{/chip_cluster_responses}}
{{#chip_server_cluster_attributes}}
{{#if isArray}}
{{#if isStruct}}

{{/if}}

{{#unless (isStrEqual chipCallback.name "Unsupported")}}
{{#if_basic_global_response}}
{{else}}
public static class Delegated{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}AttributeCallback implements ChipClusters.{{asUpperCamelCase ../name}}Cluster.{{asUpperCamelCase name}}AttributeCallback, DelegatedClusterCallback {
private ClusterCommandCallback callback;
@Override
Expand All @@ -252,18 +250,28 @@ public class ClusterInfoMapping {
false. }}
{{~#*inline "asJavaTypeForEntry"}}{{asJavaType type null parent.name forceNotList=true}}{{/inline~}}
@Override
{{#if isArray}}
public void onSuccess({{#if isNullable}}@Nullable{{/if}} List<{{> asJavaTypeForEntry isArray=false}}> valueList) {
Map<CommandResponseInfo, Object> responseValues = new LinkedHashMap<>();
CommandResponseInfo commandResponseInfo = new CommandResponseInfo("valueList", "List<{{> asJavaTypeForEntry isArray=false}}>");
responseValues.put(commandResponseInfo, valueList);
callback.onSuccess(responseValues);
}
{{else}}
public void onSuccess({{#if isNullable}}@Nullable{{/if}} {{>asJavaTypeForEntry isArray=false}} value) {
Map<CommandResponseInfo, Object> responseValues = new LinkedHashMap<>();
CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "{{> asJavaTypeForEntry isArray=false}}");
responseValues.put(commandResponseInfo, value);
callback.onSuccess(responseValues);
}
{{/if}}
@Override
public void onError(Exception ex) {
callback.onFailure(ex);
}
}
{{/if}}
{{/if_basic_global_response}}
{{/unless}}
{{/chip_server_cluster_attributes}}

{{/chip_client_clusters}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public class ClusterReadMapping {
{{/if_basic_global_response}}) callback
);
},
{{#if isArray}}
() -> new ClusterInfoMapping.Delegated{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}AttributeCallback(),
{{else}}
{{#if_basic_global_response}}
() -> new ClusterInfoMapping.Delegated{{convertAttributeCallbackTypeToJavaName chipCallback.type}}AttributeCallback(),
{{/if}}
{{else}}
() -> new ClusterInfoMapping.Delegated{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}AttributeCallback(),
{{/if_basic_global_response}}
read{{asUpperCamelCase ../name}}{{asUpperCamelCase name}}CommandParams
);
read{{asUpperCamelCase ../name}}InteractionInfo.put("read{{asUpperCamelCase name}}Attribute", read{{asUpperCamelCase ../name}}{{asUpperCamelCase name}}AttributeInteractionInfo);
Expand Down
Loading

0 comments on commit 2210660

Please sign in to comment.