Last Updated on : 2023-10-25 09:22:18download
The mobile app sends the token to the device on the same LAN. The device then completes the binding and activation process after receiving the token. This solution applies to devices that can complete the pairing process independently.
Set the pairing mode to wired.
connect_mode = PARING_MODE_WIRED
static OPERATE_RET __TUYA_IPC_SDK_START(TUYA_IPC_PARING_MODE_E connect_mode, CHAR_T *p_token)
{
printf("SDK Version:%s\r\n", tuya_ipc_get_sdk_info());
TUYA_IPC_LINK_TYPE_E link_type = TUYA_IPC_LINK_WIRE;
TUYA_IPC_SDK_RUN_VAR_S ipc_sdk_run_var ={0};
memset(&ipc_sdk_run_var,0,sizeof(ipc_sdk_run_var));
/*certification information(essential)*/
strcpy(ipc_sdk_run_var.iot_info.product_key,s_ipc_pid);
strcpy(ipc_sdk_run_var.iot_info.uuid,s_ipc_uuid);
strcpy(ipc_sdk_run_var.iot_info.auth_key,s_ipc_authkey);
strcpy(ipc_sdk_run_var.iot_info.dev_sw_version,s_app_version);
strcpy(ipc_sdk_run_var.iot_info.cfg_storage_path,s_ipc_storage);
//normal device
ipc_sdk_run_var.iot_info.dev_type = NORMAL_POWER_DEV;
//if needed, change to low power device
//ipc_sdk_run_var.iot_info.dev_type= LOW_POWER_DEV;
/*connect mode (essential)*/
ipc_sdk_run_var.net_info.connect_mode = connect_mode;
ipc_sdk_run_var.net_info.ipc_status_change_cb = TUYA_IPC_Status_Changed_cb;
ipc_sdk_run_var.net_info.link_type = link_type;
printf("MODE:%d LINK_TYPE:%d\r\n", connect_mode, ipc_sdk_run_var.net_info.link_type);
if(p_token)
{
strcpy(ipc_sdk_run_var.debug_info.qrcode_token,p_token);
}
Set the connection mode to wired.
TUYA_IPC_LINK_TYPE_E link_type = TUYA_IPC_LINK_WIRE;
ipc_sdk_run_var.net_info.link_type = link_type;
Adapt tkl_wired.c
. The development framework provides a set of APIs for Linux. You need to adapt the implementation to your specific hardware.
Take care of the following APIs.
tkl_wired_set_status_cb
OPERATE_RET tkl_wired_set_status_cb(TKL_WIRED_STATUS_CHANGE_CB cb);
Notify the SDK of changes in network status through a callback.
For example, when Ethernet is disconnected, cb(TKL_WIRED_LINK_DOWN)
is invoked. When Ethernet is connected, with an IP address assigned, cb(TKL_WIRED_LINK_UP)
is invoked.
If the mobile app cannot discover the device on the LAN, or if the device does not send advertising packets, check if the SDK receives TKL_WIRED_LINK_UP
.
tkl_wired_get_status
The SDK calls this interface to request the connection status of the network interface. The assignment of an IP address is the key factor in determining the network status. If the network interface has been activated with an IP address assigned, TKL_WIRED_LINK_UP
is returned. Otherwise, TKL_WIRED_LINK_DOWN
is returned.
tkl_wired_get_ip
The SDK calls this interface to request the IP address of the network interface to set the socket address. If the gateway has multiple Ethernet ports, the network interface of the returned IP address is used for communication. Typically, the network interface connected to the internet is used. Be sure to return the correct IP address based on your scenario.
API call sequence
tuya_ipc_init_sdk
and tuya_ipc_start_sdk
work properly.TKL_WIRED_LINK_UP
status.TY_LOG_LEVEL_DEBUG
, verify if lan init success
is logged.PARING_MODE_WIRED
.TUYA_IPC_LINK_WIRE
.tkl_wifi.c
and tkl_wired.c
must be adapted.PARING_MODE_WIRED
.TUYA_IPC_LINK_WIRE
.tuya_svc_netmgr_linkage_set_default(LINKAGE_TYPE_WIRED)
.unreg not found
being logged continuously?tkl_queue_create_init
APIs in tkl_system
are adapted. Verify if the queue
API fits your platform.tkl_system
is compiled into your code.Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback