Skip to content

Commit

Permalink
Restyled
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarmelveilleux committed Jul 31, 2024
1 parent 4a7e5b4 commit 32342d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
13 changes: 6 additions & 7 deletions examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,14 @@ void HandleSimulateLatchPosition(Json::Value & jsonValue)
if (!hasEndpointId || !hasPositionId)
{
std::string inputJson = jsonValue.toStyledString();
ChipLogError(NotSpecified,
"Missing or invalid value for one of EndpointId, PositionId in %s",
inputJson.c_str());
ChipLogError(NotSpecified, "Missing or invalid value for one of EndpointId, PositionId in %s", inputJson.c_str());
return;
}

EndpointId endpointId = static_cast<EndpointId>(jsonValue["EndpointId"].asUInt());
uint8_t positionId = static_cast<uint8_t>(jsonValue["PositionId"].asUInt());
uint8_t positionId = static_cast<uint8_t>(jsonValue["PositionId"].asUInt());

uint8_t previousPositionId = 0;
uint8_t previousPositionId = 0;
Protocols::InteractionModel::Status status = Switch::Attributes::CurrentPosition::Get(endpointId, &previousPositionId);
VerifyOrReturn(Protocols::InteractionModel::Status::Success == status,
ChipLogError(NotSpecified, "Failed to get CurrentPosition attribute"));
Expand All @@ -236,14 +234,15 @@ void HandleSimulateLatchPosition(Json::Value & jsonValue)
{
status = Switch::Attributes::CurrentPosition::Set(endpointId, positionId);
VerifyOrReturn(Protocols::InteractionModel::Status::Success == status,
ChipLogError(NotSpecified, "Failed to set CurrentPosition attribute"));
ChipLogError(NotSpecified, "Failed to set CurrentPosition attribute"));
ChipLogDetail(NotSpecified, "The latching switch is moved to a new position: %u", static_cast<unsigned>(positionId));

Clusters::SwitchServer::Instance().OnSwitchLatch(endpointId, positionId);
}
else
{
ChipLogDetail(NotSpecified, "Not moving latching switch to a new position, already at %u", static_cast<unsigned>(positionId));
ChipLogDetail(NotSpecified, "Not moving latching switch to a new position, already at %u",
static_cast<unsigned>(positionId));
}
}

Expand Down
9 changes: 6 additions & 3 deletions src/python_testing/TC_SWTCH.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def _ask_for_multi_press_short_long(self, endpoint_id: int, pressed_position: in
self.wait_for_user_input(msg)
else:
# This is just a simulator, ignore the long press instruction for now, it doesn't matter for the CI. It does for cert.
self._send_multi_press_named_pipe_command(endpoint_id, number_of_presses=2, pressed_position=pressed_position, feature_map=feature_map, multi_press_max=multi_press_max)
self._send_multi_press_named_pipe_command(
endpoint_id, number_of_presses=2, pressed_position=pressed_position, feature_map=feature_map, multi_press_max=multi_press_max)

def _ask_for_multi_press_long_short(self, endpoint_id, pressed_position, feature_map: int):
if not self._use_button_simulator():
Expand Down Expand Up @@ -419,7 +420,8 @@ async def test_TC_SWTCH_2_2(self):

data = event_listener.wait_for_event_report(cluster.Events.SwitchLatched, timeout_sec=post_prompt_settle_delay_seconds)
logging.info(f"-> SwitchLatched event last received: {data}")
asserts.assert_equal(data, cluster.Events.SwitchLatched(newPosition=expected_switch_position), "Did not get expected switch position")
asserts.assert_equal(data, cluster.Events.SwitchLatched(
newPosition=expected_switch_position), "Did not get expected switch position")

# Step 6: TH reads the CurrentPosition attribute from the DUT", "Verify that the value is 1
self.step(6)
Expand All @@ -445,7 +447,8 @@ async def test_TC_SWTCH_2_2(self):
asserts.assert_is_not_none(last_event, "Did not get SwitchLatched events since last operator action.")
last_event_data = last_event.Data
logging.info(f"-> SwitchLatched event last received: {last_event_data}")
asserts.assert_equal(last_event_data, cluster.Events.SwitchLatched(newPosition=expected_switch_position), "Did not get expected switch position")
asserts.assert_equal(last_event_data, cluster.Events.SwitchLatched(
newPosition=expected_switch_position), "Did not get expected switch position")

# Step 10: TH reads the CurrentPosition attribute from the DUT.
# Verify that the value is 0
Expand Down

0 comments on commit 32342d2

Please sign in to comment.