Last Updated on : 2023-11-29 07:25:51download
This topic describes how local reset works on Bluetooth sub-devices.
Restore a device to factory settings locally by a button press or command, with the pairing information deleted. After a local reset, the device becomes unpaired.
typedef enum {
RESET_TYPE_UNBIND,
RESET_TYPE_FACTORY_RESET,
} tuya_ble_reset_type_t;
RESET_TYPE_UNBIND
: Local unbinding.
RESET_TYPE_FACTORY_RESET
: Local factory reset.
typedef struct {
tuya_ble_reset_type_t type;
UINT8_T status; //0-succeed,1-failed.
} tuya_ble_unbind_reset_response_data_t;
type
: See tuya_ble_reset_type_t
.
status
: 0
indicates success. 1
indicates failure.
API description
When a locally unbound device is paired again, its information in the cloud remains intact.
tuya_ble_status_t tuya_ble_device_unbind(VOID_T);
API description
When a locally reset device is paired again, its information in the cloud is cleared.
tuya_ble_status_t tuya_ble_device_factory_reset(VOID_T);
case TUYA_BLE_CB_EVT_UNBIND_RESET_RESPONSE: {
if (event->reset_response_data.type == RESET_TYPE_UNBIND) {
if (event->reset_response_data.status == 0) {
// Event triggered by local unbinding.
}
} else if (event->reset_response_data.type == RESET_TYPE_FACTORY_RESET) {
if (event->reset_response_data.status == 0) {
// Event triggered by local factory reset.
}
}
} break;
TUYA_WEAK_ATTRIBUTE OPERATE_RET test_group_system(UINT8_T cmd, UINT8_T *cmd_data, UINT32_T cmd_data_len, UINT8_T *p_rsp_data)
{
TEST_GROUP_VARIABLE
switch (cmd) {
…………
case TEST_CID_FACTORY_RESET: {
if (cmd_data[0] == 0) {
ret = tuya_ble_device_unbind();
} else if (cmd_data[0] == 1) {
ret = tuya_ble_device_factory_reset();
} else {
ret = OPRT_NOT_SUPPORTED;
}
TEST_RSP
} break;
…………
default: {
} break;
}
return idx;
}
VOID_T tal_sdk_test_ble_protocol_callback(tuya_ble_cb_evt_param_t* event)
{
#if (TUYA_BLE_FEATURE_IOT_CHANNEL_ENABLE != 0) && (TUYA_BLE_FEATURE_SCENE_ENABLE != 0)
UINT8_T *rsp_buf = NULL;
UINT16_T rsp_buf_len = 0;
#endif
switch (event->evt) {
…………
case TUYA_BLE_CB_EVT_UNBIND_RESET_RESPONSE: {
if (event->reset_response_data.type == RESET_TYPE_UNBIND) {
if (event->reset_response_data.status == 0) {
tal_sdk_test_unbind_mode_rsp(3);
}
} else if (event->reset_response_data.type == RESET_TYPE_FACTORY_RESET) {
if (event->reset_response_data.status == 0) {
tal_sdk_test_unbind_mode_rsp(4);
}
}
} break;
…………
default: {
} break;
}
}
Communicate with the mobile app using a host that simulates a real device.
Local unbinding
Local factory reset
If you have any problems with host usage, see Logic Host User Guide.
If you have any problems with TuyaOS development, you can post your questions in the Tuya Developer Forum.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback