Skip to content

Commit

Permalink
YAML update to BRBINFO, ProductId (project-chip#34513)
Browse files Browse the repository at this point in the history
* Bridged Device Information Cluster, Attribute ProductID test reflects marking as O, not X

* Update src/app/tests/suites/certification/Test_TC_BRBINFO_2_1.yaml

Co-authored-by: Terence Hampson <thampson@google.com>

* corrected pics

* corrected pics

* WIP Bridged ICD, commissioning to both fabrics

* wip testing sending KeepActive

* update to bridged-device-basic-information.xml and zap generated files

* removed unrelated file

---------

Co-authored-by: Terence Hampson <thampson@google.com>
Co-authored-by: Andrei Litvin <andy314@gmail.com>
  • Loading branch information
3 people authored and hasty committed Aug 1, 2024
1 parent 12d0123 commit 9351279
Show file tree
Hide file tree
Showing 28 changed files with 423 additions and 14 deletions.
1 change: 1 addition & 0 deletions examples/placeholder/linux/apps/app1/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2476,6 +2476,7 @@ cluster BridgedDeviceBasicInformation = 57 {
readonly attribute optional char_string<32> vendorName = 1;
readonly attribute optional vendor_id vendorID = 2;
readonly attribute optional char_string<32> productName = 3;
readonly attribute optional int16u productID = 4;
attribute optional char_string<32> nodeLabel = 5;
readonly attribute optional int16u hardwareVersion = 7;
readonly attribute optional char_string<64> hardwareVersionString = 8;
Expand Down
1 change: 1 addition & 0 deletions examples/placeholder/linux/apps/app2/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2433,6 +2433,7 @@ cluster BridgedDeviceBasicInformation = 57 {
readonly attribute optional char_string<32> vendorName = 1;
readonly attribute optional vendor_id vendorID = 2;
readonly attribute optional char_string<32> productName = 3;
readonly attribute optional int16u productID = 4;
attribute optional char_string<32> nodeLabel = 5;
readonly attribute optional int16u hardwareVersion = 7;
readonly attribute optional char_string<64> hardwareVersionString = 8;
Expand Down
22 changes: 8 additions & 14 deletions src/app/tests/suites/certification/Test_TC_BRBINFO_2_1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,15 @@ tests:
response:
value: ProductNameValue

- label:
"Step 14: TH reads attribute ID 4 from the DUT (matches in ID to
ProductID in the parent cluster, but is absent on the
BridgedDeviceBasicInformation cluster)."
PICS: BRBINFO.S
cluster: "AnyCommands"
command: "ReadById"
arguments:
values:
- name: "ClusterId"
value: BRBINFO.ClusterId
- name: "AttributeId"
value: 0x0004
- label: "Step 14: TH reads ProductID from the DUT"
PICS: BRBINFO.S.A0004
command: "readAttribute"
attribute: "ProductID"
response:
error: UNSUPPORTED_ATTRIBUTE
constraints:
type: int16u
minValue: 1
maxValue: 65534

- label: "Step 17: TH reads NodeLabel from the DUT"
PICS: BRBINFO.S.A0005
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ limitations under the License.
<attribute side="server" code="1" define="VENDOR_NAME" type="char_string" length="32" optional="true">VendorName</attribute>
<attribute side="server" code="2" define="VENDOR_ID" type="vendor_id" optional="true">VendorID</attribute>
<attribute side="server" code="3" define="PRODUCT_NAME" type="char_string" length="32" optional="true">ProductName</attribute>
<attribute side="server" code="4" define="PRODUCT_ID" type="int16u" optional="true">ProductID</attribute>
<attribute side="server" code="5" define="NODE_LABEL" type="char_string" length="32" default="" writable="true" optional="true">NodeLabel</attribute>
<attribute side="server" code="7" define="HARDWARE_VERSION" type="int16u" default="0" optional="true">HardwareVersion</attribute>
<attribute side="server" code="8" define="HARDWARE_VERSION_STRING" type="char_string" minLength="1" length="64" optional="true">HardwareVersionString</attribute>
Expand Down
1 change: 1 addition & 0 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2359,6 +2359,7 @@ cluster BridgedDeviceBasicInformation = 57 {
readonly attribute optional char_string<32> vendorName = 1;
readonly attribute optional vendor_id vendorID = 2;
readonly attribute optional char_string<32> productName = 3;
readonly attribute optional int16u productID = 4;
attribute optional char_string<32> nodeLabel = 5;
readonly attribute optional int16u hardwareVersion = 7;
readonly attribute optional char_string<64> hardwareVersionString = 8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15166,6 +15166,7 @@ public static class BridgedDeviceBasicInformationCluster extends BaseChipCluster
private static final long VENDOR_NAME_ATTRIBUTE_ID = 1L;
private static final long VENDOR_I_D_ATTRIBUTE_ID = 2L;
private static final long PRODUCT_NAME_ATTRIBUTE_ID = 3L;
private static final long PRODUCT_I_D_ATTRIBUTE_ID = 4L;
private static final long NODE_LABEL_ATTRIBUTE_ID = 5L;
private static final long HARDWARE_VERSION_ATTRIBUTE_ID = 7L;
private static final long HARDWARE_VERSION_STRING_ATTRIBUTE_ID = 8L;
Expand Down Expand Up @@ -15314,6 +15315,32 @@ public void onSuccess(byte[] tlv) {
}, PRODUCT_NAME_ATTRIBUTE_ID, minInterval, maxInterval);
}

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

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

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

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

public void readNodeLabelAttribute(
CharStringAttributeCallback callback) {
ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, NODE_LABEL_ATTRIBUTE_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4460,6 +4460,7 @@ public enum Attribute {
VendorName(1L),
VendorID(2L),
ProductName(3L),
ProductID(4L),
NodeLabel(5L),
HardwareVersion(7L),
HardwareVersionString(8L),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4659,6 +4659,17 @@ private static Map<String, InteractionInfo> readBridgedDeviceBasicInformationInt
readBridgedDeviceBasicInformationProductNameCommandParams
);
result.put("readProductNameAttribute", readBridgedDeviceBasicInformationProductNameAttributeInteractionInfo);
Map<String, CommandParameterInfo> readBridgedDeviceBasicInformationProductIDCommandParams = new LinkedHashMap<String, CommandParameterInfo>();
InteractionInfo readBridgedDeviceBasicInformationProductIDAttributeInteractionInfo = new InteractionInfo(
(cluster, callback, commandArguments) -> {
((ChipClusters.BridgedDeviceBasicInformationCluster) cluster).readProductIDAttribute(
(ChipClusters.IntegerAttributeCallback) callback
);
},
() -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(),
readBridgedDeviceBasicInformationProductIDCommandParams
);
result.put("readProductIDAttribute", readBridgedDeviceBasicInformationProductIDAttributeInteractionInfo);
Map<String, CommandParameterInfo> readBridgedDeviceBasicInformationNodeLabelCommandParams = new LinkedHashMap<String, CommandParameterInfo>();
InteractionInfo readBridgedDeviceBasicInformationNodeLabelAttributeInteractionInfo = new InteractionInfo(
(cluster, callback, commandArguments) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,97 @@ class BridgedDeviceBasicInformationCluster(
}
}

suspend fun readProductIDAttribute(): UShort? {
val ATTRIBUTE_ID: UInt = 4u

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) { "Productid attribute not found in response" }

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

return decodedValue
}

suspend fun subscribeProductIDAttribute(
minInterval: Int,
maxInterval: Int,
): Flow<UShortSubscriptionState> {
val ATTRIBUTE_ID: UInt = 4u
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(
UShortSubscriptionState.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) { "Productid attribute not found in Node State update" }

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

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

suspend fun readNodeLabelAttribute(): String? {
val ATTRIBUTE_ID: UInt = 5u

Expand Down
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.

Loading

0 comments on commit 9351279

Please sign in to comment.