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

Fix bug with ReportingEngine not being run with short/0 min-reporting intervals #17426

Merged
merged 6 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions src/app/ReadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ CHIP_ERROR ReadHandler::OnStatusResponse(Messaging::ExchangeContext * apExchange
MoveToState(HandlerState::GeneratingReports);
mpExchangeCtx = nullptr;
}

//
// Schedule execution of the ReportingEngine to drive further report generation activity if needed
// on this and other subscription that have already full-filled their minimum reporting hold-off requirements
// (i.e OnUnblockHoldReportCallback was already called before we got this status response).
mrjerryjohns marked this conversation as resolved.
Show resolved Hide resolved
//
SuccessOrExit(err = InteractionModelEngine::GetInstance()->GetReportingEngine().ScheduleRun());
}
else
{
Expand Down
36 changes: 36 additions & 0 deletions src/controller/python/test/test_scripts/cluster_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,41 @@ def subUpdate(path: TypedAttributePath, transaction: SubscriptionTransaction):

sub.Shutdown()

@classmethod
@base.test_case
'''
This validates receiving subscription reports for two attributes at a time in quick succession after issuing a command that results in attribute side-effects.
Specifically, it relies on the fact that the second attribute is changed in a different execution context than the first. This ensures that we pick-up the first
attribute change and generate a notification, and validating that shortly after that, we generate a second report for the second change.

This is done using subscriptions with a min reporting interval of 0 to ensure timely notification of the above. An On() command is sent to the OnOff cluster
which should simultaneously set the state to On as well as set the level to 254.
'''
async def TestSubscribeZeroMinInterval(cls, devCtrl):
logger.info("Test Subscription With MinInterval of 0")
sub = await devCtrl.ReadAttribute(nodeid=NODE_ID, attributes=[Clusters.OnOff, Clusters.LevelControl], reportInterval=(0, 60))
data = sub.GetAttributes()

logger.info("Sending off command")

req = Clusters.OnOff.Commands.Off()
await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=req)

logger.info("Sending on command")

req = Clusters.OnOff.Commands.On()
await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=req)

# Wait for the report containing both attributes to arrive to us.
await asyncio.sleep(2)

logger.info("Checking read back value is indeed 254")

if (data[1][Clusters.LevelControl][Clusters.LevelControl.Attributes.CurrentLevel] != 254):
raise ValueError("Current Level should have been 254")

sub.Shutdown()

@classmethod
@base.test_case
async def TestReadAttributeRequests(cls, devCtrl):
Expand Down Expand Up @@ -515,6 +550,7 @@ async def RunTest(cls, devCtrl):
await cls.TestReadEventRequests(devCtrl, 1)
await cls.TestReadWriteAttributeRequestsWithVersion(devCtrl)
await cls.TestReadAttributeRequests(devCtrl)
await cls.TestSubscribeZeroMinInterval(devCtrl)
await cls.TestSubscribeAttribute(devCtrl)
await cls.TestMixedReadAttributeAndEvents(devCtrl)
# Note: Write will change some attribute values, always put it after read tests
Expand Down