Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added new attribute as per latest spec changes (#31318)
Browse files Browse the repository at this point in the history
* added new attribute as per latest changes

* regen after updating cpid
fessehaeve authored and pull[bot] committed Mar 30, 2024
1 parent 8332558 commit 2083497
Showing 24 changed files with 390 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -69,6 +69,7 @@ limitations under the License.
<attribute side="server" code="0x0007" define="TARGET_LEVEL" type="percent" isNullable="true" min="0" max="100" writable="false" optional="true">TargetLevel</attribute>
<attribute side="server" code="0x0008" define="DEFAULT_OPEN_LEVEL" type="percent" isNullable="false" min="1" max="100" writable="true" default="100" optional="true">DefaultOpenLevel</attribute>
<attribute side="server" code="0x0009" define="VALVE_FAULT" type="ValveFaultBitmap" isNullable="false" writable="false" optional="true">ValveFault</attribute>
<attribute side="server" code="0x000A" define="LEVEL_STEP" type="int8u" min="1" max="50" isNullable="false" writable="false" optional="true">LevelStep</attribute>

<command source="client" code="0x00" name="Open" optional="false">
<description>This command is used to set the valve to its open position.</description>
1 change: 1 addition & 0 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
@@ -4104,6 +4104,7 @@ provisional cluster ValveConfigurationAndControl = 129 {
readonly attribute optional nullable percent targetLevel = 7;
attribute optional percent defaultOpenLevel = 8;
readonly attribute optional ValveFaultBitmap valveFault = 9;
readonly attribute optional int8u levelStep = 10;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Original file line number Diff line number Diff line change
@@ -27873,6 +27873,7 @@ public static class ValveConfigurationAndControlCluster extends BaseChipCluster
private static final long TARGET_LEVEL_ATTRIBUTE_ID = 7L;
private static final long DEFAULT_OPEN_LEVEL_ATTRIBUTE_ID = 8L;
private static final long VALVE_FAULT_ATTRIBUTE_ID = 9L;
private static final long LEVEL_STEP_ATTRIBUTE_ID = 10L;
private static final long GENERATED_COMMAND_LIST_ATTRIBUTE_ID = 65528L;
private static final long ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID = 65529L;
private static final long EVENT_LIST_ATTRIBUTE_ID = 65530L;
@@ -28246,6 +28247,31 @@ public void onSuccess(byte[] tlv) {
}, VALVE_FAULT_ATTRIBUTE_ID, minInterval, maxInterval);
}

public void readLevelStepAttribute(
IntegerAttributeCallback callback) {
ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, LEVEL_STEP_ATTRIBUTE_ID);

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

public void subscribeLevelStepAttribute(
IntegerAttributeCallback callback, int minInterval, int maxInterval) {
ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, LEVEL_STEP_ATTRIBUTE_ID);

subscribeAttribute(new ReportCallbackImpl(callback, path) {
@Override
public void onSuccess(byte[] tlv) {
Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
}
}, LEVEL_STEP_ATTRIBUTE_ID, minInterval, maxInterval);
}

public void readGeneratedCommandListAttribute(
GeneratedCommandListAttributeCallback callback) {
ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GENERATED_COMMAND_LIST_ATTRIBUTE_ID);
Original file line number Diff line number Diff line change
@@ -8935,6 +8935,7 @@ public enum Attribute {
TargetLevel(7L),
DefaultOpenLevel(8L),
ValveFault(9L),
LevelStep(10L),
GeneratedCommandList(65528L),
AcceptedCommandList(65529L),
EventList(65530L),
Original file line number Diff line number Diff line change
@@ -8906,6 +8906,17 @@ private static Map<String, InteractionInfo> readValveConfigurationAndControlInte
readValveConfigurationAndControlValveFaultCommandParams
);
result.put("readValveFaultAttribute", readValveConfigurationAndControlValveFaultAttributeInteractionInfo);
Map<String, CommandParameterInfo> readValveConfigurationAndControlLevelStepCommandParams = new LinkedHashMap<String, CommandParameterInfo>();
InteractionInfo readValveConfigurationAndControlLevelStepAttributeInteractionInfo = new InteractionInfo(
(cluster, callback, commandArguments) -> {
((ChipClusters.ValveConfigurationAndControlCluster) cluster).readLevelStepAttribute(
(ChipClusters.IntegerAttributeCallback) callback
);
},
() -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(),
readValveConfigurationAndControlLevelStepCommandParams
);
result.put("readLevelStepAttribute", readValveConfigurationAndControlLevelStepAttributeInteractionInfo);
Map<String, CommandParameterInfo> readValveConfigurationAndControlGeneratedCommandListCommandParams = new LinkedHashMap<String, CommandParameterInfo>();
InteractionInfo readValveConfigurationAndControlGeneratedCommandListAttributeInteractionInfo = new InteractionInfo(
(cluster, callback, commandArguments) -> {
Original file line number Diff line number Diff line change
@@ -1245,6 +1245,97 @@ class ValveConfigurationAndControlCluster(
}
}

suspend fun readLevelStepAttribute(): UByte? {
val ATTRIBUTE_ID: UInt = 10u

val attributePath =
AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)

val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath))

val response = controller.read(readRequest)

if (response.successes.isEmpty()) {
logger.log(Level.WARNING, "Read command failed")
throw IllegalStateException("Read command failed with failures: ${response.failures}")
}

logger.log(Level.FINE, "Read command succeeded")

val attributeData =
response.successes.filterIsInstance<ReadData.Attribute>().firstOrNull {
it.path.attributeId == ATTRIBUTE_ID
}

requireNotNull(attributeData) { "Levelstep attribute not found in response" }

// Decode the TLV data into the appropriate type
val tlvReader = TlvReader(attributeData.data)
val decodedValue: UByte? =
if (tlvReader.isNextTag(AnonymousTag)) {
tlvReader.getUByte(AnonymousTag)
} else {
null
}

return decodedValue
}

suspend fun subscribeLevelStepAttribute(
minInterval: Int,
maxInterval: Int
): Flow<UByteSubscriptionState> {
val ATTRIBUTE_ID: UInt = 10u
val attributePaths =
listOf(
AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID)
)

val subscribeRequest: SubscribeRequest =
SubscribeRequest(
eventPaths = emptyList(),
attributePaths = attributePaths,
minInterval = Duration.ofSeconds(minInterval.toLong()),
maxInterval = Duration.ofSeconds(maxInterval.toLong())
)

return controller.subscribe(subscribeRequest).transform { subscriptionState ->
when (subscriptionState) {
is SubscriptionState.SubscriptionErrorNotification -> {
emit(
UByteSubscriptionState.Error(
Exception(
"Subscription terminated with error code: ${subscriptionState.terminationCause}"
)
)
)
}
is SubscriptionState.NodeStateUpdate -> {
val attributeData =
subscriptionState.updateState.successes
.filterIsInstance<ReadData.Attribute>()
.firstOrNull { it.path.attributeId == ATTRIBUTE_ID }

requireNotNull(attributeData) { "Levelstep attribute not found in Node State update" }

// Decode the TLV data into the appropriate type
val tlvReader = TlvReader(attributeData.data)
val decodedValue: UByte? =
if (tlvReader.isNextTag(AnonymousTag)) {
tlvReader.getUByte(AnonymousTag)
} else {
null
}

decodedValue?.let { emit(UByteSubscriptionState.Success(it)) }
}
SubscriptionState.SubscriptionEstablished -> {
emit(UByteSubscriptionState.SubscriptionEstablished)
}
}
}
}

suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {
val ATTRIBUTE_ID: UInt = 65528u

16 changes: 16 additions & 0 deletions src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/controller/python/chip/clusters/CHIPClusters.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions src/controller/python/chip/clusters/Objects.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/MTRClusters.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2083497

Please sign in to comment.