![]() |
Tuya iOS Smart Life App SDK 5.15.0
|
#import <WTLDevice.h>
Instance Methods | |
(instancetype) | - NS_UNAVAILABLE |
(NSDate *estimatedStartTime) | - API_AVAILABLE |
(void) | - setDelegate:queue: |
(NSDictionary< NSString *, id > *) | - readAttributeWithEndpointID:clusterID:attributeID:params: |
(void) | - writeAttributeWithEndpointID:clusterID:attributeID:value:expectedValueInterval:timedWriteTimeout: |
(void) | - invokeCommandWithEndpointID:clusterID:commandID:commandFields:expectedValues:expectedValueInterval:timedInvokeTimeout:queue:completion: |
(void) | - openCommissioningWindowWithSetupPasscode:discriminator:duration:queue:completion: |
(void) | - openCommissioningWindowWithDiscriminator:duration:queue:completion: |
(void) | - invokeCommandWithEndpointID:clusterID:commandID:commandFields:expectedValues:expectedValueInterval:timedInvokeTimeout:clientQueue:completion: |
Class Methods | |
(instancetype) | + NS_UNAVAILABLE |
(WTLDevice *) | + deviceWithNodeID:controller: |
(WTLDevice *) | + deviceWithNodeID:deviceController: |
Properties | |
WTLDeviceState | state |
Definition at line 34 of file WTLDevice.h.
- (NSDate *estimatedStartTime) API_AVAILABLE | (macos(13.4)) | ||
(watchos(9.5)) | |||
(tvos(16.5)) | |||
The estimated device system start time.
A device can report its events with either calendar time or time since system start time. When events are reported with time since system start time, this property will return an estimation of the device system start time. Because a device may report timestamps this way due to the lack of a wall clock, system start time can only be estimated based on event receive time and the timestamp value, and this estimation may change over time.
Device reboots may also cause the estimated device start time to jump forward.
If events are always reported with calendar time, then this property will return nil.
+ (WTLDevice *) deviceWithNodeID: | (NSNumber *) | nodeID | |
controller: | (macos(13.3)) | ||
(watchos(9.4)) | |||
(tvos(16.4)) | API_AVAILABLE | ||
TODO: Document usage better
Directly instantiate a WTLDevice with a WTLDeviceController as a shim.
All device-specific information would be stored on the device controller, and retrieved when performing actions using a combination of WTLBaseDevice and WTLAsyncCallbackQueue.
+ (WTLDevice *) deviceWithNodeID: | (uint64_t) | nodeID | |
deviceController: | ("Please use deviceWithNodeID:controller:") | ||
(macos(13.0, 13.3)) | |||
(watchos(9.1, 9.4)) | |||
(tvos(16.1, 16.4)) | WTL_DEPRECATED | ||
Deprecated WTLDevice APIs.
Provided by category WTLDevice(Deprecated).
- (void) invokeCommandWithEndpointID: | (NSNumber *) | endpointID | |
clusterID: | (NSNumber *) | clusterID | |
commandID: | (NSNumber *) | commandID | |
commandFields: | (id) | commandFields | |
expectedValues: | (NSArray< NSDictionary< NSString *, id > * > *_Nullable) | expectedValues | |
expectedValueInterval: | (NSNumber *_Nullable) | expectedValueInterval | |
timedInvokeTimeout: | (NSNumber *_Nullable) | timeout | |
clientQueue: | (dispatch_queue_t) | queue | |
completion: | ("Please use " "invokeCommandWithEndpointID:clusterID:commandID:commandFields:expectedValues:expectedValueInterval:" "timedInvokeTimeout:queue:completion:") | ||
(macos(13.0, 13.3)) | |||
(watchos(9.1, 9.4)) | |||
(tvos(16.1, 16.4)) | WTL_DEPRECATED | ||
Provided by category WTLDevice(Deprecated).
- (void) invokeCommandWithEndpointID: | (NSNumber *) | endpointID | |
clusterID: | (NSNumber *) | clusterID | |
commandID: | (NSNumber *) | commandID | |
commandFields: | (id) | commandFields | |
expectedValues: | (NSArray< NSDictionary< NSString *, id > * > *_Nullable) | expectedValues | |
expectedValueInterval: | (NSNumber *_Nullable) | expectedValueInterval | |
timedInvokeTimeout: | (NSNumber *_Nullable) | timeout | |
queue: | (dispatch_queue_t) | queue | |
completion: | (macos(13.3)) | ||
(watchos(9.4)) | |||
(tvos(16.4)) | API_AVAILABLE | ||
Invoke a command with a designated command path
commandFields | command fields object. The object must be a data-value NSDictionary object as described in the WTLDeviceResponseHandler. The attribute must be a Structure, i.e., the NSDictionary WTLTypeKey key must have the value WTLStructureValueType. |
expectedValues | array of dictionaries containing the expected values in the same format as attribute read completion handler. Requires WTLAttributePathKey values. See WTLDeviceResponseHandler definition for dictionary details. The expectedValues and expectedValueInterval arguments need to be both nil or both non-nil, or both will be both ignored. |
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
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. |
timeout | timeout in milliseconds for timed invoke, or nil. This value must be within [1, UINT16_MAX], and will be clamped to this range. |
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. |
- (instancetype) NS_UNAVAILABLE |
+ (instancetype) NS_UNAVAILABLE |
- (void) openCommissioningWindowWithDiscriminator: | (NSNumber *) | discriminator | |
duration: | (NSNumber *) | duration | |
queue: | (dispatch_queue_t) | queue | |
completion: | (WTLDeviceOpenCommissioningWindowHandler) | WTL_NEWLY_AVAILABLE | |
Open a commissioning window on the device, using a random setup passcode.
On success, completion will be called on queue with the WTLSetupPayload that can be used to commission the device.
discriminator | The discriminator to use for the commissionable advertisement. |
duration | Duration, in seconds, during which the commissioning window will be open. |
- (void) openCommissioningWindowWithSetupPasscode: | (NSNumber *) | setupPasscode | |
discriminator: | (NSNumber *) | discriminator | |
duration: | (NSNumber *) | duration | |
queue: | (dispatch_queue_t) | queue | |
completion: | (macos(13.1)) | ||
(watchos(9.2)) | |||
(tvos(16.2)) | API_AVAILABLE | ||
Open a commissioning window on the device.
On success, completion will be called on queue with the WTLSetupPayload that can be used to commission the device.
setupPasscode | The setup passcode to use for the commissioning window. See WTLSetupPayload's generateRandomSetupPasscode for generating a valid random passcode. |
discriminator | The discriminator to use for the commissionable advertisement. |
duration | Duration, in seconds, during which the commissioning window will be open. |
- (NSDictionary< NSString *, id > *) readAttributeWithEndpointID: | (NSNumber *) | endpointID | |
clusterID: | (NSNumber *) | clusterID | |
attributeID: | (NSNumber *) | attributeID | |
params: | (WTLReadParams *_Nullable) | params | |
Read attribute in a designated attribute path
TODO: Need to document that this returns "the system's best guess" of attribute values.
- (void) setDelegate: | (id< WTLDeviceDelegate >) | delegate | |
queue: | (dispatch_queue_t) | queue | |
Set the delegate to receive asynchronous callbacks about the device.
The delegate will be called on the provided queue, for attribute reports, event reports, and device state changes.
- (void) writeAttributeWithEndpointID: | (NSNumber *) | endpointID | |
clusterID: | (NSNumber *) | clusterID | |
attributeID: | (NSNumber *) | attributeID | |
value: | (id) | value | |
expectedValueInterval: | (NSNumber *) | expectedValueInterval | |
timedWriteTimeout: | (NSNumber *_Nullable) | timeout | |
Write to attribute in a designated attribute path
value | A data-value NSDictionary object as described in WTLDeviceResponseHandler. |
expectedValueInterval | maximum interval in milliseconds during which reads of the attribute will return the value being written. This value must be within [1, UINT32_MAX], and will be clamped to this range. |
TODO: document that -readAttribute... will return the expected value for the [endpoint,cluster,attribute] until one of the following:
timeout | timeout in milliseconds for timed write, or nil. This value must be within [1, UINT16_MAX], and will be clamped to this range. TODO: make timeout arguments uniform |
|
readnonatomicassign |
The current state of the device.
The three states: WTLDeviceStateUnknown Unable to determine the state of the device at the moment.
WTLDeviceStateReachable Communication with the device is expected to succeed.
WTLDeviceStateUnreachable The device is currently unreachable.
Definition at line 63 of file WTLDevice.h.