From bf0ff55c9bfcb21d367006da0d717b0a39ae126f Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Fri, 28 Jul 2023 13:48:49 -0400 Subject: [PATCH 1/3] Fix id for event report decoding --- src/lib/format/protocol_messages.matter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/format/protocol_messages.matter b/src/lib/format/protocol_messages.matter index 0346b138fd45b0..786c50d85dffb0 100644 --- a/src/lib/format/protocol_messages.matter +++ b/src/lib/format/protocol_messages.matter @@ -262,7 +262,7 @@ client cluster IMProtocol = 0xFFFF0001 { int64u delta_system_timestamp = 6; // } - cluster_event_payload data = 2; + cluster_event_payload data = 7; } struct EventReportIB { From b686c21b16351ed5ee7a9e9fa9dd10d2d5a2b0fc Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Fri, 28 Jul 2023 14:57:56 -0400 Subject: [PATCH 2/3] Add unit tests for event decoding --- src/lib/format/tests/TestDecoding.cpp | 37 +++++++++++++++++++++++++++ src/lib/format/tests/sample_data.cpp | 25 +++++++++++++++++- src/lib/format/tests/sample_data.h | 4 +++ 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/lib/format/tests/TestDecoding.cpp b/src/lib/format/tests/TestDecoding.cpp index 7dfc005e8e5988..9ad6f97b6849d5 100644 --- a/src/lib/format/tests/TestDecoding.cpp +++ b/src/lib/format/tests/TestDecoding.cpp @@ -355,6 +355,43 @@ void TestFullDataDecoding(nlTestSuite * inSuite, void * inContext) " Channel::ChangeChannel\n" " match: \"channel name\"\n" " interaction_model_revison: 1\n"); + + TestSampleData(inSuite, params, im_protocol_event_software_fault, + "report_data\n" + " event_reports\n" + " Anonymous<>\n" + " event_data\n" + " path\n" + " endpoint_id: 0\n" + " cluster_id: 52 == 'SoftwareDiagnostics'\n" + " event_id: 0 == 'SoftwareFault'\n" + " event_number: 196610\n" + " priority: 1\n" + " epoch_timestamp: 1690566548210\n" + " SoftwareDiagnostics::SoftwareFault\n" + " id: 2454952\n" + " name: \"2454952\"\n" + " faultRecording: hex:467269204A756C2032382031333A34393A30382032303233\n" + " suppress_response: true\n" + " interaction_model_revison: 1\n"); + + TestSampleData(inSuite, params, im_protocol_event_multipress, + "report_data\n" + " event_reports\n" + " Anonymous<>\n" + " event_data\n" + " path\n" + " endpoint_id: 0\n" + " cluster_id: 59 == 'Switch'\n" + " event_id: 6 == 'MultiPressComplete'\n" + " event_number: 196611\n" + " priority: 1\n" + " epoch_timestamp: 1690566820898\n" + " Switch::MultiPressComplete\n" + " previousPosition: 1\n" + " totalNumberOfPressesCounted: 23\n" + " suppress_response: true\n" + " interaction_model_revison: 1\n"); } void TestMetaDataOnlyDecoding(nlTestSuite * inSuite, void * inContext) diff --git a/src/lib/format/tests/sample_data.cpp b/src/lib/format/tests/sample_data.cpp index b5304198bdda1a..fb1f80223120f5 100644 --- a/src/lib/format/tests/sample_data.cpp +++ b/src/lib/format/tests/sample_data.cpp @@ -104,10 +104,27 @@ const uint8_t payload_1_8_change_channel[] = { 0x15, 0x28, 0x00, 0x28, 0x01, 0x3 0x00, 0x0C, 0x63, 0x68, 0x61, 0x6E, 0x6E, 0x65, 0x6C, 0x20, 0x6E, 0x61, 0x6D, 0x65, 0x18, 0x18, 0x18, 0x24, 0xFF, 0x01, 0x18 }; +// Software fault event: +// id: 2454952, name: "2454952", faultRecording: "467269204A756C2032382031333A34393A30382032303233" +const uint8_t payload_1_5_software_fault_event[] = { + 0x15, 0x36, 0x02, 0x15, 0x35, 0x01, 0x37, 0x00, 0x24, 0x01, 0x00, 0x24, 0x02, 0x34, 0x24, 0x03, 0x00, 0x18, 0x26, + 0x01, 0x02, 0x00, 0x03, 0x00, 0x24, 0x02, 0x01, 0x27, 0x03, 0xF2, 0x5A, 0x9E, 0x9D, 0x89, 0x01, 0x00, 0x00, 0x35, + 0x07, 0x26, 0x00, 0xA8, 0x75, 0x25, 0x00, 0x2C, 0x01, 0x07, 0x32, 0x34, 0x35, 0x34, 0x39, 0x35, 0x32, 0x30, 0x02, + 0x18, 0x46, 0x72, 0x69, 0x20, 0x4A, 0x75, 0x6C, 0x20, 0x32, 0x38, 0x20, 0x31, 0x33, 0x3A, 0x34, 0x39, 0x3A, 0x30, + 0x38, 0x20, 0x32, 0x30, 0x32, 0x33, 0x18, 0x18, 0x18, 0x18, 0x29, 0x04, 0x24, 0xFF, 0x01, 0x18 +}; + +// A multipress complete event +// previousPosition: 1, totalNumberOfPressesCounted: 23 +const uint8_t payload_1_5_multipress_event[] = { 0x15, 0x36, 0x02, 0x15, 0x35, 0x01, 0x37, 0x00, 0x24, 0x01, 0x00, 0x24, 0x02, 0x3B, + 0x24, 0x03, 0x06, 0x18, 0x26, 0x01, 0x03, 0x00, 0x03, 0x00, 0x24, 0x02, 0x01, 0x27, + 0x03, 0x22, 0x84, 0xA2, 0x9D, 0x89, 0x01, 0x00, 0x00, 0x35, 0x07, 0x24, 0x00, 0x01, + 0x24, 0x01, 0x17, 0x18, 0x18, 0x18, 0x18, 0x29, 0x04, 0x24, 0xFF, 0x01, 0x18 }; + } // namespace const SamplePayload secure_channel_mrp_ack = { chip::Protocols::Id(VendorId::Common, 0), 16, - ByteSpan(payload_0_16, sizeof(payload_0_16)) }; + ByteSpan(payload_0_16, sizeof(payload_0_16)) }; const SamplePayload secure_channel_pkbdf_param_request = { chip::Protocols::Id(VendorId::Common, 0), 32, ByteSpan(payload_0_32) }; const SamplePayload secure_channel_pkbdf_param_response = { chip::Protocols::Id(VendorId::Common, 0), 33, ByteSpan(payload_0_33) }; const SamplePayload secure_channel_pase_pake1 = { chip::Protocols::Id(VendorId::Common, 0), 34, ByteSpan(payload_0_34) }; @@ -127,5 +144,11 @@ const SamplePayload im_protocol_report_data_acl = { chip::Protocols::Id(VendorId const SamplePayload im_protocol_report_data_window_covering = { chip::Protocols::Id(VendorId::Common, 1), 5, ByteSpan(payload_1_5_window_covering) }; +const SamplePayload im_protocol_event_software_fault = { chip::Protocols::Id(VendorId::Common, 1), 5, + ByteSpan(payload_1_5_software_fault_event) }; + +const SamplePayload im_protocol_event_multipress = { chip::Protocols::Id(VendorId::Common, 1), 5, + ByteSpan(payload_1_5_multipress_event) }; + } // namespace TestData } // namespace chip diff --git a/src/lib/format/tests/sample_data.h b/src/lib/format/tests/sample_data.h index d8bf5864593978..cc74ae09e296fc 100644 --- a/src/lib/format/tests/sample_data.h +++ b/src/lib/format/tests/sample_data.h @@ -46,5 +46,9 @@ extern const SamplePayload im_protocol_report_data_acl; extern const SamplePayload im_protocol_report_data_window_covering; extern const SamplePayload im_protocol_invoke_request_change_channel; +// different event reports +extern const SamplePayload im_protocol_event_software_fault; +extern const SamplePayload im_protocol_event_multipress; + } // namespace TestData } // namespace chip From 6f5b7c192bd7e09f377b400638f67e77faa448d6 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 28 Jul 2023 18:59:37 +0000 Subject: [PATCH 3/3] Restyled by clang-format --- src/lib/format/tests/sample_data.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/format/tests/sample_data.cpp b/src/lib/format/tests/sample_data.cpp index fb1f80223120f5..52bfb64a54c085 100644 --- a/src/lib/format/tests/sample_data.cpp +++ b/src/lib/format/tests/sample_data.cpp @@ -117,14 +117,14 @@ const uint8_t payload_1_5_software_fault_event[] = { // A multipress complete event // previousPosition: 1, totalNumberOfPressesCounted: 23 const uint8_t payload_1_5_multipress_event[] = { 0x15, 0x36, 0x02, 0x15, 0x35, 0x01, 0x37, 0x00, 0x24, 0x01, 0x00, 0x24, 0x02, 0x3B, - 0x24, 0x03, 0x06, 0x18, 0x26, 0x01, 0x03, 0x00, 0x03, 0x00, 0x24, 0x02, 0x01, 0x27, - 0x03, 0x22, 0x84, 0xA2, 0x9D, 0x89, 0x01, 0x00, 0x00, 0x35, 0x07, 0x24, 0x00, 0x01, - 0x24, 0x01, 0x17, 0x18, 0x18, 0x18, 0x18, 0x29, 0x04, 0x24, 0xFF, 0x01, 0x18 }; + 0x24, 0x03, 0x06, 0x18, 0x26, 0x01, 0x03, 0x00, 0x03, 0x00, 0x24, 0x02, 0x01, 0x27, + 0x03, 0x22, 0x84, 0xA2, 0x9D, 0x89, 0x01, 0x00, 0x00, 0x35, 0x07, 0x24, 0x00, 0x01, + 0x24, 0x01, 0x17, 0x18, 0x18, 0x18, 0x18, 0x29, 0x04, 0x24, 0xFF, 0x01, 0x18 }; } // namespace const SamplePayload secure_channel_mrp_ack = { chip::Protocols::Id(VendorId::Common, 0), 16, - ByteSpan(payload_0_16, sizeof(payload_0_16)) }; + ByteSpan(payload_0_16, sizeof(payload_0_16)) }; const SamplePayload secure_channel_pkbdf_param_request = { chip::Protocols::Id(VendorId::Common, 0), 32, ByteSpan(payload_0_32) }; const SamplePayload secure_channel_pkbdf_param_response = { chip::Protocols::Id(VendorId::Common, 0), 33, ByteSpan(payload_0_33) }; const SamplePayload secure_channel_pase_pake1 = { chip::Protocols::Id(VendorId::Common, 0), 34, ByteSpan(payload_0_34) };