Skip to content

Commit f63b505

Browse files
lazarkovdrempelgrestyled-commits
authored
Messages Cluster XML (#31656)
* Messages Cluster XML * Update xml files without running ZAP generator script * Run ZAP regen script * Remove all clusters app * Fixing kotlin styling & random edits of zcl.json * Remove controller from the picture as well * Run ZAP * Run ZAP tool * Update xml & generate files by using ZAP * Apply manually created git diff patch * Run ZAP script * Update per comments * Update per comments * Update xml command names * Updated XML per comments * Restyled by gn * update per comments * update per comments --------- Co-authored-by: David Rempel <drempel@google.com> Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 09324e7 commit f63b505

File tree

68 files changed

+16423
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+16423
-0
lines changed

.github/workflows/tests.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ jobs:
143143
src/app/zap-templates/zcl/data-model/chip/low-power-cluster.xml \
144144
src/app/zap-templates/zcl/data-model/chip/media-input-cluster.xml \
145145
src/app/zap-templates/zcl/data-model/chip/media-playback-cluster.xml \
146+
src/app/zap-templates/zcl/data-model/chip/messages-cluster.xml \
146147
src/app/zap-templates/zcl/data-model/chip/mode-base-cluster.xml \
147148
src/app/zap-templates/zcl/data-model/chip/mode-select-cluster.xml \
148149
src/app/zap-templates/zcl/data-model/chip/network-commissioning-cluster.xml \

docs/clusters.md

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Generally regenerate using one of:
7979
| 129 | 0x81 | ValveConfigurationAndControl |
8080
| 145 | 0x91 | ElectricalEnergyMeasurement |
8181
| 150 | 0x96 | DemandResponseLoadControl |
82+
| 151 | 0x97 | Messages |
8283
| 152 | 0x98 | DeviceEnergyManagement |
8384
| 153 | 0x99 | EnergyEvse |
8485
| 155 | 0x9B | EnergyPreference |

scripts/rules.matterlint

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ load "../src/app/zap-templates/zcl/data-model/chip/low-power-cluster.xml";
5454
load "../src/app/zap-templates/zcl/data-model/chip/matter-devices.xml";
5555
load "../src/app/zap-templates/zcl/data-model/chip/media-input-cluster.xml";
5656
load "../src/app/zap-templates/zcl/data-model/chip/media-playback-cluster.xml";
57+
load "../src/app/zap-templates/zcl/data-model/chip/messages-cluster.xml";
5758
load "../src/app/zap-templates/zcl/data-model/chip/mode-base-cluster.xml";
5859
load "../src/app/zap-templates/zcl/data-model/chip/mode-select-cluster.xml";
5960
load "../src/app/zap-templates/zcl/data-model/chip/network-commissioning-cluster.xml";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include "messages-server.h"
2+
3+
#include <app-common/zap-generated/attributes/Accessors.h>
4+
#include <app-common/zap-generated/cluster-objects.h>
5+
#include <app-common/zap-generated/ids/Attributes.h>
6+
#include <app-common/zap-generated/ids/Clusters.h>
7+
#include <app-common/zap-generated/ids/Commands.h>
8+
#include <app/CommandHandler.h>
9+
#include <app/ConcreteCommandPath.h>
10+
11+
#include <app/util/af.h>
12+
#include <app/util/common.h>
13+
#include <app/util/error-mapping.h>
14+
#include <array>
15+
#include <lib/support/CodeUtils.h>
16+
#include <platform/CHIPDeviceLayer.h>
17+
18+
using namespace chip;
19+
using namespace chip::app;
20+
using namespace chip::app::Clusters::Messages;
21+
using chip::Protocols::InteractionModel::Status;
22+
23+
bool emberAfMessagesClusterPresentMessagesRequestCallback(
24+
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
25+
const chip::app::Clusters::Messages::Commands::PresentMessagesRequest::DecodableType & commandData)
26+
{
27+
return true;
28+
}
29+
/**
30+
* @brief Messages Cluster CancelMessagesRequest Command callback (from client)
31+
*/
32+
33+
bool emberAfMessagesClusterCancelMessagesRequestCallback(
34+
chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
35+
const chip::app::Clusters::Messages::Commands::CancelMessagesRequest::DecodableType & commandData)
36+
{
37+
return true;
38+
}
39+
40+
void MatterMessagesPluginServerInitCallback() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
*
3+
* Copyright (c) 2023 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#pragma once
19+
20+
#include <app-common/zap-generated/cluster-enums.h>
21+
#include <app/util/basic-types.h>
22+
23+
namespace chip {
24+
namespace app {
25+
namespace Clusters {
26+
namespace Messaging {} // namespace Messaging
27+
} // namespace Clusters
28+
} // namespace app
29+
} // namespace chip

src/app/zap-templates/zcl/data-model/all.xml

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<xi:include href="chip/low-power-cluster.xml" />
5656
<xi:include href="chip/media-input-cluster.xml" />
5757
<xi:include href="chip/media-playback-cluster.xml" />
58+
<xi:include href="chip/messages-cluster.xml" />
5859
<xi:include href="chip/mode-base-cluster.xml" />
5960
<xi:include href="chip/mode-select-cluster.xml" />
6061
<xi:include href="chip/network-commissioning-cluster.xml" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
Copyright (c) 2024 Project CHIP Authors
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<configurator>
18+
<domain name="General"/>
19+
20+
<bitmap name="Feature" type="bitmap32">
21+
<cluster code="0x0097"/>
22+
<field name="ReceivedConfirmation" mask="0x1"/>
23+
<field name="ConfirmationResponse" mask="0x2"/>
24+
<field name="ConfirmationReply" mask="0x4"/>
25+
<field name="ProtectedMessages" mask="0x8"/>
26+
</bitmap>
27+
28+
<bitmap name="MessageControlBitmap" type="bitmap8">
29+
<cluster code="0x0097"/>
30+
<field name="ConfirmationRequired" mask="0x1"/>
31+
<field name="ResponseRequired" mask="0x2"/>
32+
<field name="ReplyMessage" mask="0x4"/>
33+
<field name="MessageConfirmed" mask="0x8"/>
34+
<field name="MessageProtected" mask="0x10"/>
35+
</bitmap>
36+
37+
<enum name="FutureMessagePreferenceEnum" type="enum8">
38+
<cluster code="0x0097"/>
39+
<item value="0x00" name="Allowed"/>
40+
<item value="0x01" name="Increased" />
41+
<item value="0x02" name="Reduced"/>
42+
<item value="0x03" name="Disallowed"/>
43+
<item value="0x04" name="Banned"/>
44+
</enum>
45+
46+
<enum name="MessagePriorityEnum" type="enum8">
47+
<cluster code="0x0097"/>
48+
<item value="0x00" name="Low"/>
49+
<item value="0x01" name="Medium" />
50+
<item value="0x02" name="High"/>
51+
<item value="0x03" name="Critical"/>
52+
</enum>
53+
54+
55+
<struct name="MessageStruct"> <!-- TODO: enable isFabricScoped="true", as of Jan 2024 it breaks at compile time as command argument PresentMessagesRequest#Messages-->
56+
<cluster code="0x0097"/>
57+
<item fieldId="0" name="MessageID" type="octet_string" length="16" optional="false"/>
58+
<item fieldId="1" name="Priority" type="MessagePriorityEnum" optional="false"/>
59+
<item fieldId="2" name="MessageControl" type="MessageControlBitmap" default="0" optional="false"/>
60+
<item fieldId="3" name="StartTime" type="epoch_s" default="0" optional="false" isNullable="true"/>
61+
<item fieldId="4" name="Duration" type="int16u" default="0" optional="false" isNullable="true"/>
62+
<item fieldId="5" name="MessageText" type="char_string" length="256" optional="false"/>
63+
<item fieldId="6" name="Responses" type="MessageResponseOptionStruct" array="true" length="4" optional="true"/>
64+
</struct>
65+
66+
<struct name="MessageResponseOptionStruct">
67+
<cluster code="0x0097"/>
68+
<item fieldId="0" name="MessageResponseID" type="int32u" optional="true"/>
69+
<item fieldId="1" name="Label" type="char_string" length="32" optional="true"/>
70+
</struct>
71+
72+
<cluster>
73+
<name>Messages</name>
74+
<domain>General</domain>
75+
<description>This cluster provides an interface for passing messages to be presented by a device.</description>
76+
<code>0x0097</code>
77+
<define>MESSAGES_CLUSTER</define>
78+
<client tick="false" init="false">true</client>
79+
<server tick="false" init="false">true</server>
80+
<globalAttribute side="either" code="0xFFFD" value="3"/><!-- Revision -->
81+
<attribute side="server" code="0x0000" define="LIST_MESSAGES" type="array" entryType="MessageStruct" length="8" writable="false" optional="false">Messages</attribute>
82+
<attribute side="server" code="0x0001" define="MESSAGES_CLUSTER_ACTIVE_MESSAGES_IDS" type="ARRAY" entryType="octet_string" max="8" writable="false" optional="false">ActiveMessageIDs</attribute>
83+
<command source="client" code="0x00" name="PresentMessagesRequest" isFabricScoped="true" optional="false">
84+
<description>
85+
Command for requesting messages be presented
86+
</description>
87+
<arg name="Messages" type="MessageStruct" array="true" optional="false"/>
88+
</command>
89+
<command source="client" code="0x01" name="CancelMessagesRequest" isFabricScoped="true" optional="false">
90+
<description>
91+
Command for cancelling message present requests
92+
</description>
93+
<arg name="MessageIDs" type="octet_string" array="true" optional="false"/>
94+
</command>
95+
<event side="server" code="0x00" name="MessageQueued" priority="info" optional="false">
96+
<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>
97+
<field id="0" name="MessageID" type="octet_string" max="16"/>
98+
</event>
99+
<event side="server" code="0x01" name="MessagePresented" priority="info" optional="false">
100+
<description>This event SHALL be generated when the message is presented to the user.</description>
101+
<field id="0" name="MessageID" type="octet_string" max="16"/>
102+
</event>
103+
<event side="server" code="0x02" name="MessageComplete" priority="info" optional="false">
104+
<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>
105+
<field id="0" name="MessageID" type="octet_string" optional="false"/>
106+
<field id="1" name="ResponseID" type="int32u" isNullable="true" optional="true"/>
107+
<field id="2" name="Reply" type="char_string" length="256" isNullable="true" optional="true"/>
108+
<field id="3" name="FutureMessagesPreference" type="FutureMessagePreferenceEnum" isNullable="true" optional="false"/>
109+
</event>
110+
</cluster>
111+
</configurator>

src/app/zap-templates/zcl/zcl-with-test-extensions.json

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"low-power-cluster.xml",
7474
"media-input-cluster.xml",
7575
"media-playback-cluster.xml",
76+
"messages-cluster.xml",
7677
"mode-base-cluster.xml",
7778
"mode-select-cluster.xml",
7879
"mode-select-extensions.xml",

src/app/zap-templates/zcl/zcl.json

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"low-power-cluster.xml",
7272
"media-input-cluster.xml",
7373
"media-playback-cluster.xml",
74+
"messages-cluster.xml",
7475
"mode-base-cluster.xml",
7576
"mode-select-cluster.xml",
7677
"network-commissioning-cluster.xml",

src/app/zap_cluster_list.json

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"MEDIA_INPUT_CLUSTER": [],
6565
"MEDIA_PLAYBACK_CLUSTER": [],
6666
"MICROWAVE_OVEN_CONTROL_CLUSTER": [],
67+
"MESSAGES_CLUSTER": [],
6768
"MODE_SELECT_CLUSTER": [],
6869
"NETWORK_COMMISSIONING_CLUSTER": [],
6970
"SAMPLE_MEI_CLUSTER": [],
@@ -213,6 +214,7 @@
213214
"MEDIA_INPUT_CLUSTER": ["media-input-server"],
214215
"MEDIA_PLAYBACK_CLUSTER": ["media-playback-server"],
215216
"MICROWAVE_OVEN_CONTROL_CLUSTER": ["microwave-oven-control-server"],
217+
"MESSAGES_CLUSTER": ["messages-server"],
216218
"MODE_SELECT_CLUSTER": ["mode-select-server"],
217219
"NETWORK_COMMISSIONING_CLUSTER": ["network-commissioning"],
218220
"NITROGEN_DIOXIDE_CONCENTRATION_MEASUREMENT_CLUSTER": [

src/controller/data_model/controller-clusters.matter

+87
Original file line numberDiff line numberDiff line change
@@ -4372,6 +4372,93 @@ provisional cluster DemandResponseLoadControl = 150 {
43724372
command ClearLoadControlEventsRequest(): DefaultSuccess = 4;
43734373
}
43744374

4375+
/** This cluster provides an interface for passing messages to be presented by a device. */
4376+
cluster Messages = 151 {
4377+
revision 3;
4378+
4379+
enum FutureMessagePreferenceEnum : enum8 {
4380+
kAllowed = 0;
4381+
kIncreased = 1;
4382+
kReduced = 2;
4383+
kDisallowed = 3;
4384+
kBanned = 4;
4385+
}
4386+
4387+
enum MessagePriorityEnum : enum8 {
4388+
kLow = 0;
4389+
kMedium = 1;
4390+
kHigh = 2;
4391+
kCritical = 3;
4392+
}
4393+
4394+
bitmap Feature : bitmap32 {
4395+
kReceivedConfirmation = 0x1;
4396+
kConfirmationResponse = 0x2;
4397+
kConfirmationReply = 0x4;
4398+
kProtectedMessages = 0x8;
4399+
}
4400+
4401+
bitmap MessageControlBitmap : bitmap8 {
4402+
kConfirmationRequired = 0x1;
4403+
kResponseRequired = 0x2;
4404+
kReplyMessage = 0x4;
4405+
kMessageConfirmed = 0x8;
4406+
kMessageProtected = 0x10;
4407+
}
4408+
4409+
struct MessageResponseOptionStruct {
4410+
optional int32u messageResponseID = 0;
4411+
optional char_string<32> label = 1;
4412+
}
4413+
4414+
struct MessageStruct {
4415+
octet_string<16> messageID = 0;
4416+
MessagePriorityEnum priority = 1;
4417+
MessageControlBitmap messageControl = 2;
4418+
nullable epoch_s startTime = 3;
4419+
nullable int16u duration = 4;
4420+
char_string<256> messageText = 5;
4421+
optional MessageResponseOptionStruct responses[] = 6;
4422+
}
4423+
4424+
info event MessageQueued = 0 {
4425+
octet_string messageID = 0;
4426+
}
4427+
4428+
info event MessagePresented = 1 {
4429+
octet_string messageID = 0;
4430+
}
4431+
4432+
info event MessageComplete = 2 {
4433+
octet_string messageID = 0;
4434+
optional nullable int32u responseID = 1;
4435+
optional nullable char_string reply = 2;
4436+
nullable FutureMessagePreferenceEnum futureMessagesPreference = 3;
4437+
}
4438+
4439+
readonly attribute MessageStruct messages[] = 0;
4440+
readonly attribute octet_string activeMessageIDs[] = 1;
4441+
readonly attribute command_id generatedCommandList[] = 65528;
4442+
readonly attribute command_id acceptedCommandList[] = 65529;
4443+
readonly attribute event_id eventList[] = 65530;
4444+
readonly attribute attrib_id attributeList[] = 65531;
4445+
readonly attribute bitmap32 featureMap = 65532;
4446+
readonly attribute int16u clusterRevision = 65533;
4447+
4448+
request struct PresentMessagesRequestRequest {
4449+
MessageStruct messages[] = 0;
4450+
}
4451+
4452+
request struct CancelMessagesRequestRequest {
4453+
octet_string messageIDs[] = 0;
4454+
}
4455+
4456+
/** Command for requesting messages be presented */
4457+
fabric command PresentMessagesRequest(PresentMessagesRequestRequest): DefaultSuccess = 0;
4458+
/** Command for cancelling message present requests */
4459+
fabric command CancelMessagesRequest(CancelMessagesRequestRequest): DefaultSuccess = 1;
4460+
}
4461+
43754462
/** This cluster allows a client to manage the power draw of a device. An example of such a client could be an Energy Management System (EMS) which controls an Energy Smart Appliance (ESA). */
43764463
provisional cluster DeviceEnergyManagement = 152 {
43774464
revision 3;

0 commit comments

Comments
 (0)