From b8dde79722b6f794034f710d6b8750a1dd14d003 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Wed, 17 Jan 2024 14:36:13 +0000 Subject: [PATCH] Address PR comment --- src/controller/python/chip/ChipDeviceCtrl.py | 2 +- .../python/chip/clusters/Command.py | 34 +++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index 17f4381799640f..480e44f32f163f 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -951,7 +951,7 @@ async def SendBatchCommands(self, nodeid: int, commands: typing.List[ClusterComm - A value of `None` indicates success. - If only a single command fails, for example with `UNSUPPORTED_COMMAND`, the corresponding index associated with the command will, contain `interaction_model.Status.UnsupportedCommand`. - - If a command is not responded to by server, command will contain `interaction_model.Status.Failure` + - If a command is not responded to by server, command will contain `interaction_model.Status.NoCommandResponse` Raises: - InteractionModelError if error with sending of InvokeRequestMessage fails as a whole. ''' diff --git a/src/controller/python/chip/clusters/Command.py b/src/controller/python/chip/clusters/Command.py index 5a664ae5a74543..4c556fd97f6e45 100644 --- a/src/controller/python/chip/clusters/Command.py +++ b/src/controller/python/chip/clusters/Command.py @@ -327,17 +327,29 @@ def _BuildPyInvokeRequestData(commands: List[InvokeRequestInfo], timedRequestTim def SendBatchCommands(future: Future, eventLoop, device, commands: List[InvokeRequestInfo], timedRequestTimeoutMs: Optional[int] = None, interactionTimeoutMs: Optional[int] = None, busyWaitMs: Optional[int] = None, suppressResponse: Optional[bool] = None) -> PyChipError: - ''' Send a cluster-object encapsulated command to a device and does the following: - - On receipt of a successful data response, returns the cluster-object equivalent through the provided future. - - None (on a successful response containing no data) - - Raises an exception if any errors are encountered. - - If no response type is provided above, the type will be automatically deduced. - - If a valid timedRequestTimeoutMs is provided, a timed interaction will be initiated instead. - If a valid interactionTimeoutMs is provided, the interaction will terminate with a CHIP_ERROR_TIMEOUT if a response - has not been received within that timeout. If it isn't provided, a sensible value will be automatically computed that - accounts for the underlying characteristics of both the transport and the responsiveness of the receiver. + ''' Initiates an InvokeInteraction with the batch commands provided. + + Arguments: + - timedRequestTimeoutMs: If a valid value is provided, a timed interaction will be initiated. + - interactionTimeoutMs: If a valid value is provided, the interaction will terminate with a + CHIP_ERROR_TIMEOUT if a response is not received within the specified timeout. If not provided, + a suitable value will be automatically computed based on transport characteristics and + receiver responsiveness. + + Returns: + - PyChipError: Indicates the outcome of initiating the InvokeRequest. Upon success the caller + is expected to await on `future` to get result of the InvokeInteraction. + + Results passed via the provided future: + - Successful InvokeInteraction with path-specific responses (including path-specific errors): + - A list of responses is returned in the same order as the `commands` argument. + - Possible response elements: + - `None`: Successful command execution without additional cluster data. + - Encapsulated cluster-object: Successful command with response data. + - interaction_model.Status.*: Command failure with IM Status. + - interaction_model.Status.NoCommandResponse: No response from the server for + a specific command. + - Non-path-specific error: An `InteractionModelError` exception is raised through the future. ''' handle = chip.native.GetLibraryHandle()