Skip to content

Commit

Permalink
update per comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lazarkov committed Jan 28, 2024
1 parent 8c64f7a commit d9e589b
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 264 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ limitations under the License.
<client tick="false" init="false">true</client>
<server tick="false" init="false">true</server>
<globalAttribute side="either" code="0xFFFD" value="3"/><!-- Revision -->
<attribute side="server" code="0x0000" define="LIST_MESSAGES" type="array" entryType="MessageStruct" length="8" writable="true" optional="false">Messages</attribute>
<attribute side="server" code="0x0000" define="LIST_MESSAGES" type="array" entryType="MessageStruct" length="8" writable="false" optional="false">Messages</attribute>
<attribute side="server" code="0x0001" define="MESSAGES_CLUSTER_ACTIVE_MESSAGES_IDS" type="ARRAY" entryType="octet_string" max="8" writable="false" optional="false">ActiveMessageIDs</attribute>
<command source="client" code="0x00" name="PresentMessagesRequest" isFabricScoped="true" optional="false">
<description>
Expand Down
2 changes: 1 addition & 1 deletion src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -4436,7 +4436,7 @@ provisional cluster Messages = 151 {
nullable FutureMessagePreferenceEnum futureMessagesPreference = 3;
}

attribute MessageStruct messages[] = 0;
readonly attribute MessageStruct messages[] = 0;
readonly attribute octet_string activeMessageIDs[] = 1;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29285,15 +29285,6 @@ public void onSuccess(byte[] tlv) {
}, MESSAGES_ATTRIBUTE_ID, true);
}

public void writeMessagesAttribute(DefaultClusterCallback callback, ArrayList<ChipStructs.MessagesClusterMessageStruct> value) {
writeMessagesAttribute(callback, value, 0);
}

public void writeMessagesAttribute(DefaultClusterCallback callback, ArrayList<ChipStructs.MessagesClusterMessageStruct> value, int timedWriteTimeoutMs) {
BaseTLVType tlvValue = ArrayType.generateArrayType(value, (elementvalue) -> elementvalue.encodeTlv());
writeAttribute(new WriteAttributesCallbackImpl(callback), MESSAGES_ATTRIBUTE_ID, tlvValue, timedWriteTimeoutMs);
}

public void subscribeMessagesAttribute(
MessagesAttributeCallback callback, int minInterval, int maxInterval) {
ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, MESSAGES_ATTRIBUTE_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ import matter.controller.SubscribeRequest
import matter.controller.SubscriptionState
import matter.controller.UIntSubscriptionState
import matter.controller.UShortSubscriptionState
import matter.controller.WriteRequest
import matter.controller.WriteRequests
import matter.controller.WriteResponse
import matter.controller.cluster.structs.*
import matter.controller.model.AttributePath
import matter.controller.model.CommandPath
Expand Down Expand Up @@ -198,53 +195,6 @@ class MessagesCluster(private val controller: MatterController, private val endp
return MessagesAttribute(decodedValue)
}

suspend fun writeMessagesAttribute(
value: List<MessagesClusterMessageStruct>,
timedWriteTimeout: Duration? = null
) {
val ATTRIBUTE_ID: UInt = 0u

val tlvWriter = TlvWriter()
tlvWriter.startArray(AnonymousTag)
for (item in value.iterator()) {
item.toTlv(AnonymousTag, tlvWriter)
}
tlvWriter.endArray()

val writeRequests: WriteRequests =
WriteRequests(
requests =
listOf(
WriteRequest(
attributePath =
AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID),
tlvPayload = tlvWriter.getEncoded()
)
),
timedRequest = timedWriteTimeout
)

val response: WriteResponse = controller.write(writeRequests)

when (response) {
is WriteResponse.Success -> {
logger.log(Level.FINE, "Write command succeeded")
}
is WriteResponse.PartialWriteFailure -> {
val aggregatedErrorMessage =
response.failures.joinToString("\n") { failure ->
"Error at ${failure.attributePath}: ${failure.ex.message}"
}

response.failures.forEach { failure ->
logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}")
}

throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage")
}
}
}

suspend fun subscribeMessagesAttribute(
minInterval: Int,
maxInterval: Int
Expand Down
1 change: 0 additions & 1 deletion src/controller/python/chip/clusters/CHIPClusters.py

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

2 changes: 0 additions & 2 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.

96 changes: 0 additions & 96 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.

2 changes: 0 additions & 2 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.

11 changes: 0 additions & 11 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.

2 changes: 1 addition & 1 deletion zzz_generated/chip-tool/zap-generated/cluster/Commands.h

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

Loading

0 comments on commit d9e589b

Please sign in to comment.