![]() |
Tuya iOS Smart Life App SDK 5.15.0
|
#import <WTLBaseDevice.h>
Class Methods | |
(instancetype) | + NS_UNAVAILABLE |
(WTLBaseDevice *) | + deviceWithNodeID:controller: |
Definition at line 184 of file WTLBaseDevice.h.
- (WTLTransportType sessionTransportType) API_AVAILABLE | (macos(13.3)) | ||
(watchos(9.4)) | |||
(tvos(16.4)) | |||
The transport used by the current session with this device, or WTLTransportTypeUndefined
if no session is currently active.
- (void) deregisterReportHandlersWithClientQueue: | (dispatch_queue_t) | queue | |
completion: | ("Pease use deregisterReportHandlersWithQueue:completion:") | ||
(macos(13.0, 13.3)) | |||
(watchos(9.1, 9.4)) | |||
(tvos(16.1, 16.4)) | WTL_DEPRECATED | ||
Provided by category WTLBaseDevice(Deprecated).
- (void) deregisterReportHandlersWithQueue: | (dispatch_queue_t) | queue | |
completion: | (macos(13.3)) | ||
(watchos(9.4)) | |||
(tvos(16.4)) | API_AVAILABLE | ||
Deregister all local report handlers for a remote device
This method is applicable only for a remote device. For a local device, the stack has to be shutdown to stop report handlers. There could be multiple clients accessing a node through a remote controller object and hence it is not appropriate for one of those clients to shut down the entire stack to stop receiving reports.
+ (WTLBaseDevice *) deviceWithNodeID: | (NSNumber *) | nodeID | |
controller: | (macos(13.3)) | ||
(watchos(9.4)) | |||
(tvos(16.4)) | API_AVAILABLE | ||
Create a device object with the given node id and controller. This will always succeed, even if there is no such node id on the controller's fabric, but attempts to actually use the WTLBaseDevice will fail (asynchronously) in that case.
- (void) invalidateCASESession |
invalid the case session
- (void) invokeCommandWithEndpointId: | (NSNumber *) | endpointId | |
clusterId: | (NSNumber *) | clusterId | |
commandId: | (NSNumber *) | commandId | |
commandFields: | (id) | commandFields | |
timedInvokeTimeout: | (NSNumber *_Nullable) | timeoutMs | |
clientQueue: | (dispatch_queue_t) | clientQueue | |
completion: | ("Please use invokeCommandWithEndpointID:clusterID:commandID:commandFields:timedInvokeTimeout:queue:completion") | ||
(macos(13.0, 13.3)) | |||
(watchos(9.1, 9.4)) | |||
(tvos(16.1, 16.4)) | WTL_DEPRECATED | ||
Provided by category WTLBaseDevice(Deprecated).
- (void) invokeCommandWithEndpointID: | (NSNumber *) | endpointID | |
clusterID: | (NSNumber *) | clusterID | |
commandID: | (NSNumber *) | commandID | |
commandFields: | (id) | commandFields | |
timedInvokeTimeout: | (NSNumber *_Nullable) | timeoutMs | |
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. |
timeoutMs | timeout in milliseconds for timed invoke, or nil. |
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. |
- (void) readAttributePaths: | (NSArray< WTLAttributeRequestPath * > *_Nullable) | attributePaths | |
eventPaths: | (NSArray< WTLEventRequestPath * > *_Nullable) | eventPaths | |
params: | (WTLReadParams *_Nullable) | params | |
queue: | (dispatch_queue_t) | queue | |
completion: | (WTLDeviceResponseHandler) | WTL_NEWLY_AVAILABLE | |
Reads multiple attribute or event paths from the device.
Nil is treated as an empty array for attributePaths and eventPaths.
Lists of attribute and event paths to read can be provided via attributePaths and eventPaths.
The completion will be called with an error if the entire read interaction fails. Otherwise it will be called with an array of values. This array may be empty (e.g. if no paths matched the wildcard paths passed in, or if empty lists of paths were passed in) or may include per-path errors if particular paths failed.
If the sum of the lengths of attributePaths and eventPaths exceeds 9, the read may fail due to the device not supporting that many read paths.
- (void) readAttributesWithEndpointID: | (NSNumber *_Nullable) | endpointID | |
clusterID: | (NSNumber *_Nullable) | clusterID | |
attributeID: | (NSNumber *_Nullable) | attributeID | |
params: | (WTLReadParams *_Nullable) | params | |
queue: | (dispatch_queue_t) | queue | |
completion: | (macos(13.3)) | ||
(watchos(9.4)) | |||
(tvos(16.4)) | API_AVAILABLE | ||
Reads attributes from the device.
Nil values for endpointID, clusterID, attributeID indicate wildcards (e.g. nil attributeID means "read all the attributes from the endpoint(s) and cluster(s) that match endpointID/clusterID").
If all of endpointID, clusterID, attributeID are non-nil, a single attribute will be read.
If all of endpointID, clusterID, attributeID are nil, all attributes on the device will be read.
A non-nil attributeID along with a nil clusterID will only succeed if the attribute ID is for a global attribute that applies to all clusters.
The completion will be called with an error if the entire read interaction fails. Otherwise it will be called with values, which may be empty (e.g. if no paths matched the wildcard) or may include per-path errors if particular paths failed.
- (void) readAttributeWithEndpointId: | (NSNumber *_Nullable) | endpointId | |
clusterId: | (NSNumber *_Nullable) | clusterId | |
attributeId: | (NSNumber *_Nullable) | attributeId | |
params: | (WTLReadParams *_Nullable) | params | |
clientQueue: | (dispatch_queue_t) | clientQueue | |
completion: | ("Please use readAttributesWithEndpointID:clusterID:attributeID:params:queue:completion:") | ||
(macos(13.0, 13.3)) | |||
(watchos(9.1, 9.4)) | |||
(tvos(16.1, 16.4)) | WTL_DEPRECATED | ||
Provided by category WTLBaseDevice(Deprecated).
- (void) readEventsWithEndpointID: | (NSNumber *_Nullable) | endpointID | |
clusterID: | (NSNumber *_Nullable) | clusterID | |
eventID: | (NSNumber *_Nullable) | eventID | |
params: | (WTLReadParams *_Nullable) | params | |
queue: | (dispatch_queue_t) | queue | |
completion: | (macos(13.3)) | ||
(watchos(9.4)) | |||
(tvos(16.4)) | API_AVAILABLE | ||
Reads events from the device.
Nil values for endpointID, clusterID, eventID indicate wildcards (e.g. nil eventID means "read all the events from the endpoint(s) and cluster(s) that match endpointID/clusterID").
If all of endpointID, clusterID, eventID are non-nil, all the matching instances of a single event will be read.
If all of endpointID, clusterID, eventID are nil, all events on the device will be read.
The completion will be called with an error if the entire read interaction fails. Otherwise it will be called with values, which may be empty (e.g. if no paths matched the wildcard) or may include per-path errors if particular paths failed.
- (void) subscribeAttributeWithEndpointId: | (NSNumber *_Nullable) | endpointId | |
clusterId: | (NSNumber *_Nullable) | clusterId | |
attributeId: | (NSNumber *_Nullable) | attributeId | |
minInterval: | (NSNumber *) | minInterval | |
maxInterval: | (NSNumber *) | maxInterval | |
params: | (WTLSubscribeParams *_Nullable) | params | |
clientQueue: | (dispatch_queue_t) | clientQueue | |
reportHandler: | (WTLDeviceResponseHandler) | reportHandler | |
subscriptionEstablished: | ("Please use " "subscribeToAttributesWithEndpointID:clusterID:attributeID:params:queue:" "reportHandler:subscriptionEstablished:") | ||
(macos(13.0, 13.3)) | |||
(watchos(9.1, 9.4)) | |||
(tvos(16.1, 16.4)) | WTL_DEPRECATED | ||
Provided by category WTLBaseDevice(Deprecated).
- (void) subscribeToAttributePaths: | (NSArray< WTLAttributeRequestPath * > *_Nullable) | attributePaths | |
eventPaths: | (NSArray< WTLEventRequestPath * > *_Nullable) | eventPaths | |
params: | (WTLSubscribeParams *_Nullable) | params | |
queue: | (dispatch_queue_t) | queue | |
reportHandler: | (WTLDeviceResponseHandler) | reportHandler | |
subscriptionEstablished: | (WTLSubscriptionEstablishedHandler _Nullable) | subscriptionEstablished | |
resubscriptionScheduled: | (WTLDeviceResubscriptionScheduledHandler _Nullable) | WTL_NEWLY_AVAILABLE | |
Subscribes to multiple attribute or event paths.
Nil is treated as an empty array for attributePaths and eventPaths.
Lists of attribute and event paths to subscribe to can be provided via attributePaths and eventPaths.
The reportHandler will be called with an error if the subscription fails entirely (including when both attributePaths and eventPaths are empty).
The reportHandler will be called with arrays of response-value dictionaries (which may be data or errors) as path-specific data is received.
subscriptionEstablished will be called when the subscription is first successfully established (after the initial set of data reports has been delivered to reportHandler). If params allow automatic resubscription, it will be called any time resubscription succeeds.
resubscriptionScheduled will be called if subscription drop is detected and params allow automatic resubscription.
If the sum of the lengths of attributePaths and eventPaths exceeds 3, the subscribe may fail due to the device not supporting that many paths for a subscription.
- (void) subscribeToAttributesWithEndpointID: | (NSNumber *_Nullable) | endpointID | |
clusterID: | (NSNumber *_Nullable) | clusterID | |
attributeID: | (NSNumber *_Nullable) | attributeID | |
params: | (WTLSubscribeParams *_Nullable) | params | |
queue: | (dispatch_queue_t) | queue | |
reportHandler: | (WTLDeviceResponseHandler) | reportHandler | |
subscriptionEstablished: | (macos(13.3)) | ||
(watchos(9.4)) | |||
(tvos(16.4)) | API_AVAILABLE | ||
Subscribes to the specified attributes on the device.
Nil values for endpointID, clusterID, attributeID indicate wildcards (e.g. nil attributeID means "subscribe to all the attributes from the endpoint(s) and cluster(s) that match endpointID/clusterID").
If all of endpointID, clusterID, attributeID are non-nil, a single attribute will be subscribed to.
If all of endpointID, clusterID, attributeID are nil, all attributes on the device will be subscribed to.
A non-nil attributeID along with a nil clusterID will only succeed if the attribute ID is for a global attribute that applies to all clusters.
The reportHandler will be called with an error if the subscription fails entirely.
The reportHandler will be called with arrays of response-value dictionaries (which may be data or errors) as path-specific data is received.
subscriptionEstablished will be called when the subscription is first successfully established (after the initial set of data reports has been delivered to reportHandler). If params allow automatic resubscription, it will be called any time resubscription succeeds.
- (void) subscribeToEventsWithEndpointID: | (NSNumber *_Nullable) | endpointID | |
clusterID: | (NSNumber *_Nullable) | clusterID | |
eventID: | (NSNumber *_Nullable) | eventID | |
params: | (WTLSubscribeParams *_Nullable) | params | |
queue: | (dispatch_queue_t) | queue | |
reportHandler: | (WTLDeviceResponseHandler) | reportHandler | |
subscriptionEstablished: | (macos(13.3)) | ||
(watchos(9.4)) | |||
(tvos(16.4)) | API_AVAILABLE | ||
Subscribes to the specified events on the device.
Nil values for endpointID, clusterID, eventID indicate wildcards (e.g. nil eventID means "subscribe to all the events from the endpoint(s) and cluster(s) that match endpointID/clusterID").
If all of endpointID, clusterID, eventID are non-nil, a single event will be subscribed to.
If all of endpointID, clusterID, eventID are nil, all events on the device will be subscribed to.
The reportHandler will be called with an error if the subscription fails entirely.
The reportHandler will be called with arrays of response-value dictionaries (which may be data or errors) as path-specific data is received.
subscriptionEstablished will be called when the subscription is first successfully established (after the initial set of data reports has been delivered to reportHandler). If params allow automatic resubscription, it will be called any time resubscription succeeds.
- (void) subscribeWithQueue: | (dispatch_queue_t) | queue | |
minInterval: | (uint16_t) | minInterval | |
maxInterval: | (uint16_t) | maxInterval | |
params: | (WTLSubscribeParams *_Nullable) | params | |
cacheContainer: | (WTLAttributeCacheContainer *_Nullable) | attributeCacheContainer | |
attributeReportHandler: | (WTLDeviceReportHandler _Nullable) | attributeReportHandler | |
eventReportHandler: | (WTLDeviceReportHandler _Nullable) | eventReportHandler | |
errorHandler: | (WTLDeviceErrorHandler) | errorHandler | |
subscriptionEstablished: | (dispatch_block_t _Nullable) | subscriptionEstablishedHandler | |
resubscriptionScheduled: | ("Please use " "subscribeWithQueue:params:clusterStateCacheContainer:attributeReportHandler:eventReportHandler:errorHandler:" "subscriptionEstablished:resubscriptionScheduled:") | ||
(macos(13.0, 13.3)) | |||
(watchos(9.1, 9.4)) | |||
(tvos(16.1, 16.4)) | WTL_DEPRECATED | ||
Deprecated WTLBaseDevice APIs.
Provided by category WTLBaseDevice(Deprecated).
- (void) subscribeWithQueue: | (dispatch_queue_t) | queue | |
params: | (WTLSubscribeParams *) | params | |
clusterStateCacheContainer: | (WTLClusterStateCacheContainer *_Nullable) | clusterStateCacheContainer | |
attributeReportHandler: | (WTLDeviceReportHandler _Nullable) | attributeReportHandler | |
eventReportHandler: | (WTLDeviceReportHandler _Nullable) | eventReportHandler | |
errorHandler: | (WTLDeviceErrorHandler) | errorHandler | |
subscriptionEstablished: | (WTLSubscriptionEstablishedHandler _Nullable) | subscriptionEstablished | |
resubscriptionScheduled: | (macos(13.3)) | ||
(watchos(9.4)) | |||
(tvos(16.4)) | API_AVAILABLE | ||
Subscribe to receive attribute reports for everything (all endpoints, all clusters, all attributes, all events) on the device.
A non-nil attribute cache container will cache attribute values, retrievable through the designated attribute cache container.
attributeReportHandler will be called any time a data update is available (with a non-nil "value")
The array passed to attributeReportHandler will contain WTLAttributeReport instances. Errors for specific paths, not the whole subscription, will be reported via those objects.
eventReportHandler will be called any time an event is reported (with a non-nil "value")
The array passed to eventReportHandler will contain WTLEventReport instances. Errors for specific paths, not the whole subscription, will be reported via those objects.
errorHandler will be called any time there is an error for the entire subscription (with a non-nil "error"), and terminate the subscription. This will generally not be invoked if auto-resubscription is enabled, unless there is a fatal error during a resubscription attempt.
Both report handlers are not supported over XPC at the moment.
The subscriptionEstablished block, if not nil, will be called once the subscription is established. This will be after the first (priming) call to both report handlers. Note that if the WTLSubscribeParams are set to automatically resubscribe this can end up being called more than once.
The resubscriptionScheduled block, if not nil, will be called if auto-resubscription is enabled, subscription loss is detected, and a resubscription is scheduled. This can be called multiple times in a row without an intervening subscriptionEstablished call if the resubscription attempts fail.
- (void) writeAttributeWithEndpointId: | (NSNumber *) | endpointId | |
clusterId: | (NSNumber *) | clusterId | |
attributeId: | (NSNumber *) | attributeId | |
value: | (id) | value | |
timedWriteTimeout: | (NSNumber *_Nullable) | timeoutMs | |
clientQueue: | (dispatch_queue_t) | clientQueue | |
completion: | ("Please use writeAttributeWithEndpointID:clusterID:attributeID:value:timedWriteTimeout:queue:completion:") | ||
(macos(13.0, 13.3)) | |||
(watchos(9.1, 9.4)) | |||
(tvos(16.1, 16.4)) | WTL_DEPRECATED | ||
Provided by category WTLBaseDevice(Deprecated).
- (void) writeAttributeWithEndpointID: | (NSNumber *) | endpointID | |
clusterID: | (NSNumber *) | clusterID | |
attributeID: | (NSNumber *) | attributeID | |
value: | (id) | value | |
timedWriteTimeout: | (NSNumber *_Nullable) | timeoutMs | |
queue: | (dispatch_queue_t) | queue | |
completion: | (macos(13.3)) | ||
(watchos(9.4)) | |||
(tvos(16.4)) | API_AVAILABLE | ||
Write to attribute in a designated attribute path
value | A data-value NSDictionary object as described in WTLDeviceResponseHandler. |
timeoutMs | timeout in milliseconds for timed write, or nil. |
completion | response handler will receive either values or error. A path-specific error status will get turned into an error passed to the completion, so values will only be passed in when the write succeeds. In that case, values will have the format documented in the definition of WTLDeviceResponseHandler and will be an array with a single element which is a dictionary that has a WTLAttributePathKey entry in it, whose value is the attribute path that was successfully written to. |