Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TV Matter Media: Updated existing cluster to sync it with latest spec change #31782

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ limitations under the License.
<description>
Command for requesting messages be presented
</description>
<arg name="Messages" type="MessageStruct" array="true" optional="false"/>
<arg name="MessageID" type="octet_string" length="16" optional="false"/>
<arg name="Priority" type="MessagePriorityEnum" optional="false"/>
<arg name="MessageControl" type="MessageControlBitmap" default="0" optional="false"/>
<arg name="StartTime" type="epoch_s" default="0" optional="false" isNullable="true"/>
<arg name="Duration" type="int16u" default="0" optional="false" isNullable="true"/>
<arg name="MessageText" type="char_string" length="256" optional="false"/>
<arg name="Responses" type="MessageResponseOptionStruct" array="true" length="4" optional="true"/>
</command>
<command source="client" code="0x01" name="CancelMessagesRequest" isFabricScoped="true" optional="false">
<description>
Expand Down
8 changes: 7 additions & 1 deletion src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -4440,7 +4440,13 @@ cluster Messages = 151 {
readonly attribute int16u clusterRevision = 65533;

request struct PresentMessagesRequestRequest {
MessageStruct messages[] = 0;
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;
}

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

public void presentMessagesRequest(DefaultClusterCallback callback, ArrayList<ChipStructs.MessagesClusterMessageStruct> messages) {
presentMessagesRequest(callback, messages, 0);
public void presentMessagesRequest(DefaultClusterCallback callback, byte[] messageID, Integer priority, Integer messageControl, @Nullable Long startTime, @Nullable Integer duration, String messageText, Optional<ArrayList<ChipStructs.MessagesClusterMessageResponseOptionStruct>> responses) {
presentMessagesRequest(callback, messageID, priority, messageControl, startTime, duration, messageText, responses, 0);
}

public void presentMessagesRequest(DefaultClusterCallback callback, ArrayList<ChipStructs.MessagesClusterMessageStruct> messages, int timedInvokeTimeoutMs) {
public void presentMessagesRequest(DefaultClusterCallback callback, byte[] messageID, Integer priority, Integer messageControl, @Nullable Long startTime, @Nullable Integer duration, String messageText, Optional<ArrayList<ChipStructs.MessagesClusterMessageResponseOptionStruct>> responses, int timedInvokeTimeoutMs) {
final long commandId = 0L;

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 messageIDFieldID = 0L;
BaseTLVType messageIDtlvValue = new ByteArrayType(messageID);
elements.add(new StructElement(messageIDFieldID, messageIDtlvValue));

final long priorityFieldID = 1L;
BaseTLVType prioritytlvValue = new UIntType(priority);
elements.add(new StructElement(priorityFieldID, prioritytlvValue));

final long messageControlFieldID = 2L;
BaseTLVType messageControltlvValue = new UIntType(messageControl);
elements.add(new StructElement(messageControlFieldID, messageControltlvValue));

final long startTimeFieldID = 3L;
BaseTLVType startTimetlvValue = startTime != null ? new UIntType(startTime) : new NullType();
elements.add(new StructElement(startTimeFieldID, startTimetlvValue));

final long durationFieldID = 4L;
BaseTLVType durationtlvValue = duration != null ? new UIntType(duration) : new NullType();
elements.add(new StructElement(durationFieldID, durationtlvValue));

final long messageTextFieldID = 5L;
BaseTLVType messageTexttlvValue = new StringType(messageText);
elements.add(new StructElement(messageTextFieldID, messageTexttlvValue));

final long responsesFieldID = 6L;
BaseTLVType responsestlvValue = responses.<BaseTLVType>map((nonOptionalresponses) -> ArrayType.generateArrayType(nonOptionalresponses, (elementnonOptionalresponses) -> elementnonOptionalresponses.encodeTlv())).orElse(new EmptyType());
elements.add(new StructElement(responsesFieldID, responsestlvValue));

StructType value = new StructType(elements);
invoke(new InvokeCallbackImpl(callback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9385,7 +9385,7 @@ public static Command value(long id) throws NoSuchFieldError {
}
throw new NoSuchFieldError();
}
}public enum PresentMessagesRequestCommandField {Messages(0),;
}public enum PresentMessagesRequestCommandField {MessageID(0),Priority(1),MessageControl(2),StartTime(3),Duration(4),MessageText(5),Responses(6),;
private final int id;
PresentMessagesRequestCommandField(int id) {
this.id = id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23659,12 +23659,42 @@ public Map<String, Map<String, InteractionInfo>> getCommandMap() {

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

CommandParameterInfo messagespresentMessagesRequestmessageIDCommandParameterInfo = new CommandParameterInfo("messageID", byte[].class, byte[].class);
messagespresentMessagesRequestCommandParams.put("messageID",messagespresentMessagesRequestmessageIDCommandParameterInfo);

CommandParameterInfo messagespresentMessagesRequestpriorityCommandParameterInfo = new CommandParameterInfo("priority", Integer.class, Integer.class);
messagespresentMessagesRequestCommandParams.put("priority",messagespresentMessagesRequestpriorityCommandParameterInfo);

CommandParameterInfo messagespresentMessagesRequestmessageControlCommandParameterInfo = new CommandParameterInfo("messageControl", Integer.class, Integer.class);
messagespresentMessagesRequestCommandParams.put("messageControl",messagespresentMessagesRequestmessageControlCommandParameterInfo);

CommandParameterInfo messagespresentMessagesRequeststartTimeCommandParameterInfo = new CommandParameterInfo("startTime", Long.class, Long.class);
messagespresentMessagesRequestCommandParams.put("startTime",messagespresentMessagesRequeststartTimeCommandParameterInfo);

CommandParameterInfo messagespresentMessagesRequestdurationCommandParameterInfo = new CommandParameterInfo("duration", Integer.class, Integer.class);
messagespresentMessagesRequestCommandParams.put("duration",messagespresentMessagesRequestdurationCommandParameterInfo);

CommandParameterInfo messagespresentMessagesRequestmessageTextCommandParameterInfo = new CommandParameterInfo("messageText", String.class, String.class);
messagespresentMessagesRequestCommandParams.put("messageText",messagespresentMessagesRequestmessageTextCommandParameterInfo);

InteractionInfo messagespresentMessagesRequestInteractionInfo = new InteractionInfo(
(cluster, callback, commandArguments) -> {
((ChipClusters.MessagesCluster) cluster)
.presentMessagesRequest((DefaultClusterCallback) callback
, (ArrayList<ChipStructs.MessagesClusterMessageStruct>)
commandArguments.get("messages")
, (byte[])
commandArguments.get("messageID")
, (Integer)
commandArguments.get("priority")
, (Integer)
commandArguments.get("messageControl")
, (Long)
commandArguments.get("startTime")
, (Integer)
commandArguments.get("duration")
, (String)
commandArguments.get("messageText")
, (Optional<ArrayList<ChipStructs.MessagesClusterMessageResponseOptionStruct>>)
commandArguments.get("responses")
);
},
() -> new DelegatedDefaultClusterCallback(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,46 @@ class MessagesCluster(private val controller: MatterController, private val endp
}

suspend fun presentMessagesRequest(
messages: List<MessagesClusterMessageStruct>,
messageID: ByteArray,
priority: UByte,
messageControl: UByte,
startTime: UInt?,
duration: UShort?,
messageText: String,
responses: List<MessagesClusterMessageResponseOptionStruct>?,
timedInvokeTimeout: Duration? = null
) {
val commandId: UInt = 0u

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_D_REQ: Int = 0
tlvWriter.put(ContextSpecificTag(TAG_MESSAGE_I_D_REQ), messageID)

val TAG_PRIORITY_REQ: Int = 1
tlvWriter.put(ContextSpecificTag(TAG_PRIORITY_REQ), priority)

val TAG_MESSAGE_CONTROL_REQ: Int = 2
tlvWriter.put(ContextSpecificTag(TAG_MESSAGE_CONTROL_REQ), messageControl)

val TAG_START_TIME_REQ: Int = 3
startTime?.let { tlvWriter.put(ContextSpecificTag(TAG_START_TIME_REQ), startTime) }

val TAG_DURATION_REQ: Int = 4
duration?.let { tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) }

val TAG_MESSAGE_TEXT_REQ: Int = 5
tlvWriter.put(ContextSpecificTag(TAG_MESSAGE_TEXT_REQ), messageText)

val TAG_RESPONSES_REQ: Int = 6
responses?.let {
tlvWriter.startArray(ContextSpecificTag(TAG_RESPONSES_REQ))
for (item in responses.iterator()) {
item.toTlv(AnonymousTag, tlvWriter)
}
tlvWriter.endArray()
}
tlvWriter.endArray()
tlvWriter.endStructure()

val request: InvokeRequest =
Expand Down
8 changes: 7 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.

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

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

Loading
Loading