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

Restyle Test Event Trigger implementation for General Diagnostics Cluster #18843

Closed
wants to merge 7 commits into from
Closed
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
113 changes: 113 additions & 0 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,109 @@ server cluster GeneralCommissioning = 48 {
command access(invoke: administer) CommissioningComplete(): CommissioningCompleteResponse = 4;
}

client cluster GeneralDiagnostics = 51 {
enum BootReasonType : ENUM8 {
kUnspecified = 0;
kPowerOnReboot = 1;
kBrownOutReset = 2;
kSoftwareWatchdogReset = 3;
kHardwareWatchdogReset = 4;
kSoftwareUpdateCompleted = 5;
kSoftwareReset = 6;
}

enum HardwareFaultType : ENUM8 {
kUnspecified = 0;
kRadio = 1;
kSensor = 2;
kResettableOverTemp = 3;
kNonResettableOverTemp = 4;
kPowerSource = 5;
kVisualDisplayFault = 6;
kAudioOutputFault = 7;
kUserInterfaceFault = 8;
kNonVolatileMemoryError = 9;
kTamperDetected = 10;
}

enum InterfaceType : ENUM8 {
kUnspecified = 0;
kWiFi = 1;
kEthernet = 2;
kCellular = 3;
kThread = 4;
}

enum NetworkFaultType : ENUM8 {
kUnspecified = 0;
kHardwareFailure = 1;
kNetworkJammed = 2;
kConnectionFailed = 3;
}

enum RadioFaultType : ENUM8 {
kUnspecified = 0;
kWiFiFault = 1;
kCellularFault = 2;
kThreadFault = 3;
kNFCFault = 4;
kBLEFault = 5;
kEthernetFault = 6;
}

struct NetworkInterfaceType {
char_string<32> name = 0;
boolean isOperational = 1;
nullable boolean offPremiseServicesReachableIPv4 = 2;
nullable boolean offPremiseServicesReachableIPv6 = 3;
octet_string<8> hardwareAddress = 4;
octet_string IPv4Addresses[] = 5;
octet_string IPv6Addresses[] = 6;
InterfaceType type = 7;
}

critical event HardwareFaultChange = 0 {
HardwareFaultType current[] = 0;
HardwareFaultType previous[] = 1;
}

critical event RadioFaultChange = 1 {
RadioFaultType current[] = 0;
RadioFaultType previous[] = 1;
}

critical event NetworkFaultChange = 2 {
NetworkFaultType current[] = 0;
NetworkFaultType previous[] = 1;
}

critical event BootReason = 3 {
BootReasonType bootReason = 0;
}

readonly attribute NetworkInterfaceType networkInterfaces[] = 0;
readonly attribute int16u rebootCount = 1;
readonly attribute int64u upTime = 2;
readonly attribute int32u totalOperationalHours = 3;
readonly attribute enum8 bootReasons = 4;
readonly attribute ENUM8 activeHardwareFaults[] = 5;
readonly attribute ENUM8 activeRadioFaults[] = 6;
readonly attribute ENUM8 activeNetworkFaults[] = 7;
readonly attribute boolean testEventTriggersEnabled = 8;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;

request struct TestEventTriggerRequest {
OCTET_STRING enableKey = 0;
INT64U eventTrigger = 1;
}

command TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0;
}

server cluster GeneralDiagnostics = 51 {
enum BootReasonType : ENUM8 {
kUnspecified = 0;
Expand Down Expand Up @@ -1600,11 +1703,19 @@ server cluster GeneralDiagnostics = 51 {
readonly attribute ENUM8 activeHardwareFaults[] = 5;
readonly attribute ENUM8 activeRadioFaults[] = 6;
readonly attribute ENUM8 activeNetworkFaults[] = 7;
readonly attribute boolean testEventTriggersEnabled = 8;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;

request struct TestEventTriggerRequest {
OCTET_STRING enableKey = 0;
INT64U eventTrigger = 1;
}

command TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0;
}

server cluster GroupKeyManagement = 63 {
Expand Down Expand Up @@ -3828,6 +3939,7 @@ server cluster WindowCovering = 258 {

endpoint 0 {
binding cluster OtaSoftwareUpdateProvider;
binding cluster GeneralDiagnostics;

server cluster Identify {
ram attribute identifyTime;
Expand Down Expand Up @@ -3979,6 +4091,7 @@ endpoint 0 {
callback attribute activeHardwareFaults;
callback attribute activeRadioFaults;
callback attribute activeNetworkFaults;
callback attribute testEventTriggersEnabled;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute attributeList;
Expand Down
29 changes: 27 additions & 2 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -3355,8 +3355,17 @@
"mfgCode": null,
"define": "GENERAL_DIAGNOSTICS_CLUSTER",
"side": "client",
"enabled": 0,
"commands": [],
"enabled": 1,
"commands": [
{
"name": "TestEventTrigger",
"code": 0,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 1
}
],
"attributes": [
{
"name": "ClusterRevision",
Expand Down Expand Up @@ -3513,6 +3522,22 @@
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "TestEventTriggersEnabled",
"code": 8,
"mfgCode": null,
"side": "server",
"type": "boolean",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "GeneratedCommandList",
"code": 65528,
Expand Down
48 changes: 48 additions & 0 deletions src/app/TestEventTriggerDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2022 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <lib/core/CHIPError.h>
#include <lib/support/Span.h>
#include <stddef.h>
#include <stdint.h>

namespace chip {

class TestEventTriggerDelegate
{
public:
/**
* Checks to see if `enableKey` provided matches value chosen by the manufacturer.
*
* @param[in] enableKey Buffer of the key to verify.
*/
virtual bool DoesEnableKeyMatch(const ByteSpan & enableKey) const = 0;

/**
* Expectation is that the caller has already validated the enable key before calling this.
* Handles the test event trigger based on `eventTrigger` provided.
*
* @param[in] eventTrigger Event trigger to handle.
*
* @return CHIP_ERROR_INVALID_ARGUMENT when eventTrigger is not a valid test event trigger.
*/
virtual CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) = 0;
};

} // namespace chip
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/AttributeAccessInterface.h>
#include <app/CommandHandlerInterface.h>
#include <app/EventLogging.h>
#include <app/reporting/reporting.h>
#include <app/util/attribute-storage.h>
Expand Down Expand Up @@ -162,6 +163,11 @@ CHIP_ERROR GeneralDiagosticsAttrAccess::Read(const ConcreteReadAttributePath & a
case BootReasons::Id: {
return ReadIfSupported(&DiagnosticDataProvider::GetBootReason, aEncoder);
}
case TestEventTriggersEnabled::Id: {
// TODO actually implement this part
ChipLogDetail(Zcl, "TMsg!!!!!!!!!!!! Nice we are in here");
return aEncoder.Encode(false);
}
default: {
break;
}
Expand Down Expand Up @@ -290,6 +296,17 @@ GeneralDiagnosticsDelegate gDiagnosticDelegate;

} // anonymous namespace

bool emberAfGeneralDiagnosticsClusterTestEventTriggerCallback(CommandHandler * commandObj, const ConcreteCommandPath & commandPath,
const Commands::TestEventTrigger::DecodableType & commandData)
{

ChipLogDetail(Zcl, "TMsg!!!!!!!!!!!! We got the TestEventTrigger command");
ChipLogDetail(Zcl, "TMsg!!!!!!!!!!!! We got the TestEventTrigger commandData.enableKey.size()=%d",
(int) (commandData.enableKey.size()));
ChipLogDetail(Zcl, "TMsg!!!!!!!!!!!! commandData.eventTrigger=0x" ChipLogFormatX64, ChipLogValueX64(commandData.eventTrigger));
return false;
}

void MatterGeneralDiagnosticsPluginServerInitCallback()
{
registerAttributeAccessOverride(&gAttrAccess);
Expand Down
7 changes: 7 additions & 0 deletions src/app/server/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <app/CASESessionManager.h>
#include <app/DefaultAttributePersistenceProvider.h>
#include <app/OperationalDeviceProxyPool.h>
#include <app/TestEventTriggerDelegate.h>
#include <app/server/AclStorage.h>
#include <app/server/AppDelegate.h>
#include <app/server/CommissioningWindowManager.h>
Expand Down Expand Up @@ -105,6 +106,8 @@ struct ServerInitParams
// Network native params can be injected depending on the
// selected Endpoint implementation
void * endpointNativeParams = nullptr;
// TODO(thampson): comment here about what this does
TestEventTriggerDelegate * testEventTriggerDelegate = nullptr;
};

/**
Expand Down Expand Up @@ -242,6 +245,8 @@ class Server

PersistentStorageDelegate & GetPersistentStorage() { return *mDeviceStorage; }

TestEventTriggerDelegate * GetTestEventTriggerDelegate() { return mTestEventTriggerDelegate; }

/**
* This function send the ShutDown event before stopping
* the event loop.
Expand Down Expand Up @@ -381,6 +386,8 @@ class Server
Access::AccessControl mAccessControl;
app::AclStorage * mAclStorage;

TestEventTriggerDelegate * mTestEventTriggerDelegate;

uint16_t mOperationalServicePort;
uint16_t mUserDirectedCommissioningPort;
Inet::InterfaceId mInterfaceId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ limitations under the License.
<attribute side="server" code="0x05" define="ACTIVE_HARDWARE_FAULTS" type="ARRAY" entryType="ENUM8" writable="false" optional="true">ActiveHardwareFaults</attribute>
<attribute side="server" code="0x06" define="ACTIVE_RADIO_FAULTS" type="ARRAY" entryType="ENUM8" writable="false" optional="true">ActiveRadioFaults</attribute>
<attribute side="server" code="0x07" define="ACTIVE_NETWORK_FAULTS" type="ARRAY" entryType="ENUM8" writable="false" optional="true">ActiveNetworkFaults</attribute>
<attribute side="server" code="0x08" define="TEST_EVENT_TRIGGERS_ENABLED" type="BOOLEAN" writable="false" optional="false">TestEventTriggersEnabled</attribute>

<command source="client" code="0x00" name="TestEventTrigger" optional="false">
<description>Provide a means for certification tests to trigger some test-plan-specific events</description>
<arg name="EnableKey" type="OCTET_STRING" length="16"/>
<arg name="EventTrigger" type="INT64U"/>
</command>

<event side="server" code="0x00" name="HardwareFaultChange" priority="critical" optional="true">
<description>Indicate a change in the set of hardware faults currently detected by the Node.</description>
<field id="0" name="Current" type="HardwareFaultType" array="true"/>
Expand All @@ -110,5 +118,6 @@ limitations under the License.
<description>Indicate the reason that caused the device to start-up.</description>
<field id="0" name="BootReason" type="BootReasonType"/>
</event>

</cluster>
</configurator>
1 change: 1 addition & 0 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1958,6 +1958,7 @@ client cluster GeneralDiagnostics = 51 {
readonly attribute ENUM8 activeHardwareFaults[] = 5;
readonly attribute ENUM8 activeRadioFaults[] = 6;
readonly attribute ENUM8 activeNetworkFaults[] = 7;
readonly attribute boolean testEventTriggersEnabled = 8;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute attrib_id attributeList[] = 65531;
Expand Down
27 changes: 26 additions & 1 deletion src/controller/data_model/controller-clusters.zap
Original file line number Diff line number Diff line change
Expand Up @@ -5229,7 +5229,16 @@
"define": "GENERAL_DIAGNOSTICS_CLUSTER",
"side": "client",
"enabled": 1,
"commands": [],
"commands": [
{
"name": "TestEventTrigger",
"code": 0,
"mfgCode": null,
"source": "client",
"incoming": 0,
"outgoing": 1
},
],
"attributes": [
{
"name": "ClusterRevision",
Expand Down Expand Up @@ -5386,6 +5395,22 @@
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "TestEventTriggersEnabled",
"code": 8,
"mfgCode": null,
"side": "server",
"type": "boolean",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "GeneratedCommandList",
"code": 65528,
Expand Down
Loading