Skip to content

Commit

Permalink
WiP
Browse files Browse the repository at this point in the history
  • Loading branch information
rbultman committed Jul 31, 2024
1 parent fb58f03 commit 0ecf754
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ void AllClustersAppCommandHandler::HandleCommand(intptr_t context)
}
else if (name == "OperationalStateChange")
{
ChipLogDetail(AppServer,
"------> [rmb] Got some OperationalStateChange.");
std::string device = self->mJsonValue["Device"].asString();
std::string operation = self->mJsonValue["Operation"].asString();
self->OnOperationalStateChange(device, operation, self->mJsonValue["Param"]);
Expand Down Expand Up @@ -629,6 +631,9 @@ void AllClustersAppCommandHandler::OnOperationalStateChange(std::string device,

if (operation == "Start" || operation == "Resume")
{
ChipLogDetail(AppServer,
"------> AllClustersAppCommandHandler::OnOperationalStateChange, calling SetOperationalState in instance.");

operationalStateInstance->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kRunning));
}
else if (operation == "Pause")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ CHIP_ERROR Instance::SetCurrentPhase(const DataModel::Nullable<uint8_t> & aPhase

CHIP_ERROR Instance::SetOperationalState(uint8_t aOpState)
{
ChipLogDetail(AppServer,
"------> Got a call to SetOperationalState in the OpState base.");

// Error is only allowed to be set by OnOperationalErrorDetected.
if (aOpState == to_underlying(OperationalStateEnum::kError) || !IsSupportedOperationalState(aOpState))
{
Expand All @@ -113,6 +116,15 @@ CHIP_ERROR Instance::SetOperationalState(uint8_t aOpState)
mOperationalState = aOpState;
if (mOperationalState != oldState)
{
// This can come from from the app or over the wire. If it comes over the wire (pipe), need to tell the app/derivative.
// Assumption: over the wire == over a pipe
// Does the pipe stuff come from over the wire or from the app? Maybe this is a differentiation that needs to be accommodated?
// SetOperationalState get's called in testing from the TH via a pipe.
// Functionality seems to work ok using chip-tool from a command line. Meaning, if I send a command I see the right messages
// on the terminal, time ticks and presumably the right reports are sent.
ChipLogDetail(AppServer,
"------> States differ, so reporting that change to Matter?");

MatterReportingAttributeChangeCallback(mEndpointId, mClusterId, Attributes::OperationalState::Id);
countdownTimeUpdateNeeded = true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/python_testing/TC_OPSTATE_2_6.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def pics_TC_OPSTATE_2_6(self) -> list[str]:
async def test_TC_OPSTATE_2_6(self):
endpoint = self.matter_test_config.endpoint

await self.TEST_TC_OPSTATE_BASE_2_6(endpoint=endpoint)
# await self.TEST_TC_OPSTATE_BASE_2_6(endpoint=endpoint)
await self.TEST_TC_OPSTATE_BASE_2_6(endpoint=1)


if __name__ == "__main__":
Expand Down
29 changes: 17 additions & 12 deletions src/python_testing/TC_OpstateCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,9 @@ async def TEST_TC_OPSTATE_BASE_2_6(self, endpoint=1):
# To-Do: Update the TP to subscribe-all.
self.step(2)
sub_handler = ClusterAttributeChangeAccumulator(cluster)
await sub_handler.start(self.default_controller, self.dut_node_id, self.matter_test_config.endpoint)
logging.info(f'---------> dut node id: {self.dut_node_id}')
logging.info(f'---------> endpoint: {endpoint}')
await sub_handler.start(self.default_controller, self.dut_node_id, endpoint)

self.step(3)
if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ST_RUNNING")):
Expand All @@ -1280,20 +1282,23 @@ async def TEST_TC_OPSTATE_BASE_2_6(self, endpoint=1):
asserts.assert_less_equal(count, 5, "Received more than 5 reports for CountdownTime")
asserts.assert_greater(count, 0, "Did not receive any reports for CountdownTime")

self.step(5)
attr_value = await self.read_expect_success(
endpoint=endpoint,
attribute=attributes.OperationalState)
wait_count = 0
while (attr_value != cluster.Enums.OperationalStateEnum.kStopped) and (wait_count < 20):
time.sleep(1)
wait_count = wait_count + 1
attr_value = await self.read_expect_success(
endpoint=endpoint,
attribute=attributes.OperationalState)
count = sub_handler.attribute_report_counts[attributes.CountdownTime]
asserts.assert_less_equal(count, 5, "Received more than 5 reports for CountdownTime")
asserts.assert_greater(count, 0, "Did not receive any reports for CountdownTime")
if attr_value == cluster.Enums.OperationalStateEnum.kRunning:
self.step(5)
wait_count = 0
while (attr_value != cluster.Enums.OperationalStateEnum.kStopped) and (wait_count < 20):
time.sleep(1)
wait_count = wait_count + 1
attr_value = await self.read_expect_success(
endpoint=endpoint,
attribute=attributes.OperationalState)
count = sub_handler.attribute_report_counts[attributes.CountdownTime]
asserts.assert_less_equal(count, 5, "Received more than 5 reports for CountdownTime")
asserts.assert_greater(count, 0, "Did not receive any reports for CountdownTime")
else:
self.skip_step(5)

sub_handler.reset()
self.step(6)
Expand Down

0 comments on commit 0ecf754

Please sign in to comment.