Enhanced QR code pairing for Wi-Fi devices works as follows:
QR code: A kind of two-dimensional barcode that holds encoded data in a graphical black-and-white pattern.
Short URL: A shortened URL string generated from a long URL through programmatic conversion. Short URLs hide the real address and are easier to read, share, and remember.
The general process of QR code binding is as follows:
QR code pairing mainly applies to Wi-Fi devices.
active_shorturl callback function during device initialization to get the short URL information. Then, the device generates a QR code image and displays it on the screen.Currently, you can get a PIN only through Tuya production credential authorization. For more information, see Production Authorization.
Create a product on the Tuya Developer Platform and then enter the product development process. Under Function Definition > Product Advanced Functions, enable the Scan Code Pairing for the product. After you enable it, use this PID to purchase licenses for device authorization.
If you cannot find Scan Code Pairing in advanced functions, it is because the product solution is not bound to this advanced function. To request binding it with your product, contact your account manager or submit a service ticket.
Only licenses purchased after you enable Scan Code Pairing support this feature.
#include "tuya_iot_com_api.h"
#include "tuya_iot_config.h"
#include "tuya_iot_wifi_api.h"
#include "tuya_wifi_netcfg.h"
#define UUID "f2*************b0"
#define AUTHKEY "6P**************************MX"
#define PID "U0**************Zy"
#define PIN "1******2"
int sample_main(int argc, char *argv[])
{
int rt = OPRT_OK;
/** Required SDK initialization interface. **/
// The QR code pairing function adds PIN input in addition to the traditional UUID and AUTHKEY.
WF_GW_PROD_INFO_S prod_info = {UUID, AUTHKEY, NULL,NULL,PIN};
TUYA_CALL_ERR_RETURN(tuya_iot_set_wf_gw_prod_info(&prod_info));
/** Required SDK callback interface. **/
while (1)
{
sleep(10);
}
return 0;
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback