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

Add a String Echo Request and Echo Response Command to the Unit testing cluster #34004

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7034,6 +7034,10 @@ internal cluster UnitTesting = 4294048773 {
int8u arg1[] = 0;
}

response struct StringEchoResponse = 13 {
octet_string payload = 0;
}

request struct TestEnumsRequestRequest {
vendor_id arg1 = 0;
SimpleEnum arg2 = 1;
Expand Down Expand Up @@ -7088,6 +7092,10 @@ internal cluster UnitTesting = 4294048773 {
int8u fillCharacter = 2;
}

request struct StringEchoRequestRequest {
octet_string payload = 0;
}

request struct TestDifferentVendorMeiRequestRequest {
int8u arg1 = 0;
}
Expand Down Expand Up @@ -7167,6 +7175,10 @@ internal cluster UnitTesting = 4294048773 {
command TestBatchHelperRequest(TestBatchHelperRequestRequest): TestBatchHelperResponse = 22;
/** Second command that responds after sleepBeforeResponseTimeMs with an octet_string the size requested with fillCharacter. */
command TestSecondBatchHelperRequest(TestSecondBatchHelperRequestRequest): TestBatchHelperResponse = 23;
/** Command that takes an argument which is an octet string. The response echoes
the string back. If the string is large then it would require a session that
supports large payloads. */
command StringEchoRequest(StringEchoRequestRequest): StringEchoResponse = 24;
/** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */
command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962;
}
Expand Down Expand Up @@ -9082,6 +9094,7 @@ endpoint 1 {
handle command TestEmitTestFabricScopedEventResponse;
handle command TestListNestedStructListArgumentRequest;
handle command TestListInt8UReverseRequest;
handle command StringEchoResponse;
handle command TestEnumsRequest;
handle command TestNullableOptionalRequest;
handle command SimpleStructEchoRequest;
Expand All @@ -9091,6 +9104,7 @@ endpoint 1 {
handle command TestEmitTestFabricScopedEventRequest;
handle command TestBatchHelperRequest;
handle command TestSecondBatchHelperRequest;
handle command StringEchoRequest;
handle command TestDifferentVendorMeiRequest;
handle command TestDifferentVendorMeiResponse;
}
Expand Down
16 changes: 16 additions & 0 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -21987,6 +21987,22 @@
"source": "server",
"isIncoming": 0,
"isEnabled": 1
},
{
"name": "StringEchoRequest",
"code": 24,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "StringEchoResponse",
"code": 13,
"mfgCode": null,
"source": "server",
"isIncoming": 0,
"isEnabled": 1
}
],
"attributes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5736,6 +5736,10 @@ internal cluster UnitTesting = 4294048773 {
int8u arg1[] = 0;
}

response struct StringEchoResponse = 13 {
octet_string payload = 0;
}

request struct TestEnumsRequestRequest {
vendor_id arg1 = 0;
SimpleEnum arg2 = 1;
Expand Down Expand Up @@ -5790,6 +5794,10 @@ internal cluster UnitTesting = 4294048773 {
int8u fillCharacter = 2;
}

request struct StringEchoRequestRequest {
octet_string payload = 0;
}

request struct TestDifferentVendorMeiRequestRequest {
int8u arg1 = 0;
}
Expand Down Expand Up @@ -5869,6 +5877,10 @@ internal cluster UnitTesting = 4294048773 {
command TestBatchHelperRequest(TestBatchHelperRequestRequest): TestBatchHelperResponse = 22;
/** Second command that responds after sleepBeforeResponseTimeMs with an octet_string the size requested with fillCharacter. */
command TestSecondBatchHelperRequest(TestSecondBatchHelperRequestRequest): TestBatchHelperResponse = 23;
/** Command that takes an argument which is an octet string. The response echoes
the string back. If the string is large then it would require a session that
supports large payloads. */
command StringEchoRequest(StringEchoRequestRequest): StringEchoResponse = 24;
/** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */
command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962;
}
Expand Down Expand Up @@ -6786,6 +6798,7 @@ endpoint 1 {
handle command TestEmitTestFabricScopedEventResponse;
handle command TestListNestedStructListArgumentRequest;
handle command TestListInt8UReverseRequest;
handle command StringEchoResponse;
handle command TestEnumsRequest;
handle command TestNullableOptionalRequest;
handle command SimpleStructEchoRequest;
Expand All @@ -6795,6 +6808,7 @@ endpoint 1 {
handle command TestEmitTestFabricScopedEventRequest;
handle command TestBatchHelperRequest;
handle command TestSecondBatchHelperRequest;
handle command StringEchoRequest;
handle command TestDifferentVendorMeiRequest;
handle command TestDifferentVendorMeiResponse;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9136,6 +9136,22 @@
"source": "server",
"isIncoming": 0,
"isEnabled": 1
},
{
"name": "StringEchoRequest",
"code": 24,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "StringEchoResponse",
"code": 13,
"mfgCode": null,
"source": "server",
"isIncoming": 0,
"isEnabled": 1
}
],
"attributes": [
Expand Down
12 changes: 12 additions & 0 deletions examples/chef/devices/rootnode_contactsensor_27f76aeaf5.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1771,6 +1771,10 @@ internal cluster UnitTesting = 4294048773 {
int8u arg1[] = 0;
}

response struct StringEchoResponse = 13 {
octet_string payload = 0;
}

request struct TestEnumsRequestRequest {
vendor_id arg1 = 0;
SimpleEnum arg2 = 1;
Expand Down Expand Up @@ -1825,6 +1829,10 @@ internal cluster UnitTesting = 4294048773 {
int8u fillCharacter = 2;
}

request struct StringEchoRequestRequest {
octet_string payload = 0;
}

request struct TestDifferentVendorMeiRequestRequest {
int8u arg1 = 0;
}
Expand Down Expand Up @@ -1904,6 +1912,10 @@ internal cluster UnitTesting = 4294048773 {
command TestBatchHelperRequest(TestBatchHelperRequestRequest): TestBatchHelperResponse = 22;
/** Second command that responds after sleepBeforeResponseTimeMs with an octet_string the size requested with fillCharacter. */
command TestSecondBatchHelperRequest(TestSecondBatchHelperRequestRequest): TestBatchHelperResponse = 23;
/** Command that takes an argument which is an octet string. The response echoes
the string back. If the string is large then it would require a session that
supports large payloads. */
command StringEchoRequest(StringEchoRequestRequest): StringEchoResponse = 24;
/** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */
command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962;
}
Expand Down
10 changes: 10 additions & 0 deletions src/app/clusters/test-cluster-server/test-cluster-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,16 @@ bool emberAfUnitTestingClusterSimpleStructEchoRequestCallback(CommandHandler * c
return true;
}

bool emberAfUnitTestingClusterStringEchoRequestCallback(CommandHandler * commandObj, const ConcreteCommandPath & commandPath,
const Commands::StringEchoRequest::DecodableType & commandData)
{
Commands::StringEchoResponse::Type response;
response.payload = commandData.payload;

commandObj->AddResponse(commandPath, response);
return true;
}

bool emberAfUnitTestingClusterTimedInvokeRequestCallback(CommandHandler * commandObj, const ConcreteCommandPath & commandPath,
const Commands::TimedInvokeRequest::DecodableType & commandData)
{
Expand Down
3 changes: 2 additions & 1 deletion src/app/tests/suites/TestCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3911,14 +3911,15 @@ tests:
21,
22,
23,
24,
4294049962,
]

- label: "Validate GeneratedCommandList attribute"
command: "readAttribute"
attribute: "GeneratedCommandList"
response:
value: [0, 1, 4, 5, 6, 8, 9, 10, 11, 12, 4294049979]
value: [0, 1, 4, 5, 6, 8, 9, 10, 11, 12, 13, 4294049979]

- label: "Validate presence of MEI attribute"
command: "readAttribute"
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/suites/TestUnitTestingClusterMei.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ tests:
attribute: "GeneratedCommandList"
response:
constraints:
contains: [0, 1, 4, 5, 6, 8, 9, 10, 11, 12, 4294049979]
contains: [0, 1, 4, 5, 6, 8, 9, 10, 11, 12, 13, 4294049979]

- label: "Validate presence of MEI attribute"
command: "readAttribute"
Expand Down
17 changes: 17 additions & 0 deletions src/app/zap-templates/zcl/data-model/chip/test-cluster.xml
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,16 @@ limitations under the License.
<arg name="fillCharacter" type="int8u"/>
</command>

<command source="client" code="0x18" name="StringEchoRequest"
response="StringEchoResponse" optional="true">
<description>
Command that takes an argument which is an octet string. The response echoes
the string back. If the string is large then it would require a session that
supports large payloads.
</description>
<arg name="payload" type="octet_string"/>
</command>

<command source="client" code="0xFFF200AA" name="TestDifferentVendorMeiRequest"
optional="true" response="TestDifferentVendorMeiResponse">
<description>
Expand Down Expand Up @@ -605,6 +615,13 @@ limitations under the License.
<arg name="buffer" type="octet_string" length="800"/>
</command>

<command source="server" code="0xD" name="StringEchoResponse" optional="true" disableDefaultResponse="true">
<description>
Response to StringEchoRequest. Buffer in response is filled by the payload in the Request.
</description>
<arg name="payload" type="octet_string"/>
</command>

<command source="server" code="0xFFF200BB" name="TestDifferentVendorMeiResponse" optional="true" disableDefaultResponse="true">
<description>
Response to TestDifferentVendorMeiRequest, which is a command having a different MEI vendor ID than the cluster.
Expand Down
12 changes: 12 additions & 0 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -9623,6 +9623,10 @@ internal cluster UnitTesting = 4294048773 {
int8u arg1[] = 0;
}

response struct StringEchoResponse = 13 {
octet_string payload = 0;
}

request struct TestEnumsRequestRequest {
vendor_id arg1 = 0;
SimpleEnum arg2 = 1;
Expand Down Expand Up @@ -9677,6 +9681,10 @@ internal cluster UnitTesting = 4294048773 {
int8u fillCharacter = 2;
}

request struct StringEchoRequestRequest {
octet_string payload = 0;
}

request struct TestDifferentVendorMeiRequestRequest {
int8u arg1 = 0;
}
Expand Down Expand Up @@ -9756,6 +9764,10 @@ internal cluster UnitTesting = 4294048773 {
command TestBatchHelperRequest(TestBatchHelperRequestRequest): TestBatchHelperResponse = 22;
/** Second command that responds after sleepBeforeResponseTimeMs with an octet_string the size requested with fillCharacter. */
command TestSecondBatchHelperRequest(TestSecondBatchHelperRequestRequest): TestBatchHelperResponse = 23;
/** Command that takes an argument which is an octet string. The response echoes
the string back. If the string is large then it would require a session that
supports large payloads. */
command StringEchoRequest(StringEchoRequestRequest): StringEchoResponse = 24;
/** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */
command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64543,6 +64543,36 @@ public void onResponse(StructType invokeStructValue) {
}}, commandId, commandArgs, timedInvokeTimeoutMs);
}

public void stringEchoRequest(StringEchoResponseCallback callback, byte[] payload) {
stringEchoRequest(callback, payload, 0);
}

public void stringEchoRequest(StringEchoResponseCallback callback, byte[] payload, int timedInvokeTimeoutMs) {
final long commandId = 24L;

ArrayList<StructElement> elements = new ArrayList<>();
final long payloadFieldID = 0L;
BaseTLVType payloadtlvValue = new ByteArrayType(payload);
elements.add(new StructElement(payloadFieldID, payloadtlvValue));

StructType commandArgs = new StructType(elements);
invoke(new InvokeCallbackImpl(callback) {
@Override
public void onResponse(StructType invokeStructValue) {
final long payloadFieldID = 0L;
byte[] payload = null;
for (StructElement element: invokeStructValue.value()) {
if (element.contextTagNum() == payloadFieldID) {
if (element.value(BaseTLVType.class).type() == TLVType.ByteArray) {
ByteArrayType castingValue = element.value(ByteArrayType.class);
payload = castingValue.value(byte[].class);
}
}
}
callback.onSuccess(payload);
}}, commandId, commandArgs, timedInvokeTimeoutMs);
}

public void testDifferentVendorMeiRequest(TestDifferentVendorMeiResponseCallback callback, Integer arg1) {
testDifferentVendorMeiRequest(callback, arg1, 0);
}
Expand Down Expand Up @@ -64632,6 +64662,10 @@ public interface TestBatchHelperResponseCallback extends BaseClusterCallback {
void onSuccess(byte[] buffer);
}

public interface StringEchoResponseCallback extends BaseClusterCallback {
void onSuccess(byte[] payload);
}

public interface TestDifferentVendorMeiResponseCallback extends BaseClusterCallback {
void onSuccess(Integer arg1, Long eventNumber);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17318,6 +17318,7 @@ public enum Command {
TestEmitTestFabricScopedEventRequest(21L),
TestBatchHelperRequest(22L),
TestSecondBatchHelperRequest(23L),
StringEchoRequest(24L),
TestDifferentVendorMeiRequest(4294049962L),;
private final long id;
Command(long id) {
Expand Down Expand Up @@ -17659,6 +17660,23 @@ public static TestSecondBatchHelperRequestCommandField value(int id) throws NoSu
}
throw new NoSuchFieldError();
}
}public enum StringEchoRequestCommandField {Payload(0),;
private final int id;
StringEchoRequestCommandField(int id) {
this.id = id;
}

public int getID() {
return id;
}
public static StringEchoRequestCommandField value(int id) throws NoSuchFieldError {
for (StringEchoRequestCommandField field : StringEchoRequestCommandField.values()) {
if (field.getID() == id) {
return field;
}
}
throw new NoSuchFieldError();
}
}public enum TestDifferentVendorMeiRequestCommandField {Arg1(0),;
private final int id;
TestDifferentVendorMeiRequestCommandField(int id) {
Expand Down
Loading
Loading