user_interface.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. /*
  2. * ESPRESSIF MIT License
  3. *
  4. * Copyright (c) 2016 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
  5. *
  6. * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
  7. * it is free of charge, to any person obtaining a copy of this software and associated
  8. * documentation files (the "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the Software is furnished
  11. * to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all copies or
  14. * substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. *
  23. */
  24. #ifndef __USER_INTERFACE_H__
  25. #define __USER_INTERFACE_H__
  26. #include "os_type.h"
  27. #ifdef LWIP_OPEN_SRC
  28. #include "lwip/ip_addr.h"
  29. #else
  30. #include "ip_addr.h"
  31. #endif
  32. #include "queue.h"
  33. #include "user_config.h"
  34. #include "spi_flash.h"
  35. #include "gpio.h"
  36. #ifndef MAC2STR
  37. #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
  38. #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
  39. #endif
  40. enum rst_reason {
  41. REASON_DEFAULT_RST = 0,
  42. REASON_WDT_RST = 1,
  43. REASON_EXCEPTION_RST = 2,
  44. REASON_SOFT_WDT_RST = 3,
  45. REASON_SOFT_RESTART = 4,
  46. REASON_DEEP_SLEEP_AWAKE = 5,
  47. REASON_EXT_SYS_RST = 6
  48. };
  49. struct rst_info{
  50. uint32 reason;
  51. uint32 exccause;
  52. uint32 epc1;
  53. uint32 epc2;
  54. uint32 epc3;
  55. uint32 excvaddr;
  56. uint32 depc;
  57. };
  58. struct rst_info* system_get_rst_info(void);
  59. #define UPGRADE_FW_BIN1 0x00
  60. #define UPGRADE_FW_BIN2 0x01
  61. void system_restore(void);
  62. void system_restart(void);
  63. bool system_deep_sleep_set_option(uint8 option);
  64. bool system_deep_sleep(uint64 time_in_us);
  65. bool system_deep_sleep_instant(uint64 time_in_us);
  66. uint8 system_upgrade_userbin_check(void);
  67. void system_upgrade_reboot(void);
  68. uint8 system_upgrade_flag_check();
  69. void system_upgrade_flag_set(uint8 flag);
  70. void system_timer_reinit(void);
  71. uint32 system_get_time(void);
  72. /* user task's prio must be 0/1/2 !!!*/
  73. enum {
  74. USER_TASK_PRIO_0 = 0,
  75. USER_TASK_PRIO_1,
  76. USER_TASK_PRIO_2,
  77. USER_TASK_PRIO_MAX
  78. };
  79. bool system_os_task(os_task_t task, uint8 prio, os_event_t *queue, uint8 qlen);
  80. bool system_os_post(uint8 prio, os_signal_t sig, os_param_t par);
  81. void system_print_meminfo(void);
  82. uint32 system_get_free_heap_size(void);
  83. void system_set_os_print(uint8 onoff);
  84. uint8 system_get_os_print();
  85. uint64 system_mktime(uint32 year, uint32 mon, uint32 day, uint32 hour, uint32 min, uint32 sec);
  86. uint32 system_get_chip_id(void);
  87. typedef void (* init_done_cb_t)(void);
  88. void system_init_done_cb(init_done_cb_t cb);
  89. uint32 system_rtc_clock_cali_proc(void);
  90. uint32 system_get_rtc_time(void);
  91. bool system_rtc_mem_read(uint8 src_addr, void *des_addr, uint16 load_size);
  92. bool system_rtc_mem_write(uint8 des_addr, const void *src_addr, uint16 save_size);
  93. void system_uart_swap(void);
  94. void system_uart_de_swap(void);
  95. uint16 system_adc_read(void);
  96. void system_adc_read_fast(uint16 *adc_addr, uint16 adc_num, uint8 adc_clk_div);
  97. uint16 system_get_vdd33(void);
  98. const char *system_get_sdk_version(void);
  99. #define SYS_BOOT_ENHANCE_MODE 0
  100. #define SYS_BOOT_NORMAL_MODE 1
  101. #define SYS_BOOT_NORMAL_BIN 0
  102. #define SYS_BOOT_TEST_BIN 1
  103. uint8 system_get_boot_version(void);
  104. uint32 system_get_userbin_addr(void);
  105. uint8 system_get_boot_mode(void);
  106. bool system_restart_enhance(uint8 bin_type, uint32 bin_addr);
  107. #define SYS_CPU_80MHZ 80
  108. #define SYS_CPU_160MHZ 160
  109. bool system_update_cpu_freq(uint8 freq);
  110. uint8 system_get_cpu_freq(void);
  111. enum flash_size_map {
  112. FLASH_SIZE_4M_MAP_256_256 = 0, /**< Flash size : 4Mbits. Map : 256KBytes + 256KBytes */
  113. FLASH_SIZE_2M, /**< Flash size : 2Mbits. Map : 256KBytes */
  114. FLASH_SIZE_8M_MAP_512_512, /**< Flash size : 8Mbits. Map : 512KBytes + 512KBytes */
  115. FLASH_SIZE_16M_MAP_512_512, /**< Flash size : 16Mbits. Map : 512KBytes + 512KBytes */
  116. FLASH_SIZE_32M_MAP_512_512, /**< Flash size : 32Mbits. Map : 512KBytes + 512KBytes */
  117. FLASH_SIZE_16M_MAP_1024_1024, /**< Flash size : 16Mbits. Map : 1024KBytes + 1024KBytes */
  118. FLASH_SIZE_32M_MAP_1024_1024, /**< Flash size : 32Mbits. Map : 1024KBytes + 1024KBytes */
  119. FLASH_SIZE_32M_MAP_2048_2048, /**< attention: don't support now ,just compatible for nodemcu;
  120. Flash size : 32Mbits. Map : 2048KBytes + 2048KBytes */
  121. FLASH_SIZE_64M_MAP_1024_1024, /**< Flash size : 64Mbits. Map : 1024KBytes + 1024KBytes */
  122. FLASH_SIZE_128M_MAP_1024_1024 /**< Flash size : 128Mbits. Map : 1024KBytes + 1024KBytes */
  123. };
  124. enum flash_size_map system_get_flash_size_map(void);
  125. void system_phy_set_max_tpw(uint8 max_tpw);
  126. void system_phy_set_tpw_via_vdd33(uint16 vdd33);
  127. void system_phy_set_rfoption(uint8 option);
  128. void system_phy_set_powerup_option(uint8 option);
  129. void system_phy_freq_trace_enable(bool enable);
  130. bool system_param_save_with_protect(uint16 start_sec, void *param, uint16 len);
  131. bool system_param_load(uint16 start_sec, uint16 offset, void *param, uint16 len);
  132. void system_soft_wdt_stop(void);
  133. void system_soft_wdt_restart(void);
  134. void system_soft_wdt_feed(void);
  135. void system_show_malloc(void);
  136. #define NULL_MODE 0x00
  137. #define STATION_MODE 0x01
  138. #define SOFTAP_MODE 0x02
  139. #define STATIONAP_MODE 0x03
  140. typedef enum _auth_mode {
  141. AUTH_OPEN = 0,
  142. AUTH_WEP,
  143. AUTH_WPA_PSK,
  144. AUTH_WPA2_PSK,
  145. AUTH_WPA_WPA2_PSK,
  146. AUTH_MAX
  147. } AUTH_MODE;
  148. uint8 wifi_get_opmode(void);
  149. uint8 wifi_get_opmode_default(void);
  150. bool wifi_set_opmode(uint8 opmode);
  151. bool wifi_set_opmode_current(uint8 opmode);
  152. uint8 wifi_get_broadcast_if(void);
  153. bool wifi_set_broadcast_if(uint8 interface);
  154. struct bss_info {
  155. STAILQ_ENTRY(bss_info) next;
  156. uint8 bssid[6];
  157. uint8 ssid[32];
  158. uint8 ssid_len;
  159. uint8 channel;
  160. sint8 rssi;
  161. AUTH_MODE authmode;
  162. uint8 is_hidden;
  163. sint16 freq_offset;
  164. sint16 freqcal_val;
  165. uint8 *esp_mesh_ie;
  166. uint8 simple_pair;
  167. };
  168. typedef struct _scaninfo {
  169. STAILQ_HEAD(, bss_info) *pbss;
  170. struct espconn *pespconn;
  171. uint8 totalpage;
  172. uint8 pagenum;
  173. uint8 page_sn;
  174. uint8 data_cnt;
  175. } scaninfo;
  176. typedef void (* scan_done_cb_t)(void *arg, STATUS status);
  177. struct station_config {
  178. uint8 ssid[32];
  179. uint8 password[64];
  180. uint8 bssid_set; // Note: If bssid_set is 1, station will just connect to the router
  181. // with both ssid[] and bssid[] matched. Please check about this.
  182. uint8 bssid[6];
  183. };
  184. bool wifi_station_get_config(struct station_config *config);
  185. bool wifi_station_get_config_default(struct station_config *config);
  186. bool wifi_station_set_config(struct station_config *config);
  187. bool wifi_station_set_config_current(struct station_config *config);
  188. bool wifi_station_connect(void);
  189. bool wifi_station_disconnect(void);
  190. sint8 wifi_station_get_rssi(void);
  191. struct scan_config {
  192. uint8 *ssid; // Note: ssid == NULL, don't filter ssid.
  193. uint8 *bssid; // Note: bssid == NULL, don't filter bssid.
  194. uint8 channel; // Note: channel == 0, scan all channels, otherwise scan set channel.
  195. uint8 show_hidden; // Note: show_hidden == 1, can get hidden ssid routers' info.
  196. };
  197. bool wifi_station_scan(struct scan_config *config, scan_done_cb_t cb);
  198. uint8 wifi_station_get_auto_connect(void);
  199. bool wifi_station_set_auto_connect(uint8 set);
  200. bool wifi_station_set_reconnect_policy(bool set);
  201. enum {
  202. STATION_IDLE = 0,
  203. STATION_CONNECTING,
  204. STATION_WRONG_PASSWORD,
  205. STATION_NO_AP_FOUND,
  206. STATION_CONNECT_FAIL,
  207. STATION_GOT_IP
  208. };
  209. enum dhcp_status {
  210. DHCP_STOPPED,
  211. DHCP_STARTED
  212. };
  213. uint8 wifi_station_get_connect_status(void);
  214. uint8 wifi_station_get_current_ap_id(void);
  215. bool wifi_station_ap_change(uint8 current_ap_id);
  216. bool wifi_station_ap_number_set(uint8 ap_number);
  217. uint8 wifi_station_get_ap_info(struct station_config config[]);
  218. bool wifi_station_dhcpc_start(void);
  219. bool wifi_station_dhcpc_stop(void);
  220. enum dhcp_status wifi_station_dhcpc_status(void);
  221. bool wifi_station_dhcpc_set_maxtry(uint8 num);
  222. char* wifi_station_get_hostname(void);
  223. bool wifi_station_set_hostname(char *name);
  224. int wifi_station_set_cert_key(uint8 *client_cert, int client_cert_len,
  225. uint8 *private_key, int private_key_len,
  226. uint8 *private_key_passwd, int private_key_passwd_len);
  227. void wifi_station_clear_cert_key(void);
  228. int wifi_station_set_username(uint8 *username, int len);
  229. void wifi_station_clear_username(void);
  230. struct softap_config {
  231. uint8 ssid[32];
  232. uint8 password[64];
  233. uint8 ssid_len; // Note: Recommend to set it according to your ssid
  234. uint8 channel; // Note: support 1 ~ 13
  235. AUTH_MODE authmode; // Note: Don't support AUTH_WEP in softAP mode.
  236. uint8 ssid_hidden; // Note: default 0
  237. uint8 max_connection; // Note: default 4, max 4
  238. uint16 beacon_interval; // Note: support 100 ~ 60000 ms, default 100
  239. };
  240. bool wifi_softap_get_config(struct softap_config *config);
  241. bool wifi_softap_get_config_default(struct softap_config *config);
  242. bool wifi_softap_set_config(struct softap_config *config);
  243. bool wifi_softap_set_config_current(struct softap_config *config);
  244. struct station_info {
  245. STAILQ_ENTRY(station_info) next;
  246. uint8 bssid[6];
  247. struct ip_addr ip;
  248. };
  249. struct dhcps_lease {
  250. bool enable;
  251. struct ip_addr start_ip;
  252. struct ip_addr end_ip;
  253. };
  254. enum dhcps_offer_option{
  255. OFFER_START = 0x00,
  256. OFFER_ROUTER = 0x01,
  257. OFFER_END
  258. };
  259. uint8 wifi_softap_get_station_num(void);
  260. struct station_info * wifi_softap_get_station_info(void);
  261. void wifi_softap_free_station_info(void);
  262. bool wifi_softap_dhcps_start(void);
  263. bool wifi_softap_dhcps_stop(void);
  264. bool wifi_softap_set_dhcps_lease(struct dhcps_lease *please);
  265. bool wifi_softap_get_dhcps_lease(struct dhcps_lease *please);
  266. uint32 wifi_softap_get_dhcps_lease_time(void);
  267. bool wifi_softap_set_dhcps_lease_time(uint32 minute);
  268. bool wifi_softap_reset_dhcps_lease_time(void);
  269. enum dhcp_status wifi_softap_dhcps_status(void);
  270. bool wifi_softap_set_dhcps_offer_option(uint8 level, void* optarg);
  271. #define STATION_IF 0x00
  272. #define SOFTAP_IF 0x01
  273. bool wifi_get_ip_info(uint8 if_index, struct ip_info *info);
  274. bool wifi_set_ip_info(uint8 if_index, struct ip_info *info);
  275. bool wifi_get_macaddr(uint8 if_index, uint8 *macaddr);
  276. bool wifi_set_macaddr(uint8 if_index, uint8 *macaddr);
  277. uint8 wifi_get_channel(void);
  278. bool wifi_set_channel(uint8 channel);
  279. void wifi_status_led_install(uint8 gpio_id, uint32 gpio_name, uint8 gpio_func);
  280. void wifi_status_led_uninstall();
  281. /** Get the absolute difference between 2 u32_t values (correcting overflows)
  282. * 'a' is expected to be 'higher' (without overflow) than 'b'. */
  283. #define ESP_U32_DIFF(a, b) (((a) >= (b)) ? ((a) - (b)) : (((a) + ((b) ^ 0xFFFFFFFF) + 1)))
  284. void wifi_promiscuous_enable(uint8 promiscuous);
  285. typedef void (* wifi_promiscuous_cb_t)(uint8 *buf, uint16 len);
  286. void wifi_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb);
  287. void wifi_promiscuous_set_mac(const uint8_t *address);
  288. enum phy_mode {
  289. PHY_MODE_11B = 1,
  290. PHY_MODE_11G = 2,
  291. PHY_MODE_11N = 3
  292. };
  293. enum phy_mode wifi_get_phy_mode(void);
  294. bool wifi_set_phy_mode(enum phy_mode mode);
  295. enum sleep_type {
  296. NONE_SLEEP_T = 0,
  297. LIGHT_SLEEP_T,
  298. MODEM_SLEEP_T
  299. };
  300. bool wifi_set_sleep_type(enum sleep_type type);
  301. enum sleep_type wifi_get_sleep_type(void);
  302. void wifi_fpm_open(void);
  303. void wifi_fpm_close(void);
  304. void wifi_fpm_do_wakeup(void);
  305. sint8 wifi_fpm_do_sleep(uint32 sleep_time_in_us);
  306. void wifi_fpm_set_sleep_type(enum sleep_type type);
  307. enum sleep_type wifi_fpm_get_sleep_type(void);
  308. typedef void (*fpm_wakeup_cb)(void);
  309. void wifi_fpm_set_wakeup_cb(fpm_wakeup_cb cb);
  310. void wifi_fpm_auto_sleep_set_in_null_mode(uint8 req);
  311. enum {
  312. EVENT_STAMODE_CONNECTED = 0,
  313. EVENT_STAMODE_DISCONNECTED,
  314. EVENT_STAMODE_AUTHMODE_CHANGE,
  315. EVENT_STAMODE_GOT_IP,
  316. EVENT_STAMODE_DHCP_TIMEOUT,
  317. EVENT_SOFTAPMODE_STACONNECTED,
  318. EVENT_SOFTAPMODE_STADISCONNECTED,
  319. EVENT_SOFTAPMODE_PROBEREQRECVED,
  320. EVENT_OPMODE_CHANGED,
  321. EVENT_MAX
  322. };
  323. enum {
  324. REASON_UNSPECIFIED = 1,
  325. REASON_AUTH_EXPIRE = 2,
  326. REASON_AUTH_LEAVE = 3,
  327. REASON_ASSOC_EXPIRE = 4,
  328. REASON_ASSOC_TOOMANY = 5,
  329. REASON_NOT_AUTHED = 6,
  330. REASON_NOT_ASSOCED = 7,
  331. REASON_ASSOC_LEAVE = 8,
  332. REASON_ASSOC_NOT_AUTHED = 9,
  333. REASON_DISASSOC_PWRCAP_BAD = 10, /* 11h */
  334. REASON_DISASSOC_SUPCHAN_BAD = 11, /* 11h */
  335. REASON_IE_INVALID = 13, /* 11i */
  336. REASON_MIC_FAILURE = 14, /* 11i */
  337. REASON_4WAY_HANDSHAKE_TIMEOUT = 15, /* 11i */
  338. REASON_GROUP_KEY_UPDATE_TIMEOUT = 16, /* 11i */
  339. REASON_IE_IN_4WAY_DIFFERS = 17, /* 11i */
  340. REASON_GROUP_CIPHER_INVALID = 18, /* 11i */
  341. REASON_PAIRWISE_CIPHER_INVALID = 19, /* 11i */
  342. REASON_AKMP_INVALID = 20, /* 11i */
  343. REASON_UNSUPP_RSN_IE_VERSION = 21, /* 11i */
  344. REASON_INVALID_RSN_IE_CAP = 22, /* 11i */
  345. REASON_802_1X_AUTH_FAILED = 23, /* 11i */
  346. REASON_CIPHER_SUITE_REJECTED = 24, /* 11i */
  347. REASON_BEACON_TIMEOUT = 200,
  348. REASON_NO_AP_FOUND = 201,
  349. REASON_AUTH_FAIL = 202,
  350. REASON_ASSOC_FAIL = 203,
  351. REASON_HANDSHAKE_TIMEOUT = 204,
  352. };
  353. typedef struct {
  354. uint8 ssid[32];
  355. uint8 ssid_len;
  356. uint8 bssid[6];
  357. uint8 channel;
  358. } Event_StaMode_Connected_t;
  359. typedef struct {
  360. uint8 ssid[32];
  361. uint8 ssid_len;
  362. uint8 bssid[6];
  363. uint8 reason;
  364. } Event_StaMode_Disconnected_t;
  365. typedef struct {
  366. uint8 old_mode;
  367. uint8 new_mode;
  368. } Event_StaMode_AuthMode_Change_t;
  369. typedef struct {
  370. struct ip_addr ip;
  371. struct ip_addr mask;
  372. struct ip_addr gw;
  373. } Event_StaMode_Got_IP_t;
  374. typedef struct {
  375. uint8 mac[6];
  376. uint8 aid;
  377. } Event_SoftAPMode_StaConnected_t;
  378. typedef struct {
  379. uint8 mac[6];
  380. uint8 aid;
  381. } Event_SoftAPMode_StaDisconnected_t;
  382. typedef struct {
  383. int rssi;
  384. uint8 mac[6];
  385. } Event_SoftAPMode_ProbeReqRecved_t;
  386. typedef struct {
  387. uint8 old_opmode;
  388. uint8 new_opmode;
  389. } Event_OpMode_Change_t;
  390. typedef union {
  391. Event_StaMode_Connected_t connected;
  392. Event_StaMode_Disconnected_t disconnected;
  393. Event_StaMode_AuthMode_Change_t auth_change;
  394. Event_StaMode_Got_IP_t got_ip;
  395. Event_SoftAPMode_StaConnected_t sta_connected;
  396. Event_SoftAPMode_StaDisconnected_t sta_disconnected;
  397. Event_SoftAPMode_ProbeReqRecved_t ap_probereqrecved;
  398. Event_OpMode_Change_t opmode_changed;
  399. } Event_Info_u;
  400. typedef struct _esp_event {
  401. uint32 event;
  402. Event_Info_u event_info;
  403. } System_Event_t;
  404. typedef void (* wifi_event_handler_cb_t)(System_Event_t *event);
  405. void wifi_set_event_handler_cb(wifi_event_handler_cb_t cb);
  406. typedef enum wps_type {
  407. WPS_TYPE_DISABLE = 0,
  408. WPS_TYPE_PBC,
  409. WPS_TYPE_PIN,
  410. WPS_TYPE_DISPLAY,
  411. WPS_TYPE_MAX,
  412. } WPS_TYPE_t;
  413. enum wps_cb_status {
  414. WPS_CB_ST_SUCCESS = 0,
  415. WPS_CB_ST_FAILED,
  416. WPS_CB_ST_TIMEOUT,
  417. WPS_CB_ST_WEP,
  418. };
  419. bool wifi_wps_enable(WPS_TYPE_t wps_type);
  420. bool wifi_wps_disable(void);
  421. bool wifi_wps_start(void);
  422. typedef void (*wps_st_cb_t)(int status);
  423. bool wifi_set_wps_cb(wps_st_cb_t cb);
  424. typedef void (*freedom_outside_cb_t)(uint8 status);
  425. int wifi_register_send_pkt_freedom_cb(freedom_outside_cb_t cb);
  426. void wifi_unregister_send_pkt_freedom_cb(void);
  427. int wifi_send_pkt_freedom(uint8 *buf, int len, bool sys_seq);
  428. int wifi_rfid_locp_recv_open(void);
  429. void wifi_rfid_locp_recv_close(void);
  430. typedef void (*rfid_locp_cb_t)(uint8 *frm, int len, int rssi);
  431. int wifi_register_rfid_locp_recv_cb(rfid_locp_cb_t cb);
  432. void wifi_unregister_rfid_locp_recv_cb(void);
  433. enum FIXED_RATE {
  434. PHY_RATE_48 = 0x8,
  435. PHY_RATE_24 = 0x9,
  436. PHY_RATE_12 = 0xA,
  437. PHY_RATE_6 = 0xB,
  438. PHY_RATE_54 = 0xC,
  439. PHY_RATE_36 = 0xD,
  440. PHY_RATE_18 = 0xE,
  441. PHY_RATE_9 = 0xF,
  442. };
  443. #define FIXED_RATE_MASK_NONE 0x00
  444. #define FIXED_RATE_MASK_STA 0x01
  445. #define FIXED_RATE_MASK_AP 0x02
  446. #define FIXED_RATE_MASK_ALL 0x03
  447. int wifi_set_user_fixed_rate(uint8 enable_mask, uint8 rate);
  448. int wifi_get_user_fixed_rate(uint8 *enable_mask, uint8 *rate);
  449. enum support_rate {
  450. RATE_11B5M = 0,
  451. RATE_11B11M = 1,
  452. RATE_11B1M = 2,
  453. RATE_11B2M = 3,
  454. RATE_11G6M = 4,
  455. RATE_11G12M = 5,
  456. RATE_11G24M = 6,
  457. RATE_11G48M = 7,
  458. RATE_11G54M = 8,
  459. RATE_11G9M = 9,
  460. RATE_11G18M = 10,
  461. RATE_11G36M = 11,
  462. };
  463. int wifi_set_user_sup_rate(uint8 min, uint8 max);
  464. enum RATE_11B_ID {
  465. RATE_11B_B11M = 0,
  466. RATE_11B_B5M = 1,
  467. RATE_11B_B2M = 2,
  468. RATE_11B_B1M = 3,
  469. };
  470. enum RATE_11G_ID {
  471. RATE_11G_G54M = 0,
  472. RATE_11G_G48M = 1,
  473. RATE_11G_G36M = 2,
  474. RATE_11G_G24M = 3,
  475. RATE_11G_G18M = 4,
  476. RATE_11G_G12M = 5,
  477. RATE_11G_G9M = 6,
  478. RATE_11G_G6M = 7,
  479. RATE_11G_B5M = 8,
  480. RATE_11G_B2M = 9,
  481. RATE_11G_B1M = 10
  482. };
  483. enum RATE_11N_ID {
  484. RATE_11N_MCS7S = 0,
  485. RATE_11N_MCS7 = 1,
  486. RATE_11N_MCS6 = 2,
  487. RATE_11N_MCS5 = 3,
  488. RATE_11N_MCS4 = 4,
  489. RATE_11N_MCS3 = 5,
  490. RATE_11N_MCS2 = 6,
  491. RATE_11N_MCS1 = 7,
  492. RATE_11N_MCS0 = 8,
  493. RATE_11N_B5M = 9,
  494. RATE_11N_B2M = 10,
  495. RATE_11N_B1M = 11
  496. };
  497. #define RC_LIMIT_11B 0
  498. #define RC_LIMIT_11G 1
  499. #define RC_LIMIT_11N 2
  500. #define RC_LIMIT_P2P_11G 3
  501. #define RC_LIMIT_P2P_11N 4
  502. #define RC_LIMIT_NUM 5
  503. #define LIMIT_RATE_MASK_NONE 0x00
  504. #define LIMIT_RATE_MASK_STA 0x01
  505. #define LIMIT_RATE_MASK_AP 0x02
  506. #define LIMIT_RATE_MASK_ALL 0x03
  507. bool wifi_set_user_rate_limit(uint8 mode, uint8 ifidx, uint8 max, uint8 min);
  508. uint8 wifi_get_user_limit_rate_mask(void);
  509. bool wifi_set_user_limit_rate_mask(uint8 enable_mask);
  510. enum {
  511. USER_IE_BEACON = 0,
  512. USER_IE_PROBE_REQ,
  513. USER_IE_PROBE_RESP,
  514. USER_IE_ASSOC_REQ,
  515. USER_IE_ASSOC_RESP,
  516. USER_IE_MAX
  517. };
  518. typedef void (*user_ie_manufacturer_recv_cb_t)(uint8 type, const uint8 sa[6], const uint8 m_oui[3], uint8 *ie, uint8 ie_len, int rssi);
  519. bool wifi_set_user_ie(bool enable, uint8 *m_oui, uint8 type, uint8 *user_ie, uint8 len);
  520. int wifi_register_user_ie_manufacturer_recv_cb(user_ie_manufacturer_recv_cb_t cb);
  521. void wifi_unregister_user_ie_manufacturer_recv_cb(void);
  522. void wifi_enable_gpio_wakeup(uint32 i, GPIO_INT_TYPE intr_status);
  523. void wifi_disable_gpio_wakeup(void);
  524. void uart_div_modify(uint8 uart_no, uint32 DivLatchValue);
  525. #endif