blob: e655cc97c353080c90f7b60f7bb3f1891da79676 [file]
{{> header}}
{{#if (chip_has_client_clusters)}}
package chip.devicecontroller;
import java.util.List;
public class ChipClusters {
public interface DefaultClusterCallback {
void onSuccess();
void onError(Exception error);
}
public interface CharStringAttributeCallback {
/** Indicates a successful read for a CHAR_STRING attribute. */
void onSuccess(String value);
void onError(Exception error);
}
public interface OctetStringAttributeCallback {
/** Indicates a successful read for an OCTET_STRING attribute. */
void onSuccess(byte[] value);
void onError(Exception error);
}
public interface IntegerAttributeCallback {
void onSuccess(int value);
void onError(Exception error);
}
public interface LongAttributeCallback {
void onSuccess(long value);
void onError(Exception error);
}
public interface BooleanAttributeCallback {
void onSuccess(boolean value);
void onError(Exception error);
}
public static abstract class BaseChipCluster {
protected long chipClusterPtr;
public BaseChipCluster(long devicePtr, int endpointId) {
chipClusterPtr = initWithDevice(devicePtr, endpointId);
}
public abstract long initWithDevice(long devicePtr, int endpointId);
public native void deleteCluster(long chipClusterPtr);
@SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
super.finalize();
if (chipClusterPtr != 0) {
deleteCluster(chipClusterPtr);
chipClusterPtr = 0;
}
}
}
{{#chip_client_clusters}}
public static class {{asCamelCased name false}}Cluster extends BaseChipCluster {
public {{asCamelCased name false}}Cluster(long devicePtr, int endpointId) {
super(devicePtr, endpointId);
}
@Override
public native long initWithDevice(long devicePtr, int endpointId);
{{#chip_server_cluster_commands}}
{{#if (zcl_command_arguments_count this.id)}}
public void {{asCamelCased name}}({{#if hasSpecificResponse}}{{asCamelCased responseName false}}Callback{{else}}DefaultClusterCallback{{/if}} callback, {{#chip_server_cluster_command_arguments}}{{asJavaBasicType type}} {{asCamelCased label}}{{#unless (isLastElement index count)}}, {{/unless}}{{/chip_server_cluster_command_arguments}}) {
{{else}}
public void {{asCamelCased name}}({{#if hasSpecificResponse}}{{asCamelCased responseName false}}Callback{{else}}DefaultClusterCallback{{/if}} callback) {
{{/if}}
{{#if (zcl_command_arguments_count this.id)}}
{{asCamelCased name}}(chipClusterPtr, callback, {{#chip_server_cluster_command_arguments}}{{asCamelCased label}}{{#unless (isLastElement index count)}}, {{/unless}}{{/chip_server_cluster_command_arguments}});
{{else}}
{{asCamelCased name}}(chipClusterPtr, callback);
{{/if}}
}
{{/chip_server_cluster_commands}}
{{#chip_server_cluster_commands}}
{{#if (zcl_command_arguments_count this.id)}}
private native void {{asCamelCased name}}(long chipClusterPtr, {{#if hasSpecificResponse}}{{asCamelCased responseName false}}Callback{{else}}DefaultClusterCallback{{/if}} callback, {{#chip_server_cluster_command_arguments}}{{asJavaBasicType type}} {{asCamelCased label}}{{#unless (isLastElement index count)}}, {{/unless}}{{/chip_server_cluster_command_arguments}});
{{else}}
private native void {{asCamelCased name}}(long chipClusterPtr, {{#if hasSpecificResponse}}{{asCamelCased responseName false}}Callback{{else}}DefaultClusterCallback{{/if}} callback);
{{/if}}
{{/chip_server_cluster_commands}}
{{#chip_server_cluster_responses}}
public interface {{asCamelCased name false}}Callback {
void onSuccess(
{{#chip_server_cluster_response_arguments}}
{{#unless (isStrEqual label "status")}}
{{#if isArray}}
// {{asSymbol label}}: {{asUnderlyingZclType type}}
// Conversion from this type to Java is not properly implemented yet
{{else if (isOctetString type)}}
{{omitCommaForFirstNonStatusCommand parent.id index}}byte[] {{asSymbol label}}
{{else if (isShortString type)}}
{{omitCommaForFirstNonStatusCommand parent.id index}}String {{asSymbol label}}
{{else}}
{{omitCommaForFirstNonStatusCommand parent.id index}}{{asJavaBasicTypeForZclType type false}} {{asSymbol label}}
{{/if}}
{{/unless}}
{{/chip_server_cluster_response_arguments}}
);
void onError(Exception error);
}
{{/chip_server_cluster_responses}}
{{#chip_server_cluster_attributes}}
{{#if isList}}
{{#if isStruct}}
public static class {{asCamelCased name false}}Attribute {
{{#chip_attribute_list_entryTypes}}
{{#if (isOctetString type)}}
public byte[] {{asCamelCased name true}};
{{else if (isCharString type)}}
// Add String member here after ByteSpan is properly emitted in C++ layer
{{else}}
public {{asJavaBasicType label type}} {{asCamelCased name true}};
{{/if}}
{{/chip_attribute_list_entryTypes}}
public {{asCamelCased name false}}Attribute(
{{#chip_attribute_list_entryTypes}}
{{#if (isOctetString type)}}
byte[] {{asCamelCased name true}}{{#unless (isLastElement index count)}},{{/unless}}
{{else if (isCharString type)}}
// Add String field here after ByteSpan is properly emitted in C++ layer
{{else}}
{{asJavaBasicType label type}} {{asCamelCased name true}}{{#unless (isLastElement index count)}},{{/unless}}
{{/if}}
{{/chip_attribute_list_entryTypes}}
) {
{{#chip_attribute_list_entryTypes}}
this.{{asCamelCased name true}} = {{asCamelCased name true}};
{{/chip_attribute_list_entryTypes}}
}
}
{{/if}}
public interface {{asCamelCased name false}}AttributeCallback {
void onSuccess(List<
{{#if isStruct}}
{{asCamelCased name false}}Attribute
{{else}}
{{#if (isOctetString type)}}
byte[]
{{else if (isCharString type)}}
// Add String field here after ByteSpan is properly emitted in C++ layer
{{else}}
{{asJavaBasicTypeForZclType type true}}
{{/if}}
{{/if}}
> valueList);
void onError(Exception ex);
}
{{/if}}
{{/chip_server_cluster_attributes}}
{{#chip_server_cluster_attributes}}
public void read{{asCamelCased name false}}Attribute(
{{#if isList}}
{{asCamelCased name false}}AttributeCallback callback
{{else}}
{{convertAttributeCallbackTypeToJavaName chipCallback.type}}AttributeCallback callback
{{/if}}
) {
read{{asCamelCased name false}}Attribute(chipClusterPtr, callback);
}
{{#if isWritableAttribute}}
public void write{{asCamelCased name false}}Attribute(DefaultClusterCallback callback, {{asJavaBasicType type}} value) {
write{{asCamelCased name false}}Attribute(chipClusterPtr, callback, value);
}
{{/if}}
{{/chip_server_cluster_attributes}}
{{#chip_server_cluster_attributes}}
private native void read{{asCamelCased name false}}Attribute(long chipClusterPtr,
{{#if isList}}
{{asCamelCased name false}}AttributeCallback callback
{{else}}
{{convertAttributeCallbackTypeToJavaName chipCallback.type}}AttributeCallback callback
{{/if}}
);
{{#if isWritableAttribute}}
private native void write{{asCamelCased name false}}Attribute(long chipClusterPtr, DefaultClusterCallback callback, {{asJavaBasicType type}} value);
{{/if}}
{{/chip_server_cluster_attributes}}
}
{{#unless (isLastElement index count)}}
{{/unless}}
{{/chip_client_clusters}}
}
{{/if}}