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 f12e16c commit 5f0b9b0
Show file tree
Hide file tree
Showing 23 changed files with 132 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ limitations under the License.
<item value="0x03" name="Critical"/>
</enum>

<struct name="MessageStruct" isFabricScoped="true">

<struct name="MessageStruct"> <!-- TODO: enable isFabricScoped="true", as of Jan 2024 it breaks at compile time as command argument PresentMessagesRequest#Messages-->
<cluster code="0x0097"/>
<item fieldId="0" name="MessageID" type="octet_string" length="16" optional="false"/>
<item fieldId="1" name="Priority" type="MessagePriorityEnum" optional="false"/>
Expand Down Expand Up @@ -83,7 +84,7 @@ limitations under the License.
<description>
Command for requesting messages be presented
</description>
<arg name="Messages" type="octet_string" array="true" optional="false"/>
<arg name="Messages" type="MessageStruct" array="true" optional="false"/>
</command>
<command source="client" code="0x01" name="CancelMessagesRequest" isFabricScoped="true" optional="false">
<description>
Expand All @@ -93,11 +94,11 @@ limitations under the License.
</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>
<field id="0" name="MessageID" type="octet_string" length="16"/>
<field id="0" name="MessageID" type="octet_string" max="16"/>
</event>
<event side="server" code="0x01" name="MessagePresented" priority="info" optional="false">
<description>This event SHALL be generated when the message is presented to the user.</description>
<field id="0" name="MessageID" type="octet_string" length="16"/>
<field id="0" name="MessageID" type="octet_string" max="16"/>
</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>
Expand Down
5 changes: 2 additions & 3 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -4411,15 +4411,14 @@ provisional cluster Messages = 151 {
optional char_string<32> label = 1;
}

fabric_scoped struct MessageStruct {
struct MessageStruct {
octet_string<16> messageID = 0;
MessagePriorityEnum priority = 1;
MessageControlBitmap messageControl = 2;
nullable epoch_s startTime = 3;
nullable int16u duration = 4;
char_string<256> messageText = 5;
optional MessageResponseOptionStruct responses[] = 6;
fabric_idx fabricIndex = 254;
}

info event MessageQueued = 0 {
Expand Down Expand Up @@ -4447,7 +4446,7 @@ provisional cluster Messages = 151 {
readonly attribute int16u clusterRevision = 65533;

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

request struct CancelMessagesRequestRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29208,16 +29208,16 @@ public long initWithDevice(long devicePtr, int endpointId) {
return 0L;
}

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

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

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

StructType value = new StructType(elements);
Expand Down Expand Up @@ -29274,11 +29274,6 @@ public interface AttributeListAttributeCallback extends BaseAttributeCallback {

public void readMessagesAttribute(
MessagesAttributeCallback callback) {
readMessagesAttributeWithFabricFilter(callback, true);
}

public void readMessagesAttributeWithFabricFilter(
MessagesAttributeCallback callback, boolean isFabricFiltered) {
ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, MESSAGES_ATTRIBUTE_ID);

readAttribute(new ReportCallbackImpl(callback, path) {
Expand All @@ -29287,7 +29282,7 @@ public void onSuccess(byte[] tlv) {
List<ChipStructs.MessagesClusterMessageStruct> value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv);
callback.onSuccess(value);
}
}, MESSAGES_ATTRIBUTE_ID, isFabricFiltered);
}, MESSAGES_ATTRIBUTE_ID, true);
}

public void writeMessagesAttribute(DefaultClusterCallback callback, ArrayList<ChipStructs.MessagesClusterMessageStruct> value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6528,15 +6528,13 @@ public static class MessagesClusterMessageStruct {
public @Nullable Integer duration;
public String messageText;
public Optional<ArrayList<ChipStructs.MessagesClusterMessageResponseOptionStruct>> responses;
public Integer fabricIndex;
private static final long MESSAGE_I_D_ID = 0L;
private static final long PRIORITY_ID = 1L;
private static final long MESSAGE_CONTROL_ID = 2L;
private static final long START_TIME_ID = 3L;
private static final long DURATION_ID = 4L;
private static final long MESSAGE_TEXT_ID = 5L;
private static final long RESPONSES_ID = 6L;
private static final long FABRIC_INDEX_ID = 254L;

public MessagesClusterMessageStruct(
byte[] messageID,
Expand All @@ -6545,8 +6543,7 @@ public MessagesClusterMessageStruct(
@Nullable Long startTime,
@Nullable Integer duration,
String messageText,
Optional<ArrayList<ChipStructs.MessagesClusterMessageResponseOptionStruct>> responses,
Integer fabricIndex
Optional<ArrayList<ChipStructs.MessagesClusterMessageResponseOptionStruct>> responses
) {
this.messageID = messageID;
this.priority = priority;
Expand All @@ -6555,7 +6552,6 @@ public MessagesClusterMessageStruct(
this.duration = duration;
this.messageText = messageText;
this.responses = responses;
this.fabricIndex = fabricIndex;
}

public StructType encodeTlv() {
Expand All @@ -6567,7 +6563,6 @@ public StructType encodeTlv() {
values.add(new StructElement(DURATION_ID, duration != null ? new UIntType(duration) : new NullType()));
values.add(new StructElement(MESSAGE_TEXT_ID, new StringType(messageText)));
values.add(new StructElement(RESPONSES_ID, responses.<BaseTLVType>map((nonOptionalresponses) -> ArrayType.generateArrayType(nonOptionalresponses, (elementnonOptionalresponses) -> elementnonOptionalresponses.encodeTlv())).orElse(new EmptyType())));
values.add(new StructElement(FABRIC_INDEX_ID, new UIntType(fabricIndex)));

return new StructType(values);
}
Expand All @@ -6583,7 +6578,6 @@ public static MessagesClusterMessageStruct decodeTlv(BaseTLVType tlvValue) {
@Nullable Integer duration = null;
String messageText = null;
Optional<ArrayList<ChipStructs.MessagesClusterMessageResponseOptionStruct>> responses = Optional.empty();
Integer fabricIndex = null;
for (StructElement element: ((StructType)tlvValue).value()) {
if (element.contextTagNum() == MESSAGE_I_D_ID) {
if (element.value(BaseTLVType.class).type() == TLVType.ByteArray) {
Expand Down Expand Up @@ -6620,11 +6614,6 @@ public static MessagesClusterMessageStruct decodeTlv(BaseTLVType tlvValue) {
ArrayType castingValue = element.value(ArrayType.class);
responses = Optional.of(castingValue.map((elementcastingValue) -> ChipStructs.MessagesClusterMessageResponseOptionStruct.decodeTlv(elementcastingValue)));
}
} else if (element.contextTagNum() == FABRIC_INDEX_ID) {
if (element.value(BaseTLVType.class).type() == TLVType.UInt) {
UIntType castingValue = element.value(UIntType.class);
fabricIndex = castingValue.value(Integer.class);
}
}
}
return new MessagesClusterMessageStruct(
Expand All @@ -6634,8 +6623,7 @@ public static MessagesClusterMessageStruct decodeTlv(BaseTLVType tlvValue) {
startTime,
duration,
messageText,
responses,
fabricIndex
responses
);
}

Expand Down Expand Up @@ -6664,9 +6652,6 @@ public String toString() {
output.append("\tresponses: ");
output.append(responses);
output.append("\n");
output.append("\tfabricIndex: ");
output.append(fabricIndex);
output.append("\n");
output.append("}\n");
return output.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23725,13 +23725,11 @@ public Map<String, Map<String, InteractionInfo>> getCommandMap() {

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

CommandParameterInfo messagespresentMessagesRequestmessagesCommandParameterInfo = new CommandParameterInfo("messages", ArrayList.class, ArrayList.class);
messagespresentMessagesRequestCommandParams.put("messages",messagespresentMessagesRequestmessagesCommandParameterInfo);
InteractionInfo messagespresentMessagesRequestInteractionInfo = new InteractionInfo(
(cluster, callback, commandArguments) -> {
((ChipClusters.MessagesCluster) cluster)
.presentMessagesRequest((DefaultClusterCallback) callback
, (ArrayList<byte[]>)
, (ArrayList<ChipStructs.MessagesClusterMessageStruct>)
commandArguments.get("messages")
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class MessagesClusterMessageStruct(
val startTime: ULong?,
val duration: UInt?,
val messageText: String,
val responses: Optional<List<MessagesClusterMessageResponseOptionStruct>>,
val fabricIndex: UInt
val responses: Optional<List<MessagesClusterMessageResponseOptionStruct>>
) {
override fun toString(): String = buildString {
append("MessagesClusterMessageStruct {\n")
Expand All @@ -43,7 +42,6 @@ class MessagesClusterMessageStruct(
append("\tduration : $duration\n")
append("\tmessageText : $messageText\n")
append("\tresponses : $responses\n")
append("\tfabricIndex : $fabricIndex\n")
append("}\n")
}

Expand Down Expand Up @@ -72,7 +70,6 @@ class MessagesClusterMessageStruct(
}
endArray()
}
put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex)
endStructure()
}
}
Expand All @@ -85,7 +82,6 @@ class MessagesClusterMessageStruct(
private const val TAG_DURATION = 4
private const val TAG_MESSAGE_TEXT = 5
private const val TAG_RESPONSES = 6
private const val TAG_FABRIC_INDEX = 254

fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MessagesClusterMessageStruct {
tlvReader.enterStructure(tlvTag)
Expand Down Expand Up @@ -121,7 +117,6 @@ class MessagesClusterMessageStruct(
} else {
Optional.empty()
}
val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX))

tlvReader.exitContainer()

Expand All @@ -132,8 +127,7 @@ class MessagesClusterMessageStruct(
startTime,
duration,
messageText,
responses,
fabricIndex
responses
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class MessagesCluster(private val controller: MatterController, private val endp
}

suspend fun presentMessagesRequest(
messages: List<ByteArray>,
messages: List<MessagesClusterMessageStruct>,
timedInvokeTimeout: Duration? = null
) {
val commandId: UInt = 0u
Expand All @@ -116,7 +116,7 @@ class MessagesCluster(private val controller: MatterController, private val endp
val TAG_MESSAGES_REQ: Int = 0
tlvWriter.startArray(ContextSpecificTag(TAG_MESSAGES_REQ))
for (item in messages.iterator()) {
tlvWriter.put(AnonymousTag, item)
item.toTlv(AnonymousTag, tlvWriter)
}
tlvWriter.endArray()
tlvWriter.endStructure()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class MessagesClusterMessageStruct(
val startTime: UInt?,
val duration: UShort?,
val messageText: String,
val responses: Optional<List<MessagesClusterMessageResponseOptionStruct>>,
val fabricIndex: UByte
val responses: Optional<List<MessagesClusterMessageResponseOptionStruct>>
) {
override fun toString(): String = buildString {
append("MessagesClusterMessageStruct {\n")
Expand All @@ -43,7 +42,6 @@ class MessagesClusterMessageStruct(
append("\tduration : $duration\n")
append("\tmessageText : $messageText\n")
append("\tresponses : $responses\n")
append("\tfabricIndex : $fabricIndex\n")
append("}\n")
}

Expand Down Expand Up @@ -72,7 +70,6 @@ class MessagesClusterMessageStruct(
}
endArray()
}
put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex)
endStructure()
}
}
Expand All @@ -85,7 +82,6 @@ class MessagesClusterMessageStruct(
private const val TAG_DURATION = 4
private const val TAG_MESSAGE_TEXT = 5
private const val TAG_RESPONSES = 6
private const val TAG_FABRIC_INDEX = 254

fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MessagesClusterMessageStruct {
tlvReader.enterStructure(tlvTag)
Expand Down Expand Up @@ -121,7 +117,6 @@ class MessagesClusterMessageStruct(
} else {
Optional.empty()
}
val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX))

tlvReader.exitContainer()

Expand All @@ -132,8 +127,7 @@ class MessagesClusterMessageStruct(
startTime,
duration,
messageText,
responses,
fabricIndex
responses
)
}
}
Expand Down
20 changes: 6 additions & 14 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.

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.

6 changes: 2 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.

Loading

0 comments on commit 5f0b9b0

Please sign in to comment.