Last Updated on : 2025-04-30 02:10:42download
This topic describes the features of the Wi-Fi protocol.
OPERATE_RET tkl_wifi_init(WIFI_EVENT_CB cb)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[in] | cb | The callback invoked when Wi-Fi operating status is set. |
Return value
OPRT_OK
: Success.OPERATE_RET tkl_wifi_scan_ap(CONST SCHAR_T *ssid, AP_IF_S **ap_ary, UINT_T *num)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[in] | ssid | If ssid is NULL , scan for all APs. Otherwise, scan for the specified AP. |
[out] | ap_ary | The result of scanning. |
[out] | num | The number of scanned APs. |
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_AP_SCAN_FAILED
: Scanning failed.tkl_wifi_release_ap
to release the memory.OPERATE_RET tkl_wifi_release_ap(AP_IF_S *ap)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[in] | ap | Release the AP information obtained by tkl_wifi_scan_ap . |
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_AP_RELEASE_FAILED
: Failure.OPERATE_RET tkl_wifi_start_ap(CONST WF_AP_CFG_IF_S *cfg)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[in] | cfg | The AP configuration parameter. |
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_AP_START_FAILED
: Failure.max_conn
parameter.OPERATE_RET tkl_wifi_stop_ap(VOID_T)
Function description
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_AP_STOP_FAILED
: Failure.OPERATE_RET tkl_wifi_set_cur_channel(CONST UCHAR_T chan)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[in] | chan | The channel. |
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_CHAN_SET_FAILED
: Failure.OPERATE_RET tkl_wifi_get_cur_channel(UCHAR_T *chan);
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[out] | chan | The channel. |
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_CHAN_GET_FAILED
: Failure.OPERATE_RET tkl_wifi_set_sniffer(CONST BOOL_T en, CONST SNIFFER_CALLBACK cb)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[in] | en | Turn the sniffer on or off. |
[in] | cb | The packet capture data callback. |
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_SNIFFER_SET_FAILED
: Failure.The data returned to the application includes management pack data.
OPERATE_RET tkl_wifi_get_ip(CONST WF_IF_E wf, NW_IP_S *ip)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[in] | wf | The Wi-Fi mode.
|
[out] | ip | The IP address. |
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_IP_GET_FAILED
: Failure.IP address configuration must be differentiated based on the Wi-Fi operation mode specified in the input parameters.
OPERATE_RET tkl_wifi_set_ip(CONST WF_IF_E wf, NW_IP_S *ip)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[in] | wf | The Wi-Fi mode.
|
[in] | ip | The IP address. |
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_IP_GET_FAILED
: Failure.IP address configuration must be differentiated based on the Wi-Fi operation mode specified in the input parameters.
OPERATE_RET tkl_wifi_set_mac(CONST WF_IF_E wf, CONST NW_MAC_S *mac)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[in] | wf | The Wi-Fi mode.
|
[in] | mac | The MAC address. |
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_MAC_SET_FAILED
: Failure.This configuration shall be permanently stored and persist after power cycles.
OPERATE_RET tkl_wifi_get_mac(CONST WF_IF_E wf, NW_MAC_S *mac);
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[in] | wf | The Wi-Fi mode.
|
[out] | mac | The MAC address. |
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_MAC_GET_FAILED
: Failure.In StationAP mode, the MAC address allocation shall be differentiated based on the Wi-Fi operation mode specified in the input parameters.
OPERATE_RET tkl_wifi_set_work_mode(CONST WF_WK_MD_E mode)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[in] | mode | The Wi-Fi operation mode.
|
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_WORKMODE_SET_FAILED
: Failure.void tuya_app_main(void)
shall not exceed 200 milliseconds.tuya_hal_wifi_set_work_mode
is the first Wi-Fi-related API called by Tuya services. It verifies whether Wi-Fi initialization is completed. If initialization is incomplete, the function must block until completion is confirmed (single verification required).OPERATE_RET tkl_wifi_get_work_mode(WF_WK_MD_E *mode)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[out] | mode | The Wi-Fi operation mode.
|
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_WORKMODE_GET_FAILED
: Failure.OPERATE_RET tkl_wifi_get_connected_ap_info(FAST_WF_CONNECTED_AP_INFO_T **fast_ap_info)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[out] | fast_ap_info | The information about the connected AP. |
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_APINFO_GET_FAILED
: Failure.fast_ap_info
shall dynamically allocate memory within this API.OPERATE_RET tkl_wifi_get_bssid(UCHAR_T *mac)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[out] | mac | The MAC address. |
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_BSSID_GET_FAILED
: Failure.OPERATE_RET tkl_wifi_set_country_code(CONST COUNTRY_CODE_E ccode)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[in] | ccode | The country code. Valid values:
|
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_CCODE_SET_FAILED
: Failure.OPERATE_RET tkl_wifi_set_rf_calibrated(VOID_T);
Function description
Return value
true
: The RF is calibrated.
false
: The RF is not calibrated.
OPERATE_RET tkl_wifi_set_lp_mode(CONST BOOL_T enable, CONST UCHAR_T dtim)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[in] | enable | Specifies whether to enable the low power mode of the Wi-Fi. |
[in] | dtim | The delivery traffic indication map (DTIM) parameter. |
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_WF_LPMODE_SET_FAILED
: Failure.OPERATE_RET tkl_wifi_station_fast_connect(CONST FAST_WF_CONNECTED_AP_INFO_T *fast_ap_info)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[in] | fast_ap_info | The information about the AP required for Wi-Fi Easy Connect. |
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_FAST_CONN_FAILED
: Failure.This function shall only be invoked during the first connection attempt after pairing and restart.
OPERATE_RET tkl_wifi_station_connect(CONST SCHAR_T *ssid, CONST SCHAR_T *passwd)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[in] | ssid | The SSID of the wireless network. |
[in] | passwd | The password. |
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_CONN_FAILED
: Failure.tuya_hal_wifi_station_get_status
every 1s to query the Wi-Fi connection status.OPERATE_RET tkl_wifi_station_disconnect(VOID_T)
Function description
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_DISCONN_FAILED
: Failure.OPERATE_RET tkl_wifi_station_get_conn_ap_rssi(SCHAR_T *rssi)
Function description
Get the signal strength of the connected AP.
Parameter
Input/Output | Parameter | Description |
---|---|---|
[out] | rssi | The signal strength. |
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_RSSI_GET_FAILED
: Failure.OPERATE_RET tkl_wifi_station_get_status(WF_STATION_STAT_E *stat)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[out] | stat | The connection status. Valid values:
|
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_STAT_GET_FAILED
: Failure.OPERATE_RET tkl_wifi_send_mgnt(CONST UCHAR_T *buf, CONST UINT_T len)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[in] | buf | The data buffer of the management pack. |
[in] | len | The data length of the management pack. |
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_MGNT_SEND_FAILED
: Failure.OPERATE_RET tkl_wifi_register_recv_mgnt_callback(CONST BOOL_T enable, CONST WIFI_REV_MGNT_CB recv_cb)
Function description
Parameter
Input/Output | Parameter | Description |
---|---|---|
[in] | enable | Specifies whether to enable receiving management pack data. |
[in] | recv_cb | The callback for receiving management pack data. |
Return value
OPRT_OS_ADAPTER_OK
: Success.OPRT_OS_ADAPTER_MGNT_REG_FAILED
: Failure.Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback