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. Wi Fi EZ Mode

Wi-Fi EZ Mode

Last Updated on: 2024-06-03 08:00:11

This topic describes the Wi-Fi Easy Connect (EZ) or SmartConfig mode to pair devices. After a user connects a mobile phone to a router, the router broadcasting is used to communicate and pair the mobile phone with the device. It is easy-to-use, but has compatibility requirements for mobile phones and routers. The success rate is lower than that of hotspot or access point (AP) mode.

Note

For iOS 14.5 and later, we recommend that you use the AP mode instead of the Wi-Fi EZ mode. The former trumps the latter when it comes to the following aspects:

  • Compared with the Wi-Fi EZ mode, the AP mode results in a higher success rate, optimal reliability, and fewer compatibility requirements for mobile phones and routers.
  • The app built with Xcode 12.5 cannot send the EZ pairing data packets from iPhone that runs iOS 14.5 or later. In this case, the permission com.apple.developer.networking.multicast must be enabled for the app. This permission must be approved by Apple before it can be enabled. As a temporary solution, you can use an earlier Xcode version, but the AP mode is still recommended.

Get a token

Before the Wi-Fi EZ pairing process, the SDK must get a pairing token from the cloud in the networked state. The token is valid for 10 minutes and expires immediately after the device is paired. A new token must be generated if the device needs to be paired again.

API description

- (void)getTokenWithHomeId:(long long)homeId
                   success:(ThingSuccessString)success
                   failure:(ThingFailureError)failure;

Parameters

Parameter Description
homeId The ID of the home with which the device is bound.
success The success callback. A pairing token is returned.
failure The failure callback. An error message is returned.

Example

Objective-C:

- (void)getToken {
        ThingSmartActivator *ezActivator = [[ThingSmartActivator alloc] init];
    [ezActivator getTokenWithHomeId:homeId success:^(NSString *token) {
        NSLog(@"getToken success: %@", token);
        // TODO: startConfigWiFi
    } failure:^(NSError *error) {
        NSLog(@"getToken failure: %@", error.localizedDescription);
    }];
}

Swift:

func getToken() {
    let ezActivator = ThingSmartActivator()
    ezActivator.getTokenWithHomeId(homeId, success: { token in
        print("getToken success: (token)")
        // TODO: startConfigWiFi
    }, failure: { error in
        print("getToken failure: (error.localizedDescription)")
    })
}

Callback of pairing delegate

For pairing in the Wi-Fi EZ mode, you only need to implement this delegate callback method and handle the devices and errors in this method. When pairing is successful or fails (in case of pairing timeout or error), callbacks are made on this delegate.

API description

- (void)activator:(ThingSmartActivator *)activator didReceiveDevice:(ThingSmartDeviceModel *)deviceModel error:(NSError *)error;

Parameters

Parameter Description
activator The instance of the ThingSmartActivator object for pairing.
deviceModel The paired device model that is returned if the request is successful. nil is returned if the request failed.
error The error message that is returned if the request failed. nil is returned if the request is successful.

Start pairing

API description

- (void)startConfigWiFi:(ThingActivatorMode)mode
                   ssid:(NSString *)ssid
               password:(NSString *)password
                  token:(NSString *)token
                timeout:(NSTimeInterval)timeout;

Parameters

Parameter Description
mode The pairing mode.
ssid The name of the target Wi-Fi network.
password The password of the target Wi-Fi network.
token The pairing token.
timeout The timeout value of a pairing task. Default value: 100. Unit: seconds.

Example

Objective-C:

- (void)startConfigWiFi:(NSString *)ssid password:(NSString *)password token:(NSString *)token {
    // Implements the delegate method of `ThingSmartActivator`.
    self.ezActivator.delegate = self;

    // Start Wi-Fi EZ pairing, in which `mode` is set to `ThingActivatorModeEZ`.
    [self.ezActivator startConfigWiFi:ThingActivatorModeEZ ssid:ssid password:password token:token timeout:100];
}

- (ThingSmartActivator *)ezActivator {
    if (!_ezActivator) {
        _ezActivator = [[ThingSmartActivator alloc] init];
    }
    return _ezActivator;
}

#pragma mark - ThingSmartActivatorDelegate
- (void)activator:(ThingSmartActivator *)activator didReceiveDevice:(ThingSmartDeviceModel *)deviceModel error:(NSError *)error {

    if (!error && deviceModel) {
        // The device is paired.
    }

    if (error) {
        // Failed to pair the device.
    }
}

Swift:


func startConfigWiFi(ssid: String, password: String, token: String) {
    // Implements the delegate method of `ThingSmartActivator`.
    ezActivator.delegate = self

    // Start Wi-Fi EZ pairing, in which `mode` is set to `ThingActivatorModeEZ`.
    ezActivator.startConfigWiFi(.ez, ssid: ssid, password: password, token: token, timeout: 100)
}

lazy var ezActivator: ThingSmartActivator = {
    let activator = ThingSmartActivator()
    return activator
}()

// Implements the protocol method ThingSmartActivatorDelegate.
func activator(_ activator: ThingSmartActivator, didReceiveDevice deviceModel: ThingSmartDeviceModel?, error: Error?) {
    if let error = error {
        // Failed to pair the device.
        print("Config WiFi failed: \(error.localizedDescription)")
    } else if let deviceModel = deviceModel {
        // The device is paired.
        print("Config WiFi success: \(deviceModel)")
    }
}

Stop pairing

After the pairing process is started, the app continuously broadcasts the pairing data until a device is paired or the process times out. To allow users to cancel or complete pairing during the process, you must call the API method [ThingSmartActivator stopConfigWiFi] to stop pairing.

API description

- (void)stopConfigWiFi;

Example

Objective-C:

- (void)stopConfigWifi {
    self.ezActivator.delegate = nil;
    [self.ezActivator stopConfigWiFi];
}

Swift:

func stopConfigWifi() {
    ezActivator.delegate = nil
    ezActivator.stopConfigWiFi()
}
  • Prev Doc Device Pairing (iOS)
  • Next Doc AP Mode
This page contains content