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

Drop-off fabric sensitive event when fabric is undefined #21874

Closed
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
2 changes: 2 additions & 0 deletions src/app/EventLogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ CHIP_ERROR LogEvent(const T & aEventData, EndpointId aEndpoint, EventNumber & aE
eventOptions.mPriority = aEventData.GetPriorityLevel();
eventOptions.mFabricIndex = aEventData.GetFabricIndex();

VerifyOrReturnError(eventOptions.mFabricIndex != kUndefinedFabricIndex, CHIP_NO_ERROR);

//
// Unlike attributes which have a different 'EncodeForRead' for fabric-scoped structs,
// fabric-sensitive events don't require that since the actual omission of the event in its entirety
Expand Down
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
20 changes: 19 additions & 1 deletion src/controller/python/test/test_scripts/cluster_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ async def _TriggerEvent(cls, devCtrl):
await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=Clusters.TestCluster.Commands.TestEmitTestEventRequest())
await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=Clusters.TestCluster.Commands.TestEmitTestEventRequest())
await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=Clusters.TestCluster.Commands.TestEmitTestEventRequest())
await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=Clusters.TestCluster.Commands.TestEmitTestFabricScopedEventRequest(arg1=0))
await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=Clusters.TestCluster.Commands.TestEmitTestFabricScopedEventRequest(arg1=1))
await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=Clusters.TestCluster.Commands.TestEmitTestFabricScopedEventRequest(arg1=2))

@classmethod
async def _RetryForContent(cls, request, until, retryCount=10, intervalSeconds=1):
Expand All @@ -331,6 +331,22 @@ async def TriggerAndWaitForEvents(cls, devCtrl, req):
await cls._TriggerEvent(devCtrl)
await cls._RetryForContent(request=lambda: devCtrl.ReadEvent(nodeid=NODE_ID, events=req), until=lambda res: res != 0)

@classmethod
@base.test_case
async def TestGenerateUndefinedFabricScopedEventRequests(cls, devCtrl, expectEventsNum):
await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=Clusters.TestCluster.Commands.TestEmitTestFabricScopedEventRequest(arg1=0))
if isinstance(res, Clusters.TestCluster.Commands.TestEmitTestEventResponse):
logger.error(f"Unexpected response of type {type(res)} received.")
raise ValueError()

@classmethod
@base.test_case
async def TestGenerateUndefinedFabricScopedEventRequests(cls, devCtrl, expectEventsNum):
await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=Clusters.TestCluster.Commands.TestEmitTestFabricScopedEventRequest(arg1=1))
if isinstance(res, Clusters.TestCluster.Commands.TestEmitTestEventResponse):
logger.error(f"Unexpected response of type {type(res)} received.")
raise ValueError()

@classmethod
@base.test_case
async def TestReadEventRequests(cls, devCtrl, expectEventsNum):
Expand Down Expand Up @@ -557,6 +573,8 @@ async def RunTest(cls, devCtrl):
await cls.TestWriteRequest(devCtrl)
await cls.TestTimedRequest(devCtrl)
await cls.TestTimedRequestTimeout(devCtrl)
await cls.TestGenerateUndefinedFabricScopedEventRequests(devCtrl)
await cls.TestGenerateDefinedFabricScopedEventRequests(devCtrl)
except Exception as ex:
logger.error(
f"Unexpected error occurred when running tests: {ex}")
Expand Down