-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python: Support for specifying absolute timeouts for Invoke/Write (#2…
…0531) (#21035) * Python: Support for specifying absolute timeouts for Invoke/Write This adds support for specifying an absolute timeout for ChipDeviceController.SendCommand and ChipDeviceController.WriteAttribute methods. This timeout is used to bound both mDNS discovery and the subsequent IM interaction. * Review feedback * Review feedback Co-authored-by: Jerry Johns <[email protected]>
- Loading branch information
1 parent
63faaf5
commit d24168c
Showing
8 changed files
with
137 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* | ||
* Copyright (c) 2020-2022 Project CHIP Authors | ||
* Copyright (c) 2019-2020 Google LLC. | ||
* Copyright (c) 2013-2018 Nest Labs, Inc. | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* @file | ||
* Implementation of the native methods expected by the Python | ||
* version of Chip Device Manager. | ||
* | ||
*/ | ||
|
||
#include "system/SystemClock.h" | ||
#include <app/DeviceProxy.h> | ||
#include <stdio.h> | ||
#include <system/SystemError.h> | ||
|
||
using namespace chip; | ||
|
||
static_assert(std::is_same<uint32_t, ChipError::StorageType>::value, "python assumes CHIP_ERROR maps to c_uint32"); | ||
|
||
extern "C" { | ||
|
||
/** | ||
* @brief | ||
* | ||
* This computes the value for a timeout based on the round trip time it takes for a message to be sent to a peer, | ||
* the message to be processed given the upperLayerProcessingTimeoutMs argument, and a response to come back. | ||
* | ||
* See Session::ComputeRoundTripTimeout for more specific details. | ||
* | ||
* A valid DeviceProxy pointer with a valid, established session is required for this method. | ||
* | ||
* | ||
*/ | ||
uint32_t pychip_DeviceProxy_ComputeRoundTripTimeout(DeviceProxy * device, uint32_t upperLayerProcessingTimeoutMs) | ||
{ | ||
VerifyOrDie(device != nullptr); | ||
|
||
auto * deviceProxy = static_cast<DeviceProxy *>(device); | ||
VerifyOrDie(deviceProxy->GetSecureSession().HasValue()); | ||
|
||
return deviceProxy->GetSecureSession() | ||
.Value() | ||
->ComputeRoundTripTimeout(System::Clock::Milliseconds32(upperLayerProcessingTimeoutMs)) | ||
.count(); | ||
} | ||
} |