Copied!
Private Cloud
  • Application Development Services
    • Quick Start
    • API Gateway
      • API Request
        • Request Structure
        • Authorization Method
        • Sign Requests
        • Global Error Codes
      • Best Practice
        • Set Postman Environment and Call API Operations
      • API List
        • Basic API
          • Authorization Token Management
            • Refresh Token
            • Get a Token
        • IoT Core
          • Device Management
            • Query Devices in Space
            • Get Status Reporting Log
            • Get Update Progress
            • Query Device Details in Bulk
            • Delete Device
            • Get Update Information
            • Query Device Details
            • Confirm Start of Update
            • Get Device State
            • Get Operation Log
            • Modify Basic Properties
            • Freeze/Unfreeze Device
            • Transfer Device
            • Restore Factory Defaults
            • Query Pairing Result
          • Device Control
            • Send Property
            • Query Properties
            • Modify Properties
            • Set Desired Property
            • Query Desired Properties
            • Query Things Data Model
            • Device Control (Standard Instruction Set)
              • Get Status Set
              • Send Commands
              • Get Specifications and Properties of the Device
              • Get Instruction Set of the Device
              • Get Instruction Set of the Category
              • Get Status of a Single Device
              • Get Latest Status of Multiple Devices
          • Device Group
            • Create Group
            • Delete Group
            • Query Group
            • Rename Group
            • Get Group in Space
            • Add Device
            • Delete Devices
            • Get Device Group
            • Query Group Properties
            • Send Group Properties
            • Query Group Devices
    • Message Gateway
      • Preparations
      • Development Guide
        • Integrate with Message Service
        • Data Signature
        • Message Types
      • Best Practices
        • Get Push Messages by Pulsar (Java SDK)
        • Get Push Messages by Pulsar (Python SDK)
        • Get Push Messages by Pulsar (Go SDK)
        • Get Push Messages by Pulsar (Node.js SDK)
        • Get Push Messages by Pulsar (C# SDK)
  • App Development
    • Preparation
    • Developer Guide for iOS
      • Fast Integration with Cube App SDK for iOS
      • Upgrade Guide
      • Quick Start with Cube App SDK for iOS
      • iOS App: Implement User Account Features
      • User Account Management (iOS)
        • Register and Login with Phone Number
        • Register and Login with Email Address
        • Login with UID
        • Login with Third-Party Account
        • Register and Login with Anonymous Account
        • QR Code-Based Login Authorization
        • Manage User Accounts
      • Home Management
        • Home Information Management
        • Room Information Management
        • Member Information Management
      • Device Pairing (iOS)
        • Wi-Fi EZ Mode
        • AP Mode
        • Wired Mode
        • Sub-Device Pairing
        • NB-IoT Device Pairing
        • HomeKit Device Pairing
        • Pegasus Pairing
        • CPPLUS Link-Based Device Binding
        • Matter Devices
          • Prepare for Integration with Matter Device
          • Pair Matter Device
        • Pair with QR Code on Device
      • Bluetooth Devices
        • Bluetooth Mesh
        • CPPLUS Mesh
      • Device Management
        • Firmware Update
        • Query Reported DP Logs
        • Device Sharing
        • Backup Wi-Fi Networks
        • Offline Device Alerts
        • CPPLUS Link-Based Devices
        • Manage Matter Devices
      • Device Control
        • Multi-Control Linkage
        • Scheduled Tasks
        • Group Management
        • All Category Control Panel
        • Air Conditioning Category Control Panel
        • Switch Control Panel
        • Device DP Parser
      • Smart Scenes
        • Scene Recommendation
      • Common API Methods
      • Integrate with Push Notifications
      • Message Management
        • Configure Push Notifications
        • Message Capabilities
      • Configure Widget Project
      • Error Codes
      • FAQ
      • Extension SDK
        • IPC SDK
          • SDK Architecture
          • Fast Integration with IPC SDK for iOS
          • Quick Start with IPC SDK for iOS
          • IPCs
          • Device Pairing
          • IPC Control (iOS)
          • Live Video Streaming
          • Playback of Video Stored on SD Card
          • SD Card Management
          • Audio and Video Features
          • Low Power Doorbell
          • PTZ Control
          • Doorbell Call Service
          • Cloud Storage
          • Cloud Storage Debugging Tool
          • Detection Alerts
          • Encrypted Images
          • Timeline View
          • Offline Log
          • Migrate IPC UI BizBundles
          • P2P Capabilities
          • IPC SDK Automated Test Tool
          • IPC SDK Test Cases (Reference)
          • FAQ
          • Error Codes
        • Sweeper SDK
          • P2P Download from Robot Vacuums
          • Gyroscope and Visual Robot Vacuums
          • Laser Robot Vacuum
          • Voice Package Download
          • Error Codes
          • Sample Code
        • Smart Lock SDK
          • Wi-Fi Lock
          • Bluetooth Lock
          • Wi-Fi Lock Audio and Video Capability
          • Smart Lock Basic API
      • What is UI BizBundle SDK for iOS?
        • Preparation
        • Integrate with Framework
        • Home Management UI BizBundle
        • Device Pairing UI BizBundle
        • Scene UI BizBundle
        • Multi-Control Linkage UI BizBundle
        • Device Control UI BizBundle
        • OTA UI BizBundle
        • Group Management UI BizBundle
        • Device Details UI BizBundle
        • Panel Multilingual BizBundle
        • IPC UI BizBundles
        • Cloud Storage UI BizBundle
        • FAQ UI BizBundle
        • Message Center UI BizBundle
        • Voice Skills Account Linking UI BizBundle
        • Theme Color Configuration BizBundle
        • Sharing UI BizBundle
      • Changelog
    • Developer Guide for Android
      • Fast Integration with Cube App SDK for Android
      • Upgrade Guide
      • User Account Management
        • Register and Login with Phone Number
        • Register and Login with Email Address
        • Login with UID
        • Login with Third-Party Account
        • Register and Login with Anonymous Account
        • QR Code-Based Login Authorization
        • Manage User Accounts
      • Home Management
        • Home Information Management
        • Room Information Management
        • Member Information Management
      • Device Pairing (iOS)
        • Wi-Fi EZ Mode
        • AP Mode
        • Wired Mode
        • Pair with QR Code on Device
        • Pegasus Pairing
        • Sub-Device Pairing
        • NB-IoT Device Pairing
        • CPPLUS Link-Based Device Binding
        • Matter Devices
          • Prepare for Integration with Matter Device
          • Pair Matter Device
        • Pair with QR Code on Device
      • Bluetooth Devices
        • Bluetooth LE Devices
        • Bluetooth Mesh
        • CPPLUS Mesh
      • Device Management
        • Firmware Update
        • Query Reported DP Logs
        • Device Sharing
        • Backup Wi-Fi Networks
        • Notifications of Devices Getting Offline
        • CPPLUS Link-Based Devices
        • Manage Matter Devices
      • Device Control
        • Sub-Device Control Through Zigbee Gateway
        • Multi-Control Linkage
        • Scheduled Tasks
        • Group Management
        • Device DP Parser
      • Smart Scenes
        • Scene Recommendation
      • Common API Methods
      • Integrate with Push Notifications
        • Integrate with FCM Push
        • Integrate with Xiaomi Push Notifications
        • Integrate with Huawei Push Notifications
      • Message Management
        • Configure Push Notifications
        • Message Capabilities
      • Error Codes
      • FAQ
      • Extension SDK
        • IPC SDK
          • IPC SDK Architecture
          • Fast Integration with IPC SDK for Android
          • IPCs
          • Device Pairing
          • Live Video Streaming
          • SD Card-Stored Video Playback
          • SD Card Management
          • Audio and Video Features
          • Cloud Storage
          • Cloud Storage Debugging Tool
          • Alert List
          • Video Alerts
          • Low Power Doorbell
          • Encrypted Images
          • Timeline View
          • P2P Capabilities
          • IPC SDK Automated Test Tool
          • IPC SDK Test Cases (Reference)
          • Error Codes
          • SDK Log
          • Changelog
        • Sweeper SDK
          • P2P Download from Robot Vacuums
          • Gyroscope and Visual Robot Vacuums
          • Laser Robot Vacuum
          • Voice Package Download
          • Changelog
          • Error Codes
          • Sample Code
        • Smart Lock SDK
          • Wi-Fi Smart Lock
          • Bluetooth Smart Lock
          • Wi-Fi Smart Lock Audio and Video Capabilities
          • Zigbee Lock
          • Smart Lock Basic API
          • Changelog
      • What is UI BizBundle SDK for iOS?
        • Preparation
        • Integrate with Framework
        • Home Management UI BizBundle
        • Device Pairing UI BizBundle
        • Generic Pairing BizBundle
        • Device Control UI BizBundle
        • Multi-Control Linkage UI BizBundle
        • Scene UI BizBundle
        • Group Management UI BizBundle
        • Device Details UI BizBundle
        • OTA UI BizBundle
        • IPC UI BizBundles
        • Cloud Storage UI BizBundle
        • Message Center UI BizBundle
        • FAQ UI BizBundle
        • Maps Service UI BizBundle
        • Voice Skills Account Linking UI BizBundle
        • Panel Multilingual BizBundle
        • Theme Color Configuration BizBundle
        • Sharing UI BizBundle
        • FAQ
      • Changelog
  1. Home
  2. App Development
  3. I OS
  4. Pegasus Pairing

Pegasus Pairing

Last Updated on: 2024-06-06 11:39:11

Cube App SDK enables HomeKit devices to be compatible with both Tuya’s and Apple’s ecosystems based on the following capabilities. Users add devices locally in Apple’s Home app, and the devices can be simultaneously bound with the Tuya Developer Platform.

Search devices for Pegasus pairing

Get devices that support Pegasus pairing

API description

/// Returns the devices that support Pegasus.
/// @param homeID The home ID.
/// @return A list of devices that support Pegasus.
+ (NSArray <ThingSmartDeviceModel *> *)pegasusDeviceListWithHomeID:(long long)homeID;

Parameters

Parameter Description
homeId The home ID.

Example

Objc:

NSArray <ThingSmartDeviceModel *> *deviceList = [ThingSmartPegasusActivator pegasusDeviceListWithHomeID:homeId];

Swift:

let deviceList =  ThingSmartPegasusActivator.pegasusDeviceList(withHomeID: homeId)
Search devices for Pegasus pairing

API description

/// Start Pegasus Activator discover pending device.
/// @param devIDs Device ID list
/// @param serverTimeout Configured devices, search timeout for devices to be configured.
/// @param clientTimeout Pending devices, pending devices is searched for and not added to the family timeout.
/// @param success Called when the task finishes successfully.
/// @param failure Called when the task is interrupted by an error.
- (void)startDiscoverWithDevIDs:(NSArray<NSString *> *)devIDs
                  serverTimeout:(NSTimeInterval)serverTimeout
                  clientTimeout:(NSTimeInterval)clientTimeout
                        success:(ThingSuccessHandler)success
                        failure:(ThingFailureError)failure;

Parameters

Parameter Description
devIDs The list of devices that support Pegasus pairing.
serverTimeout The timeout value for the server to search for devices to be paired. Unit: seconds.
clientTimeout The timeout value for the client. Unit: seconds.
success The success callback.
failure The failure callback.

Example

Objc:

[self.pegasusActivator startDiscoverWithDevIDs:dArr serverTimeout:120 clientTimeout:120 success:^{
} failure:^(NSError *error) {
    NSLog("The callback that is executed when no clients are found.");
}];

Swift:

let pegasusActivator = ThingSmartPegasusActivator.init()
pegasusActivator.startDiscover(withDevIDs:devids , serverTimeout: 120, clientTimeout: 120) {

} failure: { error in

}
Callback of discovered devices

API description

@protocol ThingSmartPegasusActivatorDelegate <NSObject>

/// Devices found by Pegasus.
/// @param activator Activator instance.
/// @param serverDeviceModel Device in the home that supports pegasus.
/// @param deviceModel The device is found, but there is no device ID at this time.
/// @param error Error message.
- (void)pegasusActivator:(ThingSmartPegasusActivator *)activator serverDevice:(ThingSmartDeviceModel *)serverDeviceModel didFoundDevice:(ThingSmartDeviceModel *)deviceModel error:(NSError * __nullable)error;

@end

Parameters

Parameter Description
activator The object of ThingSmartPegasusActivator for pairing.
serverDeviceModel The list of devices that support Pegasus pairing.
deviceModel The discovered client.
error The error message.

Example

Objc:

- (void)pegasusActivator:(ThingSmartPegasusActivator *)activator serverDevice:(ThingSmartDeviceModel *)serverDeviceModel didFoundDevice:(ThingSmartDeviceModel *)deviceModel error:(NSError * __nullable)error {
    NSLog(@"⚡️⚡️⚡️ pegasus did found, server:%@ client:%@ error:%@",serverDeviceModel.devId, deviceModel.uuid, error);
}

Swift:

    func pegasusActivator(_ activator: ThingSmartPegasusActivator, serverDevice serverDeviceModel: ThingSmartDeviceModel, didFoundDevice deviceModel: ThingSmartDeviceModel, error: Error?) {

    }
Stop searching

API description

/// Stops pairing devices by Pegasus after devices are paired.
///
/// The value of 'devIDs' is generated in the call of ThingSmartPegasusActivator::pegasusDeviceListWithHomeID:.
///
/// @param devIDs A list of devices that support Pegasus.
/// @param success Called when the task is finished.
/// @param failure Called when the task is interrupted by an error.
- (void)stopDiscoverWithDevIDs:(NSArray<NSString *> *)devIDs
                        success:(ThingSuccessHandler)success
                        failure:(ThingFailureError)failure;

Parameters

Parameter Description
devIDs The list of devices that support Pegasus pairing.
success The success callback.
failure The failure callback.

Example

Objc:

[self.pegasusActivator stopDiscoverWithDevIDs:dArr success:^{
} failure:^(NSError *error) {
}];

Swift:

let pegasusActivator = ThingSmartPegasusActivator.init()
pegasusActivator.stopDiscover(withDevIDs: devIDS) {

} failure: { error in

}

Pair devices

Start pairing

API description

/// Pairs specified devices by using Pegasus.
///
/// The value of 'token' can be generated in the call of ThingSmartActivator::getTokenWithHomeId:success:failure:.
///
/// @param devIDs A list of devices that support Pegasus.
/// @param UUIDs A list of UUIDs of devices to be paired.
/// @param token The pairing token.
/// @param timeout The timeout value. Unit: seconds. Default value: 100.
/// @param success Called when the task is finished.
/// @param failure Called when the task is interrupted by an error.
- (void)startActivatorWithDevIDs:(NSArray<NSString *> *)devIDs
                           UUIDs:(NSArray<NSString *> *)UUIDs
                           token:(NSString *)token
                         timeout:(NSTimeInterval)timeout
                         success:(ThingSuccessHandler)success
                         failure:(ThingFailureError)failure;

Parameters

Parameter Description
devID The list of devices that support Pegasus pairing.
UUIDs The list of client IDs.
token The pairing token.
timeout The timeout value.
success The success callback.
failure The failure callback.

Example

Objc:

[self.pegasusActivator startActivatorWithDevIDs:dArr UUIDs:mArr.copy token:result timeout:120 success:^{
} failure:^(NSError *error) {
    ThingLogError(error.localizedDescription);
}];

Swift:

let pegasusActivator = ThingSmartPegasusActivator.init()
pegasusActivator.start(withDevIDs: devIDS, uuids: uuids, token: token, timeout: 120) {

} failure: { error in

}

Callback of the pairing result

API description

@protocol ThingSmartPegasusActivatorDelegate <NSObject>

/// Returns the devices that are found by Pegasus.
/// @param activator The activator instance.
/// @param deviceModel The device that is found by Pegasus.
/// @param error An error occurs while processing the request.
- (void)pegasusActivator:(ThingSmartPegasusActivator *)activator didReceiveDevice:(ThingSmartDeviceModel *)deviceModel error:(NSError * __nullable)error;

@end

Parameters

Parameter Description
activator The object of ThingSmartPegasusActivator for pairing.
deviceModel The paired device.
error The error message.

Example

Objc:

- (void)pegasusActivator:(ThingSmartPegasusActivator *)activator didReceiveDevice:(ThingSmartDeviceModel *)deviceModel error:(NSError * __nullable)error {
        NSLog(@"⚡️⚡️⚡️ pegasus did receive, client-uuid:%@ devID:%@ error:%@",deviceModel.uuid,deviceModel.devId,error);

}

Swift:

func pegasusActivator(_ activator: ThingSmartPegasusActivator, didReceiveDevice deviceModel: ThingSmartDeviceModel, error: Error?) {

}
Stop pairing

API description

/// Cancels the Pegasus-based pairing of devices.
/// @param devIDs A list of devices that support Pegasus.
/// @param UUIDs A list of UUIDs of devices to be paired.
/// @param success Called when the task is finished.
/// @param failure Called when the task is interrupted by an error.
- (void)cancelActivatorWithDevIDs:(NSArray<NSString *> *)devIDs
                            UUIDs:(NSArray<NSString *> *)UUIDs
                          success:(ThingSuccessHandler)success
                          failure:(ThingFailureError)failure;

Parameters

Parameter Description
devIDs The list of devices that support Pegasus pairing.
UUIDs The list of client IDs.
success The success callback.
failure The failure callback.

Example

Objc:

[self.pegasusActivator cancelActivatorWithDevIDs:dArr UUIDs:mArr.copy success:^{
} failure:^(NSError *error) {
}];

Swift:

let pegasusActivator = ThingSmartPegasusActivator.init()
pegasusActivator.cancel(withDevIDs: devIDS, uuids: uuids) {

} failure: { error in

}
  • Prev Doc HomeKit Device Pairing
  • Next Doc CPPLUS Link-Based Device Binding
This page contains content