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

[Android] Fix ChipCluster subscribe issue #33192

Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public class ChipClusters {
long attributeId,
int minInterval,
int maxInterval) {
ReportCallbackJni jniCallback = new ReportCallbackJni(callback, callback, null);
ReportCallbackJni jniCallback = new ReportCallbackJni(callback, callback, callback);
ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, attributeId);
ChipInteractionClient.subscribe(0, jniCallback.getCallbackHandle(), devicePtr, Arrays.asList(path), null, null, minInterval, maxInterval, false, true, timeoutMillis.orElse(0L).intValue(), null);
}
Expand Down Expand Up @@ -250,7 +250,7 @@ public class ChipClusters {
}
}

abstract static class ReportCallbackImpl implements ReportCallback, SubscriptionEstablishedCallback {
abstract static class ReportCallbackImpl implements ReportCallback, SubscriptionEstablishedCallback, ResubscriptionAttemptCallback {
private BaseAttributeCallback callback;
private ChipAttributePath path;

Expand Down Expand Up @@ -308,6 +308,9 @@ public class ChipClusters {
callback.onSubscriptionEstablished(subscriptionId);
}

@Override
public void onResubscriptionAttempt(long terminationCause, long nextResubscribeIntervalMsec) {}

public abstract void onSuccess(byte[] tlv);
}

Expand Down Expand Up @@ -551,6 +554,7 @@ public class ChipClusters {
public void onSuccess(byte[] tlv) {
{%- set encodable = attribute.definition | asEncodable(typeLookup) %}
{{encode_value_without_optional(cluster, encodable, 0)}} value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
callback.onSuccess(value);
}
}, {{attribute.definition.name | constcase}}_ATTRIBUTE_ID, minInterval, maxInterval);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected void subscribeAttribute(
long attributeId,
int minInterval,
int maxInterval) {
ReportCallbackJni jniCallback = new ReportCallbackJni(callback, callback, null);
ReportCallbackJni jniCallback = new ReportCallbackJni(callback, callback, callback);
ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, attributeId);
ChipInteractionClient.subscribe(0, jniCallback.getCallbackHandle(), devicePtr, Arrays.asList(path), null, null, minInterval, maxInterval, false, true, timeoutMillis.orElse(0L).intValue(), null);
}
Expand Down Expand Up @@ -173,7 +173,7 @@ protected void finalize() throws Throwable {
}
}

abstract static class ReportCallbackImpl implements ReportCallback, SubscriptionEstablishedCallback {
abstract static class ReportCallbackImpl implements ReportCallback, SubscriptionEstablishedCallback, ResubscriptionAttemptCallback {
private BaseAttributeCallback callback;
private ChipAttributePath path;

Expand Down Expand Up @@ -231,6 +231,9 @@ public void onSubscriptionEstablished(long subscriptionId) {
callback.onSubscriptionEstablished(subscriptionId);
}

@Override
public void onResubscriptionAttempt(long terminationCause, long nextResubscribeIntervalMsec) {}

public abstract void onSuccess(byte[] tlv);
}

Expand Down Expand Up @@ -334,6 +337,7 @@ public void subscribeSomeIntegerAttribute(
@Override
public void onSuccess(byte[] tlv) {
Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
callback.onSuccess(value);
}
}, SOME_INTEGER_ATTRIBUTE_ID, minInterval, maxInterval);
}
Expand Down Expand Up @@ -385,6 +389,7 @@ public void subscribeFabricsAttribute(
@Override
public void onSuccess(byte[] tlv) {
List<ChipStructs.SecondClusterFabricDescriptorStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
callback.onSuccess(value);
}
}, FABRICS_ATTRIBUTE_ID, minInterval, maxInterval);
}
Expand All @@ -410,6 +415,7 @@ public void subscribeSomeBytesAttribute(
@Override
public void onSuccess(byte[] tlv) {
byte[] value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
callback.onSuccess(value);
}
}, SOME_BYTES_ATTRIBUTE_ID, minInterval, maxInterval);
}
Expand Down Expand Up @@ -461,6 +467,7 @@ public void subscribeSomeEnumAttribute(
@Override
public void onSuccess(byte[] tlv) {
Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
callback.onSuccess(value);
}
}, SOME_ENUM_ATTRIBUTE_ID, minInterval, maxInterval);
}
Expand Down Expand Up @@ -495,6 +502,7 @@ public void subscribeOptionsAttribute(
@Override
public void onSuccess(byte[] tlv) {
Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
callback.onSuccess(value);
}
}, OPTIONS_ATTRIBUTE_ID, minInterval, maxInterval);
}
Expand Down
Loading
Loading