Composite Scan

Last Updated on : 2023-10-11 02:55:11download

Composite scan currently supports eight pairing types: Wi-Fi EZ mode, password-free pairing, Pegasus pairing, wired gateway pairing, sub-device pairing, gateway router pairing, Bluetooth device pairing, and Matter device pairing. You can choose one or more composite scan capabilities.

  • Multiple scan functions are merged into one, simplifying the processing of callbacks.
  • The unified scan class provides a unique identifier for each pairing type, making the category of a discovered device crystal clear.

Scan result

class ThingActivatorScanDeviceBean(
    /**
     * uniqueId
     */
    val uniqueId: String = "",

    /**
     * device name
     */
    var name: String? = "",

    /**
     * device iconurl
     */
    var icon: String? = "",

    /**
     * What scanning capabilities are used to scan
     */
    var scanDeviceTypeList: MutableList<ThingActivatorScanType> = mutableListOf(),

    /**
     * What ThingDeviceActiveModeEnum
     */
    var supprotActivatorTypeList: MutableList<ThingDeviceActiveModeEnum> = mutableListOf(),

    /**
     * Pid
     */
    var pid: String? = "",

    var deviceType: MatterDeviceTypeEnum? = null

) : Serializable

Supported scan types

public enum ThingActivatorScanType {

    /**
     * Wi-Fi EZ mode
     */
    EZ,

    /**
     * Password-free pairing
     */
    FREE_PWD,

    /**
     * Pegasus pairing
     */
    LIGHTNING,

    /**
     * Wired
     */
    LOCAL_GATEWAY,

    /**
     * Sub-device pairing
     */
    SUB,

    /**
     * Router
     */
    GW_ROUTER,

    /**
     * Bluetooth
     */
    BLUETOOTH,

    /**
     * Matter
     */
    MATTER

}

Parameter description

The required parameters and implementations vary by pairing type. All the pairing types are encapsulated into the uniform parameter class ThingActivatorScanBuilder to simplify their implementations.

Wi-Fi EZ mode, password-free pairing, gateway routers, and sub-devices do not involve an actual scan process. For them, scan means the pairing process. You can incorporate them into the display of the search result of pairing types that have a search process, such as Bluetooth.

Common parameters

Required parameter Description
millisTimeout The timeout value, in milliseconds. The minimum timeout is 120 seconds.

Bluetooth device

For Android 11 and earlier, location and Bluetooth permissions are required. For Android 12 and later, the Bluetooth scan permission is required.

Required parameter Description
blueToothScanTypeList The type supported by Bluetooth scan. For more information, see ScanType.

Wi-Fi EZ mode

Required parameter Description
ssid The name of the target Wi-Fi network.
pwd The password of the target Wi-Fi network.
token The identifier for authentication.
context The context.

Password-free pairing

Required parameter Description
freePwdIdList The list of device IDs that support password-free pairing.
token The identifier for authentication.
context The context.

Gateway router

Required parameter Description
gwRouterIdList The list of device IDs that support the gateway router.
token The identifier for authentication.
context The context.

Sub-device

Required parameter Description
gwId The gateway ID.

Pegasus pairing

Required parameter Description
lightningIdList The list of device IDs that support the Pegasus pairing.

Wired gateway and Matter device

No required parameters.

Start scanning

val activatorScanKey = ThingActivatorCoreKit.getScanDeviceManager().startScan(
            ThingActivatorScanBuilder(), object : ThingActivatorScanCallback {
                override fun deviceFound(deviceBean: ThingActivatorScanDeviceBean) {
                    //Scan to device

                }

                override fun deviceRepeat(deviceBean: ThingActivatorScanDeviceBean) {
                    //Repeat scan to device

                }

                override fun deviceUpdate(deviceBean: ThingActivatorScanDeviceBean) {
                    //The device has been scanned before, and the capabilities are updated.
                }

                override fun scanFailure(failureBean: ThingActivatorScanFailureBean) {
                    //Scan failure
                }

                override fun scanFinish() {
                    //Scan finish

                }

            }
        )

Stop scanning

//Stop all scanning functions
ThingActivatorCoreKit.getScanDeviceManager().stopScan(activatorScanKey)

// Stop some scanning functions
ThingActivatorCoreKit.getScanDeviceManager().stopPartScan(activatorScanKey,ThingActivatorScanType.xxx)

Error codes

Error codes Description
10002 Wrong parameter.
1006 Search timeout.