Skip to content

Commit 3ce3206

Browse files
author
Juan Erasmo Trejo
committed
Added TODO for FakeMethods. Updated naming for Status to DoorOpen. Updated to boolean as we only have 2 status and int is not needed.
1 parent 3791a5a commit 3ce3206

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -287,41 +287,41 @@ void HandleSimulateLatchPosition(Json::Value & jsonValue)
287287
}
288288

289289
/**
290-
* Named pipe handler for simulating a latched switch movement.
290+
* Named pipe handler for simulating a Door Opening.
291291
*
292292
* Usage example:
293293
* echo '{"Name":"SetRefDoorStatus", "EndpointId": 1, "Status": 1}' > /tmp/chip_all_clusters_fifo_1146610
294294
*
295295
* JSON Arguments:
296296
* - "Name": Must be "SetRefDoorStatus"
297-
* - "EndpointId": ID of endpoint having a switch cluster
298-
* - "Status": Status of the door, open or closed.
297+
* - "EndpointId": ID of endpoint
298+
* - "DoorOpen": Status of the door, open or closed.
299299
*
300300
* @param jsonValue - JSON payload from named pipe
301301
*/
302302
void SetRefrigetatorDoorStatusHandler(Json::Value & jsonValue)
303303
{
304304
bool hasEndpointId = HasNumericField(jsonValue, "EndpointId");
305-
bool hasDoorStatus = HasNumericField(jsonValue, "Status");
305+
bool hasDoorStatus = HasNumericField(jsonValue, "DoorOpen");
306306

307307
if (!hasEndpointId || !hasDoorStatus)
308308
{
309309
std::string inputJson = jsonValue.toStyledString();
310310
ChipLogError(NotSpecified, "Missing or invalid value for one of EndpointId, Status in %s", inputJson.c_str());
311311
return;
312312
}
313-
// values to updatethe state
313+
// values to update the door status
314314
EndpointId endpointId = static_cast<EndpointId>(jsonValue["EndpointId"].asUInt());
315-
uint8_t doorStatus = static_cast<uint8_t>(jsonValue["Status"].asUInt());
315+
bool doorStatus = static_cast<bool>(jsonValue["DoorOpen"].asBool());
316316
ChipLogDetail(NotSpecified, "SetRefrigetatorDoorStatusHandler State -> %d.",doorStatus);
317-
if ( doorStatus == 0 ) {
317+
if ( !doorStatus ) {
318318
RefrigeratorAlarmServer::Instance().SetMaskValue(endpointId,doorStatus);
319319
ChipLogDetail(NotSpecified, "Refrigeratoralarm status updated to :%d", doorStatus);
320-
}else if (doorStatus == 1){
320+
}else if (doorStatus){
321321
RefrigeratorAlarmServer::Instance().SetMaskValue(endpointId,doorStatus);
322322
RefrigeratorAlarmServer::Instance().SetStateValue(endpointId,doorStatus);
323323
}else {
324-
ChipLogError(NotSpecified, "Invalid State value to set.");
324+
ChipLogError(NotSpecified, "Invalid value to set.");
325325
return;
326326
}
327327
}

src/python_testing/TC_REFALM_2_2.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@
5252

5353
logger = logging.getLogger(__name__)
5454

55-
# Implement fake commands for the RefrigeratorAlarm Cluster #
55+
# TODO(#37217) Refactor using generic method.
56+
# Implement fake commands for the RefrigeratorAlarm Cluster
57+
# These comands are Disallowed (X) in the spec.
5658
# When running those commands must return 0x81 (UNSUPPORTED COMMAND)
5759
@dataclass
5860
class FakeReset(ClusterCommand):
@@ -185,11 +187,11 @@ def _send_named_pipe_command(self, command_dict: dict[str, Any]):
185187
sleep(0.1)
186188

187189
def _send_open_door_command(self):
188-
command_dict = {"Name":"SetRefrigeratorDoorStatus", "EndpointId": self.endpoint, "Status": Clusters.RefrigeratorAlarm.Bitmaps.AlarmBitmap.kDoorOpen}
190+
command_dict = {"Name":"SetRefrigeratorDoorStatus", "EndpointId": self.endpoint, "DoorOpen": Clusters.RefrigeratorAlarm.Bitmaps.AlarmBitmap.kDoorOpen}
189191
self._send_named_pipe_command(command_dict)
190192

191193
def _send_close_door_commnad(self):
192-
command_dict = {"Name":"SetRefrigeratorDoorStatus", "EndpointId": self.endpoint, "Status": 0}
194+
command_dict = {"Name":"SetRefrigeratorDoorStatus", "EndpointId": self.endpoint, "DoorOpen": 0}
193195
self._send_named_pipe_command(command_dict)
194196

195197
@async_test_body

0 commit comments

Comments
 (0)