TuyaOS
结构体 | 宏定义 | 类型定义 | 枚举 | 函数
tkl_wifi.h 文件参考

Common process - adapter the wi-fi api 更多...

#include "tuya_cloud_types.h"
tkl_wifi.h 的引用(Include)关系图:
此图展示该文件直接或间接的被哪些文件引用了:

浏览源代码.

结构体

struct  FAST_WF_CONNECTED_AP_INFO_T
 

宏定义

#define WIFI_PASSWD_LEN   64
 
#define WIFI_SSID_LEN   32
 

类型定义

typedef VOID_T(* SNIFFER_CALLBACK) (CONST UINT8_T *buf, CONST UINT16_T len, CONST INT8_T rssi)
 callback function: SNIFFER_CALLBACK when wifi sniffers package from air, notify tuyaos with this callback. the package should include 更多...
 
typedef VOID_T(* WIFI_EVENT_CB) (WF_EVENT_E event, VOID_T *arg)
 callback function: WIFI_STATUS_CHANGE_CB when wifi connect status changed, notify tuyaos with this callback. 更多...
 
typedef VOID_T(* WIFI_REV_MGNT_CB) (UCHAR_T *buf, UINT_T len)
 callback function: WIFI_REV_MGNT_CB when receive wifi management frame, notify tuyaos with this callback. 更多...
 

枚举

enum  COUNTRY_CODE_E { COUNTRY_CODE_CN , COUNTRY_CODE_US , COUNTRY_CODE_JP , COUNTRY_CODE_EU }
 
enum  WF_AP_AUTH_MODE_E {
  WAAM_OPEN = 0 , WAAM_WEP , WAAM_WPA_PSK , WAAM_WPA2_PSK ,
  WAAM_WPA_WPA2_PSK , WAAM_WPA_WPA3_SAE , WAAM_UNKNOWN
}
 
enum  WF_EVENT_E { WFE_CONNECTED , WFE_CONNECT_FAILED , WFE_DISCONNECTED }
 
enum  WF_IF_E { WF_STATION = 0 , WF_AP }
 
enum  WF_IOCTL_CMD_E { WFI_BEACON_CMD }
 
enum  WF_STATION_STAT_E {
  WSS_IDLE = 0 , WSS_CONNECTING , WSS_PASSWD_WRONG , WSS_NO_AP_FOUND ,
  WSS_CONN_FAIL , WSS_CONN_SUCCESS , WSS_GOT_IP
}
 
enum  WF_WK_MD_E {
  WWM_POWERDOWN = 0 , WWM_SNIFFER , WWM_STATION , WWM_SOFTAP ,
  WWM_STATIONAP , WWM_UNKNOWN
}
 

函数

OPERATE_RET tkl_wifi_get_bssid (UCHAR_T *mac)
 get wifi bssid 更多...
 
OPERATE_RET tkl_wifi_get_connected_ap_info (FAST_WF_CONNECTED_AP_INFO_T **fast_ap_info)
 : get ap info for fast connect 更多...
 
OPERATE_RET tkl_wifi_get_cur_channel (UCHAR_T *chan)
 get wifi interface work channel 更多...
 
OPERATE_RET tkl_wifi_get_ip (CONST WF_IF_E wf, NW_IP_S *ip)
 get wifi ip info.when wifi works in ap+station mode, wifi has two ips. 更多...
 
OPERATE_RET tkl_wifi_get_mac (CONST WF_IF_E wf, NW_MAC_S *mac)
 get wifi mac info.when wifi works in ap+station mode, wifi has two macs. 更多...
 
OPERATE_RET tkl_wifi_get_work_mode (WF_WK_MD_E *mode)
 get wifi work mode 更多...
 
OPERATE_RET tkl_wifi_init (WIFI_EVENT_CB cb)
 set wifi station work status changed callback 更多...
 
OPERATE_RET tkl_wifi_ioctl (WF_IOCTL_CMD_E cmd, VOID *args)
 wifi ioctl 更多...
 
OPERATE_RET tkl_wifi_register_recv_mgnt_callback (CONST BOOL_T enable, CONST WIFI_REV_MGNT_CB recv_cb)
 register receive wifi management callback 更多...
 
OPERATE_RET tkl_wifi_release_ap (AP_IF_S *ap)
 release the memory malloced in <tkl_wifi_ap_scan> if needed. tuyaos will call this function when the ap info is no use. 更多...
 
OPERATE_RET tkl_wifi_scan_ap (CONST SCHAR_T *ssid, AP_IF_S **ap_ary, UINT_T *num)
 scan current environment and obtain the ap infos in current environment 更多...
 
OPERATE_RET tkl_wifi_send_mgnt (CONST UCHAR_T *buf, CONST UINT_T len)
 send wifi management 更多...
 
OPERATE_RET tkl_wifi_set_country_code (CONST COUNTRY_CODE_E ccode)
 set wifi country code 更多...
 
OPERATE_RET tkl_wifi_set_cur_channel (CONST UCHAR_T chan)
 set wifi interface work channel 更多...
 
OPERATE_RET tkl_wifi_set_lp_mode (CONST BOOL_T enable, CONST UCHAR_T dtim)
 set wifi lowpower mode 更多...
 
OPERATE_RET tkl_wifi_set_mac (CONST WF_IF_E wf, CONST NW_MAC_S *mac)
 set wifi mac info.when wifi works in ap+station mode, wifi has two macs. 更多...
 
OPERATE_RET tkl_wifi_set_rf_calibrated (VOID_T)
 do wifi calibration 更多...
 
OPERATE_RET tkl_wifi_set_sniffer (CONST BOOL_T en, CONST SNIFFER_CALLBACK cb)
 enable / disable wifi sniffer mode. if wifi sniffer mode is enabled, wifi recv from packages from the air, and user shoud send these packages to tuya-sdk with callback <cb>. 更多...
 
OPERATE_RET tkl_wifi_set_work_mode (CONST WF_WK_MD_E mode)
 set wifi work mode 更多...
 
OPERATE_RET tkl_wifi_start_ap (CONST WF_AP_CFG_IF_S *cfg)
 start a soft ap 更多...
 
OPERATE_RET tkl_wifi_station_connect (CONST SCHAR_T *ssid, CONST SCHAR_T *passwd)
 connect wifi with ssid and passwd 更多...
 
OPERATE_RET tkl_wifi_station_disconnect (VOID_T)
 disconnect wifi from connect ap 更多...
 
OPERATE_RET tkl_wifi_station_fast_connect (CONST FAST_WF_CONNECTED_AP_INFO_T *fast_ap_info)
 : fast connect 更多...
 
OPERATE_RET tkl_wifi_station_get_conn_ap_rssi (SCHAR_T *rssi)
 get wifi connect rssi 更多...
 
OPERATE_RET tkl_wifi_station_get_status (WF_STATION_STAT_E *stat)
 get wifi station work status 更多...
 
OPERATE_RET tkl_wifi_stop_ap (VOID_T)
 stop a soft ap 更多...
 

详细描述

Common process - adapter the wi-fi api

Common process - adapter the wi-fi hostap api

版本
0.1
日期
2020-11-09

类型定义说明

◆ SNIFFER_CALLBACK

typedef VOID_T(* SNIFFER_CALLBACK) (CONST UINT8_T *buf, CONST UINT16_T len, CONST INT8_T rssi)

callback function: SNIFFER_CALLBACK when wifi sniffers package from air, notify tuyaos with this callback. the package should include

参数
[in]bufthe buf wifi recv
[in]lenthe len of buf

◆ WIFI_EVENT_CB

typedef VOID_T(* WIFI_EVENT_CB) (WF_EVENT_E event, VOID_T *arg)

callback function: WIFI_STATUS_CHANGE_CB when wifi connect status changed, notify tuyaos with this callback.

参数
[out]is_upthe wifi link status is up or not

◆ WIFI_REV_MGNT_CB

typedef VOID_T(* WIFI_REV_MGNT_CB) (UCHAR_T *buf, UINT_T len)

callback function: WIFI_REV_MGNT_CB when receive wifi management frame, notify tuyaos with this callback.

参数
[in]bufthe buf wifi recv
[in]lenthe len of buf

枚举类型说明

◆ WF_AP_AUTH_MODE_E

枚举值
WAAM_OPEN 

open

WAAM_WEP 

WEP

WAAM_WPA_PSK 

WPA—PSK

WAAM_WPA2_PSK 

WPA2—PSK

WAAM_WPA_WPA2_PSK 

WPA/WPA2

◆ WF_IF_E

enum WF_IF_E
枚举值
WF_STATION 

station type

WF_AP 

ap type

◆ WF_STATION_STAT_E

枚举值
WSS_IDLE 

not connected

WSS_CONNECTING 

connecting wifi

WSS_PASSWD_WRONG 

passwd not match

WSS_NO_AP_FOUND 

ap is not found

WSS_CONN_FAIL 

connect fail

WSS_CONN_SUCCESS 

connect wifi success

WSS_GOT_IP 

get ip success

◆ WF_WK_MD_E

enum WF_WK_MD_E
枚举值
WWM_POWERDOWN 

wifi work in powerdown mode

WWM_SNIFFER 

wifi work in sniffer mode

WWM_STATION 

wifi work in station mode

WWM_SOFTAP 

wifi work in ap mode

WWM_STATIONAP 

wifi work in station+ap mode

WWM_UNKNOWN 

wifi work in unknown mode

函数说明

◆ tkl_wifi_get_bssid()

OPERATE_RET tkl_wifi_get_bssid ( UCHAR_T *  mac)

get wifi bssid

参数
[out]macuplink mac
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_get_connected_ap_info()

OPERATE_RET tkl_wifi_get_connected_ap_info ( FAST_WF_CONNECTED_AP_INFO_T **  fast_ap_info)

: get ap info for fast connect

参数
[out]fast_ap_info
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_get_cur_channel()

OPERATE_RET tkl_wifi_get_cur_channel ( UCHAR_T *  chan)

get wifi interface work channel

参数
[out]chanthe channel wifi works
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_get_ip()

OPERATE_RET tkl_wifi_get_ip ( CONST WF_IF_E  wf,
NW_IP_S ip 
)

get wifi ip info.when wifi works in ap+station mode, wifi has two ips.

参数
[in]wfwifi function type
[out]ipthe ip addr info
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_get_mac()

OPERATE_RET tkl_wifi_get_mac ( CONST WF_IF_E  wf,
NW_MAC_S mac 
)

get wifi mac info.when wifi works in ap+station mode, wifi has two macs.

参数
[in]wfwifi function type
[out]macthe mac info
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_get_work_mode()

OPERATE_RET tkl_wifi_get_work_mode ( WF_WK_MD_E mode)

get wifi work mode

参数
[out]modewifi work mode
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_init()

OPERATE_RET tkl_wifi_init ( WIFI_EVENT_CB  cb)

set wifi station work status changed callback

参数
[in]cbthe wifi station work status changed callback
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_ioctl()

OPERATE_RET tkl_wifi_ioctl ( WF_IOCTL_CMD_E  cmd,
VOID *  args 
)

wifi ioctl

参数
[in]cmdrefer to WF_IOCTL_CMD_E
[in]argsargs associated with the command
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_register_recv_mgnt_callback()

OPERATE_RET tkl_wifi_register_recv_mgnt_callback ( CONST BOOL_T  enable,
CONST WIFI_REV_MGNT_CB  recv_cb 
)

register receive wifi management callback

参数
[in]enable
[in]recv_cbreceive callback
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_release_ap()

OPERATE_RET tkl_wifi_release_ap ( AP_IF_S ap)

release the memory malloced in <tkl_wifi_ap_scan> if needed. tuyaos will call this function when the ap info is no use.

参数
[in]apthe ap info
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_scan_ap()

OPERATE_RET tkl_wifi_scan_ap ( CONST SCHAR_T *  ssid,
AP_IF_S **  ap_ary,
UINT_T *  num 
)

scan current environment and obtain the ap infos in current environment

参数
[in]ssidthe specific ssid
[out]ap_arycurrent ap info array
[out]numthe num of ar_ary
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h
注解
if ssid == NULL means scan all ap, otherwise means scan the specific ssid

◆ tkl_wifi_send_mgnt()

OPERATE_RET tkl_wifi_send_mgnt ( CONST UCHAR_T *  buf,
CONST UINT_T  len 
)

send wifi management

参数
[in]bufpointer to buffer
[in]lenlength of buffer
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_set_country_code()

OPERATE_RET tkl_wifi_set_country_code ( CONST COUNTRY_CODE_E  ccode)

set wifi country code

参数
[in]ccodecountry code
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_set_cur_channel()

OPERATE_RET tkl_wifi_set_cur_channel ( CONST UCHAR_T  chan)

set wifi interface work channel

参数
[in]chanthe channel to set
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_set_lp_mode()

OPERATE_RET tkl_wifi_set_lp_mode ( CONST BOOL_T  enable,
CONST UCHAR_T  dtim 
)

set wifi lowpower mode

参数
[in]enableenbale lowpower mode
[in]dtimthe wifi dtim
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_set_mac()

OPERATE_RET tkl_wifi_set_mac ( CONST WF_IF_E  wf,
CONST NW_MAC_S mac 
)

set wifi mac info.when wifi works in ap+station mode, wifi has two macs.

参数
[in]wfwifi function type
[in]macthe mac info
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_set_rf_calibrated()

OPERATE_RET tkl_wifi_set_rf_calibrated ( VOID_T  )

do wifi calibration

注解
called when test wifi
返回
true on success. faile on failure

◆ tkl_wifi_set_sniffer()

OPERATE_RET tkl_wifi_set_sniffer ( CONST BOOL_T  en,
CONST SNIFFER_CALLBACK  cb 
)

enable / disable wifi sniffer mode. if wifi sniffer mode is enabled, wifi recv from packages from the air, and user shoud send these packages to tuya-sdk with callback <cb>.

参数
[in]enenable or disable
[in]cbnotify callback
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_set_work_mode()

OPERATE_RET tkl_wifi_set_work_mode ( CONST WF_WK_MD_E  mode)

set wifi work mode

参数
[in]modewifi work mode
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_start_ap()

OPERATE_RET tkl_wifi_start_ap ( CONST WF_AP_CFG_IF_S cfg)

start a soft ap

参数
[in]cfgthe soft ap config
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_station_connect()

OPERATE_RET tkl_wifi_station_connect ( CONST SCHAR_T *  ssid,
CONST SCHAR_T *  passwd 
)

connect wifi with ssid and passwd

参数
[in]ssid
[in]passwd
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_station_disconnect()

OPERATE_RET tkl_wifi_station_disconnect ( VOID_T  )

disconnect wifi from connect ap

返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_station_fast_connect()

OPERATE_RET tkl_wifi_station_fast_connect ( CONST FAST_WF_CONNECTED_AP_INFO_T fast_ap_info)

: fast connect

参数
[in]fast_ap_info
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_station_get_conn_ap_rssi()

OPERATE_RET tkl_wifi_station_get_conn_ap_rssi ( SCHAR_T *  rssi)

get wifi connect rssi

参数
[out]rssithe return rssi
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_station_get_status()

OPERATE_RET tkl_wifi_station_get_status ( WF_STATION_STAT_E stat)

get wifi station work status

参数
[out]statthe wifi station work status
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tkl_wifi_stop_ap()

OPERATE_RET tkl_wifi_stop_ap ( VOID_T  )

stop a soft ap

返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h