Skip to content

Commit 0c86d5a

Browse files
tehampsonj-ororke
authored andcommitted
Add fabric sync related changed into bridge device info cluster (project-chip#34336)
1 parent d26d450 commit 0c86d5a

37 files changed

+865
-6
lines changed

examples/placeholder/linux/apps/app1/config.matter

+11
Original file line numberDiff line numberDiff line change
@@ -2320,6 +2320,10 @@ cluster BridgedDeviceBasicInformation = 57 {
23202320
kFabric = 5;
23212321
}
23222322

2323+
bitmap Feature : bitmap32 {
2324+
kBridgedICDSupport = 0x100000;
2325+
}
2326+
23232327
struct ProductAppearanceStruct {
23242328
ProductFinishEnum finish = 0;
23252329
nullable ColorEnum primaryColor = 1;
@@ -2339,6 +2343,10 @@ cluster BridgedDeviceBasicInformation = 57 {
23392343
boolean reachableNewValue = 0;
23402344
}
23412345

2346+
info event ActiveChanged = 128 {
2347+
int32u promisedActiveDuration = 0;
2348+
}
2349+
23422350
readonly attribute optional char_string<32> vendorName = 1;
23432351
readonly attribute optional vendor_id vendorID = 2;
23442352
readonly attribute optional char_string<32> productName = 3;
@@ -2361,6 +2369,9 @@ cluster BridgedDeviceBasicInformation = 57 {
23612369
readonly attribute attrib_id attributeList[] = 65531;
23622370
readonly attribute bitmap32 featureMap = 65532;
23632371
readonly attribute int16u clusterRevision = 65533;
2372+
2373+
/** The server SHALL attempt to keep the devices specified active for StayActiveDuration milliseconds when they are next active. */
2374+
command KeepActive(): DefaultSuccess = 128;
23642375
}
23652376

23662377
/** This cluster exposes interactions with a switch device, for the purpose of using those interactions by other devices.

examples/placeholder/linux/apps/app2/config.matter

+11
Original file line numberDiff line numberDiff line change
@@ -2277,6 +2277,10 @@ cluster BridgedDeviceBasicInformation = 57 {
22772277
kFabric = 5;
22782278
}
22792279

2280+
bitmap Feature : bitmap32 {
2281+
kBridgedICDSupport = 0x100000;
2282+
}
2283+
22802284
struct ProductAppearanceStruct {
22812285
ProductFinishEnum finish = 0;
22822286
nullable ColorEnum primaryColor = 1;
@@ -2296,6 +2300,10 @@ cluster BridgedDeviceBasicInformation = 57 {
22962300
boolean reachableNewValue = 0;
22972301
}
22982302

2303+
info event ActiveChanged = 128 {
2304+
int32u promisedActiveDuration = 0;
2305+
}
2306+
22992307
readonly attribute optional char_string<32> vendorName = 1;
23002308
readonly attribute optional vendor_id vendorID = 2;
23012309
readonly attribute optional char_string<32> productName = 3;
@@ -2318,6 +2326,9 @@ cluster BridgedDeviceBasicInformation = 57 {
23182326
readonly attribute attrib_id attributeList[] = 65531;
23192327
readonly attribute bitmap32 featureMap = 65532;
23202328
readonly attribute int16u clusterRevision = 65533;
2329+
2330+
/** The server SHALL attempt to keep the devices specified active for StayActiveDuration milliseconds when they are next active. */
2331+
command KeepActive(): DefaultSuccess = 128;
23212332
}
23222333

23232334
/** This cluster exposes interactions with a switch device, for the purpose of using those interactions by other devices.

src/app/zap-templates/zcl/data-model/chip/bridged-device-basic-information.xml

+14
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ limitations under the License.
7171
<server tick="false" init="false">true</server>
7272
<globalAttribute side="either" code="0xFFFD" value="3"/>
7373

74+
<features>
75+
<feature bit="20" code="BIS" name="BridgedICDSupport" summary="Support Bridged ICD Devices.">
76+
<optionalConform/>
77+
</feature>
78+
</features>
79+
7480
<attribute side="server" code="1" define="VENDOR_NAME" type="char_string" length="32" optional="true">VendorName</attribute>
7581
<attribute side="server" code="2" define="VENDOR_ID" type="vendor_id" optional="true">VendorID</attribute>
7682
<attribute side="server" code="3" define="PRODUCT_NAME" type="char_string" length="32" optional="true">ProductName</attribute>
@@ -88,6 +94,10 @@ limitations under the License.
8894
<attribute side="server" code="18" define="UNIQUE_ID" type="char_string" length="32" optional="false">UniqueID</attribute>
8995
<attribute side="server" code="20" define="PRODUCT_APPEARANCE" type="ProductAppearanceStruct" optional="true">ProductAppearance</attribute>
9096

97+
<command source="client" code="0x80" name="KeepActive" optional="true" apiMaturity="provisional">
98+
<description> The server SHALL attempt to keep the devices specified active for StayActiveDuration milliseconds when they are next active.</description>
99+
</command>
100+
91101
<event side="server" code="0x00" name="StartUp" priority="critical" optional="true">
92102
<description>The StartUp event SHALL be emitted by a Node as soon as reasonable after completing a boot or reboot process.</description>
93103
<field id="0" name="SoftwareVersion" type="int32u"/>
@@ -102,6 +112,10 @@ limitations under the License.
102112
<description>This event SHALL be generated when there is a change in the Reachable attribute.</description>
103113
<field id="0" name="ReachableNewValue" type="boolean"/>
104114
</event>
115+
<event side="server" code="0x80" name="ActiveChanged" priority="info" optional="true" apiMaturity="provisional">
116+
<description>This event (when supported) SHALL be generated the next time a bridged device becomes active after a KeepActive command is received.</description>
117+
<field id="0" name="PromisedActiveDuration" type="int32u"/>
118+
</event>
105119

106120
</cluster>
107121
</configurator>

src/controller/data_model/controller-clusters.matter

+11
Original file line numberDiff line numberDiff line change
@@ -2225,6 +2225,10 @@ cluster BridgedDeviceBasicInformation = 57 {
22252225
kFabric = 5;
22262226
}
22272227

2228+
bitmap Feature : bitmap32 {
2229+
kBridgedICDSupport = 0x100000;
2230+
}
2231+
22282232
struct ProductAppearanceStruct {
22292233
ProductFinishEnum finish = 0;
22302234
nullable ColorEnum primaryColor = 1;
@@ -2244,6 +2248,10 @@ cluster BridgedDeviceBasicInformation = 57 {
22442248
boolean reachableNewValue = 0;
22452249
}
22462250

2251+
info event ActiveChanged = 128 {
2252+
int32u promisedActiveDuration = 0;
2253+
}
2254+
22472255
readonly attribute optional char_string<32> vendorName = 1;
22482256
readonly attribute optional vendor_id vendorID = 2;
22492257
readonly attribute optional char_string<32> productName = 3;
@@ -2266,6 +2274,9 @@ cluster BridgedDeviceBasicInformation = 57 {
22662274
readonly attribute attrib_id attributeList[] = 65531;
22672275
readonly attribute bitmap32 featureMap = 65532;
22682276
readonly attribute int16u clusterRevision = 65533;
2277+
2278+
/** The server SHALL attempt to keep the devices specified active for StayActiveDuration milliseconds when they are next active. */
2279+
command KeepActive(): DefaultSuccess = 128;
22692280
}
22702281

22712282
/** This cluster exposes interactions with a switch device, for the purpose of using those interactions by other devices.

src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java

+16
Original file line numberDiff line numberDiff line change
@@ -14963,6 +14963,22 @@ public long initWithDevice(long devicePtr, int endpointId) {
1496314963
return 0L;
1496414964
}
1496514965

14966+
public void keepActive(DefaultClusterCallback callback) {
14967+
keepActive(callback, 0);
14968+
}
14969+
14970+
public void keepActive(DefaultClusterCallback callback, int timedInvokeTimeoutMs) {
14971+
final long commandId = 128L;
14972+
14973+
ArrayList<StructElement> elements = new ArrayList<>();
14974+
StructType commandArgs = new StructType(elements);
14975+
invoke(new InvokeCallbackImpl(callback) {
14976+
@Override
14977+
public void onResponse(StructType invokeStructValue) {
14978+
callback.onSuccess();
14979+
}}, commandId, commandArgs, timedInvokeTimeoutMs);
14980+
}
14981+
1496614982
public interface ProductAppearanceAttributeCallback extends BaseAttributeCallback {
1496714983
void onSuccess(ChipStructs.BridgedDeviceBasicInformationClusterProductAppearanceStruct value);
1496814984
}

src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java

+46
Original file line numberDiff line numberDiff line change
@@ -1899,6 +1899,52 @@ public String toString() {
18991899
return output.toString();
19001900
}
19011901
}
1902+
public static class BridgedDeviceBasicInformationClusterActiveChangedEvent {
1903+
public Long promisedActiveDuration;
1904+
private static final long PROMISED_ACTIVE_DURATION_ID = 0L;
1905+
1906+
public BridgedDeviceBasicInformationClusterActiveChangedEvent(
1907+
Long promisedActiveDuration
1908+
) {
1909+
this.promisedActiveDuration = promisedActiveDuration;
1910+
}
1911+
1912+
public StructType encodeTlv() {
1913+
ArrayList<StructElement> values = new ArrayList<>();
1914+
values.add(new StructElement(PROMISED_ACTIVE_DURATION_ID, new UIntType(promisedActiveDuration)));
1915+
1916+
return new StructType(values);
1917+
}
1918+
1919+
public static BridgedDeviceBasicInformationClusterActiveChangedEvent decodeTlv(BaseTLVType tlvValue) {
1920+
if (tlvValue == null || tlvValue.type() != TLVType.Struct) {
1921+
return null;
1922+
}
1923+
Long promisedActiveDuration = null;
1924+
for (StructElement element: ((StructType)tlvValue).value()) {
1925+
if (element.contextTagNum() == PROMISED_ACTIVE_DURATION_ID) {
1926+
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
1927+
UIntType castingValue = element.value(UIntType.class);
1928+
promisedActiveDuration = castingValue.value(Long.class);
1929+
}
1930+
}
1931+
}
1932+
return new BridgedDeviceBasicInformationClusterActiveChangedEvent(
1933+
promisedActiveDuration
1934+
);
1935+
}
1936+
1937+
@Override
1938+
public String toString() {
1939+
StringBuilder output = new StringBuilder();
1940+
output.append("BridgedDeviceBasicInformationClusterActiveChangedEvent {\n");
1941+
output.append("\tpromisedActiveDuration: ");
1942+
output.append(promisedActiveDuration);
1943+
output.append("\n");
1944+
output.append("}\n");
1945+
return output.toString();
1946+
}
1947+
}
19021948
public static class SwitchClusterSwitchLatchedEvent {
19031949
public Integer newPosition;
19041950
private static final long NEW_POSITION_ID = 0L;

src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -4455,7 +4455,8 @@ public enum Event {
44554455
StartUp(0L),
44564456
ShutDown(1L),
44574457
Leave(2L),
4458-
ReachableChanged(3L),;
4458+
ReachableChanged(3L),
4459+
ActiveChanged(128L),;
44594460
private final long id;
44604461
Event(long id) {
44614462
this.id = id;
@@ -4475,7 +4476,8 @@ public static Event value(long id) throws NoSuchFieldError {
44754476
}
44764477
}
44774478

4478-
public enum Command {;
4479+
public enum Command {
4480+
KeepActive(128L),;
44794481
private final long id;
44804482
Command(long id) {
44814483
this.id = id;

src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java

+12
Original file line numberDiff line numberDiff line change
@@ -24028,6 +24028,18 @@ public Map<String, Map<String, InteractionInfo>> getCommandMap() {
2402824028

2402924029
Map<String, InteractionInfo> bridgedDeviceBasicInformationClusterInteractionInfoMap = new LinkedHashMap<>();
2403024030

24031+
Map<String, CommandParameterInfo> bridgedDeviceBasicInformationkeepActiveCommandParams = new LinkedHashMap<String, CommandParameterInfo>();
24032+
InteractionInfo bridgedDeviceBasicInformationkeepActiveInteractionInfo = new InteractionInfo(
24033+
(cluster, callback, commandArguments) -> {
24034+
((ChipClusters.BridgedDeviceBasicInformationCluster) cluster)
24035+
.keepActive((DefaultClusterCallback) callback
24036+
);
24037+
},
24038+
() -> new DelegatedDefaultClusterCallback(),
24039+
bridgedDeviceBasicInformationkeepActiveCommandParams
24040+
);
24041+
bridgedDeviceBasicInformationClusterInteractionInfoMap.put("keepActive", bridgedDeviceBasicInformationkeepActiveInteractionInfo);
24042+
2403124043
commandMap.put("bridgedDeviceBasicInformation", bridgedDeviceBasicInformationClusterInteractionInfoMap);
2403224044

2403324045
Map<String, InteractionInfo> switchClusterInteractionInfoMap = new LinkedHashMap<>();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
*
3+
* Copyright (c) 2023 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package chip.devicecontroller.cluster.eventstructs
18+
19+
import chip.devicecontroller.cluster.*
20+
import matter.tlv.ContextSpecificTag
21+
import matter.tlv.Tag
22+
import matter.tlv.TlvReader
23+
import matter.tlv.TlvWriter
24+
25+
class BridgedDeviceBasicInformationClusterActiveChangedEvent(val promisedActiveDuration: ULong) {
26+
override fun toString(): String = buildString {
27+
append("BridgedDeviceBasicInformationClusterActiveChangedEvent {\n")
28+
append("\tpromisedActiveDuration : $promisedActiveDuration\n")
29+
append("}\n")
30+
}
31+
32+
fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
33+
tlvWriter.apply {
34+
startStructure(tlvTag)
35+
put(ContextSpecificTag(TAG_PROMISED_ACTIVE_DURATION), promisedActiveDuration)
36+
endStructure()
37+
}
38+
}
39+
40+
companion object {
41+
private const val TAG_PROMISED_ACTIVE_DURATION = 0
42+
43+
fun fromTlv(
44+
tlvTag: Tag,
45+
tlvReader: TlvReader,
46+
): BridgedDeviceBasicInformationClusterActiveChangedEvent {
47+
tlvReader.enterStructure(tlvTag)
48+
val promisedActiveDuration =
49+
tlvReader.getULong(ContextSpecificTag(TAG_PROMISED_ACTIVE_DURATION))
50+
51+
tlvReader.exitContainer()
52+
53+
return BridgedDeviceBasicInformationClusterActiveChangedEvent(promisedActiveDuration)
54+
}
55+
}
56+
}

src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ eventstructs_sources = [
162162
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt",
163163
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt",
164164
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt",
165+
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterActiveChangedEvent.kt",
165166
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt",
166167
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt",
167168
"${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/CommissionerControlClusterCommissioningRequestResultEvent.kt",

src/controller/java/generated/java/matter/controller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt

+21
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import java.util.logging.Logger
2323
import kotlinx.coroutines.flow.Flow
2424
import kotlinx.coroutines.flow.transform
2525
import matter.controller.BooleanSubscriptionState
26+
import matter.controller.InvokeRequest
27+
import matter.controller.InvokeResponse
2628
import matter.controller.MatterController
2729
import matter.controller.ReadData
2830
import matter.controller.ReadRequest
@@ -36,6 +38,7 @@ import matter.controller.WriteRequests
3638
import matter.controller.WriteResponse
3739
import matter.controller.cluster.structs.*
3840
import matter.controller.model.AttributePath
41+
import matter.controller.model.CommandPath
3942
import matter.tlv.AnonymousTag
4043
import matter.tlv.TlvReader
4144
import matter.tlv.TlvWriter
@@ -97,6 +100,24 @@ class BridgedDeviceBasicInformationCluster(
97100
object SubscriptionEstablished : AttributeListAttributeSubscriptionState()
98101
}
99102

103+
suspend fun keepActive(timedInvokeTimeout: Duration? = null) {
104+
val commandId: UInt = 128u
105+
106+
val tlvWriter = TlvWriter()
107+
tlvWriter.startStructure(AnonymousTag)
108+
tlvWriter.endStructure()
109+
110+
val request: InvokeRequest =
111+
InvokeRequest(
112+
CommandPath(endpointId, clusterId = CLUSTER_ID, commandId),
113+
tlvPayload = tlvWriter.getEncoded(),
114+
timedRequest = timedInvokeTimeout,
115+
)
116+
117+
val response: InvokeResponse = controller.invoke(request)
118+
logger.log(Level.FINE, "Invoke command succeeded: ${response}")
119+
}
120+
100121
suspend fun readVendorNameAttribute(): String? {
101122
val ATTRIBUTE_ID: UInt = 1u
102123

0 commit comments

Comments
 (0)