Tuya iOS Smart Life App SDK 5.15.0
WTLDevice Class Reference

#import <WTLDevice.h>

Inheritance diagram for WTLDevice:

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
 

Detailed Description

Definition at line 34 of file WTLDevice.h.

Method Documentation

◆ API_AVAILABLE

- (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.

◆ deviceWithNodeID:controller:

+ (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.

◆ deviceWithNodeID:deviceController:

+ (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).

◆ invokeCommandWithEndpointID:clusterID:commandID:commandFields:expectedValues:expectedValueInterval:timedInvokeTimeout:clientQueue:completion:

- (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).

◆ invokeCommandWithEndpointID:clusterID:commandID:commandFields:expectedValues:expectedValueInterval:timedInvokeTimeout:queue:completion:

- (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

Parameters
commandFieldscommand 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.
expectedValuesarray 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

Parameters
expectedValueIntervalmaximum 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.
timeouttimeout in milliseconds for timed invoke, or nil. This value must be within [1, UINT16_MAX], and will be clamped to this range.
completionresponse 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.

◆ NS_UNAVAILABLE [1/2]

- (instancetype) NS_UNAVAILABLE

◆ NS_UNAVAILABLE [2/2]

+ (instancetype) NS_UNAVAILABLE

◆ openCommissioningWindowWithDiscriminator:duration:queue:completion:

- (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.

Parameters
discriminatorThe discriminator to use for the commissionable advertisement.
durationDuration, in seconds, during which the commissioning window will be open.

◆ openCommissioningWindowWithSetupPasscode:discriminator:duration:queue:completion:

- (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.

Parameters
setupPasscodeThe setup passcode to use for the commissioning window. See WTLSetupPayload's generateRandomSetupPasscode for generating a valid random passcode.
discriminatorThe discriminator to use for the commissionable advertisement.
durationDuration, in seconds, during which the commissioning window will be open.

◆ readAttributeWithEndpointID:clusterID:attributeID:params:

- (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.

Returns
a data-value dictionary of the attribute as described in WTLDeviceResponseHandler

◆ setDelegate:queue:

- (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.

◆ writeAttributeWithEndpointID:clusterID:attributeID:value:expectedValueInterval:timedWriteTimeout:

- (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

Parameters
valueA data-value NSDictionary object as described in WTLDeviceResponseHandler.
expectedValueIntervalmaximum 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:

  1. Another write for the same attribute happens.
  2. expectedValueIntervalMs (clamped) expires. Need to figure out phrasing here.
  3. We succeed at writing the attribute.
  4. We fail at writing the attribute and give up on the write
Parameters
timeouttimeout 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

Property Documentation

◆ state

- (WTLDeviceState) state
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.


The documentation for this class was generated from the following file: