1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 5 #ifndef BWIFI_EVENT_H 6 #define BWIFI_EVENT_H 7 #if LWIP_SUPPORT 8 #include "lwip/ip_addr.h" 9 #endif 10 #ifdef __cplusplus 11 extern "C" 12 { 13 #endif 14 15 typedef struct { 16 int status; /**< status of scanning APs */ 17 //struct dl_list *scan_result; /**< list of APs found */ 18 } BWIFI_EVENT_STAMODE_SCANDONE_T; 19 20 typedef enum { 21 INTER_STATE_AUTHENTICATING, /* Authentication start */ 22 INTER_STATE_AUTH_REJECT, /* Authentication rejected by AP */ 23 INTER_STATE_AUTH_TIMEOUT, /* Authentication timeout */ 24 INTER_STATE_ASSOCIATING, /* Association start */ 25 INTER_STATE_ASSOC_REJECT, /* Association request rejected by AP */ 26 INTER_STATE_ASSOC_TIMEOUT, /* Association timeout */ 27 INTER_STATE_ASSOCIATED, /* Associated to target AP */ 28 INTER_STATE_4WAY_HANDSHAKE, /* 4way-handshake start */ 29 INTER_STATE_HANDSHAKE_FAIL, /* 4way-handshake fail */ 30 INTER_STATE_GROUP_HANDSHAKE, /* Group handshake start */ 31 /* CONNECTED */ 32 } BWIFI_CONNECT_INTER_STATE; 33 34 typedef struct { 35 u8 ssid[32]; /**< SSID of the connecting AP */ 36 u8 ssid_len; /**< SSID length of the connecting AP */ 37 u8 bssid[6]; /**< BSSID of the connecting AP */ 38 BWIFI_CONNECT_INTER_STATE state; /**< intermediate state during connection */ 39 } BWIFI_EVENT_STAMODE_CONNECTING_T; 40 41 typedef struct { 42 u8 ssid[32]; /**< SSID of connected AP */ 43 u8 ssid_len; /**< SSID length of connected AP */ 44 u8 bssid[6]; /**< BSSID of connected AP*/ 45 u8 channel; /**< channel of connected AP*/ 46 } BWIFI_EVENT_STAMODE_CONNECTED_T; 47 48 typedef struct { 49 u8 ssid[32]; /**< SSID of disconnected AP */ 50 u8 ssid_len; /**< SSID length of disconnected AP */ 51 u8 bssid[6]; /**< BSSID of disconnected AP */ 52 u8 reason; /**< reason of disconnection */ 53 } BWIFI_EVENT_STAMODE_DISCONNECTED_T; 54 55 typedef struct { 56 u8 old_mode; /**< the old auth mode of AP */ 57 u8 new_mode; /**< the new auth mode of AP */ 58 } BWIFI_EVENT_STAMODE_AUTHMODE_CHANGE_T; 59 60 typedef struct { 61 #if LWIP_SUPPORT 62 ip_addr_t ip; /**< IP address that station got from connected AP */ 63 ip_addr_t mask; /**< netmask that station got from connected AP */ 64 ip_addr_t gw; /**< gateway that station got from connected AP */ 65 #endif 66 } BWIFI_EVENT_STAMODE_GOT_IP_T; 67 68 typedef struct { 69 u32 pac_rxc_rx_buf_in_ptr; 70 u32 pac_rxc_rx_buf_out_ptr; 71 u32 scheduler_events; 72 u32 lmac_pc0; 73 u32 lmac_pc1; 74 u32 lmac_lr; 75 u32 lmac_sp; 76 u32 pac_ntd_status_peek; 77 u32 pac_txc_status; 78 u32 QUEUE_0_CONTROL; 79 u32 QUEUE_1_CONTROL; 80 u32 QUEUE_2_CONTROL; 81 u32 QUEUE_3_CONTROL; 82 u32 wlan_sw_override_1; 83 u32 tsq_in_prog; 84 u32 tsq_in_cmpl; 85 } BWIFI_LMAC_STATUS_DUMP_T; 86 87 typedef struct { 88 u8 rst_flag; /**< reset flag to indicate status: 89 0 - no reset; 1 - reset start; 2 - reset end.*/ 90 u16 error_cause; /**< error cause (bitmask) */ 91 BWIFI_LMAC_STATUS_DUMP_T dump_info; /**< LMAC status dump on fatal error */ 92 } BWIFI_FATAL_ERROR_RESET_T; 93 94 typedef struct { 95 u16 error_cause; /**< error cause (bitmask) */ 96 BWIFI_LMAC_STATUS_DUMP_T dump_info; /**< LMAC status dump on fatal error */ 97 } BWIFI_EVENT_STAMODE_FATAL_ERROR_T; 98 99 //typedef struct { 100 // u8 mac[6]; /**< MAC address of the station connected to soft-AP */ 101 // u8 aid; /**< the aid that soft-AP gives to the station connected to */ 102 //} BWIFI_EVENT_SOFTAPMODE_STACONNECTED_T; 103 104 //typedef struct { 105 // u8 mac[6]; /**< MAC address of the station disconnects to soft-AP */ 106 // u8 aid; /**< the aid that soft-AP gave to the station disconnects to */ 107 //} BWIFI_EVENT_SOFTAPMODE_STADISCONNECTED_T; 108 109 //typedef struct { 110 // int rssi; /**< Received probe request signal strength */ 111 // u8 mac[6]; /**< MAC address of the station which send probe request */ 112 //} BWIFI_EVENT_SOFTAPMODE_PROBEREQRECVED_T; 113 114 typedef union { 115 BWIFI_EVENT_STAMODE_SCANDONE_T scan_done; /**< station scan (APs) done */ 116 BWIFI_EVENT_STAMODE_CONNECTING_T connecting; /**< station is connecting to AP */ 117 BWIFI_EVENT_STAMODE_CONNECTED_T connected; /**< station connected to AP */ 118 BWIFI_EVENT_STAMODE_DISCONNECTED_T disconnected; /**< station disconnected to AP */ 119 BWIFI_EVENT_STAMODE_AUTHMODE_CHANGE_T auth_change; /**< the auth mode of AP connected by station changed */ 120 BWIFI_EVENT_STAMODE_GOT_IP_T got_ip; /**< station got IP */ 121 BWIFI_EVENT_STAMODE_FATAL_ERROR_T fatal_err; /**< LMAC fatal error */ 122 //BWIFI_EVENT_SOFTAPMODE_STACONNECTED_T sta_connected; /**< a station connected to soft-AP */ 123 //BWIFI_EVENT_SOFTAPMODE_STADISCONNECTED_T sta_disconnected; /**< a station disconnected to soft-AP */ 124 //BWIFI_EVENT_SOFTAPMODE_PROBEREQRECVED_T ap_probereqrecved; /**< soft-AP received probe request packet */ 125 } BWIFI_EVENT_INFO_U; 126 127 typedef enum { 128 EVENT_STAMODE_SCAN_DONE = 0, /**< station finish scanning AP */ 129 EVENT_STAMODE_CONNECTING = 1, /**< station is connecting to AP */ 130 EVENT_STAMODE_CONNECTED = 2, /**< station connected to AP */ 131 EVENT_STAMODE_DISCONNECTED = 3, /**< station disconnected to AP */ 132 EVENT_STAMODE_AUTHMODE_CHANGE = 4, /**< the auth mode of AP connected by station changed */ 133 EVENT_STAMODE_GOT_IP = 5, /**< station got IP from connected AP */ 134 EVENT_STAMODE_DHCP_TIMEOUT = 6, /**< station dhcp client got IP timeout */ 135 EVENT_STAMODE_FATAL_ERROR = 7, /**< lower mac got a fatal error */ 136 EVENT_STAMODE_WPS_CONNECTED = 8, /**< WPS connected to AP */ 137 //EVENT_SOFTAPMODE_STACONNECTED, /**< a station connected to soft-AP */ 138 //EVENT_SOFTAPMODE_STADISCONNECTED, /**< a station disconnected to soft-AP */ 139 //EVENT_SOFTAPMODE_PROBEREQRECVED, /**< soft-AP received probe request packet */ 140 EVENT_MAX 141 } BWIFI_SYSTEM_EVENT; 142 143 typedef struct bwifi_event { 144 BWIFI_SYSTEM_EVENT event_id; /**< even ID */ 145 BWIFI_EVENT_INFO_U event_info; /**< event information */ 146 } BWIFI_SYSTEM_EVENT_T; 147 148 /** 149 * The Wi-Fi event handler. 150 * 151 * No complex operations are allowed in callback. 152 * If users want to execute any complex operations, please post message to another task instead. 153 * 154 * @param BWIFI_SYSTEM_EVENT_T *event : WiFi event 155 * 156 * @return null 157 */ 158 typedef void (*BWIFI_EVENT_HANDLER_CB_T)(BWIFI_SYSTEM_EVENT_T *event); 159 160 int bwifi_send_event(BWIFI_SYSTEM_EVENT_T* event); 161 162 #ifdef __cplusplus 163 } 164 #endif 165 #endif /*BWIFI_STATEMACHINE_H*/ 166