• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef BWIFI_EVENT_H
16 #define BWIFI_EVENT_H
17 #ifdef  __cplusplus
18 extern "C"
19 {
20 #endif
21 
22 typedef struct {
23     int ap_num;                     /**< number of scanning APs */
24     //struct dl_list *ap_list;      /**< list of APs found */
25 } BWIFI_EVENT_STAMODE_SCANDONE_T;
26 
27 typedef enum {
28     INTER_STATE_AUTHENTICATING,     /* Authentication start */
29     INTER_STATE_AUTH_REJECT,        /* Authentication rejected by AP */
30     INTER_STATE_AUTH_TIMEOUT,       /* Authentication timeout */
31     INTER_STATE_ASSOCIATING,        /* Association start */
32     INTER_STATE_ASSOC_REJECT,       /* Association request rejected by AP */
33     INTER_STATE_ASSOC_TIMEOUT,      /* Association timeout */
34     INTER_STATE_ASSOCIATED,         /* Associated to target AP */
35     INTER_STATE_4WAY_HANDSHAKE,     /* 4way-handshake start */
36     INTER_STATE_HANDSHAKE_FAIL,     /* 4way-handshake fail */
37     INTER_STATE_GROUP_HANDSHAKE,    /* Group handshake start */
38     /* CONNECTED */
39 } BWIFI_CONNECT_INTER_STATE;
40 
41 typedef struct {
42     uint8_t ssid[32];                    /**< SSID of the connecting AP */
43     uint8_t ssid_len;                    /**< SSID length of the connecting AP */
44     uint8_t bssid[6];                    /**< BSSID of the connecting AP */
45     BWIFI_CONNECT_INTER_STATE state;/**< intermediate state during connection */
46 } BWIFI_EVENT_STAMODE_CONNECTING_T;
47 
48 typedef struct {
49     uint8_t ssid[32];                    /**< SSID of connected AP */
50     uint8_t ssid_len;                    /**< SSID length of connected AP */
51     uint8_t bssid[6];                    /**< BSSID of connected AP */
52     uint8_t channel;                     /**< channel of connected AP */
53 } BWIFI_EVENT_STAMODE_CONNECTED_T;
54 
55 typedef struct {
56     uint8_t ssid[32];                    /**< SSID of disconnected AP */
57     uint8_t ssid_len;                    /**< SSID length of disconnected AP */
58     uint8_t bssid[6];                    /**< BSSID of disconnected AP */
59     uint16_t reason;                     /**< reason of disconnection */
60 } BWIFI_EVENT_STAMODE_DISCONNECTED_T;
61 
62 typedef struct {
63     uint8_t old_mode;                    /**< the old auth mode of AP */
64     uint8_t new_mode;                    /**< the new auth mode of AP */
65 } BWIFI_EVENT_STAMODE_AUTHMODE_CHANGE_T;
66 
67 typedef struct {
68     uint32_t ip;                   /**< IP address that station got from connected AP */
69     uint32_t mask;                 /**< netmask that station got from connected AP */
70     uint32_t gw;                   /**< gateway that station got from connected AP */
71 } BWIFI_EVENT_STAMODE_GOT_IP_T;
72 
73 typedef struct {
74     uint8_t ssid[32];                    /**< SSID of connected AP */
75     uint8_t ssid_len;                    /**< SSID length of connected AP */
76     uint8_t bssid[6];                    /**< BSSID of connected AP */
77     uint8_t channel;                     /**< channel of connected AP */
78 } BWIFI_EVENT_STAMODE_ROAM_COMPLETE_T;
79 
80 typedef struct {
81     uint32_t pac_rxc_rx_buf_in_ptr;
82     uint32_t pac_rxc_rx_buf_out_ptr;
83     uint32_t scheduler_events;
84     uint32_t lmac_pc0;
85     uint32_t lmac_pc1;
86     uint32_t lmac_lr;
87     uint32_t lmac_sp;
88     uint32_t pac_ntd_status_peek;
89     uint32_t pac_txc_status;
90     uint32_t QUEUE_0_CONTROL;
91     uint32_t QUEUE_1_CONTROL;
92     uint32_t QUEUE_2_CONTROL;
93     uint32_t QUEUE_3_CONTROL;
94     uint32_t wlan_sw_override_1;
95     uint32_t tsq_in_prog;
96     uint32_t tsq_in_cmpl;
97 } BWIFI_LMAC_STATUS_DUMP_T;
98 
99 typedef struct {
100     uint8_t rst_flag;                         /**< reset flag to indicate status:
101                                               0 - no reset; 1 - reset start; 2 - reset end.*/
102     uint16_t error_cause;                     /**< error cause (bitmask) */
103     BWIFI_LMAC_STATUS_DUMP_T dump_info;  /**< LMAC status dump on fatal error */
104 } BWIFI_FATAL_ERROR_RESET_T;
105 
106 typedef struct {
107     uint16_t error_cause;                     /**< error cause (bitmask) */
108     BWIFI_LMAC_STATUS_DUMP_T dump_info;  /**< LMAC status dump on fatal error */
109 } BWIFI_EVENT_LMAC_FATAL_ERROR_T;
110 
111 typedef struct {
112     uint8_t mac[6];                           /**< MAC address of the station connected or disconnected */
113     uint16_t reason;                          /**< reason of disconnection */
114 } BWIFI_AP_STA_INFO_T;
115 
116 typedef struct {
117     uint8_t mac[6];                           /**< MAC address of the station connected to soft-AP */
118 //    uint8_t aid;                            /**< the aid that soft-AP gives to the station connected to */
119 } BWIFI_EVENT_SAPMODE_STA_CONNECTED_T;
120 
121 typedef struct {
122     uint8_t mac[6];                           /**< MAC address of the station disconnects to soft-AP */
123     uint16_t reason;                          /**< reason of disconnection */
124 } BWIFI_EVENT_SAPMODE_STA_DISCONNECTED_T;
125 
126 //typedef struct {
127 //    int rssi;		/**< Received probe request signal strength */
128 //    uint8_t mac[6];		/**< MAC address of the station which send probe request */
129 //} BWIFI_EVENT_SAPMODE_PROBEREQRECVED_T;
130 
131 typedef struct {
132     uint8_t mode;                           /**< wifi/bt coex mode, 0: tdd, 1: fdd */
133 } BWIFI_EVENT_COEX_MODE_T;
134 
135 typedef union {
136     BWIFI_EVENT_STAMODE_SCANDONE_T            scan_done;          /**< station scan (APs) done */
137     BWIFI_EVENT_STAMODE_CONNECTING_T          connecting;         /**< station is connecting to AP */
138     BWIFI_EVENT_STAMODE_CONNECTED_T           connected;          /**< station connected to AP */
139     BWIFI_EVENT_STAMODE_DISCONNECTED_T        disconnected;       /**< station disconnected to AP */
140     BWIFI_EVENT_STAMODE_AUTHMODE_CHANGE_T     auth_change;        /**< the auth mode of AP connected by station changed */
141     BWIFI_EVENT_STAMODE_GOT_IP_T              got_ip;             /**< station got IP */
142     BWIFI_EVENT_STAMODE_ROAM_COMPLETE_T       roam_complete;      /**< station roamed to a new AP */
143     BWIFI_EVENT_SAPMODE_STA_CONNECTED_T       sta_connected;      /**< a station connected to soft-AP */
144     BWIFI_EVENT_SAPMODE_STA_DISCONNECTED_T    sta_disconnected;   /**< a station disconnected to soft-AP */
145     //BWIFI_EVENT_SAPMODE_PROBEREQRECVED_T      ap_probereqrecved;  /**< soft-AP received probe request packet */
146     BWIFI_EVENT_COEX_MODE_T            coex_mode;          /**< wifi/bt coex mode */
147     BWIFI_EVENT_LMAC_FATAL_ERROR_T            fatal_err;          /**< LMAC fatal error */
148 } BWIFI_EVENT_INFO_U;
149 
150 typedef enum {
151     EVENT_STAMODE_SCAN_DONE                   = 0,  /**< station finish scanning AP */
152     EVENT_STAMODE_CONNECTING                  = 1,  /**< station is connecting to AP */
153     EVENT_STAMODE_CONNECTED                   = 2,  /**< station connected to AP */
154     EVENT_STAMODE_DISCONNECTED                = 3,  /**< station disconnected to AP */
155     EVENT_STAMODE_AUTHMODE_CHANGE             = 4,  /**< the auth mode of AP connected by station changed */
156     EVENT_STAMODE_GOT_IP                      = 5,  /**< station got IP from connected AP */
157     EVENT_STAMODE_DHCP_TIMEOUT                = 6,  /**< station dhcp client got IP timeout */
158     EVENT_STAMODE_WPS_CONNECTED               = 7,  /**< WPS connected to AP */
159     EVENT_STAMODE_ROAM_COMPLETE               = 8,  /**< station roamed to another AP in the same ESS */
160     EVENT_SAPMODE_STA_CONNECTED               = 9,  /**< a station connected to soft-AP */
161     EVENT_SAPMODE_STA_DISCONNECTED            = 10, /**< a station disconnected to soft-AP */
162     //EVENT_SAPMODE_PROBEREQRECVED            = 11, /**< soft-AP received probe request packet */
163     EVENT_COEX_MODE_CHANGE                          = 12, /**< switch wifi/bt coex mode between fdd and tdd */
164 
165     EVENT_LMAC_FATAL_ERROR                    = 20, /**< lower mac got a fatal error */
166     EVENT_UMAC_CRASH                          = 21, /**< upper mac (cp) got crashed */
167 
168     EVENT_MAX
169 } BWIFI_SYSTEM_EVENT;
170 
171 typedef struct bwifi_event {
172     BWIFI_SYSTEM_EVENT event_id;      /**< even ID */
173     BWIFI_EVENT_INFO_U event_info;    /**< event information */
174 } BWIFI_SYSTEM_EVENT_T;
175 
176 /**
177   * The Wi-Fi tcpip input handler.
178   *
179   * The example: if tcpip is lwip, set ethernetif_input func.
180   *
181   * @param uint16_t devnum , 0 is station, 1 is softap.
182   * @param void *buf, rx pkt data buf.
183   * @param int size, the length of param buf.
184   * @return null
185   */
186 typedef void (*eth_input_handler)(uint8_t devnum, void *buf, int size);
187 
188 /**
189   * The Wi-Fi event handler.
190   *
191   * No complex operations are allowed in callback.
192   * If users want to execute any complex operations, please post message to another task instead.
193   *
194   * @param BWIFI_SYSTEM_EVENT_T *event : WiFi event
195   *
196   * @return null
197   */
198 typedef int (*evt_recv_handler)(BWIFI_SYSTEM_EVENT_T *event);
199 
200 
201 #ifdef  __cplusplus
202 }
203 #endif
204 #endif /*BWIFI_STATEMACHINE_H*/
205