wm_wifi.h 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352
  1. /**
  2. * @file wm_wifi.h
  3. *
  4. * @brief Wi-Fi API
  5. *
  6. * @author WinnerMicro
  7. *
  8. * Copyright (c) 2015 Winner Microelectronics Co., Ltd.
  9. */
  10. #ifndef TLS_WIFI_FUNC_H
  11. #define TLS_WIFI_FUNC_H
  12. /* Return Error definition*/
  13. /** invalid SSID */
  14. #define WM_WIFI_ERR_SSID -1
  15. /** invalid key */
  16. #define WM_WIFI_ERR_KEY -2
  17. /** wps is busing */
  18. #define WM_WIFI_WPS_BUSY -3
  19. /** scan is busing */
  20. #define WM_WIFI_SCANNING_BUSY -4
  21. /** station is connecting */
  22. #define WM_WIFI_STA_BUSY -5
  23. /* error number definition */
  24. /** no error */
  25. #define WM_WIFI_ENOERR 0
  26. /** ap not exist */
  27. #define WM_WIFI_ENOAP 1
  28. /** pre-shared key may be incorrect */
  29. #define WM_WIFI_EKEY 2
  30. /** Low signal intensity */
  31. #define WM_WIFI_ELSI 3
  32. #ifndef ETH_ALEN
  33. /** mac address length */
  34. #define ETH_ALEN 6
  35. #endif
  36. /* bss type definition*/
  37. #ifndef IEEE80211_MODE_INFRA
  38. /** station mode */
  39. #define IEEE80211_MODE_INFRA 1
  40. /** ibss mode */
  41. #define IEEE80211_MODE_IBSS 2
  42. /** softap mode */
  43. #define IEEE80211_MODE_AP 4
  44. #endif
  45. /** authenticate mode : open */
  46. #define IEEE80211_ENCRYT_NONE 0
  47. /** authenticate mode : WEP40 */
  48. #define IEEE80211_ENCRYT_WEP40 1
  49. /** authenticate mode : WEP104 */
  50. #define IEEE80211_ENCRYT_WEP104 2
  51. /** authenticate mode : WPA_PSK_TKIP */
  52. #define IEEE80211_ENCRYT_TKIP_WPA 3
  53. /** authenticate mode : WPA_PSK_CCMP */
  54. #define IEEE80211_ENCRYT_CCMP_WPA 4
  55. /** authenticate mode : WPA2_PSK_TKIP */
  56. #define IEEE80211_ENCRYT_TKIP_WPA2 5
  57. /** authenticate mode : WPA2_PSK_CCMP */
  58. #define IEEE80211_ENCRYT_CCMP_WPA2 6
  59. /** authenticate mode : WPA_PSK_TKIP&AES */
  60. #define IEEE80211_ENCRYT_AUTO_WPA 7
  61. /** authenticate mode : WPA2_PSK_TKIP&AES */
  62. #define IEEE80211_ENCRYT_AUTO_WPA2 8
  63. #ifdef TLS_CONFIG_WPS
  64. /** length of WPS pin code */
  65. #define WPS_PIN_LEN 8
  66. #endif
  67. /** set auto connecting flag */
  68. #define WIFI_AUTO_CNT_FLAG_SET 1
  69. /** get auto connecting flag */
  70. #define WIFI_AUTO_CNT_FLAG_GET 0
  71. /** disable Wi-Fi auto connecting */
  72. #define WIFI_AUTO_CNT_OFF 0x0
  73. /** enable Wi-Fi auto connecting */
  74. #define WIFI_AUTO_CNT_ON 0x1
  75. /** disable Wi-Fi auto connecting temporary */
  76. #define WIFI_AUTO_CNT_TMP_OFF 0x3
  77. /** Wi-Fi join net successfully */
  78. #define WIFI_JOIN_SUCCESS 0x1
  79. /** Wi-Fi join net failed */
  80. #define WIFI_JOIN_FAILED 0x2
  81. /** Wi-Fi disconnected */
  82. #define WIFI_DISCONNECTED 0x3
  83. /** Wi-Fi create ap successfully */
  84. #define WIFI_SOFTAP_SUCCESS 0x4
  85. /** Wi-Fi create softap failure */
  86. #define WIFI_SOFTAP_FAILED 0x5
  87. /** Wi-Fi close softap */
  88. #define WIFI_SOFTAP_CLOSED 0x6
  89. enum tls_wifi_auth_mode {
  90. WM_WIFI_AUTH_MODE_OPEN = 0, /**< authenticate mode : open */
  91. WM_WIFI_AUTH_MODE_WEP_AUTO = 3, /**< authenticate mode : wep (open or/and shared...) */
  92. WM_WIFI_AUTH_MODE_WPA_PSK_TKIP = 4, /**< authenticate mode : wpa psk rc4 */
  93. WM_WIFI_AUTH_MODE_WPA_PSK_CCMP = 8, /**< authenticate mode : wpa psk aes */
  94. WM_WIFI_AUTH_MODE_WPA_PSK_AUTO = (WM_WIFI_AUTH_MODE_WPA_PSK_TKIP | WM_WIFI_AUTH_MODE_WPA_PSK_CCMP), /**< authenticate mode : wpa psk, tkip and aes */
  95. WM_WIFI_AUTH_MODE_WPA2_PSK_TKIP = 16, /**< authenticate mode : wpa2 psk rc4 */
  96. WM_WIFI_AUTH_MODE_WPA2_PSK_CCMP = 32, /**< authenticate mode : wpa2 psk aes */
  97. WM_WIFI_AUTH_MODE_WPA2_PSK_AUTO = (WM_WIFI_AUTH_MODE_WPA2_PSK_TKIP | WM_WIFI_AUTH_MODE_WPA2_PSK_CCMP), /**< authenticate mode : wpa2 psk, tkip and aes */
  98. WM_WIFI_AUTH_MODE_WPA_WPA2_PSK_TKIP = (WM_WIFI_AUTH_MODE_WPA_PSK_TKIP | WM_WIFI_AUTH_MODE_WPA2_PSK_TKIP),
  99. WM_WIFI_AUTH_MODE_WPA_WPA2_PSK_CCMP = (WM_WIFI_AUTH_MODE_WPA_PSK_CCMP | WM_WIFI_AUTH_MODE_WPA2_PSK_CCMP),
  100. WM_WIFI_AUTH_MODE_WPA_WPA2_PSK_AUTO = (WM_WIFI_AUTH_MODE_WPA_PSK_AUTO | WM_WIFI_AUTH_MODE_WPA2_PSK_AUTO), /**< authenticate mode : wpa and wpa2, tkip and aes */
  101. WM_WIFI_AUTH_MODE_UNKNOWN = 128
  102. };
  103. /** Wi-Fi encryption enum */
  104. enum tls_wifi_encrypt_mode {
  105. WM_WIFI_ECN_MODE_OPEN = 0, /**< encrypt mode : open */
  106. WM_WIFI_ECN_MODE_WEP = 1, /**< encrypt mode : wep*/
  107. WM_WIFI_ECN_MODE_WPA_PSK = 2, /**< encrypt mode : wpa psk*/
  108. WM_WIFI_ECN_MODE_WPA2_PSK = 3, /**< encrypt mode : wpa2 psk*/
  109. WM_WIFI_ECN_MODE_WPA_WPA2_PSK = 4, /**< encrypt mode : wpa and wpa2 psk*/
  110. WM_WIFI_ECN_MODE_UNKNOWN = 5, /**< encrypt mode : unknown*/
  111. };
  112. /** Wi-Fi group/pairwise cipher enumu*/
  113. enum tls_wifi_cipher_mode{
  114. WM_WIFI_CIPHER_NONE = 0,
  115. WM_WIFI_CIPHER_WEP40 = 1,
  116. WM_WIFI_CIPHER_WEP104 = 2,
  117. WM_WIFI_CIPHER_TKIP = 3,
  118. WM_WIFI_CIPHER_CCMP = 4,
  119. WM_WIFI_CIPHER_TKIP_AND_CCMP = 5,
  120. WM_WIFI_CIPHER_AES_CMAC_128 = 6,
  121. };
  122. /** Wi-Fi states */
  123. enum tls_wifi_states {
  124. WM_WIFI_DISCONNECTED, /**< Disconnected state */
  125. WM_WIFI_SCANNING, /**< Scanning for a network */
  126. WM_WIFI_JOINING, /**< Trying to join with a BSS/SSID */
  127. WM_WIFI_JOINED /**< All authentication completed */
  128. };
  129. /** frame type of the manager */
  130. enum tls_wifi_mgmt_type {
  131. WM_WIFI_MGMT_TYPE_ASSOC_REQ = 0x0000, /**< association request frame */
  132. WM_WIFI_MGMT_TYPE_ASSOC_RESP = 0x0010, /**< association response frame */
  133. WM_WIFI_MGMT_TYPE_REASSOC_REQ = 0x0020, /**< reassociation request frame */
  134. WM_WIFI_MGMT_TYPE_REASSOC_RESP = 0x0030, /**< reassociation response frame */
  135. WM_WIFI_MGMT_TYPE_PROBE_REQ = 0x0040, /**< probe request frame */
  136. WM_WIFI_MGMT_TYPE_PROBE_RESP = 0x0050, /**< probe response frame */
  137. WM_WIFI_MGMT_TYPE_BEACON = 0x0080, /**< beacon frame */
  138. WM_WIFI_MGMT_TYPE_ATIM = 0x0090, /**< ATIM frame */
  139. WM_WIFI_MGMT_TYPE_DISASSOC = 0x00A0, /**< disassociation frame */
  140. WM_WIFI_MGMT_TYPE_AUTH = 0x00B0, /**< authentication frame */
  141. WM_WIFI_MGMT_TYPE_DEAUTH = 0x00C0, /**< deauthentication frame */
  142. WM_WIFI_MGMT_TYPE_ACTION = 0x00D0 /**< action frame */
  143. };
  144. /** Wi-Fi ransport rate */
  145. enum tls_wifi_tx_rate {
  146. WM_WIFI_TX_RATEIDX_1M = 0, /**< 11b, 1M */
  147. WM_WIFI_TX_RATEIDX_2M, /**< 11b, 2M */
  148. WM_WIFI_TX_RATEIDX_5_5M, /**< 11b, 5.5M */
  149. WM_WIFI_TX_RATEIDX_11M, /**< 11b, 11M */
  150. WM_WIFI_TX_RATEIDX_6M, /**< 11g, 6M */
  151. WM_WIFI_TX_RATEIDX_9M, /**< 11g, 9M */
  152. WM_WIFI_TX_RATEIDX_12M, /**< 11g, 12M */
  153. WM_WIFI_TX_RATEIDX_18M, /**< 11g, 18M */
  154. WM_WIFI_TX_RATEIDX_24M, /**< 11g, 24M */
  155. WM_WIFI_TX_RATEIDX_36M, /**< 11g, 36M */
  156. WM_WIFI_TX_RATEIDX_48M, /**< 11g, 48M */
  157. WM_WIFI_TX_RATEIDX_54M, /**< 11g, 54M */
  158. WM_WIFI_TX_RATEIDX_MCS0, /**< 11n-20MHz, mcs0 */
  159. WM_WIFI_TX_RATEIDX_MCS1, /**< 11n-20MHz, mcs1 */
  160. WM_WIFI_TX_RATEIDX_MCS2, /**< 11n-20MHz, mcs2 */
  161. WM_WIFI_TX_RATEIDX_MCS3, /**< 11n-20MHz, mcs3 */
  162. WM_WIFI_TX_RATEIDX_MCS4, /**< 11n-20MHz, mcs4 */
  163. WM_WIFI_TX_RATEIDX_MCS5, /**< 11n-20MHz, mcs5 */
  164. WM_WIFI_TX_RATEIDX_MCS6, /**< 11n-20MHz, mcs6 */
  165. WM_WIFI_TX_RATEIDX_MCS7, /**< 11n-20MHz, mcs7 */
  166. WM_WIFI_TX_RATEIDX_MCS8, /**< 11n-40MHz, mcs8 */
  167. WM_WIFI_TX_RATEIDX_MCS9, /**< 11n-40MHz, mcs9 */
  168. WM_WIFI_TX_RATEIDX_MCS10, /**< 11n-40MHz, mcs10 */
  169. WM_WIFI_TX_RATEIDX_MCS11, /**< 11n-40MHz, mcs11 */
  170. WM_WIFI_TX_RATEIDX_MCS12, /**< 11n-40MHz, mcs12 */
  171. WM_WIFI_TX_RATEIDX_MCS13, /**< 11n-40MHz, mcs13 */
  172. WM_WIFI_TX_RATEIDX_MCS14, /**< 11n-40MHz, mcs14 */
  173. WM_WIFI_TX_RATEIDX_MCS15, /**< 11n-40MHz, mcs15 */
  174. WM_WIFI_TX_RATEIDX_MCS32 /**< invalid rate */
  175. };
  176. enum tls_wifi_oneshot_result_type {
  177. WM_WIFI_ONESHOT_TYPE_SSIDPWD,
  178. WM_WIFI_ONESHOT_TYPE_CUSTOMDATA
  179. };
  180. enum tls_wifi_client_event_type {
  181. WM_WIFI_CLIENT_EVENT_ONLINE,
  182. WM_WIFI_CLIENT_EVENT_OFFLINE
  183. };
  184. enum tls_wifi_op_mode{
  185. STATION_MODE = 1,
  186. SOFTAP_MODE,
  187. STATIONAP_MODE
  188. };
  189. /** current bss information */
  190. struct tls_curr_bss_t{
  191. u8 bssid[ETH_ALEN]; /**< BSSID of connected AP */
  192. u8 ssid[32]; /**< SSID of connected AP */
  193. u8 ssid_len; /**< SSID length of connected AP */
  194. u8 channel; /**< channel of connected AP */
  195. u8 type; /**< BSS's type of connected AP, value is:
  196. IEEE80211_MODE_INFRA, IEEE80211_MODE_IBSS,
  197. IEEE80211_MODE_AP, IEEE80211_MODE_APSTA */
  198. u8 encryptype; /**< BSS's encryption type of connected AP, value is: IEEE80211_ENCRYT_NONE,
  199. IEEE80211_ENCRYT_WEP40, IEEE80211_ENCRYT_WEP104,
  200. IEEE80211_ENCRYT_TKIP_WPA, IEEE80211_ENCRYT_CCMP_WPA,
  201. IEEE80211_ENCRYT_TKIP_WPA2, IEEE80211_ENCRYT_CCMP_WPA2,
  202. IEEE80211_ENCRYT_AUTO_WPA, IEEE80211_ENCRYT_AUTO_WPA2 */
  203. u8 rssi; /**< single strength of AP */
  204. };
  205. /** secret key information */
  206. struct tls_key_info_t{
  207. u8 format; /**< key format, value is: 0-hex, 1-ascii */
  208. u8 index; /**< key index, value is: 1-4 (only wep) */
  209. u8 key_len; /**< key length */
  210. u8 key[64]; /**< key content */
  211. };
  212. /** Wi-Fi configuration of softap */
  213. struct tls_softap_info_t{
  214. u8 ssid[33]; /**< SSID of softap */
  215. u8 encrypt; /**< encryption mode of softap, value is: IEEE80211_ENCRYT_NONE,
  216. IEEE80211_ENCRYT_WEP40, IEEE80211_ENCRYT_WEP104,
  217. IEEE80211_ENCRYT_TKIP_WPA, IEEE80211_ENCRYT_CCMP_WPA,
  218. IEEE80211_ENCRYT_TKIP_WPA2, IEEE80211_ENCRYT_CCMP_WPA2 */
  219. u8 channel; /**< channel of softap */
  220. struct tls_key_info_t keyinfo; /**< Password (key) of softap */
  221. };
  222. /** ip address information */
  223. struct tls_ip_info_t{
  224. u8 ip_addr[4]; /**< IP address */
  225. u8 netmask[4]; /**< netmask */
  226. u8 dnsname[32]; /**< DNS server name */
  227. };
  228. /** Wi-Fi configuration of ibss */
  229. struct tls_ibss_info_t{
  230. u8 ssid[33]; /**< SSID of ibss */
  231. u8 encrypt; /**< encryption mode of ibss, value is: IEEE80211_ENCRYT_NONE,
  232. IEEE80211_ENCRYT_WEP40, IEEE80211_ENCRYT_WEP104,
  233. IEEE80211_ENCRYT_TKIP_WPA, IEEE80211_ENCRYT_CCMP_WPA,
  234. IEEE80211_ENCRYT_TKIP_WPA2, IEEE80211_ENCRYT_CCMP_WPA2,
  235. IEEE80211_ENCRYT_AUTO_WPA, IEEE80211_ENCRYT_AUTO_WPA2 */
  236. u8 channel; /**< channel of ibss */
  237. struct tls_key_info_t keyinfo; /**< Password (key) of ibss */
  238. };
  239. /** ip address information of ibss */
  240. struct tls_ibssip_info_t{
  241. u8 ip[4]; /**< IP address */
  242. u8 netmask[4]; /**< netmask */
  243. u8 gateway[4]; /**< gateway */
  244. u8 dns1[4]; /**< DNS1 IP address */
  245. u8 dns2[4]; /**< DNS2 IP address */
  246. };
  247. /** bss information */
  248. struct tls_bss_info_t {
  249. u8 bssid[ETH_ALEN]; /**< MAC address of AP */
  250. u8 mode; /**< AP type, value is: 1-ibss, 2-ess */
  251. u8 channel; /**< channel of AP */
  252. u8 privacy; /**< encryption type, @ref enum tls_wifi_auth_mode */
  253. u8 ssid_len; /**< SSID length */
  254. u8 rssi; /**< signal strength of AP, real rssi = (signed char)rssi */
  255. u8 ssid[32]; /**< SSID of AP */
  256. u32 max_data_rate; /**< maximum rate of AP, the unit is Mbps */
  257. bool wps_support; /**< is support WPS function */
  258. };
  259. /** scan result */
  260. struct tls_scan_bss_t {
  261. u32 count; /**< total count */
  262. u32 length; /**< bss info total length */
  263. struct tls_bss_info_t bss[1]; /**< list of bss found*/
  264. };
  265. /** format2 bss information */
  266. struct tls_bss_info_format2_t {
  267. u8 ecn; /**< encryption type, @ref enum tls_wifi_encrypt_mode */
  268. u8 rssi; /**< signal strength of AP, real rssi = (signed char)rssi */
  269. u8 ssid[32]; /**< SSID of AP */
  270. u8 ssid_len; /**< SSID length */
  271. u8 bssid[ETH_ALEN]; /**< MAC address of AP */
  272. u8 channel; /**< channel of AP */
  273. s16 freq_offset; /**< reserved do not support*/
  274. s16 freqcal_val; /**< reserved do not support*/
  275. s8 pairwise_cipher; /**< pairwise cipher. @ref enum tls_wifi_cipher_mode */
  276. s8 group_cipher; /**< group cipher. @ref enum tls_wifi_cipher_mode */
  277. u8 bgn; /**< bgnmode, bit0:b mode, bit1:g mode, bit2:n mode */
  278. bool wps_support; /**< is support WPS function */
  279. };
  280. /** format2 scan result */
  281. struct tls_scan_bss_format2_t {
  282. u32 count; /**< total count */
  283. u32 length; /**< bss info total length */
  284. struct tls_bss_info_format2_t bss[1]; /**< list of bss found*/
  285. };
  286. /** station information */
  287. struct tls_sta_info_t {
  288. u8 mac_addr[ETH_ALEN]; /**< MAC address of station */
  289. };
  290. /** 802.11 packet information from the physical layer */
  291. struct tls_wifi_ext_t {
  292. u8 rssi; /**< signal strength */
  293. u8 rx_rate; /**< Rx_rate */
  294. };
  295. /** 802.11 mac address */
  296. struct tls_wifi_hdr_mac_t {
  297. u8 da_addr[ETH_ALEN]; /**< MAC address of destination */
  298. u8 sa_addr[ETH_ALEN]; /**< MAC address of source */
  299. u8 bssid[ETH_ALEN]; /**< MAC address of AP */
  300. };
  301. /** transport rate and gain */
  302. struct tls_wifi_tx_rate_t {
  303. enum tls_wifi_tx_rate tx_rate; /**< Wi-Fi ransport rate */
  304. u8 tx_gain; /**< Wi-Fi ransport gain,
  305. The caller can get the maximum gain
  306. by using the tls_wifi_get_tx_gain_max function. */
  307. u8 retry_times; /**< Wi-Fi number of retransmissions, ranging from 1 to 15. */
  308. };
  309. /** scan param */
  310. struct tls_wifi_scan_param_t{
  311. u16 scan_type;
  312. u16 scan_times; /**< Scan times, >=0, if zero, only 1 times */
  313. u16 scan_chanlist; /**< Scan channel list ,[0,3FFF],per bit is one channel,if zero or above 0x3FFF, scan all channel*/
  314. u16 scan_chinterval; /**< Scan channel switch time,>=0, if zero, use default value, unit:ms */
  315. };
  316. /** callback function of receive Wi-Fi data */
  317. typedef void (*tls_wifi_data_recv_callback)(u8* data, u32 data_len);
  318. /** callback function of Wi-Fi PSMode Preprocess when enter chipsleep function */
  319. typedef void (*tls_wifi_psm_prechipsleep_callback)(void);
  320. /** callback function of Wi-Fi PSMode Using chipsleep function */
  321. typedef void (*tls_wifi_psm_chipsleep_callback)(u32 sleeptime);
  322. /** callback function of Wi-Fi PSMode Postprocess after chip wakeup */
  323. typedef void (*tls_wifi_psm_postchipsleep_callback)(void);
  324. /** callback function of receive ETHERNET data */
  325. typedef int (*net_rx_data_cb)(const u8 *bssid, u8 *buf, u32 buf_len);
  326. /** callback function of receive Wi-Fi data with some information of the physical layer */
  327. typedef void (*tls_wifi_data_ext_recv_callback)(u8* data, u32 data_len, struct tls_wifi_ext_t *ext);
  328. /**
  329. * @defgroup Wi-Fi_APIs Wi-Fi APIs
  330. * @brief Wi-Fi related APIs
  331. */
  332. /**
  333. * @addtogroup Wi-Fi_APIs
  334. * @{
  335. */
  336. /**
  337. * @brief This function is used to enable/disable listen mode
  338. *
  339. * @param[in] enable:non-zero, disable: 0
  340. *
  341. * @return None
  342. *
  343. * @note This function used when oneshot start.
  344. */
  345. void tls_wifi_set_listen_mode(u8 enable);
  346. /**
  347. * @brief This function is used to get listen mode
  348. *
  349. * @param None
  350. *
  351. * @retval 0 normal mode
  352. * @retval non-zero listen mode
  353. *
  354. * @note None
  355. */
  356. u8 tls_wifi_get_listen_mode(void);
  357. /**
  358. * @brief This function is used to filter multicast frames
  359. * @param mac: The multicast frame that we want receive or filter.
  360. *
  361. * @param receive: 1, receive this multicast frame
  362. * 0, filter this multicast frame
  363. *
  364. * @note usage: For example: u8 mac[6]={01, 00, 5e, 7f, ff, fa},if receive
  365. * is set to 0,the 802.11 multicast frames whose hdr->addr1 is
  366. * [01 00 5e 7f ff fa] will be filtered.
  367. */
  368. u8 tls_filter_mcast_mac(u8 *mac, u8 receive);
  369. /**
  370. * @brief This function is used to set mac filter.
  371. * @param[in] mac: mac: to be filtered or received
  372. *
  373. * @param[in] receive: 1:not filter,zero:filter
  374. *
  375. * @param[in] clear: 1:clear all, 0:do not clear, only add new filter
  376. *
  377. * @return None
  378. *
  379. * @note usage: normally, it is used to oneshot config
  380. */
  381. void tls_wifi_set_bcast_mac_filter(u8 *mac, u8 receive, u8 clear);
  382. /**
  383. * @brief This function is used to restore mac filter to normal mode.
  384. *
  385. * @param[in] None
  386. *
  387. * @return None
  388. *
  389. * @note Normally, it is used to restore mac filter after oneshot config
  390. */
  391. void tls_wifi_restore_bcast_mac_filter(void);
  392. /**
  393. * @brief This function is used to register recv wifi data callback function
  394. *
  395. * @param[in] callback point to receive Wi-Fi data function
  396. *
  397. * @return None
  398. *
  399. * @note None
  400. */
  401. void tls_wifi_data_recv_cb_register(tls_wifi_data_recv_callback callback);
  402. /**
  403. * @brief This function is used to register recv wifi extended
  404. * data callback function
  405. *
  406. * @param[in] callback point to receive Wi-Fi extended data function
  407. *
  408. * @return None
  409. *
  410. * @note None
  411. */
  412. void tls_wifi_data_ext_recv_cb_register(tls_wifi_data_ext_recv_callback callback);
  413. /**
  414. * @brief This function is used to register recv wifi management frame
  415. * callback function
  416. *
  417. * @param[in] callback point to receive Wi-Fi management frame function
  418. *
  419. * @return None
  420. *
  421. * @note None
  422. */
  423. void tls_wifi_mgmt_ext_recv_cb_register(tls_wifi_data_ext_recv_callback callback);
  424. /**
  425. * @brief This function is used to register chipsleep callback function
  426. * when using chip sleep for powersaving
  427. *
  428. * @param[in] sleepcallback: pointer to function when enter to chipsleep
  429. * @param[in] precallback: pointer to function before enter to chipsleep
  430. * @param[in] postcallback: pointer to function after leave chipsleep
  431. *
  432. * @return None
  433. *
  434. * @note None
  435. */
  436. void tls_wifi_psm_chipsleep_cb_register(tls_wifi_psm_chipsleep_callback sleepcallback,
  437. tls_wifi_psm_prechipsleep_callback precallback,
  438. tls_wifi_psm_postchipsleep_callback postcallback);
  439. /**
  440. * @brief This function is used to set chipsleep valid flag
  441. *
  442. * @param[in] flag: use chipsleep when psm using.0:using normal wifi sleep, non-zero:using chipsleep
  443. *
  444. * @return None
  445. *
  446. * @note None
  447. */
  448. void tls_wifi_set_psm_chipsleep_flag(u32 flag);
  449. /**
  450. * @brief This function is used to get chipsleep valid flag
  451. *
  452. * @param[in] None
  453. *
  454. * @return None
  455. *
  456. * @note None
  457. */
  458. u32 tls_wifi_get_psm_chipsleep_flag(void);
  459. /**
  460. * @brief This function is used to set oneshot config flag
  461. *
  462. * @param[in] flag 0: closed oneshot
  463. * 1: one shot open
  464. * 2: AP+socket
  465. * 3: AP+WEBSERVER
  466. * 4: bt
  467. *
  468. * @return 0£ºsuccess
  469. * -1£ºfailed
  470. *
  471. * @note None
  472. */
  473. int tls_wifi_set_oneshot_flag(u8 flag);
  474. /**
  475. * @brief This function is used to get one shot flag
  476. *
  477. * @param None
  478. *
  479. * @retval 0: oneshot closed
  480. * 1: one shot open
  481. * 2: AP+socket
  482. * 3: AP+WEBSERVER
  483. * 4: bt
  484. *
  485. * @note None
  486. */
  487. int tls_wifi_get_oneshot_flag(void);
  488. /** callback function of oneshot result */
  489. typedef void (*tls_wifi_oneshot_result_callback)(enum tls_wifi_oneshot_result_type type);
  490. /**
  491. * @brief before calling tls_wifi_get_oneshot_ssidpwd or tls_wifi_get_oneshot_customdata,
  492. * application should call this function to register the call back function
  493. *
  494. * @param[in] callback callback function pointer
  495. *
  496. * @return None
  497. *
  498. * @note None
  499. */
  500. void tls_wifi_oneshot_result_cb_register(tls_wifi_oneshot_result_callback callback);
  501. /**
  502. * @brief This function is used to get one shot ssid and password information.
  503. *
  504. * @param[in] ssid wifi name
  505. * @param[in] pwd pwssword
  506. *
  507. * @return None
  508. *
  509. * @note None
  510. */
  511. void tls_wifi_get_oneshot_ssidpwd(u8 *ssid, u8 *pwd);
  512. /**
  513. * @brief This function is used to get one shot custom data
  514. *
  515. * @param[in] data custom data
  516. *
  517. * @return None
  518. *
  519. * @note None
  520. */
  521. void tls_wifi_get_oneshot_customdata(u8 *data);
  522. /**
  523. * @brief This function is used to change channel actively
  524. *
  525. * @param[in] chanid
  526. *
  527. * @return None
  528. *
  529. * @note Normally, it is just used in listen mode;
  530. */
  531. void tls_wifi_change_chanel(u32 chanid);
  532. /**
  533. * @brief This function is used to trigger scan AP
  534. *
  535. * @param None
  536. *
  537. * @retval WM_SUCCESS start scan
  538. * @retval WM_WIFI_SCANNING_BUSY scanning
  539. * @retval WM_FAILED failed
  540. *
  541. * @note If not SUCCESS, user needs to call this function again
  542. * to trigger scan
  543. */
  544. int tls_wifi_scan(void);
  545. /**
  546. * @brief This function is used to trigger scan AP
  547. *
  548. * @param None
  549. *
  550. * @retval WM_SUCCESS start scan
  551. * @retval WM_WIFI_SCANNING_BUSY scanning
  552. * @retval WM_FAILED failed
  553. *
  554. * @note If not SUCCESS, user needs to call this function again
  555. * to trigger scan
  556. */
  557. int tls_wifi_passive_scan(void);
  558. /**
  559. * @brief scan AP ,user can set channellist,scan times and switch interval per channel
  560. *
  561. * @param[in] scan_param
  562. * scan_param member
  563. * scan_times: scan times, >=0, if zero, only 1 times
  564. * scan_chanlist: scan channel list ,[0,3FFF],per bit is one channel,if zero or above 0x3FFF, scan all channel
  565. * scan_chinterval: scan channel switch time if zero, use default value. when value is non-zero,if input value >=20 use it, else input value <20 use 20, unit:ms
  566. *
  567. * @retval WM_SUCCESS will start scan
  568. * @retval WM_WIFI_SCANNING_BUSY wifi module is scanning now
  569. * @retval WM_FAILED other Error
  570. *
  571. * @note in case not SUCCESS, user need to call this function again to trigger the scan
  572. */
  573. int tls_wifi_scan_by_param(struct tls_wifi_scan_param_t *scan_param);
  574. /**
  575. * @brief Before calling tls_wifi_scan() , application should call
  576. * this function to register the call back function;
  577. *
  578. * @param[in] callback point to callback function
  579. *
  580. * @return None
  581. *
  582. * @note In callback function, user should send a message
  583. * and return immediately.
  584. * After callback called, scan result can be get by
  585. * calling function tls_wifi_get_scan_rslt
  586. */
  587. void tls_wifi_scan_result_cb_register(void (*callback)(void));
  588. /**
  589. * @brief This function is used to get scan result
  590. *
  591. * @param[out] buf buf to be used to store returned BSS info
  592. * @param[in] buffer_size buf size
  593. *
  594. * @retval WM_SUCCESS success
  595. * @retval WM_FAILED failed
  596. *
  597. * @note User need to alloc buffer in advance.
  598. * One item of scan result is @ref struct tls_bss_info_t.
  599. * Size for one item of scan result is 48Bytes;
  600. * The buffer size depends how many items user wants.
  601. * Compared with the previous scanning results,
  602. * max_data_rate and wps_support fields were added,
  603. * and the meaning of the privacy field was extended.
  604. */
  605. int tls_wifi_get_scan_rslt(u8* buf, u32 buffer_size);
  606. /***************************************************************************
  607. * Function: tls_wifi_get_scan_rslt_format2
  608. *
  609. * Description: get result of last scan for format2 result
  610. *
  611. * Input: buffer: address to store returned BSS info
  612. * buffer_size: the length of the buffer
  613. * Output: BSS info got by last scan
  614. *
  615. * Return: WM_SUCCESS: return ok;
  616. * WM_FAILED: failed to get result;
  617. * Note: user need to memalloc a buffer in advance. size for one item of scan result is @ref struct tls_bss_info_format2_t
  618. * the buffer size depends how many items user wants.
  619. * Date : 2022-6-07
  620. ****************************************************************************/
  621. int tls_wifi_get_scan_rslt_format2(u8* buf, u32 buffer_size);
  622. /**
  623. * @brief This function is used to create soft ap
  624. *
  625. * @param[in] apinfo softap Wi-Fi configuration
  626. * @param[in] ipinfo softap ip address
  627. *
  628. * @retval WM_WIFI_ERR_SSID SSID is NULL
  629. * @retval WM_WIFI_ERR_KEY key info not correct
  630. * @retval WM_SUCCESS soft ap create OK
  631. * @retval WM_WIFI_STA_BUSY station is connecting
  632. *
  633. * @note None
  634. */
  635. int tls_wifi_softap_create(struct tls_softap_info_t* apinfo, struct tls_ip_info_t* ipinfo);
  636. /**
  637. * @brief This function is used to destroy soft ap
  638. *
  639. * @param None
  640. *
  641. * @return None
  642. *
  643. * @note None
  644. */
  645. void tls_wifi_softap_destroy(void);
  646. /**
  647. * @brief This function is used to get soft ap's state
  648. *
  649. * @param None
  650. *
  651. * @return softap's state, @ref tls_wifi_states
  652. *
  653. * @note None
  654. */
  655. enum tls_wifi_states tls_wifi_softap_get_state(void);
  656. /** callback function of wifi client event */
  657. typedef void (*tls_wifi_client_event_callback)(u8 *mac, enum tls_wifi_client_event_type event);
  658. /**
  659. * @brief This function is used to register client event
  660. *
  661. * @param[in] client event callback
  662. *
  663. * @return None
  664. *
  665. * @note None
  666. */
  667. void tls_wifi_softap_client_event_register(tls_wifi_client_event_callback callback);
  668. /**
  669. * @brief This function is used to get the authed sta list
  670. *
  671. * @param[out] sta_num the authed's station number
  672. *
  673. * @param[out] buf address to store returned station list info(struct tls_sta_info_t[])
  674. *
  675. * @param[in] buf_size
  676. *
  677. * @return None
  678. *
  679. * @note None
  680. */
  681. void tls_wifi_get_authed_sta_info(u32 *sta_num, u8 *buf, u32 buf_size);
  682. /**
  683. * @brief This function is used to create or join ibss
  684. *
  685. * @param[in] *ibssinfo ibss Wi-Fi configuration
  686. * @param[in] *ipinfo ibss ip address
  687. *
  688. * @retval WM_SUCCESS IBSS join or create ok
  689. * @retval WM_WIFI_ERR_SSID SSID is NULL
  690. * @retval WM_WIFI_ERR_KEY key info not correct
  691. *
  692. * @note Join IBSS if existed
  693. * Create IBSS by SSID when not existed.
  694. */
  695. int tls_wifi_ibss_create(struct tls_ibss_info_t *ibssinfo, struct tls_ibssip_info_t *ipinfo);
  696. /**
  697. * @brief This function is used to destroy or leave Wi-Fi network
  698. *
  699. * @param None
  700. *
  701. * @return None
  702. *
  703. * @note For AP, destroy soft AP
  704. * For STA, leave the network by AP
  705. * For IBSS, destroy or leave the IBSS network.
  706. */
  707. void tls_wifi_disconnect(void);
  708. /* void *connectinfo (about 1024 bytes buf) */
  709. int tls_wifi_faslink_connect(void *connectinfo);
  710. /* void *connectinfo (about 1024 bytes buf) */
  711. int tls_wifi_get_fastlink_info(void *connectinfo);
  712. /**
  713. * @brief This function is used to connect AP
  714. *
  715. * @param[in] *ssid Network Name to connect
  716. * @param[in] ssid_len length of SSID
  717. * @param[in] *pwd password to connect AP
  718. * @param[in] pwd_len length of password
  719. *
  720. * @retval WM_SUCCESS config ok, wifi will start to connect AP;
  721. * @retval WM_FAILED parameter wrong
  722. *
  723. * @note User should register Wi-Fi status callback function
  724. * to get result;
  725. * wifi_status_change_cb just return WIFI MAC layer status;
  726. * User should register netif status callback
  727. * to get TCP/IP layer status;
  728. */
  729. int tls_wifi_connect(u8 *ssid, u8 ssid_len, u8 *pwd, u8 pwd_len);
  730. /**
  731. * @brief This function is used to connect AP by BSSID
  732. *
  733. * @param[in] *bssid BSSID to connect
  734. * @param[in] *pwd password to connect AP
  735. * @param[in] pwd_len length of password
  736. *
  737. * @retval WM_SUCCESS success
  738. * @retval WM_FAILED failed
  739. *
  740. * @note When SSID hided,this function can not be used.
  741. * User should register Wi-Fi status callback function
  742. * to get result;
  743. * wifi_status_change_cb just return WIFI MAC layer status;
  744. * User should register netif status callback
  745. * to get TCP/IP layer status;
  746. */
  747. int tls_wifi_connect_by_bssid(u8 *bssid, u8 *pwd, u8 pwd_len);
  748. /**
  749. * @brief This function is used to connect AP by SSID an BSSID
  750. *
  751. * @param[in] *ssid Network Name to connect
  752. * @param[in] ssid_len length of SSID
  753. * @param[in] *bssid BSSID to connect with SSID
  754. * @param[in] *pwd password to connect AP
  755. * @param[in] pwd_len length of password
  756. *
  757. * @retval WM_SUCCESS success
  758. * @retval WM_FAILED failed
  759. *
  760. * @note When SSID&BSSID is knonw, user can use this function
  761. * to connect Wi-Fi AP.
  762. * User should register Wi-Fi status callback function
  763. * to get result;
  764. * wifi_status_change_cb just return WIFI MAC layer status;
  765. * User should register netif status callback
  766. * to get TCP/IP layer status;
  767. */
  768. int tls_wifi_connect_by_ssid_bssid(u8 *ssid, u8 ssid_len, u8 *bssid, u8 *pwd, u8 pwd_len );
  769. /**
  770. * @brief Set auto connect mode: Enable/Disable.
  771. * Get auto connect mode parameter
  772. *
  773. * @param[in] opt WIFI_AUTO_CNT_FLAG_SET or WIFI_AUTO_CNT_FLAG_GET
  774. * @param[in] mode WIFI_AUTO_CNT_OFF WIFI_AUTO_CNT_ON
  775. * or WIFI_AUTO_CNT_TMP_OFF
  776. *
  777. * @retval WM_SUCCESS success
  778. * @retval WM_FAILED failed
  779. *
  780. * @note WIFI_AUTO_CNT_OFF Disable/d;
  781. * WIFI_AUTO_CNT_ON Enable/d;
  782. * WIFI_AUTO_CNT_TMP_OFF For user initiated "DISCONNECT",
  783. * such as AT CMD; In such case, user might expect
  784. * "disconnect witout reconnection, even in WIFI_AUTO_CNT_ON
  785. * status; WIFI_AUTO_CNT_TMP_OFF flag just be effective
  786. * for one time of "DISCONNECT";
  787. * After that or reboot, the FLAG will be set to the previous value;
  788. */
  789. int tls_wifi_auto_connect_flag(u8 opt, u8* mode);
  790. /**
  791. * @brief This function is used to register wifi status changed callback function
  792. *
  793. * @param[in] callback point to wifi status function
  794. *
  795. * @return None
  796. *
  797. * @note
  798. * WIFI_JOIN_SUCCESS connect with wifi AP correctly in Wifi layer;
  799. * No IP address
  800. * WIFI_JOIN_FAILED did not connect with wifi AP;
  801. * normally, timeout in 20s after start connection
  802. * WIFI_DISCONNECTED STA is disconnected with AP for any case,
  803. * such as wifi AP shut dow, Wi-Fi AP
  804. * changed password, and so on;
  805. */
  806. void tls_wifi_status_change_cb_register(void (*callback)(u8 status));
  807. /**
  808. * @brief This function is used to get AP's info
  809. *
  810. * @param[out] bss address where the network parameters will be write;
  811. *
  812. * @return None
  813. *
  814. * @note None
  815. */
  816. void tls_wifi_get_current_bss(struct tls_curr_bss_t* bss);
  817. /*********************************************************************************************************
  818. Wifi WPS API
  819. *********************************************************************************************************/
  820. #ifdef TLS_CONFIG_WPS
  821. /**
  822. * @brief This function generate random PIN code
  823. *
  824. * @param[out] pin buf to store pin code, WPS_PIN_LEN Bytes
  825. *
  826. * @retval WM_SUCCESS success
  827. * @retval other failed
  828. *
  829. * @note None
  830. */
  831. int tls_wps_get_pin(u8* pin);
  832. /**
  833. * @brief set PIN code into system
  834. *
  835. * @param[in] pin 8bytes string
  836. * @param[in] pin_len length of pin, should be 8 by current WPS spec
  837. *
  838. * @retval WM_SUCCESS success
  839. * @retval WM_FAILED failed
  840. *
  841. * @note normally, the @pin code will be hard coded during manufacturing. should not use this function;
  842. */
  843. int tls_wps_set_pin(u8* pin, u8 pin_len);
  844. /**
  845. * @brief Start WPS process via PIN mode
  846. *
  847. * @param None
  848. *
  849. * @retval WM_SUCCESS success
  850. * @retval WM_FAILED failed
  851. * @retval WM_WIFI_WPS_BUSY last WPS process is not finished;
  852. *
  853. * @note Normally, 120s for WPS protocol, but for us, 180s totally;
  854. * Adapter will use the PIN code in system for WPS process
  855. * and before that, the PIN code should be input
  856. * into AP/Registrar mannually
  857. */
  858. int tls_wps_start_pin(void);
  859. /**
  860. * @brief Start WPS process via PBC/PushButton mode
  861. *
  862. * @param None
  863. *
  864. * @retval WM_SUCCESS success
  865. * @retval WM_FAILED failed
  866. * @retval WM_WIFI_WPS_BUSY last WPS process is not finished;
  867. *
  868. * @note Normally, 120s for WPS protocol, but for us, 180s totally;
  869. * if OK, adaptor will start the WPS connection;
  870. * APP should register Wi-Fi/netif status callback to get result
  871. */
  872. int tls_wps_start_pbc(void);
  873. #endif
  874. /**
  875. * @brief This function is used to register ETHERNET data rx callback function
  876. *
  877. * @param[in] callback point to receive ETHERNET data function
  878. *
  879. * @return None
  880. *
  881. * @note None
  882. */
  883. void tls_ethernet_data_rx_callback(net_rx_data_cb callback);
  884. #if TLS_CONFIG_AP_OPT_FWD
  885. /**
  886. * @brief This function is used to forward IP data packets
  887. * by routing, only for APSTA mode.
  888. *
  889. * @param[in] callback point to receive ETHERNET data function
  890. *
  891. * @return None
  892. *
  893. * @note Only in APSTA mode, this function to deal with IP data
  894. */
  895. void tls_ethernet_ip_rx_callback(net_rx_data_cb callback);
  896. #endif
  897. /**
  898. * @brief This function is used to set powersave flag
  899. *
  900. * @param[in] enable non-zero: enable 0: disable
  901. * @param[in] alwaysflag 0: only once, lost when restart; !0: always
  902. *
  903. * @return None
  904. *
  905. * @note None
  906. */
  907. void tls_wifi_set_psflag(bool enable, bool alwaysflag);
  908. /**
  909. * @brief This function is used to get current powersave flag
  910. *
  911. * @param None
  912. *
  913. * @retval 0 power-saving disable
  914. * @retval non-zero power-saving enable
  915. *
  916. * @note None
  917. */
  918. u32 tls_wifi_get_psflag(void);
  919. /**
  920. * @brief This function is used to send oneshot data to other sta
  921. *
  922. * @param[in] *dst NULL , send broadcast info
  923. * !NULL, send unicast info
  924. * @param[in] *ssid SSID to be sent
  925. * @param[in] ssid_len SSID length to be sent
  926. *
  927. * @return None
  928. *
  929. * @note None
  930. */
  931. void tls_wifi_send_oneshotdata(u8 *dst, const u8 *ssid, u8 ssid_len);
  932. /**
  933. * @brief This function is used to get max gain by rate index
  934. *
  935. * @param[in] tx_rate rate index (enum)
  936. *
  937. * @retval Max Gain
  938. *
  939. * @note None
  940. */
  941. u8 tls_wifi_get_tx_gain_max(enum tls_wifi_tx_rate tx_rate);
  942. /**
  943. * @brief This function is used to send 802.11 management packet
  944. *
  945. * @param[in] type management packet type
  946. * @param[in] *mac mac address
  947. * @param[in] *ie information elements, if have no ie can fill NULL
  948. * @param[in] ie_len information elements length, it's zero if ie is NULL.
  949. * @param[in] *tx rate and gain to transfer
  950. *
  951. * @retval 0 success
  952. * @retval other failed
  953. *
  954. * @note None
  955. */
  956. int tls_wifi_send_mgmt(enum tls_wifi_mgmt_type type, struct tls_wifi_hdr_mac_t *mac, u8 *ie, u16 ie_len, struct tls_wifi_tx_rate_t *tx);
  957. /**
  958. * @brief This function is used to send an 802.11 frame
  959. *
  960. * @param[in] *mac mac address, it can be NULL
  961. * @param[in] *data data packet buffer
  962. * @param[in] data_len data packet length
  963. * @param[in] *tx rate and gain, it can be NULL
  964. *
  965. * @retval 0 success
  966. * @retval other failed
  967. *
  968. * @note If the @*mac is NULL, @*data should be an entire 802.11 frame.
  969. * If the @*mac is not NULL, this function will build an 802.11 frame
  970. * with @*mac as destination mac address and @*data as the data body.
  971. * If the @*tx is NULL, the packet will be sent at 11B 1Mbps.
  972. */
  973. int tls_wifi_send_data(struct tls_wifi_hdr_mac_t *mac, u8 *data, u16 data_len, struct tls_wifi_tx_rate_t *tx);
  974. /**
  975. * @brief This function is used to get current Wi-Fi State
  976. *
  977. * @param None
  978. *
  979. * @retval Wi-Fi State, @ref tls_wifi_states
  980. *
  981. * @note None
  982. */
  983. enum tls_wifi_states tls_wifi_get_state(void);
  984. /**
  985. * @brief This function is used to get current error number during joining AP
  986. *
  987. * @param None
  988. *
  989. * @retval Error Number(WM_WIFI_ENOERR,WM_WIFI_ENOAP,
  990. * WM_WIFI_EKEY,WM_WIFI_ELSI)
  991. *
  992. * @note None
  993. */
  994. int tls_wifi_get_errno(void);
  995. /**
  996. * @brief This function is used to print current error during joining AP
  997. *
  998. * @param[in] *info prefix information
  999. *
  1000. * @return None
  1001. *
  1002. * @note None
  1003. */
  1004. void tls_wifi_perror(const char *info);
  1005. /**
  1006. * @brief This function is used to get wifi error
  1007. *
  1008. * @param[in] eno error number(WM_WIFI_ENOERR,WM_WIFI_ENOAP,
  1009. * WM_WIFI_EKEY,WM_WIFI_ELSI)
  1010. *
  1011. * @retval error description
  1012. *
  1013. * @note None
  1014. */
  1015. const char *tls_wifi_get_errinfo(int eno);
  1016. /**
  1017. * @brief This function is used to customize wifi tx&rx memory
  1018. *
  1019. * @param[in] startmem: memory addr, only used from 0x20028000 to 0x20048000
  1020. *
  1021. * @param[in] txcnt: wifi tx buf cnt, non -zero value
  1022. *
  1023. * @param[in] rxcnt: wifi rx buf cnt, greater than 2 && lower than 30
  1024. *
  1025. * @retval 0 :successfullly
  1026. * <0:failure
  1027. *
  1028. * @note None
  1029. */
  1030. int tls_wifi_mem_cfg(u32 startmem, u8 txcnt, u8 rxcnt);
  1031. /**
  1032. * @brief This function is used to set max sta num
  1033. *
  1034. * @param[in] ap_sta_num: can be accepted num for sta
  1035. *
  1036. * @retval 0 :successfullly
  1037. * <0:failure if ap_sta_num is 0
  1038. *
  1039. * @note max sta num is 8, this function must be called before ap created.
  1040. */
  1041. int tls_wifi_softap_set_sta_num(unsigned char ap_sta_num);
  1042. /**
  1043. * @brief This function is used to deauth sta connected to softap
  1044. *
  1045. * @param[in] hwaddr: sta's mac to deauth
  1046. *
  1047. * @retval 0 :successfullly
  1048. * <0:failure if hwaddr is null
  1049. *
  1050. * @note None
  1051. */
  1052. int tls_wifi_softap_del_station(unsigned char* hwaddr);
  1053. /**
  1054. * @brief This function used to add sta to black list for softap
  1055. *
  1056. * @param[out] hwaddr: sta's mac address to forbid
  1057. *
  1058. * @return None
  1059. *
  1060. * @note None
  1061. */
  1062. int tls_wifi_softap_add_blacksta(unsigned char *hwaddr);
  1063. /**
  1064. * @brief This function used to accept sta joining softap that sta in balck list
  1065. *
  1066. * @param[out] hwaddr: mac address to delete from black list
  1067. *
  1068. * @return None
  1069. *
  1070. * @note None
  1071. */
  1072. int tls_wifi_softap_del_blacksta(unsigned char *hwaddr);
  1073. /**
  1074. * @brief This function used to get stations from blacklist
  1075. *
  1076. * @param[out] sta_num: station's number in blacklist
  1077. * @param[out] buf: store stations to get from blacklist
  1078. * @param[in] buf_size: memory size to store stations in blacklist
  1079. *
  1080. * @return None
  1081. *
  1082. * @note None
  1083. */
  1084. int tls_wifi_softap_get_blackinfo(u32 *sta_num, u8 *buf, u32 buf_size);
  1085. /**
  1086. * @brief This function is used to set some information display in the process of wifi networking
  1087. *
  1088. * @param[in] enable true: enable false: disable
  1089. *
  1090. * @return None
  1091. *
  1092. * @note None
  1093. */
  1094. void tls_wifi_enable_log(bool enable);
  1095. /**
  1096. * @brief This function is used to set temperature compensation flag
  1097. *
  1098. * @param[in] flag:0- close temperature compensation,non-zero-open temperature compensation
  1099. *
  1100. * @return None
  1101. *
  1102. * @note None
  1103. */
  1104. void tls_wifi_set_tempcomp_flag(int flag);
  1105. /**
  1106. * @brief This function is used to get temperature compensation flag
  1107. *
  1108. * @param[in] None
  1109. *
  1110. * @return flag: 0- no temperature compensation. non zero-temperature compensation valid
  1111. *
  1112. * @note None
  1113. */
  1114. u8 tls_wifi_get_tempcomp_flag(void);
  1115. /**
  1116. * @brief This function is used to get temperature compensation flag
  1117. *
  1118. * @param[in] fixrateindex: 11b:0-3, 11g:4-11, 11n-ht20:12-19, 11n-ht40:20-27
  1119. * @param[in] retrycnt: retry count, range[1,15]
  1120. *
  1121. * @return None
  1122. *
  1123. * @note When use this function, data to be transfered will use fix rate.
  1124. */
  1125. void tls_wifi_set_fixed_rate(u32 fixrateindex, u32 retrycnt);
  1126. /**
  1127. * @brief This function is used to set listen_interval (dummy interface)
  1128. *
  1129. * @param[in] listen_interval: >=1
  1130. *
  1131. * @return None
  1132. *
  1133. * @note this is dummy interface. this value can used only in sta mode.
  1134. */
  1135. int tls_wifi_cfg_listen_interval(u16 listen_interval);
  1136. /**
  1137. * @brief This function is used to set connect timeout
  1138. *
  1139. * @param[in] timeout: to connect ap's time, >=5s
  1140. *
  1141. * @return None
  1142. *
  1143. * @note valid only when scan AP failed.
  1144. */
  1145. int tls_wifi_cfg_connect_timeout(u16 timeout);
  1146. /**
  1147. * @brief This function is used to configure scan mode
  1148. *
  1149. * @param[in] mode:0-find max RSSI AP, 1-find AP and immediately stop scan to start join
  1150. *
  1151. * @return None
  1152. *
  1153. * @note only used in STA mode.
  1154. */
  1155. int tls_wifi_cfg_connect_scan_mode(u32 mode);
  1156. /**
  1157. * @brief This function is used to set pci flag
  1158. *
  1159. * @param[in] pci flag:0-can join any supported AP(open,wep,wpa,wpa2)
  1160. * 1-only join AP(WPA/WPA2 that supported)
  1161. *
  1162. * @return None
  1163. *
  1164. * @note none.
  1165. */
  1166. int tls_wifi_cfg_connect_pci(u32 pci_en);
  1167. /**
  1168. * @brief This function is used to set 11b's digital gain
  1169. *
  1170. * @param[in] value:gain value, <0x40
  1171. *
  1172. * @return 0:if value is valid,-1:if value is invalid
  1173. *
  1174. * @note none.
  1175. */
  1176. int tls_wifi_set_11b_digital_gain(u8 value);
  1177. /**
  1178. * @brief This function is used to get 11b's gain value
  1179. *
  1180. * @param[in] None
  1181. *
  1182. * @return gain value
  1183. *
  1184. * @note none.
  1185. */
  1186. u8 tls_wifi_get_11b_digital_gain(void);
  1187. /**
  1188. * @brief This function is used to set 11n's digital gain
  1189. *
  1190. * @param[in] value:gain value, <0x40
  1191. *
  1192. * @return 0:if value is valid,-1:if value is invalid
  1193. *
  1194. * @note none.
  1195. */
  1196. int tls_wifi_set_11n_digital_gain(u8 value);
  1197. /**
  1198. * @brief This function is used to get 11n's gain value
  1199. *
  1200. * @param[in] None
  1201. *
  1202. * @return gain value
  1203. *
  1204. * @note none.
  1205. */
  1206. u8 tls_wifi_get_11n_digital_gain(void);
  1207. /**
  1208. * @}
  1209. */
  1210. /**
  1211. * @}
  1212. */
  1213. int tls_wl_get_isr_count(void);
  1214. #endif /* TLS_WIFI_FUNC_H */