Offline Unbinding

Last Updated on : 2023-11-29 07:32:21download

This topic describes how offline unbinding works on Bluetooth sub-devices.

Concepts

Offline unbinding is also known as abnormal unbinding or offline removing. The user triggers Remove or Remove and Clear Data on the app panel when the device is disconnected. On a successful operation, the device becomes unbound in the cloud, but remains in the bound state on the device side.

In this case, when this device is advertising, if any Tuya-based mobile app connects to it, the app will send the device a command to unbind. Note that the process of device handling offline unbinding will not be reflected on the mobile app.

Data structure

tuya_ble_anomaly_unbound_data_t

typedef struct {
    UINT8_T data;
} tuya_ble_anomaly_unbound_data_t;

data: A reserved field having no meaning.

API description

Trigger event

The user taps Remove or Remove and Clear Data on the app panel while the device is offline.

TUYA_BLE_CB_EVT_ANOMALY_UNBOUND

How to use

Communication process

Offline Unbinding

Code development

See the example code in tal_sdk_test.c.

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_ANOMALY_UNBOUND: {
            tal_sdk_test_unbind_mode_rsp(1);
        } break;

        …………

        default: {
        } break;
    }
}

Functional testing

Prerequisites

  • You have installed the Tuya app on your phone.
  • Your device has been paired.

Procedure

  1. After the device has been paired, turn off Bluetooth on the phone.

  2. Open the device panel on the app and tap the pencil icon in the top right corner.

  3. Tap Remove Device.

  4. Go back to the home page of the app. Tap + in the top right corner and then Add Device. The mobile phone will scan for Bluetooth devices and then trigger the offline unbinding process.

    Offline Unbinding

If you have any problems with host usage, see Logic Host User Guide.

Support and help

If you have any problems with TuyaOS development, you can post your questions in the Tuya Developer Forum.