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 25, 2024
1 parent 486327b commit 2253253
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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" 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"/>
<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"/>
</event>
</cluster>
</configurator>
4 changes: 2 additions & 2 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;
optional nullable int32u responseID = 1;
optional nullable char_string reply = 2;
nullable int32u responseID = 1;
nullable char_string reply = 2;
nullable FutureMessagePreferenceEnum futureMessagesPreference = 3;
}

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 Optional<Long> responseID;
public @Nullable Optional<String> reply;
public @Nullable Long responseID;
public @Nullable 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 Optional<Long> responseID,
@Nullable Optional<String> reply,
@Nullable Long responseID,
@Nullable 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 ? 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(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(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 Optional<Long> responseID = null;
@Nullable Optional<String> reply = null;
@Nullable Long responseID = null;
@Nullable 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 = Optional.of(castingValue.value(Long.class));
responseID = 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 = Optional.of(castingValue.value(String.class));
reply = 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 @@ -17,16 +17,15 @@
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: Optional<ULong>?,
val reply: Optional<String>?,
val responseID: ULong?,
val reply: String?,
val futureMessagesPreference: UInt?
) {
override fun toString(): String = buildString {
Expand All @@ -43,18 +42,12 @@ class MessagesClusterMessageCompleteEvent(
startStructure(tlvTag)
put(ContextSpecificTag(TAG_MESSAGE_I_D), messageID)
if (responseID != null) {
if (responseID.isPresent) {
val optresponseID = responseID.get()
put(ContextSpecificTag(TAG_RESPONSE_I_D), optresponseID)
}
put(ContextSpecificTag(TAG_RESPONSE_I_D), responseID)
} else {
putNull(ContextSpecificTag(TAG_RESPONSE_I_D))
}
if (reply != null) {
if (reply.isPresent) {
val optreply = reply.get()
put(ContextSpecificTag(TAG_REPLY), optreply)
}
put(ContextSpecificTag(TAG_REPLY), reply)
} else {
putNull(ContextSpecificTag(TAG_REPLY))
}
Expand All @@ -78,22 +71,14 @@ class MessagesClusterMessageCompleteEvent(
val messageID = tlvReader.getByteArray(ContextSpecificTag(TAG_MESSAGE_I_D))
val responseID =
if (!tlvReader.isNull()) {
if (tlvReader.isNextTag(ContextSpecificTag(TAG_RESPONSE_I_D))) {
Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_RESPONSE_I_D)))
} else {
Optional.empty()
}
tlvReader.getULong(ContextSpecificTag(TAG_RESPONSE_I_D))
} else {
tlvReader.getNull(ContextSpecificTag(TAG_RESPONSE_I_D))
null
}
val reply =
if (!tlvReader.isNull()) {
if (tlvReader.isNextTag(ContextSpecificTag(TAG_REPLY))) {
Optional.of(tlvReader.getString(ContextSpecificTag(TAG_REPLY)))
} else {
Optional.empty()
}
tlvReader.getString(ContextSpecificTag(TAG_REPLY))
} else {
tlvReader.getNull(ContextSpecificTag(TAG_REPLY))
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package matter.controller.cluster.eventstructs

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

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

8 changes: 4 additions & 4 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.

30 changes: 11 additions & 19 deletions src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.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.

0 comments on commit 2253253

Please sign in to comment.