Skip to content

Commit

Permalink
Update xml command names
Browse files Browse the repository at this point in the history
  • Loading branch information
lazarkov committed Jan 25, 2024
1 parent 2253253 commit b0ef8c1
Show file tree
Hide file tree
Showing 19 changed files with 167 additions and 195 deletions.
12 changes: 6 additions & 6 deletions src/app/zap-templates/zcl/data-model/chip/messages-cluster.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ limitations under the License.
<description>
Command for requesting messages be presented
</description>
<arg name="Messages" type="MessageStruct" array="true"/>
<arg name="Messages" type="MessageStruct" array="true" optional="false"/>
</command>
<command source="client" code="0x01" name="CancelMessagesRequest" isFabricScoped="true" optional="false">
<description>
Command for cancelling message present requests
</description>
<arg name="Messages" type="MessageStruct" array="true"/>
<arg name="MessageIDs" type="octet_string" array="true" optional="false"/>
</command>
<event side="server" code="0x00" name="MessageQueued" priority="info" optional="false">
<description>This event SHALL be generated when the message is confirmed by the user, or when the expiration date of the message is reached.</description>
Expand All @@ -101,10 +101,10 @@ limitations under the License.
</event>
<event side="server" code="0x02" name="MessageComplete" priority="info" optional="false">
<description>This event SHALL be generated when the message is confirmed by the user, or when the expiration date of the message is reached.</description>
<field id="0" name="MessageID" type="octet_string"/>
<field id="1" name="ResponseID" type="int32u" isNullable="true"/>
<field id="2" name="Reply" type="char_string" length="256" isNullable="true"/>
<field id="3" name="FutureMessagesPreference" type="FutureMessagePreferenceEnum" isNullable="true"/>
<field id="0" name="MessageID" type="octet_string" optional="false"/>
<field id="1" name="ResponseID" type="int32u" isNullable="true" optional="true"/>
<field id="2" name="Reply" type="char_string" length="256" isNullable="true" optional="true"/>
<field id="3" name="FutureMessagesPreference" type="FutureMessagePreferenceEnum" isNullable="true" optional="false"/>
</event>
</cluster>
</configurator>
6 changes: 3 additions & 3 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -4432,8 +4432,8 @@ provisional cluster Messages = 151 {

info event MessageComplete = 2 {
octet_string messageID = 0;
nullable int32u responseID = 1;
nullable char_string reply = 2;
optional nullable int32u responseID = 1;
optional nullable char_string reply = 2;
nullable FutureMessagePreferenceEnum futureMessagesPreference = 3;
}

Expand All @@ -4451,7 +4451,7 @@ provisional cluster Messages = 151 {
}

request struct CancelMessagesRequestRequest {
MessageStruct messages[] = 0;
octet_string messageIDs[] = 0;
}

/** Command for requesting messages be presented */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29228,17 +29228,17 @@ public void onResponse(StructType invokeStructValue) {
}}, commandId, value, timedInvokeTimeoutMs);
}

public void cancelMessagesRequest(DefaultClusterCallback callback, ArrayList<ChipStructs.MessagesClusterMessageStruct> messages) {
cancelMessagesRequest(callback, messages, 0);
public void cancelMessagesRequest(DefaultClusterCallback callback, ArrayList<byte[]> messageIDs) {
cancelMessagesRequest(callback, messageIDs, 0);
}

public void cancelMessagesRequest(DefaultClusterCallback callback, ArrayList<ChipStructs.MessagesClusterMessageStruct> messages, int timedInvokeTimeoutMs) {
public void cancelMessagesRequest(DefaultClusterCallback callback, ArrayList<byte[]> messageIDs, int timedInvokeTimeoutMs) {
final long commandId = 1L;

ArrayList<StructElement> elements = new ArrayList<>();
final long messagesFieldID = 0L;
BaseTLVType messagestlvValue = ArrayType.generateArrayType(messages, (elementmessages) -> elementmessages.encodeTlv());
elements.add(new StructElement(messagesFieldID, messagestlvValue));
final long messageIDsFieldID = 0L;
BaseTLVType messageIDstlvValue = ArrayType.generateArrayType(messageIDs, (elementmessageIDs) -> new ByteArrayType(elementmessageIDs));
elements.add(new StructElement(messageIDsFieldID, messageIDstlvValue));

StructType value = new StructType(elements);
invoke(new InvokeCallbackImpl(callback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3854,8 +3854,8 @@ public String toString() {
}
public static class MessagesClusterMessageCompleteEvent {
public byte[] messageID;
public @Nullable Long responseID;
public @Nullable String reply;
public @Nullable Optional<Long> responseID;
public @Nullable Optional<String> reply;
public @Nullable Integer futureMessagesPreference;
private static final long MESSAGE_I_D_ID = 0L;
private static final long RESPONSE_I_D_ID = 1L;
Expand All @@ -3864,8 +3864,8 @@ public static class MessagesClusterMessageCompleteEvent {

public MessagesClusterMessageCompleteEvent(
byte[] messageID,
@Nullable Long responseID,
@Nullable String reply,
@Nullable Optional<Long> responseID,
@Nullable Optional<String> reply,
@Nullable Integer futureMessagesPreference
) {
this.messageID = messageID;
Expand All @@ -3877,8 +3877,8 @@ public MessagesClusterMessageCompleteEvent(
public StructType encodeTlv() {
ArrayList<StructElement> values = new ArrayList<>();
values.add(new StructElement(MESSAGE_I_D_ID, new ByteArrayType(messageID)));
values.add(new StructElement(RESPONSE_I_D_ID, responseID != null ? new UIntType(responseID) : new NullType()));
values.add(new StructElement(REPLY_ID, reply != null ? new StringType(reply) : new NullType()));
values.add(new StructElement(RESPONSE_I_D_ID, responseID != null ? responseID.<BaseTLVType>map((nonOptionalresponseID) -> new UIntType(nonOptionalresponseID)).orElse(new EmptyType()) : new NullType()));
values.add(new StructElement(REPLY_ID, reply != null ? reply.<BaseTLVType>map((nonOptionalreply) -> new StringType(nonOptionalreply)).orElse(new EmptyType()) : new NullType()));
values.add(new StructElement(FUTURE_MESSAGES_PREFERENCE_ID, futureMessagesPreference != null ? new UIntType(futureMessagesPreference) : new NullType()));

return new StructType(values);
Expand All @@ -3889,8 +3889,8 @@ public static MessagesClusterMessageCompleteEvent decodeTlv(BaseTLVType tlvValue
return null;
}
byte[] messageID = null;
@Nullable Long responseID = null;
@Nullable String reply = null;
@Nullable Optional<Long> responseID = null;
@Nullable Optional<String> reply = null;
@Nullable Integer futureMessagesPreference = null;
for (StructElement element: ((StructType)tlvValue).value()) {
if (element.contextTagNum() == MESSAGE_I_D_ID) {
Expand All @@ -3901,12 +3901,12 @@ public static MessagesClusterMessageCompleteEvent decodeTlv(BaseTLVType tlvValue
} else if (element.contextTagNum() == RESPONSE_I_D_ID) {
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
UIntType castingValue = element.value(UIntType.class);
responseID = castingValue.value(Long.class);
responseID = Optional.of(castingValue.value(Long.class));
}
} else if (element.contextTagNum() == REPLY_ID) {
if (element.value(BaseTLVType.class).type() == TLVType.String) {
StringType castingValue = element.value(StringType.class);
reply = castingValue.value(String.class);
reply = Optional.of(castingValue.value(String.class));
}
} else if (element.contextTagNum() == FUTURE_MESSAGES_PREFERENCE_ID) {
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9406,7 +9406,7 @@ public static PresentMessagesRequestCommandField value(int id) throws NoSuchFiel
}
throw new NoSuchFieldError();
}
}public enum CancelMessagesRequestCommandField {Messages(0),;
}public enum CancelMessagesRequestCommandField {MessageIDs(0),;
private final int id;
CancelMessagesRequestCommandField(int id) {
this.id = id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23740,12 +23740,14 @@ public Map<String, Map<String, InteractionInfo>> getCommandMap() {

Map<String, CommandParameterInfo> messagescancelMessagesRequestCommandParams = new LinkedHashMap<String, CommandParameterInfo>();

CommandParameterInfo messagescancelMessagesRequestmessageIDsCommandParameterInfo = new CommandParameterInfo("messageIDs", ArrayList.class, ArrayList.class);
messagescancelMessagesRequestCommandParams.put("messageIDs",messagescancelMessagesRequestmessageIDsCommandParameterInfo);
InteractionInfo messagescancelMessagesRequestInteractionInfo = new InteractionInfo(
(cluster, callback, commandArguments) -> {
((ChipClusters.MessagesCluster) cluster)
.cancelMessagesRequest((DefaultClusterCallback) callback
, (ArrayList<ChipStructs.MessagesClusterMessageStruct>)
commandArguments.get("messages")
, (ArrayList<byte[]>)
commandArguments.get("messageIDs")
);
},
() -> new DelegatedDefaultClusterCallback(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
package chip.devicecontroller.cluster.eventstructs

import chip.devicecontroller.cluster.*
import java.util.Optional
import matter.tlv.ContextSpecificTag
import matter.tlv.Tag
import matter.tlv.TlvReader
import matter.tlv.TlvWriter

class MessagesClusterMessageCompleteEvent(
val messageID: ByteArray,
val responseID: ULong?,
val reply: String?,
val responseID: Optional<ULong>?,
val reply: Optional<String>?,
val futureMessagesPreference: UInt?
) {
override fun toString(): String = buildString {
Expand All @@ -42,12 +43,18 @@ class MessagesClusterMessageCompleteEvent(
startStructure(tlvTag)
put(ContextSpecificTag(TAG_MESSAGE_I_D), messageID)
if (responseID != null) {
put(ContextSpecificTag(TAG_RESPONSE_I_D), responseID)
if (responseID.isPresent) {
val optresponseID = responseID.get()
put(ContextSpecificTag(TAG_RESPONSE_I_D), optresponseID)
}
} else {
putNull(ContextSpecificTag(TAG_RESPONSE_I_D))
}
if (reply != null) {
put(ContextSpecificTag(TAG_REPLY), reply)
if (reply.isPresent) {
val optreply = reply.get()
put(ContextSpecificTag(TAG_REPLY), optreply)
}
} else {
putNull(ContextSpecificTag(TAG_REPLY))
}
Expand All @@ -71,14 +78,22 @@ class MessagesClusterMessageCompleteEvent(
val messageID = tlvReader.getByteArray(ContextSpecificTag(TAG_MESSAGE_I_D))
val responseID =
if (!tlvReader.isNull()) {
tlvReader.getULong(ContextSpecificTag(TAG_RESPONSE_I_D))
if (tlvReader.isNextTag(ContextSpecificTag(TAG_RESPONSE_I_D))) {
Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_RESPONSE_I_D)))
} else {
Optional.empty()
}
} else {
tlvReader.getNull(ContextSpecificTag(TAG_RESPONSE_I_D))
null
}
val reply =
if (!tlvReader.isNull()) {
tlvReader.getString(ContextSpecificTag(TAG_REPLY))
if (tlvReader.isNextTag(ContextSpecificTag(TAG_REPLY))) {
Optional.of(tlvReader.getString(ContextSpecificTag(TAG_REPLY)))
} else {
Optional.empty()
}
} else {
tlvReader.getNull(ContextSpecificTag(TAG_REPLY))
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,18 @@ class MessagesCluster(private val controller: MatterController, private val endp
}

suspend fun cancelMessagesRequest(
messages: List<MessagesClusterMessageStruct>,
messageIDs: List<ByteArray>,
timedInvokeTimeout: Duration? = null
) {
val commandId: UInt = 1u

val tlvWriter = TlvWriter()
tlvWriter.startStructure(AnonymousTag)

val TAG_MESSAGES_REQ: Int = 0
tlvWriter.startArray(ContextSpecificTag(TAG_MESSAGES_REQ))
for (item in messages.iterator()) {
item.toTlv(AnonymousTag, tlvWriter)
val TAG_MESSAGE_I_DS_REQ: Int = 0
tlvWriter.startArray(ContextSpecificTag(TAG_MESSAGE_I_DS_REQ))
for (item in messageIDs.iterator()) {
tlvWriter.put(AnonymousTag, item)
}
tlvWriter.endArray()
tlvWriter.endStructure()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package matter.controller.cluster.eventstructs

import java.util.Optional
import matter.controller.cluster.*
import matter.tlv.ContextSpecificTag
import matter.tlv.Tag
Expand All @@ -24,8 +25,8 @@ import matter.tlv.TlvWriter

class MessagesClusterMessageCompleteEvent(
val messageID: ByteArray,
val responseID: UInt?,
val reply: String?,
val responseID: Optional<UInt>?,
val reply: Optional<String>?,
val futureMessagesPreference: UByte?
) {
override fun toString(): String = buildString {
Expand All @@ -42,12 +43,18 @@ class MessagesClusterMessageCompleteEvent(
startStructure(tlvTag)
put(ContextSpecificTag(TAG_MESSAGE_I_D), messageID)
if (responseID != null) {
put(ContextSpecificTag(TAG_RESPONSE_I_D), responseID)
if (responseID.isPresent) {
val optresponseID = responseID.get()
put(ContextSpecificTag(TAG_RESPONSE_I_D), optresponseID)
}
} else {
putNull(ContextSpecificTag(TAG_RESPONSE_I_D))
}
if (reply != null) {
put(ContextSpecificTag(TAG_REPLY), reply)
if (reply.isPresent) {
val optreply = reply.get()
put(ContextSpecificTag(TAG_REPLY), optreply)
}
} else {
putNull(ContextSpecificTag(TAG_REPLY))
}
Expand All @@ -71,14 +78,22 @@ class MessagesClusterMessageCompleteEvent(
val messageID = tlvReader.getByteArray(ContextSpecificTag(TAG_MESSAGE_I_D))
val responseID =
if (!tlvReader.isNull()) {
tlvReader.getUInt(ContextSpecificTag(TAG_RESPONSE_I_D))
if (tlvReader.isNextTag(ContextSpecificTag(TAG_RESPONSE_I_D))) {
Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_RESPONSE_I_D)))
} else {
Optional.empty()
}
} else {
tlvReader.getNull(ContextSpecificTag(TAG_RESPONSE_I_D))
null
}
val reply =
if (!tlvReader.isNull()) {
tlvReader.getString(ContextSpecificTag(TAG_REPLY))
if (tlvReader.isNextTag(ContextSpecificTag(TAG_REPLY))) {
Optional.of(tlvReader.getString(ContextSpecificTag(TAG_REPLY)))
} else {
Optional.empty()
}
} else {
tlvReader.getNull(ContextSpecificTag(TAG_REPLY))
null
Expand Down
43 changes: 31 additions & 12 deletions src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp

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

2 changes: 1 addition & 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.

Loading

0 comments on commit b0ef8c1

Please sign in to comment.