Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Ensure that MTRDevice invokes provide a timed invoke timeout when needed." #29869

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions src/darwin/Framework/CHIP/MTRCommandTimedCheck.h

This file was deleted.

3 changes: 0 additions & 3 deletions src/darwin/Framework/CHIP/MTRDefines_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,3 @@
_Pragma("clang diagnostic pop")
typedef struct {} variable_hidden_by_mtr_hide;
// clang-format on

// Default timed interaction timeout, in ms, if another one is not provided.
#define MTR_DEFAULT_TIMED_INTERACTION_TIMEOUT_MS 10000
50 changes: 14 additions & 36 deletions src/darwin/Framework/CHIP/MTRDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,54 +126,32 @@ typedef NS_ENUM(NSUInteger, MTRDeviceState) {
/**
* Invoke a command with a designated command path
*
* @param commandFields command fields object. The object must be a data-value NSDictionary object
* @param commandFields command fields object. The object must be a data-value NSDictionary object
* as described in the MTRDeviceResponseHandler.
* The value must be a Structure, i.e.,
* The attribute must be a Structure, i.e.,
* the NSDictionary MTRTypeKey key must have the value MTRStructureValueType.
*
* @param expectedValues The expected values of attributes that will be affected by the command, if
* any. If these are provided, the relevant attributes will have the provided
* values when read until one of the following happens:
*
* 1. Something (another invoke or a write) sets different expected values.
* 2. expectedValueInterval elapses without the device reporting the
* attributes changing their values to the expected values.
* 3. The command invoke fails.
* 4. The device reports some other values for these attributes.
*
* The dictionaries in this array are expected to be response-value
* dictionaries as documented in the documentation of
* MTRDeviceResponseHandler, and each one must have an MTRAttributePathKey.
*
* @param expectedValues array of dictionaries containing the expected values in the same format as
* attribute read completion handler. Requires MTRAttributePathKey values.
* See MTRDeviceResponseHandler definition for dictionary details.
* The expectedValues and expectedValueInterval arguments need to be both
* nil or both non-nil, or both will be both ignored.
*
* @param expectedValueInterval maximum interval in milliseconds during which reads of the
* attributes that had expected values provided will return the
* expected values. If the value is less than 1, both this value and
* expectedValues will be ignored. If this value is greater than
* UINT32_MAX, it will be clamped to UINT32_MAX.
* TODO: document better the expectedValues is how this command is expected to change attributes when read, and that the next
* readAttribute will get these values
*
* @param expectedValueInterval maximum interval in milliseconds during which reads of the attribute will return the value being
* written. If the value is less than 1, both this value and expectedValues will be ignored.
If this value is greater than UINT32_MAX, it will be clamped to UINT32_MAX.
*
* @param timeout timeout in milliseconds for timed invoke, or nil. This value must be within [1, UINT16_MAX], and will be clamped
* to this range.
*
* @param completion response handler will receive either values or error. A
* path-specific error status from the command invocation
* will result in an error being passed to the completion, so
* values will only be passed in when the command succeeds.
*
* If values are passed, the array length will always be 1 and the single
* response-value in it will have an MTRCommandPathKey. If the command
* response is just a success status, there will be no MTRDataKey. If the
* command response has data fields, there will be an MTRDataKey, whose value
* will be of type MTRStructureValueType and describe the response payload.
*/
- (void)invokeCommandWithEndpointID:(NSNumber *)endpointID
clusterID:(NSNumber *)clusterID
commandID:(NSNumber *)commandID
commandFields:(id)commandFields
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedValues
expectedValueInterval:(NSNumber * _Nullable)expectedValueInterval
queue:(dispatch_queue_t)queue
completion:(MTRDeviceResponseHandler)completion MTR_NEWLY_AVAILABLE;

- (void)invokeCommandWithEndpointID:(NSNumber *)endpointID
clusterID:(NSNumber *)clusterID
commandID:(NSNumber *)commandID
Expand Down
26 changes: 0 additions & 26 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#import "MTRBaseSubscriptionCallback.h"
#import "MTRCluster.h"
#import "MTRClusterConstants.h"
#import "MTRCommandTimedCheck.h"
#import "MTRDefines_Internal.h"
#import "MTRDeviceController_Internal.h"
#import "MTRDevice_Internal.h"
#import "MTRError_Internal.h"
Expand Down Expand Up @@ -1089,26 +1087,6 @@ - (void)writeAttributeWithEndpointID:(NSNumber *)endpointID
[_asyncWorkQueue enqueueWorkItem:workItem descriptionWithFormat:@"write %@ %@ %@", endpointID, clusterID, attributeID];
}

- (void)invokeCommandWithEndpointID:(NSNumber *)endpointID
clusterID:(NSNumber *)clusterID
commandID:(NSNumber *)commandID
commandFields:(id)commandFields
expectedValues:(NSArray<NSDictionary<NSString *, id> *> * _Nullable)expectedValues
expectedValueInterval:(NSNumber * _Nullable)expectedValueInterval
queue:(dispatch_queue_t)queue
completion:(MTRDeviceResponseHandler)completion
{
[self invokeCommandWithEndpointID:endpointID
clusterID:clusterID
commandID:commandID
commandFields:commandFields
expectedValues:expectedValues
expectedValueInterval:expectedValueInterval
timedInvokeTimeout:nil
queue:queue
completion:completion];
}

- (void)invokeCommandWithEndpointID:(NSNumber *)endpointID
clusterID:(NSNumber *)clusterID
commandID:(NSNumber *)commandID
Expand Down Expand Up @@ -1155,10 +1133,6 @@ - (void)_invokeCommandWithEndpointID:(NSNumber *)endpointID
serverSideProcessingTimeout = [serverSideProcessingTimeout copy];
timeout = [timeout copy];

if (timeout == nil && MTRCommandNeedsTimedInvoke(clusterID, commandID)) {
timeout = @(MTR_DEFAULT_TIMED_INTERACTION_TIMEOUT_MS);
}

NSDate * cutoffTime;
if (timeout) {
cutoffTime = [NSDate dateWithTimeIntervalSinceNow:(timeout.doubleValue / 1000)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#import "MTRStructsObjc.h"
#import "NSStringSpanConversion.h"
#import "NSDataSpanConversion.h"
#import "MTRDefines_Internal.h"

#include <app-common/zap-generated/cluster-objects.h>
#include <app/util/im-client-callbacks.h>
Expand Down Expand Up @@ -98,7 +97,7 @@ MTR{{cluster}}Cluster{{command}}Params
auto * timedInvokeTimeoutMs = params.timedInvokeTimeoutMs;
{{#if mustUseTimedInvoke}}
if (timedInvokeTimeoutMs == nil) {
timedInvokeTimeoutMs = @(MTR_DEFAULT_TIMED_INTERACTION_TIMEOUT_MS);
timedInvokeTimeoutMs = @(10000);
}
{{/if}}

Expand Down Expand Up @@ -176,9 +175,9 @@ MTR{{cluster}}Cluster{{command}}Params
timedWriteTimeout.SetValue(params.timedWriteTimeout.unsignedShortValue);
}
}
{{#if mustUseTimedWrite}}
{{#if mustUseTimedInvoke}}
if (!timedWriteTimeout.HasValue()) {
timedWriteTimeout.SetValue(MTR_DEFAULT_TIMED_INTERACTION_TIMEOUT_MS);
timedWriteTimeout.SetValue(10000);
}
{{/if}}

Expand Down
5 changes: 2 additions & 3 deletions src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#import "MTRStructsObjc.h"
#import "MTRCommandPayloadsObjc.h"
#import "MTRLogging_Internal.h"
#import "MTRDefines_Internal.h"

#include <app-common/zap-generated/cluster-objects.h>
#include <platform/CHIPDeviceLayer.h>
Expand Down Expand Up @@ -80,7 +79,7 @@ MTR{{cluster}}Cluster{{command}}Params
auto * timedInvokeTimeoutMs = params.timedInvokeTimeoutMs;
{{#if mustUseTimedInvoke}}
if (timedInvokeTimeoutMs == nil) {
timedInvokeTimeoutMs = @(MTR_DEFAULT_TIMED_INTERACTION_TIMEOUT_MS);
timedInvokeTimeoutMs = @(10000);
}
{{/if}}

Expand Down Expand Up @@ -134,7 +133,7 @@ MTR{{cluster}}Cluster{{command}}Params
NSNumber *timedWriteTimeout = params.timedWriteTimeout;
{{#if mustUseTimedWrite}}
if (!timedWriteTimeout) {
timedWriteTimeout = @(MTR_DEFAULT_TIMED_INTERACTION_TIMEOUT_MS);
timedWriteTimeout = @(10000);
}
{{/if}}

Expand Down

This file was deleted.

5 changes: 0 additions & 5 deletions src/darwin/Framework/CHIP/templates/templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@
"path": "MTRAttributeSpecifiedCheck-src.zapt",
"name": "Function to check if attribute is specified",
"output": "src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm"
},
{
"path": "MTRCommandTimedCheck-src.zapt",
"name": "Function to check if command needs timed invoke",
"output": "src/darwin/Framework/CHIP/zap-generated/MTRCommandTimedCheck.mm"
}
]
}
Loading
Loading