Skip to content

Commit

Permalink
Merge branch 'master' into topic/pucn_infineonrestructure
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 authored Aug 18, 2022
2 parents 93957ef + 1ea6bbe commit 61c7028
Show file tree
Hide file tree
Showing 73 changed files with 4,065 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3827,6 +3827,32 @@ server cluster TestCluster = 4294048773 {
command TestEmitTestFabricScopedEventRequest(TestEmitTestFabricScopedEventRequestRequest): TestEmitTestFabricScopedEventResponse = 21;
}

server cluster FaultInjection = 4294048774 {
enum FaultType : ENUM8 {
kUnspecified = 0;
kSystemFault = 1;
kInetFault = 2;
kChipFault = 3;
kCertFault = 4;
}

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 FailAtFaultRequest {
FaultType type = 0;
INT32U id = 1;
INT32U numCallsToSkip = 2;
INT32U numCallsToFail = 3;
BOOLEAN takeMutex = 4;
}

command access(invoke: manage) FailAtFault(FailAtFaultRequest): DefaultSuccess = 0;
}

endpoint 0 {
device type rootdevice = 22;
binding cluster OtaSoftwareUpdateProvider;
Expand Down Expand Up @@ -4145,6 +4171,14 @@ endpoint 0 {
ram attribute featureMap;
ram attribute clusterRevision default = 3;
}

server cluster FaultInjection {
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute attributeList;
ram attribute featureMap;
ram attribute clusterRevision default = 1;
}
}
endpoint 1 {
device type onofflight = 256;
Expand Down
142 changes: 142 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 @@ -8445,6 +8445,148 @@
"reportableChange": 0
}
]
},
{
"name": "Fault Injection",
"code": 4294048774,
"mfgCode": null,
"define": "FAULT_INJECTION_CLUSTER",
"side": "client",
"enabled": 0,
"commands": [
{
"name": "FailAtFault",
"code": 0,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 1
}
],
"attributes": [
{
"name": "FeatureMap",
"code": 65532,
"mfgCode": null,
"side": "client",
"type": "bitmap32",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ClusterRevision",
"code": 65533,
"mfgCode": null,
"side": "client",
"type": "int16u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "1",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
}
]
},
{
"name": "Fault Injection",
"code": 4294048774,
"mfgCode": null,
"define": "FAULT_INJECTION_CLUSTER",
"side": "server",
"enabled": 1,
"attributes": [
{
"name": "GeneratedCommandList",
"code": 65528,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AcceptedCommandList",
"code": 65529,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AttributeList",
"code": 65531,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
"mfgCode": null,
"side": "server",
"type": "bitmap32",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ClusterRevision",
"code": 65533,
"mfgCode": null,
"side": "server",
"type": "int16u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "1",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
}
]
}
]
},
Expand Down
2 changes: 2 additions & 0 deletions examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ set(PRIV_INCLUDE_DIRS_LIST
"${CMAKE_CURRENT_LIST_DIR}/include"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/third_party/nlfaultinjection/repo/include"
)
set(SRC_DIRS_LIST
"${CMAKE_CURRENT_LIST_DIR}"
Expand All @@ -41,6 +42,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/application-basic-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/test-cluster-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/descriptor"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fault-injection-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fan-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fixed-label-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/user-label-server"
Expand Down
2 changes: 2 additions & 0 deletions src/app/EventLogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ CHIP_ERROR LogEvent(const T & aEventData, EndpointId aEndpoint, EventNumber & aE
eventOptions.mPath = path;
eventOptions.mPriority = aEventData.GetPriorityLevel();
eventOptions.mFabricIndex = aEventData.GetFabricIndex();
// this skips logging the event if it's fabric-scoped but no fabric association exists yet.
VerifyOrReturnError(eventOptions.mFabricIndex != kUndefinedFabricIndex, CHIP_NO_ERROR);

//
// Unlike attributes which have a different 'EncodeForRead' for fabric-scoped structs,
Expand Down
96 changes: 96 additions & 0 deletions src/app/clusters/fault-injection-server/fault-injection-server.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/**
*
* Copyright (c) 2022 Project CHIP Authors
*
* 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.
*/

#include "app/server/Server.h"
#include <app-common/zap-generated/af-structs.h>
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/CommandResponseHelper.h>
#include <app/util/af.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/CHIPLogging.h>

#if CHIP_WITH_NLFAULTINJECTION
#include <inet/InetFaultInjection.h>
#include <lib/support/CHIPFaultInjection.h>
#include <system/SystemFaultInjection.h>
#endif

using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters::FaultInjection;
using chip::Protocols::InteractionModel::Status;

bool emberAfFaultInjectionClusterFailAtFaultCallback(CommandHandler * commandObj, const ConcreteCommandPath & commandPath,
const Commands::FailAtFault::DecodableType & commandData)
{
if (commandPath.mClusterId != Clusters::FaultInjection::Id)
{
// We shouldn't have been called at all.
commandObj->AddStatus(commandPath, Status::UnsupportedCluster);
return true;
}

#if CHIP_WITH_NLFAULTINJECTION
Status returnStatus = Status::Success;
nl::FaultInjection::Manager * faultInjectionMgr = nullptr;

switch (commandData.type)
{
case FaultType::kSystemFault:
faultInjectionMgr = &chip::System::FaultInjection::GetManager();
break;
case FaultType::kInetFault:
faultInjectionMgr = &chip::Inet::FaultInjection::GetManager();
break;
case FaultType::kChipFault:
faultInjectionMgr = &chip::FaultInjection::GetManager();
break;
default:
ChipLogError(Zcl, "FaultInjection: Unsupported Fault type received");
returnStatus = Status::InvalidCommand;
break;
}

if (faultInjectionMgr != nullptr)
{
ChipLogProgress(Zcl, "FaultInjection: Configure a fault of type: %d and Id: %d to be triggered deterministically",
static_cast<uint8_t>(commandData.type), commandData.id);
int32_t err = faultInjectionMgr->FailAtFault(commandData.id, commandData.numCallsToSkip, commandData.numCallsToFail,
commandData.takeMutex);

if (err != 0)
{
ChipLogError(Zcl, "FaultInjection: Pass invalid inputs to FailAtFault");
returnStatus = Status::InvalidCommand;
}
}
else
{
ChipLogError(Zcl, "FaultInjection: Failed to get Fault Injection manager");
returnStatus = Status::Failure;
}
#else
Status returnStatus = Status::UnsupportedCommand;
#endif // CHIP_WITH_NLFAULTINJECTION

commandObj->AddStatus(commandPath, returnStatus);
return true;
}

void MatterFaultInjectionPluginServerInitCallback() {}
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ bool emberAfTestClusterClusterTestEmitTestFabricScopedEventRequestCallback(
{
Commands::TestEmitTestFabricScopedEventResponse::Type responseData;
Events::TestFabricScopedEvent::Type event{ commandData.arg1 };

event.fabricIndex = commandData.arg1;
if (CHIP_NO_ERROR != LogEvent(event, commandPath.mEndpointId, responseData.value))
{
emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE);
Expand Down
1 change: 1 addition & 0 deletions src/app/tests/suites/TestDescriptorCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ tests:
0x0040, # Fixed Label
0x0041, # User Label
0x0405, # Relative Humidity Measurement (why on EP0?)
0xFFF1FC06, # Fault Injection
]

- label: "Read attribute Client list"
Expand Down
1 change: 1 addition & 0 deletions src/app/zap-templates/zcl/data-model/all.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<xi:include href="chip/diagnostic-logs-cluster.xml" />
<xi:include href="chip/door-lock-cluster.xml" />
<xi:include href="chip/ethernet-network-diagnostics-cluster.xml" />
<xi:include href="chip/fault-injection-cluster.xml" />
<xi:include href="chip/fixed-label-cluster.xml" />
<xi:include href="chip/flow-measurement-cluster.xml" />
<xi:include href="chip/general-commissioning-cluster.xml" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2022 Project CHIP Authors
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.
-->
<configurator>
<domain name="CHIP"/>
<enum name="FaultType" type="ENUM8">
<cluster code="0xFFF1FC06"/>
<item name="Unspecified" value="0x00"/>
<item name="SystemFault" value="0x01"/>
<item name="InetFault" value="0x02"/>
<item name="ChipFault" value="0x03"/>
<item name="CertFault" value="0x04"/>
</enum>
<cluster>
<domain>CHIP</domain>
<name>Fault Injection</name>
<code>0xFFF1FC06</code>
<define>FAULT_INJECTION_CLUSTER</define>
<description>The Fault Injection Cluster provide a means for a test harness to configure faults(for example triggering a fault in the system).</description>
<command source="client" code="0x00" name="FailAtFault" optional="false">
<description>Configure a fault to be triggered deterministically</description>
<arg name="Type" type="FaultType"/>
<arg name="Id" type="INT32U"/>
<arg name="NumCallsToSkip" type="INT32U"/>
<arg name="NumCallsToFail" type="INT32U"/>
<arg name="TakeMutex" type="BOOLEAN"/>
<access op="invoke" role="manage"/>
</command>
</cluster>
</configurator>
Loading

0 comments on commit 61c7028

Please sign in to comment.