source: ReferenceDesigns/w3_802.11/c/wlan_mac_high_ap/wlan_mac_ap_uart_menu.c

Last change on this file was 6319, checked in by chunter, 5 years ago

1.8.0 release wlan-mac-se

File size: 8.1 KB
Line 
1/** @file wlan_mac_ap_uart_menu.c
2 *  @brief Access Point UART Menu
3 *
4 *  This contains code for the 802.11 Access Point's UART menu.
5 *
6 *  @copyright Copyright 2013-2019, Mango Communications. All rights reserved.
7 *          Distributed under the Mango Communications Reference Design License
8 *              See LICENSE.txt included in the design archive or
9 *              at http://mangocomm.com/802.11/license
10 *
11 *  This file is part of the Mango 802.11 Reference Design (https://mangocomm.com/802.11)
12 */
13
14/***************************** Include Files *********************************/
15
16#include "wlan_mac_high_sw_config.h"
17
18// Xilinx SDK includes
19#include "xil_types.h"
20
21// WLAN includes
22#include "wlan_platform_common.h"
23#include "wlan_mac_event_log.h"
24#include "wlan_mac_entries.h"
25#include "wlan_mac_ap.h"
26#include "ascii_characters.h"
27#include "wlan_mac_schedule.h"
28#include "wlan_mac_network_info.h"
29#include "wlan_mac_station_info.h"
30#include "wlan_mac_high.h"
31#include "wlan_mac_queue.h"
32#include "wlan_mac_dl_list.h"
33
34
35//
36// Use the UART Menu
37//     - If WLAN_USE_UART_MENU in wlan_mac_ap.h is commented out, then this function
38//       will do nothing.  This might be necessary to save code space.
39//
40
41
42#ifndef WLAN_USE_UART_MENU
43
44void uart_rx(u8 rxByte){ };
45
46#else
47
48
49/*************************** Constant Definitions ****************************/
50
51//-----------------------------------------------
52// UART Menu Modes
53#define UART_MODE_MAIN 0
54#define UART_MODE_INTERACTIVE 1
55
56
57/*********************** Global Variable Definitions *************************/
58extern network_info_t* active_network_info;
59extern u16 mcast_qid;
60
61/*************************** Variable Definitions ****************************/
62
63static volatile u8 uart_mode = UART_MODE_MAIN;
64static volatile u32 schedule_id;
65static volatile u8 print_scheduled = 0;
66
67/*************************** Functions Prototypes ****************************/
68
69void print_main_menu();
70
71void print_station_status();
72void print_queue_status();
73
74void start_periodic_print();
75void stop_periodic_print();
76
77
78/*************************** Variable Definitions ****************************/
79
80
81/******************************** Functions **********************************/
82
83
84/*****************************************************************************/
85/**
86 * Process each character received by the UART
87 *
88 * The following functionality is supported:
89 *    - Main Menu
90 *      - Interactive Menu (prints all station infos)
91 *      - Print queue status
92 *      - Print all counts
93 *      - Print event log size (hidden)
94 *      - Print Network List
95 *      - Print Malloc info (hidden)
96 *    - Interactive Menu
97 *      - Reset counts
98 *      - Deauthenticate all stations
99 *      - Turn on/off "Traffic Blaster" (hidden)
100 *
101 * The escape key is used to return to the Main Menu.
102 *
103 *****************************************************************************/
104void uart_rx(u8 rxByte){
105
106    // ----------------------------------------------------
107    // Return to the Main Menu
108    //    - Stops any prints / LTGs
109    if (rxByte == ASCII_ESC) {
110        uart_mode = UART_MODE_MAIN;
111        stop_periodic_print();
112        print_main_menu();
113        return;
114    }
115
116    switch(uart_mode){
117
118        // ------------------------------------------------
119        // Main Menu processing
120        //
121        case UART_MODE_MAIN:
122            switch(rxByte){
123
124                // ----------------------------------------
125                // '1' - Switch to Interactive Menu
126                //
127                case ASCII_1:
128                    uart_mode = UART_MODE_INTERACTIVE;
129                    start_periodic_print();
130                break;
131
132                // ----------------------------------------
133                // '2' - Print Queue status
134                //
135                case ASCII_2:
136                    print_queue_status();
137                break;
138
139                // ----------------------------------------
140                // '3' - Print Station Infos with Counts
141                //
142                case ASCII_3:
143                    station_info_print(NULL , STATION_INFO_PRINT_OPTION_FLAG_INCLUDE_COUNTS);
144                break;
145
146                // ----------------------------------------
147                // 'e' - Print event log size
148                //
149                case ASCII_e:
150#if WLAN_SW_CONFIG_ENABLE_LOGGING
151                    event_log_config_logging(EVENT_LOG_LOGGING_DISABLE);
152                    print_event_log_size();
153                    event_log_config_logging(EVENT_LOG_LOGGING_ENABLE);
154#endif //WLAN_SW_CONFIG_ENABLE_LOGGING
155                break;
156
157                // ----------------------------------------
158                // 'a' - Print BSS information
159                //
160                case ASCII_a:
161                    print_network_info();
162                break;
163
164                // ----------------------------------------
165                // 'm' - Display Heap / Malloc information
166                //
167                case ASCII_m:
168                    wlan_mac_high_display_mallinfo();
169                break;
170
171            }
172        break;
173
174
175        // ------------------------------------------------
176        // Interactive Menu processing
177        //
178        case UART_MODE_INTERACTIVE:
179            switch(rxByte){
180
181                // ----------------------------------------
182                // 'r' - Reset station counts
183                //
184                case ASCII_r:
185#if WLAN_SW_CONFIG_ENABLE_TXRX_COUNTS
186                    txrx_counts_zero_all();
187#endif
188                break;
189
190                // ----------------------------------------
191                // 'd' - De-authenticate all stations
192                //
193                case ASCII_d:
194                    deauthenticate_all_stations();
195                break;
196            }
197        break;
198
199        default:
200            uart_mode = UART_MODE_MAIN;
201            print_main_menu();
202        break;
203    }
204}
205
206
207
208void print_main_menu(){
209    xil_printf("\f");
210    xil_printf("********************** AP Menu **********************\n");
211    xil_printf("[1]   - Interactive AP Status\n");
212    xil_printf("[2]   - Print Queue Status\n");
213    xil_printf("[3]   - Print all Observed Counts\n");
214    xil_printf("\n");
215    xil_printf("[a]   - Display Network List\n");
216    xil_printf("*****************************************************\n");
217}
218
219
220
221void print_station_status(){
222
223    station_info_t* curr_station_info;
224    dl_entry* curr_entry;
225
226    u64 timestamp;
227
228    if((active_network_info != NULL) && (uart_mode == UART_MODE_INTERACTIVE)){
229        timestamp = get_system_time_usec();
230        xil_printf("\f");
231
232        curr_entry = active_network_info->members.first;
233
234        while(curr_entry != NULL){
235            curr_station_info = (station_info_t*)(curr_entry->data);
236            xil_printf("---------------------------------------------------\n");
237            if(curr_station_info->hostname[0] != 0){
238                xil_printf(" Hostname: %s\n", curr_station_info->hostname);
239            }
240            xil_printf(" AID: %02x -- MAC Addr: %02x:%02x:%02x:%02x:%02x:%02x\n", curr_station_info->ID,
241                    curr_station_info->addr[0],curr_station_info->addr[1],curr_station_info->addr[2],curr_station_info->addr[3],curr_station_info->addr[4],curr_station_info->addr[5]);
242
243            xil_printf("     - Last heard from         %d ms ago\n",((u32)(timestamp - (curr_station_info->latest_rx_timestamp)))/1000);
244            xil_printf("     - # of queued MPDUs:      %d\n", queue_length(curr_station_info->QID));
245            curr_entry = dl_entry_next(curr_entry);
246        }
247
248            xil_printf("---------------------------------------------------\n");
249            xil_printf("\n");
250            xil_printf("[r] - reset counts\n");
251            xil_printf("[d] - deauthenticate all stations\n\n");
252    }
253}
254
255
256
257void print_queue_status(){
258    dl_entry* curr_entry;
259    station_info_t* curr_station_info;
260    xil_printf("\nQueue Status:\n");
261    xil_printf(" FREE || MCAST|");
262
263    if(active_network_info != NULL){
264        curr_entry = active_network_info->members.first;
265        while(curr_entry != NULL){
266            curr_station_info = (station_info_t*)(curr_entry->data);
267            xil_printf("%6d|", curr_station_info->ID);
268            curr_entry = dl_entry_next(curr_entry);
269        }
270    }
271    xil_printf("\n");
272
273
274    xil_printf("%6d||%6d|",queue_num_free(),queue_length(mcast_qid));
275    if(active_network_info != NULL){
276        curr_entry = active_network_info->members.first;
277        while(curr_entry != NULL){
278            curr_station_info = (station_info_t*)(curr_entry->data);
279            xil_printf("%6d|", queue_length(curr_station_info->QID));
280            curr_entry = dl_entry_next(curr_entry);
281        }
282    }
283    xil_printf("\n");
284
285}
286
287void start_periodic_print(){
288    stop_periodic_print();
289    print_station_status();
290    print_scheduled = 1;
291    schedule_id = wlan_mac_schedule_add_event(SCHEDULE_ID_COARSE, 1000000, SCHEDULE_REPEAT_FOREVER, (void*)print_station_status);
292}
293
294
295
296void stop_periodic_print(){
297    if (print_scheduled) {
298        print_scheduled = 0;
299        wlan_mac_schedule_remove_event(schedule_id);
300    }
301}
302
303
304#endif
305
306
Note: See TracBrowser for help on using the repository browser.