Last Updated on : 2023-12-19 08:36:57download
Pairing is a process where a device capable of network provisioning, such as a mobile phone, connects an unpaired device to the network.
How it works:
SSID
and password
of the router and the token
to the unpaired device through Tuya’s AP pairing protocol.tuya_iot_wifi_api.h
To use AP pairing, you need to enable the pairing mode that supports AP mode on device initialization.
Pairing mode | Description |
---|---|
WF_START_AP_ONLY | Only AP mode is supported. |
WF_START_SMART_ONLY | Only EZ (Wi-Fi Easy Connect) mode is supported. |
WF_START_AP_FIRST | AP mode or EZ mode is supported, defaulting to AP mode. After the device is reset, it changes to EZ mode. |
WF_START_SMART_FIRST | AP mode or EZ mode is supported, defaulting to EZ mode. After the device is reset, it changes to AP mode. |
WF_START_SMART_AP_CONCURRENT | AP mode and EZ mode coexist. This is a universal pairing mode and allows you to enable support for Bluetooth pairing, Pegasus pairing, and FFS pairing as needed. |
The name of the AP defaults to SmartLife-xxxx
where xxxx
represents the last four digits of the MAC address. You can call this interface to customize the name of the AP.
This interface must be called before device initialization.
/**
* @brief tuya_iot_set_user_def_ap_if
*
* @param[in] ssid: user defined ssid
* @param[in] passwd: user defined passwd
*
* @return OPERATE_RET
*
* @note need call before tuya_iot_wf_xxx_init
*/
OPERATE_RET tuya_iot_set_user_def_ap_if(IN CONST CHAR_T *ssid, IN CONST CHAR_T *passwd);
Request the SSID
and password
of the AP.
/**
* @brief tuya_iot_get_dev_ap_if
*
* @param[in] ssid: the ssid of ap
* @param[in] passwd: the passwd of ap
*
* @return OPERATE_RET
*
*/
OPERATE_RET tuya_iot_get_dev_ap_if(OUT CHAR_T *ssid, OUT CHAR_T *passwd);
int main(int argc, char *argv[])
{
//Set the name of the access point (AP). If a custom name is not needed, calling this API is not required.
TUYA_CALL_ERR_RETURN(tuya_iot_set_user_def_ap_if("test_ap", "test_passwd"));
TY_IOT_CBS_S wf_cbs = {
.gw_status_cb = status_changed_cb,
.gw_ug_cb = (GW_UG_INFORM_CB)gw_ug_inform_cb,
.gw_reset_cb = vResetCB,
.dev_obj_dp_cb = dev_obj_dp_cb,
.dev_raw_dp_cb = dev_raw_dp_cb,
.dev_dp_query_cb = dev_dp_query_cb,
.dev_ug_cb = (DEV_UG_INFORM_CB)dev_ug_inform_cb,
};
//You can specify the start_mode as any of the pairing modes that enable startup in AP mode, such as WF_START_SMART_AP_CONCURRENT
TUYA_CALL_ERR_RETURN(tuya_iot_wf_mcu_dev_init(GWCM_OLD, WF_START_SMART_AP_CONCURRENT, &wf_cbs, tuya_get_user_firmware_key(), "product_key", tuya_get_user_sw_ver(), "1.1.0"));
}
The network segments vary depending on encryption methods. There are two network segments: 192.168.175.1
and 192.168.176.1
. Be sure the SDK sets the network segment for AP pairing in the development environment.
When the device enters the AP pairing mode, it regularly broadcasts UDP packets. The packets are broadcast to 255.255.255.255
at an interval of one second.
It is about 3.5 KB.
Yes, it can coexist with the pairing modes you need. In universal pairing mode, all pairing modes can coexist, specifically, EZ pairing, AP pairing, Bluetooth pairing, FFS pairing, and Pegasus pairing.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback