Skip to content

Commit

Permalink
regen
Browse files Browse the repository at this point in the history
  • Loading branch information
tehampson committed Feb 7, 2025
1 parent f660044 commit 42b40ae
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8183,6 +8183,10 @@ public interface BasicCommissioningInfoAttributeCallback extends BaseAttributeCa
void onSuccess(ChipStructs.GeneralCommissioningClusterBasicCommissioningInfo value);
}

public interface TCUpdateDeadlineAttributeCallback extends BaseAttributeCallback {
void onSuccess(@Nullable Long value);
}

public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback {
void onSuccess(List<Long> value);
}
Expand Down Expand Up @@ -8443,26 +8447,26 @@ public void onSuccess(byte[] tlv) {
}

public void readTCUpdateDeadlineAttribute(
LongAttributeCallback callback) {
TCUpdateDeadlineAttributeCallback callback) {
ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, TC_UPDATE_DEADLINE_ATTRIBUTE_ID);

readAttribute(new ReportCallbackImpl(callback, path) {
@Override
public void onSuccess(byte[] tlv) {
Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
@Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
callback.onSuccess(value);
}
}, TC_UPDATE_DEADLINE_ATTRIBUTE_ID, true);
}

public void subscribeTCUpdateDeadlineAttribute(
LongAttributeCallback callback, int minInterval, int maxInterval) {
TCUpdateDeadlineAttributeCallback callback, int minInterval, int maxInterval) {
ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, TC_UPDATE_DEADLINE_ATTRIBUTE_ID);

subscribeAttribute(new ReportCallbackImpl(callback, path) {
@Override
public void onSuccess(byte[] tlv) {
Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
@Nullable Long value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
callback.onSuccess(value);
}
}, TC_UPDATE_DEADLINE_ATTRIBUTE_ID, minInterval, maxInterval);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2735,6 +2735,27 @@ public void onError(Exception ex) {
}
}

public static class DelegatedGeneralCommissioningClusterTCUpdateDeadlineAttributeCallback implements ChipClusters.GeneralCommissioningCluster.TCUpdateDeadlineAttributeCallback, DelegatedClusterCallback {
private ClusterCommandCallback callback;
@Override
public void setCallbackDelegate(ClusterCommandCallback callback) {
this.callback = callback;
}

@Override
public void onSuccess(@Nullable Long value) {
Map<CommandResponseInfo, Object> responseValues = new LinkedHashMap<>();
CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Long");
responseValues.put(commandResponseInfo, value);
callback.onSuccess(responseValues);
}

@Override
public void onError(Exception ex) {
callback.onFailure(ex);
}
}

public static class DelegatedGeneralCommissioningClusterGeneratedCommandListAttributeCallback implements ChipClusters.GeneralCommissioningCluster.GeneratedCommandListAttributeCallback, DelegatedClusterCallback {
private ClusterCommandCallback callback;
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ class GeneralCommissioningCluster(
object SubscriptionEstablished : BasicCommissioningInfoAttributeSubscriptionState()
}

class TCUpdateDeadlineAttribute(val value: UInt?)

sealed class TCUpdateDeadlineAttributeSubscriptionState {
data class Success(val value: UInt?) : TCUpdateDeadlineAttributeSubscriptionState()

data class Error(val exception: Exception) : TCUpdateDeadlineAttributeSubscriptionState()

object SubscriptionEstablished : TCUpdateDeadlineAttributeSubscriptionState()
}

class GeneratedCommandListAttribute(val value: List<UInt>)

sealed class GeneratedCommandListAttributeSubscriptionState {
Expand Down Expand Up @@ -1170,7 +1180,7 @@ class GeneralCommissioningCluster(
}
}

suspend fun readTCUpdateDeadlineAttribute(): UInt? {
suspend fun readTCUpdateDeadlineAttribute(): TCUpdateDeadlineAttribute {
val ATTRIBUTE_ID: UInt = 9u

val attributePath =
Expand All @@ -1197,19 +1207,24 @@ class GeneralCommissioningCluster(
// Decode the TLV data into the appropriate type
val tlvReader = TlvReader(attributeData.data)
val decodedValue: UInt? =
if (tlvReader.isNextTag(AnonymousTag)) {
tlvReader.getUInt(AnonymousTag)
if (!tlvReader.isNull()) {
if (tlvReader.isNextTag(AnonymousTag)) {
tlvReader.getUInt(AnonymousTag)
} else {
null
}
} else {
tlvReader.getNull(AnonymousTag)
null
}

return decodedValue
return TCUpdateDeadlineAttribute(decodedValue)
}

suspend fun subscribeTCUpdateDeadlineAttribute(
minInterval: Int,
maxInterval: Int,
): Flow<UIntSubscriptionState> {
): Flow<TCUpdateDeadlineAttributeSubscriptionState> {
val ATTRIBUTE_ID: UInt = 9u
val attributePaths =
listOf(
Expand All @@ -1228,7 +1243,7 @@ class GeneralCommissioningCluster(
when (subscriptionState) {
is SubscriptionState.SubscriptionErrorNotification -> {
emit(
UIntSubscriptionState.Error(
TCUpdateDeadlineAttributeSubscriptionState.Error(
Exception(
"Subscription terminated with error code: ${subscriptionState.terminationCause}"
)
Expand All @@ -1248,16 +1263,21 @@ class GeneralCommissioningCluster(
// Decode the TLV data into the appropriate type
val tlvReader = TlvReader(attributeData.data)
val decodedValue: UInt? =
if (tlvReader.isNextTag(AnonymousTag)) {
tlvReader.getUInt(AnonymousTag)
if (!tlvReader.isNull()) {
if (tlvReader.isNextTag(AnonymousTag)) {
tlvReader.getUInt(AnonymousTag)
} else {
null
}
} else {
tlvReader.getNull(AnonymousTag)
null
}

decodedValue?.let { emit(UIntSubscriptionState.Success(it)) }
decodedValue?.let { emit(TCUpdateDeadlineAttributeSubscriptionState.Success(it)) }
}
SubscriptionState.SubscriptionEstablished -> {
emit(UIntSubscriptionState.SubscriptionEstablished)
emit(TCUpdateDeadlineAttributeSubscriptionState.SubscriptionEstablished)
}
}
}
Expand Down

0 comments on commit 42b40ae

Please sign in to comment.