1 /*
2  * Copyright (C) 2019-2020 Alibaba Group Holding Limited
3  */
4 
5 #ifndef HAL_WIFI_H
6 #define HAL_WIFI_H
7 //#include <drivers/u_ld.h>
8 #include <vfsdev/wifi_dev.h>
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 typedef struct {
14     /* system info */
15     /* type, eg: rtos, linux */
16     const char *os;
17     /* type, eg: solo, sub, gw */
18     const char *type;
19     /* partner name, eg: tmall_genie */
20     const char *partner;
21     /* app protocol, eg: http, lwm2m */
22     const char *app_net;
23     /* project name, eg: tmall_genie*/
24     const char *project;
25     /* cloud name, eg: aliyun or others */
26     const char *cloud;
27 } wifi_driver_info_t;
28 
29 //27个HAL接口
30 typedef struct wifi_driver {
31     wifi_driver_info_t base;
32 
33     /** common APIs */
34     int (*init)(netdev_t *dev);
35     int (*deinit)(netdev_t *dev);
36     int (*set_mode)(netdev_t *dev, wifi_mode_t mode);
37     int (*get_mode)(netdev_t *dev, wifi_mode_t *devode);
38     int (*install_event_cb)(netdev_t *dev, wifi_event_func *evt_cb);
39     int (*cancel_connect)(netdev_t *dev);
40 
41     /** conf APIs */
42     int (*set_mac_addr)(netdev_t *dev, const uint8_t *devac);
43     int (*get_mac_addr)(netdev_t *dev, uint8_t *devac);
44     int (*set_lpm)(netdev_t *dev, wifi_lpm_mode_t mode); //ps on/pff
45     int (*get_lpm)(netdev_t *dev, wifi_lpm_mode_t *mode);
46 
47     int (*notify_ip_state2drv)(netdev_t *dev, wifi_ip_stat_t *out_net_para, wifi_mode_t wifi_type);
48 
49     /** connection APIs */
50     int (*start_scan)(netdev_t *dev, wifi_scan_config_t *config, bool block);
51     int (*connect)(netdev_t *dev, wifi_config_t * config); //start ap or sta
52     int (*disconnect)(netdev_t *dev);//stop ap or sta
53     int (*sta_get_link_status)(netdev_t *dev, wifi_ap_record_t *ap_info);
54     int (*ap_get_sta_list)(netdev_t *dev, wifi_sta_list_t *sta);
55 
56 
57     /** promiscuous APIs */
58     int (*start_monitor)(netdev_t *dev, wifi_promiscuous_cb_t cb);
59     int (*stop_monitor)(netdev_t *dev);
60     int (*send_80211_raw_frame)(netdev_t *dev, void *buffer, uint16_t len);
61     int (*set_channel)(netdev_t *dev, int channel);
62     int (*get_channel)(netdev_t *dev, int *channel);
63     int (*start_specified_scan)(netdev_t *dev, ap_list_t *ap_list, int ap_num);
64     int (*register_monitor_cb)(netdev_t *dev, monitor_data_cb_t fn);
65     int (*start_mgnt_monitor)(netdev_t *dev);
66     int (*stop_mgnt_monitor)(netdev_t *dev);
67     int (*register_mgnt_monitor_cb)(netdev_t *dev, monitor_data_cb_t fn);
68 
69     /* esp8266 related API */
70     int (*set_smartcfg)(netdev_t *dev, int enable);
71 
72      /* channellist for wifi scan related API */
73     int (*set_channellist)(netdev_t *dev, wifi_channel_list_t *channellist);
74     int (*get_channellist)(netdev_t *dev, wifi_channel_list_t *channellist);
75 } wifi_driver_t;
76 
77 int vfs_wifi_dev_register(wifi_driver_t *ops, int id);
78 
79 #ifdef __cplusplus
80 }
81 #endif
82 
83 #endif
84 
85 
86