Some products are designed with the reset button to clear device configurations and reset devices to the factory settings. Device manufacturers implements these features. However, in some scenarios, if a device manufacturer requires IoT Platform to detect a reset operation on a device, an API operation provided by Link SDK must be called to inform IoT Platform of the reset.

On Android devices, reset can be triggered only by users. For example, a user presses a button or key to call the reset API operation of the SDK. Then, one of the following two processes is used:
  • If the device is connected to IoT Platform, the reset API operation is called. If this call is successful, the deinit function is then called to deinitialize the SDK. If this call failed, the second process applies.
  • If the device is disconnected from IoT Platform, a reset flag bit is set and the SDK is deinitialized. When the SDK is reinitialized later, the reset operation is called if the reset flag bit exists after the connection is created. IoT Platform responds to the discovery of the device after the reset is completed. After an application is uninstalled or the application data is deleted, the reset operation will not be performed during the next startup because the flag bit is cleared.
LinkKit.getInstance().reset(new IConnectSendListener() {
    @Override
    public void onResponse(ARequest aRequest, AResponse aResponse) {
        ALog.d(TAG, "reset onResponse ");
    }

    @Override
    public void onFailure(ARequest aRequest, AError aError) {
        ALog.d(TAG, "reset onFailure");
    }
});
        

Unbind a device from a user on Living Link

Background

If you register a product with Living Link, you can control a device of the product only after you bind the device by using a mobile app. If the device is sold or transferred to another user, the new user can notify IoT Platform to remove the binding between the device and the original user by pressing the reset key, so that the original user cannot control the device any longer.

In this case, you can call the LinkKit.getInstance().reset operation to unbind the device from the original user.

Allow repeated dynamic registration

Background

If a product is dynamically registered, only the ProductKey and ProductSecret are flashed into a device of the product in factory. When the device is connected to IoT Platform, the device can obtain the DeviceSecret from IoT Platform by using dynamic registration. However, after the device obtains its DeviceSecret, it cannot use dynamic registration to obtain the DeviceSecret again. Otherwise, IoT Platform rejects this request.

Therefore, after the device obtains its DeviceSecret, it must permanently store the DeviceSecret to a non-application storage. You cannot delete the DeviceSecret even if you press the reset key, uninstall an application, or delete application data. If the DeviceSecret of the device is deleted for some reason, you must record the ProductKey and DeviceName of the device, delete the corresponding device in the IoT Platform console, and then create a device with the same DeviceName as the deleted device. Device manufacturers must ensure that users cannot delete the DeviceSecrets of devices under their formally launched products.