IPC Scanning App's QR Code for Pairing

Last Updated on : 2024-01-30 09:56:19download

The mobile app connects to the router and generates a QR code. The device scans the QR code, extracts information from it, and then connects to the router to complete cloud activation.

Process

AppCloudDeviceRouterEnter the SSID andpassword of therouter's Wi-Fi.Get the token.Return the token.Generate a QR code.Point the QR code to the camera lens.Parse the QR code.Connect to the router's Wi-Fi.Return the IP address afterbeing connected.Poll for activated devices by thetoken.Request activation.Activated.MQTT is connected.Return the activateddevices.Query device information.Return device information.AppCloudDeviceRouter

Development guide

Prerequisites

  • Install a Tuya-enabled mobile app that can generate a QR code.
  • The device can read QR codes, such as with a ZBar integration.
  • The camera has good focus accuracy.

API setup

  • Set the pairing mode to wireless.

    apps/tuya_demo_ipc/src/user_main.c
    
    connect_mode = PARING_MODE_WIFI_AP
    
  • Set the connection mode to wireless.

    TUYA_IPC_LINK_TYPE_E link_type = TUYA_IPC_LINK_WIFI;
    ipc_sdk_run_var.net_info.link_type = link_type;
    
  • Adapt tkl_wifi.c.

    The development framework provides a set of APIs for Linux. You need to adapt the implementation to your specific hardware.

  • Pass the QR code reading to the SDK.

    OPERATE_RET tuya_ipc_direct_connect(IN CONST CHAR_T *p_str, IN CONST TUYA_IPC_DIRECT_CONNECT_TYPE_E source);
    

FAQs

Why can’t the device read the QR code generated on the mobile app?

  1. Screenshot the QR code and try reading it using another mobile app to verify if the device has a problem with reading the QR code.
  2. Check if the device has integrated with a QR code reading algorithm, such as the ZBar library.
  3. Check if the YUV or JPEG image the device obtains and passes to the QR code reading algorithm is clear.

Why can’t the device be activated despite successfully scanning the QR code?

  1. Check the SSID and password of the router input on the mobile app.
  2. Check if the pairing mode and connection mode are set correctly. The recommended pairing mode and connection mode are PARING_MODE_WIFI_AP and TUYA_IPC_LINK_WIFI respectively.
  3. Check if all the required tkl_wifi.c APIs are adapted.
  4. Verify if tkl_wifi_init(WIFI_EVENT_CB cb) proactively notifies the SDK of the current network status when the network changes.