Tuya iOS Smart Life App SDK 5.15.0
WTLDeviceController Class Reference

#import <WTLDeviceController.h>

Inheritance diagram for WTLDeviceController:

Instance Methods

(instancetype) - NS_UNAVAILABLE
 
(NSNumber *controllerNodeID) - API_AVAILABLE
 
(uint64_t) - getCompressedFabricId
 
(uint64_t) - getFabricIndex
 
(void) - cleanSession
 
(nullable NSString *) - getPeerAddressAndPort:
 
(BOOL) - setupCommissioningSessionWithPayload:newNodeID:error:
 
(BOOL) - setupCommissioningSessionWithPayload:newNodeID:peripheral:error:
 
(BOOL) - commissionNodeWithID:commissioningParams:error:
 
(BOOL) - continueCommissioningDevice:ignoreAttestationFailure:error:
 
(BOOL) - cancelCommissioningForNodeID:error:
 
(nullable WTLBaseDevice *) - deviceBeingCommissionedWithNodeID:error:
 
(WTLBaseDevice *) - writeTokenWithNodeId:activeToken:error:
 
(void) - writeTokenAfterCase:activeToken:
 
(void) - setDeviceControllerDelegate:queue:
 
(NSData *_Nullable) - attestationChallengeForDeviceID:
 
(void) - shutdown
 
(void) - updateAdminVendorID:
 
(BOOL) - isDeviceSessionExistWithNodeId:
 
(BOOL) - shutdownDeviceSessionForNode:
 
(NSNumber *controllerNodeId) - WTL_DEPRECATED
 
(nullable NSData *) - fetchAttestationChallengeForDeviceId:
 
(BOOL) - getBaseDevice:queue:completionHandler:
 
(BOOL) - pairDevice:discriminator:setupPINCode:error:
 
(BOOL) - pairDevice:address:port:setupPINCode:error:
 
(BOOL) - pairDevice:onboardingPayload:error:
 
(BOOL) - commissionDevice:commissioningParams:error:
 
(BOOL) - stopDevicePairing:error:
 
(nullable WTLBaseDevice *) - getDeviceBeingCommissioned:error:
 
(BOOL) - openPairingWindow:duration:error:
 
(nullable NSString *) - openPairingWindowWithPIN:duration:discriminator:setupPIN:error:
 
(nullable NSData *) - computePaseVerifier:iterations:salt:
 
(void) - setPairingDelegate:queue:
 
(void) - setNocChainIssuer:queue:
 

Class Methods

(instancetype) + NS_UNAVAILABLE
 
(nullable NSData *) + computePASEVerifierForSetupPasscode:iterations:salt:error:
 
(WTLDeviceController *) + sharedControllerWithId:xpcConnectBlock:
 
(WTLDeviceController *) + sharedControllerWithID:xpcConnectBlock:
 
(NSArray< NSDictionary< NSString *, id > * > *_Nullable) + encodeXPCResponseValues:
 
(NSArray< NSDictionary< NSString *, id > * > *_Nullable) + decodeXPCResponseValues:
 
(NSDictionary< NSString *, id > *_Nullable) + encodeXPCReadParams:
 
(WTLReadParams *_Nullable) + decodeXPCReadParams:
 
(NSDictionary< NSString *, id > *_Nullable) + encodeXPCSubscribeParams:
 
(WTLSubscribeParams *_Nullable) + decodeXPCSubscribeParams:
 
(16.5) + tvos
 
(16.5) + tvos
 

Properties

BOOL running
 
id< WTLOperationalCertificateIssuer > operationalCertificateIssuer
 
dispatch_queue_t operationalCertificateIssuerQueue
 
BOOL isPairingThingDevice
 
BOOL isPairingLiteDevice
 

Detailed Description

Definition at line 34 of file WTLDeviceController.h.

Method Documentation

◆ API_AVAILABLE

- (NSNumber *controllerNodeID) API_AVAILABLE (macos(13.3)) 
(watchos(9.4)) 
(tvos(16.4))   

Return the Node ID assigned to the controller. Will return nil if the controller is not running (and hence does not know its node id).

◆ attestationChallengeForDeviceID:

- (NSData *_Nullable) attestationChallengeForDeviceID: (macos(13.3)) 
(watchos(9.4)) 
(tvos(16.4))  API_AVAILABLE 

Return the attestation challenge for the secure session of the device being commissioned.

Attempts to retrieve the attestation challenge for a commissionee with the given Device ID. Returns nil if given Device ID does not match an active commissionee, or if a Secure Session is not availale.

◆ cancelCommissioningForNodeID:error:

- (BOOL) cancelCommissioningForNodeID: (NSNumber *)  nodeID
error: (macos(13.3)) 
(watchos(9.4)) 
(tvos(16.4))  API_AVAILABLE 

Cancel commissioning for the given node id. This will shut down any existing commissioning session for that node id.

◆ cleanSession

- (void) cleanSession

◆ commissionDevice:commissioningParams:error:

- (BOOL) commissionDevice: (uint64_t)  deviceId
commissioningParams: (WTLCommissioningParameters *)  commissioningParams
error: ("Please use commissionNodeWithID:commissioningParams:error:") 
(macos(13.0, 13.3)) 
(watchos(9.1, 9.4)) 
(tvos(16.1, 16.4))  WTL_DEPRECATED 

Provided by category WTLDeviceController(Deprecated).

◆ commissionNodeWithID:commissioningParams:error:

- (BOOL) commissionNodeWithID: (NSNumber *)  nodeID
commissioningParams: (WTLCommissioningParameters *)  commissioningParams
error: (macos(13.3)) 
(watchos(9.4)) 
(tvos(16.4))  API_AVAILABLE 

Commission the node with the given node ID. The node ID must match the node ID that was used to set up the commissioning session.

◆ computePaseVerifier:iterations:salt:

- (nullable NSData *) computePaseVerifier: (uint32_t)  setupPincode
iterations: (uint32_t)  iterations
salt: ("Please use computePASEVerifierForSetupPasscode:iterations:salt:error:") 
(macos(13.0, 13.3)) 
(watchos(9.1, 9.4)) 
(tvos(16.1, 16.4))  WTL_DEPRECATED 

Provided by category WTLDeviceController(Deprecated).

◆ computePASEVerifierForSetupPasscode:iterations:salt:error:

+ (nullable NSData *) computePASEVerifierForSetupPasscode: (NSNumber *)  setupPasscode
iterations: (NSNumber *)  iterations
salt: (NSData *)  salt
error: (macos(13.3)) 
(watchos(9.4)) 
(tvos(16.4))  API_AVAILABLE 

Compute a PASE verifier for the desired setup passcode.

Parameters
[in]setupPasscodeThe desired passcode to use.
[in]iterationsThe number of iterations to use when generating the verifier.
[in]saltThe 16-byte salt for verifier computation.

Returns nil on errors (e.g. salt has the wrong size), otherwise the computed verifier bytes.

◆ continueCommissioningDevice:ignoreAttestationFailure:error:

- (BOOL) continueCommissioningDevice: (void *)  opaqueDeviceHandle
ignoreAttestationFailure: (BOOL)  ignoreAttestationFailure
error: (NSError *__autoreleasing *)  error 

Call this method after WTLDeviceAttestationDelegate deviceAttestationFailedForController:opaqueDeviceHandle:error: or deviceAttestationCompletedForController:opaqueDeviceHandle:attestationDeviceInfo:error: is called to continue commissioning the device.

◆ decodeXPCReadParams:

+ (WTLReadParams *_Nullable) decodeXPCReadParams: (NSDictionary< NSString *, id > *_Nullable)  params

Returns a deserialized read parameter object from an object received over XPC

Provided by category WTLDeviceController(XPC).

◆ decodeXPCResponseValues:

+ (NSArray< NSDictionary< NSString *, id > * > *_Nullable) decodeXPCResponseValues: (NSArray< NSDictionary< NSString *, id > * > *_Nullable)  values

Returns a decoded values object from a values object received from XPC for read, write and command interactions

Provided by category WTLDeviceController(XPC).

◆ decodeXPCSubscribeParams:

+ (WTLSubscribeParams *_Nullable) decodeXPCSubscribeParams: (NSDictionary< NSString *, id > *_Nullable)  params

Returns a deserialized subscribe parameter object from an object received over XPC

Provided by category WTLDeviceController(XPC).

◆ deviceBeingCommissionedWithNodeID:error:

- (nullable WTLBaseDevice *) deviceBeingCommissionedWithNodeID: (NSNumber *)  nodeID
error: (macos(13.3)) 
(watchos(9.4)) 
(tvos(16.4))  API_AVAILABLE 

Get an WTLBaseDevice for a commissioning session that was set up for the given node ID. Returns nil if no such commissioning session is available.

◆ encodeXPCReadParams:

+ (NSDictionary< NSString *, id > *_Nullable) encodeXPCReadParams: (WTLReadParams *)  params

Returns a serialized read parameter object to send over XPC

Provided by category WTLDeviceController(XPC).

◆ encodeXPCResponseValues:

+ (NSArray< NSDictionary< NSString *, id > * > *_Nullable) encodeXPCResponseValues: (NSArray< NSDictionary< NSString *, id > * > *_Nullable)  values

Returns an encoded values object to send over XPC for read, write and command interactions

Provided by category WTLDeviceController(XPC).

◆ encodeXPCSubscribeParams:

+ (NSDictionary< NSString *, id > *_Nullable) encodeXPCSubscribeParams: (WTLSubscribeParams *_Nullable)  params

Returns a serialized subscribe parameter object to send over XPC

Provided by category WTLDeviceController(XPC).

◆ fetchAttestationChallengeForDeviceId:

- (nullable NSData *) fetchAttestationChallengeForDeviceId: ("Please use attestationChallengeForDeviceID") 
(macos(13.0, 13.3)) 
(watchos(9.1, 9.4)) 
(tvos(16.1, 16.4))  WTL_DEPRECATED 

Provided by category WTLDeviceController(Deprecated).

◆ getBaseDevice:queue:completionHandler:

- (BOOL) getBaseDevice: (uint64_t)  deviceID
queue: (dispatch_queue_t)  queue
completionHandler: ("Please use ")  [WTLBaseDevice deviceWithNodeID:controller:]
(macos(13.0, 13.3)) 
(watchos(9.1, 9.4)) 
(tvos(16.1, 16.4))  WTL_DEPRECATED 

Provided by category WTLDeviceController(Deprecated).

◆ getCompressedFabricId

- (uint64_t) getCompressedFabricId

◆ getDeviceBeingCommissioned:error:

- (nullable WTLBaseDevice *) getDeviceBeingCommissioned: (uint64_t)  deviceId
error: ("Please use deviceBeingCommissionedWithNodeID:error:") 
(macos(13.0, 13.3)) 
(watchos(9.1, 9.4)) 
(tvos(16.1, 16.4))  WTL_DEPRECATED 

Provided by category WTLDeviceController(Deprecated).

◆ getFabricIndex

- (uint64_t) getFabricIndex

◆ getPeerAddressAndPort:

- (nullable NSString *) getPeerAddressAndPort: (uint64_t)  deviceId

◆ isDeviceSessionExistWithNodeId:

- (BOOL) isDeviceSessionExistWithNodeId: (NSNumber *)  nodeID

◆ NS_UNAVAILABLE [1/2]

- (instancetype) NS_UNAVAILABLE

Controllers are created via the WTLDeviceControllerFactory object.

◆ NS_UNAVAILABLE [2/2]

+ (instancetype) NS_UNAVAILABLE

◆ openPairingWindow:duration:error:

- (BOOL) openPairingWindow: (uint64_t)  deviceID
duration: (NSUInteger)  duration
error: ("Please use WTLDevice or WTLBaseDevice openCommissioningWindowWithSetupPasscode") 
(macos(13.0, 13.3)) 
(watchos(9.1, 9.4)) 
(tvos(16.1, 16.4))  WTL_DEPRECATED 

Provided by category WTLDeviceController(Deprecated).

◆ openPairingWindowWithPIN:duration:discriminator:setupPIN:error:

- (nullable NSString *) openPairingWindowWithPIN: (uint64_t)  deviceID
duration: (NSUInteger)  duration
discriminator: (NSUInteger)  discriminator
setupPIN: (NSUInteger)  setupPIN
error: ("Please use WTLDevice or WTLBaseDevice openCommissioningWindowWithSetupPasscode") 
(macos(13.0, 13.3)) 
(watchos(9.1, 9.4)) 
(tvos(16.1, 16.4))  WTL_DEPRECATED 

Provided by category WTLDeviceController(Deprecated).

◆ pairDevice:address:port:setupPINCode:error:

- (BOOL) pairDevice: (uint64_t)  deviceID
address: (NSString *)  address
port: (uint16_t)  port
setupPINCode: (uint32_t)  setupPINCode
error: ("Please use setupCommissioningSessionWithPayload:newNodeID:error:") 
(macos(13.0, 13.3)) 
(watchos(9.1, 9.4)) 
(tvos(16.1, 16.4))  WTL_DEPRECATED 

Provided by category WTLDeviceController(Deprecated).

◆ pairDevice:discriminator:setupPINCode:error:

- (BOOL) pairDevice: (uint64_t)  deviceID
discriminator: (uint16_t)  discriminator
setupPINCode: (uint32_t)  setupPINCode
error: ("Please use setupCommissioningSessionWithPayload:newNodeID:error:") 
(macos(13.0, 13.3)) 
(watchos(9.1, 9.4)) 
(tvos(16.1, 16.4))  WTL_DEPRECATED 

Provided by category WTLDeviceController(Deprecated).

◆ pairDevice:onboardingPayload:error:

- (BOOL) pairDevice: (uint64_t)  deviceID
onboardingPayload: (NSString *)  onboardingPayload
error: ("Please use setupCommissioningSessionWithPayload:newNodeID:error:") 
(macos(13.0, 13.3)) 
(watchos(9.1, 9.4)) 
(tvos(16.1, 16.4))  WTL_DEPRECATED 

Provided by category WTLDeviceController(Deprecated).

◆ setDeviceControllerDelegate:queue:

- (void) setDeviceControllerDelegate: (id< WTLDeviceControllerDelegate >)  delegate
queue: (macos(13.3)) 
(watchos(9.4)) 
(tvos(16.4))  API_AVAILABLE 

Set the Delegate for the device controller as well as the Queue on which the Delegate callbacks will be triggered

Parameters
[in]delegateThe delegate the commissioning process should use
[in]queueThe queue on which the callbacks will be delivered

◆ setNocChainIssuer:queue:

- (void) setNocChainIssuer: (id< WTLNOCChainIssuer >)  nocChainIssuer
queue: ("Please set the operationalCertificateIssuer in the WTLDeviceControllerStartupParams instead.") 
(macos(13.0, 13.3)) 
(watchos(9.1, 9.4)) 
(tvos(16.1, 16.4))  WTL_DEPRECATED 

Provided by category WTLDeviceController(Deprecated).

◆ setPairingDelegate:queue:

- (void) setPairingDelegate: (id< WTLDevicePairingDelegate >)  delegate
queue: ("Please use setDeviceControllerDelegate:") 
(macos(13.0, 13.3)) 
(watchos(9.1, 9.4)) 
(tvos(16.1, 16.4))  WTL_DEPRECATED 

Provided by category WTLDeviceController(Deprecated).

◆ setupCommissioningSessionWithPayload:newNodeID:error:

- (BOOL) setupCommissioningSessionWithPayload: (WTLSetupPayload *)  payload
newNodeID: (NSNumber *)  newNodeID
error: (macos(13.1)) 
(watchos(9.2)) 
(tvos(16.2))  API_AVAILABLE 

Set up a commissioning session for a device, using the provided setup payload to discover it and connect to it.

Parameters
payloada setup payload (probably created from a QR code or numeric code onboarding payload).
newNodeIDthe planned node id for the node. @error error indication if discovery can't start at all (e.g. because the setup payload is invalid).

The IP and port for the device will be discovered automatically based on the provided discriminator.

Then a PASE session will be established with the device, unless an error occurs. WTLDeviceControllerDelegate will be notified as follows:

  • Discovery fails: onStatusUpdate with WTLCommissioningStatusFailed.
  • Discovery succeeds but commissioning session setup fails: onPairingComplete with an error.
  • Commissioning session setup succeeds: onPairingComplete with no error.

Once a commissioning session is set up, getDeviceBeingCommissioned can be used to get an WTLBaseDevice and discover what sort of network credentials the device might need, and commissionDevice can be used to commission the device.

◆ setupCommissioningSessionWithPayload:newNodeID:peripheral:error:

- (BOOL) setupCommissioningSessionWithPayload: (WTLSetupPayload *)  payload
newNodeID: (NSNumber *)  newNodeID
peripheral: (void *)  peripheral
error: (NSError *__autoreleasing _Nullable *)  error 

◆ sharedControllerWithId:xpcConnectBlock:

+ (WTLDeviceController *) sharedControllerWithId: (id< NSCopying > _Nullable)  controllerID
xpcConnectBlock: ("Please use sharedControllerWithID:xpcConnectBlock:") 
(macos(13.0, 13.3)) 
(watchos(9.1, 9.4)) 
(tvos(16.1, 16.4))  WTL_DEPRECATED 

Provided by category WTLDeviceController(Deprecated_XPC).

◆ sharedControllerWithID:xpcConnectBlock:

+ (WTLDeviceController *) sharedControllerWithID: (id< NSCopying > _Nullable)  controllerID
xpcConnectBlock: (macos(13.3)) 
(watchos(9.4)) 
(tvos(16.4))  API_AVAILABLE 

Returns a shared device controller proxy for the controller object over XPC connection.

Parameters
controllerIDan implementation specific id in case multiple shared device controllers are available over XPC connection
xpcConnectBlockblock to connect to an XPC listener serving the shared device controllers in an implementation specific way

Provided by category WTLDeviceController(XPC).

◆ shutdown

- (void) shutdown

Shut down the controller. Calls to shutdown after the first one are NO-OPs. This must be called, either directly or via shutting down the WTLDeviceControllerFactory, to avoid leaking the controller.

◆ shutdownDeviceSessionForNode:

- (BOOL) shutdownDeviceSessionForNode: (NSNumber *)  nodeID

◆ stopDevicePairing:error:

- (BOOL) stopDevicePairing: (uint64_t)  deviceID
error: ("Please use cancelCommissioningForNodeID:error:") 
(macos(13.0, 13.3)) 
(watchos(9.1, 9.4)) 
(tvos(16.1, 16.4))  WTL_DEPRECATED 

Provided by category WTLDeviceController(Deprecated).

◆ tvos [1/2]

+ (16.5) tvos

Returns an NSXPCInterface configured for WTLDeviceControllerServerProtocol.

Provided by category WTLDeviceController(XPC).

◆ tvos [2/2]

+ (16.5) tvos

Returns an NSXPCInterface configured for WTLDeviceControllerClientProtocol.

Provided by category WTLDeviceController(XPC).

◆ updateAdminVendorID:

- (void) updateAdminVendorID: (uint16_t)  vid

◆ writeTokenAfterCase:activeToken:

- (void) writeTokenAfterCase: (long long)  nodeID
activeToken: (NSString *)  token 

◆ writeTokenWithNodeId:activeToken:error:

- (WTLBaseDevice *) writeTokenWithNodeId: (NSNumber *)  nodeID
activeToken: (NSString *)  token
error: (NSError *__autoreleasing *)  error 

Optionally pre-warm the controller for setting up a commissioning session. This may be called before setupCommissioningSessionWithPayload if it's known that a commissioning attempt will soon take place but the commissioning payload is not known yet.

For example this may do a BLE scan in advance so results are ready earlier once the discriminator is known.

◆ WTL_DEPRECATED

- (NSNumber *controllerNodeId) WTL_DEPRECATED ("Please use controllerNodeID") 
(macos(13.0, 13.3)) 
(watchos(9.1, 9.4)) 
(tvos(16.1, 16.4))   

Provided by category WTLDeviceController(Deprecated).

Property Documentation

◆ isPairingLiteDevice

- (BOOL) isPairingLiteDevice
readwritenonatomicassign

Definition at line 59 of file WTLDeviceController.h.

◆ isPairingThingDevice

- (BOOL) isPairingThingDevice
readwritenonatomicassign

Definition at line 57 of file WTLDeviceController.h.

◆ operationalCertificateIssuer

- (id<WTLOperationalCertificateIssuer>) operationalCertificateIssuer
readatomicassign

Definition at line 54 of file WTLDeviceController.h.

◆ operationalCertificateIssuerQueue

- (dispatch_queue_t) operationalCertificateIssuerQueue
readatomicassign

Definition at line 55 of file WTLDeviceController.h.

◆ running

- (BOOL) running
readnonatomicassign

If true, the controller has not been shut down yet.

Definition at line 45 of file WTLDeviceController.h.


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