Device Reset

Last Updated on : 2023-05-12 08:08:02download

This topic describes how to implement the device reset feature that restores an NB-IoT device to the settings that the device had before it was paired and activated.

Background

Device reset can be triggered by hardware operation or mobile app operation. In terms of device status after a reset, there are two types of reset:

  • Normal reset (device unbound): Unbind a device from the cloud and retain the data stored in the cloud and the device. After the device is activated again, all the sub-devices and smart scenes associated with this device are restored.

  • Factory reset (device unbound with data erased): Unbind a device from the cloud and clear the data stored in the cloud and the device.

If the device is reset via a mobile app, no interface needs to be called. If the device is reset locally, the application should proactively call the reset interface.

API description

Reset module and restore factory settings

Function prototype int32_t tuya_user_api_factory_data_reset (tuya_user_api_dev_reset_cb cb)
Parameter cb: The event reporting callback. For more information, see tuya_user_api_dev_reset_cb.
Description Reset the NB-IoT module and restore factory settings.
Header file #include <tuya_user_api.h>
Return value
  • 0: Success.
  • Other values: Failure.

Description

The function pointer tuya_user_api_dev_reset_cb:

// Implement the function as needed. See tuya_user_api.h for details.
typedef void (*tuya_user_api_dev_reset_cb)(int code);