Pairing and Binding

Last Updated on : 2023-10-17 02:14:21download

Pairing allows a device to connect to the router. Binding enables the paired device to access Tuya’s service for registration and binding. For simplicity, pairing and binding are collectively referred to as pairing throughout the topic.

The IPC Development Framework provides multiple pairing modes to fit different use cases.

Pairing modes

The IPC Development Framework provides the following pairing capabilities.

Pairing modes Description
Device binding over a LAN The mobile app and device are connected to the same LAN, and the device can access a wide area network (WAN).
Pairing in AP mode The IPC broadcasts a Wi-Fi access point (AP). The user connects their mobile phone to this AP as instructed by the mobile app to send the router’s Wi-Fi credentials to the IPC for an internet connection.
Bluetooth pairing The Wi-Fi and Bluetooth combo device can exchange pairing information with the mobile app over Bluetooth to complete pairing.
Pairing with QR code The mobile app generates a QR code that the IPC can scan to get paired.
Activation and binding with QR code The IPC has been connected to a WAN and generated a short URL. You can create a QR code with the short URL and place it on the device or display it on the screen. The user can scan the QR code with the mobile app to pair the device.

FAQs

Why can’t the device enter pairing mode?

  1. Check if tuya_ipc_init_sdk and tuya_ipc_start_sdk return relevant errors.
  2. Check if the pairing mode (TUYA_IPC_PARING_MODE_E) and connection mode (TUYA_IPC_LINK_TYPE_E) align with the product definition.
  3. Check the adaptation of tkl_wifi.c or tkl_wired.c.
  4. tkl_wifi_init(WIFI_EVENT_CB cb) or tkl_wired_set_status_cb(TKL_WIRED_STATUS_CHANGE_CB cb) notifies the SDK of the current network status when the network changes.

How can I set the pairing mode and connection mode if the device supports both wired and wireless connections?

  • Set the pairing mode to PARING_MODE_WIFI_AP.
  • Set the connection mode to TUYA_IPC_LINK_WIFI | TUYA_IPC_LINK_WIRE.
  • Adapt tkl_wifi.c and tkl_wired.c.

How can I set the pairing mode and connection mode if the device supports two modes (wireless and Bluetooth) or three modes (wired, wireless, and Bluetooth)?

  • Set the pairing mode to PARING_MODE_WIFI_AP.
  • Set the connection mode to TUYA_IPC_LINK_WIFI | TUYA_IPC_LINK_WIRE | TUYA_IPC_LINK_BT.
  • Adapt tkl_wifi.c, tkl_wired.c, and tkl_bluetooth.h.

How can I set the pairing mode and connection mode for 4G devices?

  • Two methods are available to pair 4G devices: the mobile app scans the device’s QR code, or the smart camera scans the QR code generated on the mobile app.
  • Set the pairing mode to: PARING_MODE_WIRED.
  • Set the connection mode to: TUYA_IPC_LINK_WIRE.

Why can’t the device be paired? During pairing, no more MQTT logs are printed after mqtt topics cnt 1 is output.

  1. Check if tkl_mutex_create_init supports recursion. If it does not, enable recursion.
  2. Review TKL adaptation.

How can I enable dynamic network switching for devices that are both wired and wireless?

  1. Call mqc_set_connection_switch(TRUE) after tuya_ipc_start_sdk.
  2. When the network changes, call tkl_wifi_init(WIFI_EVENT_CB cb) or tkl_wired_set_status_cb(TKL_WIRED_STATUS_CHANGE_CB cb) to notify the SDK of the current network status.