Replace Faulty Gateway

Last Updated on : 2024-07-15 09:53:05download

End users can switch to a new gateway if the current gateway fails. All the sub-device data and scene configuration on the failed device can be migrated to the new one without reconfiguration.

  • The replacement only works if the new and old gateways are of the same type and have the same DP.
  • The gateway backs up information, including sub-device data, linkages, and scenes, every 15 minutes.

Check support for replacing the faulty gateway

API description

/**
 * Check support for replacing the faulty gateway
 *
 * @param gwId    The ID of the new gateway
 * @param listener boolean
 */
fun isSupportedMigrationWithGwId(gwId: String,listener: Business.ResultListener<Boolean>)

Parameters

Parameter Type Description
gwId String The ID of the new gateway.
listener ResultListener Boolean callback

Example

val manager = DeviceBusinessDataManager.getInstance().getMigrationManager()
manager.isSupportShareByDeviceId(devId, object : Business.ResultListener<Boolean?> {
    override fun onFailure(
        bizResponse: BusinessResponse?,
        bizResult: Boolean?,
        apiName: String?
    ) {

    }

    override fun onSuccess(
        bizResponse: BusinessResponse?,
        bizResult: Boolean?,
        apiName: String?
    ) {

    }

})

Query the list of faulty gateways

API description

/**
 *  Query the list of faulty gateways
 *
 * @param gwId  The ID of the new gateway
 * @param gid  The ID of the current space
 * @param listener  Return data structure: ["xxxxx"] is the device ID or SN of the faulty gateway.
 */
fun getEnableMigratedGatewayList(
    gwId: String,
    gid: Long,
    listener: Business.ResultListener<ArrayList<String>>
)

Parameters

Parameter Type Description
gwId String The ID of the new gateway.
gid Long The ID of the current space.
listener ResultListener ArrayList<String> callback.

Example

val manager = DeviceBusinessDataManager.getInstance().getMigrationManager()
manager.getEnableMigratedGatewayList("devId", gid, object : Business.ResultListener<ArrayList<String?>> {
    override fun onFailure(
        bizResponse: BusinessResponse,
        bizResult: ArrayList<String?>,
        apiName: String
    ) {

    }

    override fun onSuccess(
        bizResponse: BusinessResponse,
        bizResult: ArrayList<String?>,
        apiName: String
    ) {

    }
})

Start replacing faulty gateway

API description

/**
 * Start replacing faulty gateway
 *
 * @param sourcesGwId  The ID of the new gateway
 * @param targetGwId  The ID or SN of the faulty gateway
 * @param gid  The ID of the current space
 * @param listener MigrationInfo
 */
fun startMigrateGateway(
    sourcesGwId: String,
    targetGwId: String,
    gid: Long,
    listener: Business.ResultListener<MigrationInfo?>
)

Parameters

Parameter Type Description
sourcesGwId String The ID of the new gateway.
targetGwId String The ID or SN of the faulty gateway.
gid Long The ID of the current space.
listener ResultListener MigrationInfo callback.

Example

val manager = DeviceBusinessDataManager.getInstance().getMigrationManager()
manager.startMigrateGateway("sourcesGwId", "targetGwId", gid,object : Business.ResultListener<MigrationInfo?> {
    override fun onFailure(
        bizResponse: BusinessResponse,
        bizResult: MigrationInfo?,
        apiName: String
    ) {

    }

    override fun onSuccess(
        bizResponse: BusinessResponse,
        bizResult: MigrationInfo?,
        apiName: String
    ) {

    }
})

Return data

MigrationInfo class

Property Type Description
sourceGwId String The ID of the new gateway.
targetGwId String The ID or SN of the faulty gateway.

Check replacement status

API description

/**
 * Check replacement status
 *
 * @param gwId  The ID of the new gateway
 * @param listener MigrationInfo
 */
fun getMigratedGwState(gwId: String, listener: Business.ResultListener<MigrationInfo?>)

Parameters

Parameter Type Description
sourcesGwId String The ID of the new gateway.
callback ResultListener MigrationInfo callback.

Example

val manager = DeviceBusinessDataManager.getInstance().getMigrationManager()
manager.getMigratedGwState("sourcesGwId", object : Business.ResultListener<MigrationInfo?> {
    override fun onFailure(
        bizResponse: BusinessResponse,
        bizResult: MigrationInfo?,
        apiName: String
    ) {

    }

    override fun onSuccess(
        bizResponse: BusinessResponse,
        bizResult: MigrationInfo?,
        apiName: String
    ) {

    }
})

Return data

MigrationInfo class

Property Type Description
status String Replacement status:
  • DEVICE_CONFIG_INIT: Configuration initialized.
  • DEVICE_DATA_INIT: Data initialized.
  • OS_CONFIG_INIT: Cloud initialized.
  • FINISH: Replacement succeeded.
  • FAILED: Replacement failed.
  • NONE: No status.
sourceGwId String The ID of the new gateway.
targetGwId String The ID or SN of the faulty gateway.
targetGwName String The name of the faulty gateway.
currentTimeMillis long The current timestamp.
failedCode String The error code.

Replacement status listener

API description

/**
 * Register the replacement status listener
 *
 * @param listener IMigratedStateListener
 */
fun addMigratedStateListener(listener: IMigratedStateListener)

/**
 * Unregister the replacement status listener
 *
 * @param listener IMigratedStateListener
 */
fun removeMigratedStateListener(listener: IMigratedStateListener)

Parameters

Parameter Type Description
backupList List The list of alternative networks.
listener IMigratedStateListener MigrationInfo callback.

Example

val manager = DeviceBusinessDataManager.getInstance().getDeviceNetSetManager("deviceId")

val listener = object :IMigratedStateListener{
            override fun onMigratedStateChange(migrationInfo: MigrationInfo?) {

            }
        }

manager.addMigratedStateListener(listener)

manager.removeMigratedStateListener(listener)

Return data

MigrationInfo class

Property Type Description
status String Replacement status:
  • DEVICE_CONFIG_INIT: Configuration initialized.
  • DEVICE_DATA_INIT: Data initialized.
  • OS_CONFIG_INIT: Cloud initialized.
  • FINISH: Replacement succeeded.
  • FAILED: Replacement failed.
  • NONE: No status.
sourceGwId String The ID of the new gateway.
targetGwId String The ID or SN of the faulty gateway.
targetGwName String The name of the faulty gateway.
currentTimeMillis long The current timestamp.
failedCode String The error code.