#include <ctype.h>
#include <board.h>
#include "wl_api.h"
#include "wl_cm.h"
#include "lwip/netif.h"
#include "http_server_gui.h"
#include "gui.h"
#include "et024006dhu.h"
#include "clocks.h"
#include "wl_util.h"
#include "util.h"
#include <string.h>
Go to the source code of this file.
Defines | |
#define | GUI_MAX_NETWORKS 16 |
#define | gui_printk(line, args...) |
#define | MAX_KEY_LEN 64 |
Functions | |
static void | gui_connect_cb (void) |
void | gui_link_down_cb (void) |
void | gui_link_up_cb (void) |
static void | gui_scan_cb (void) |
void | gui_start (void) |
void | gui_status_down_cb (void) |
void | gui_status_up_cb (void) |
static void | set_wep_key_cb (char *ascii_key, size_t len, void *ctx) |
static void | set_wpa_key_cb (char *ascii_key, size_t len, void *ctx) |
Variables | |
char | ascii_key [MAX_KEY_LEN] |
static int | gui_network_cnt = 0 |
static struct wl_network_t | gui_network_list [GUI_MAX_NETWORKS] |
char | gui_print_buf [80] |
#define GUI_MAX_NETWORKS 16 |
#define gui_printk | ( | line, | |||
args... | ) |
Value:
do { \ extern char gui_print_buf[80]; \ sniprintf(gui_print_buf, sizeof(gui_print_buf), args); \ gui_set_title(gui_print_buf, line); \ } while(0)
Definition at line 57 of file http_server_gui.c.
Referenced by gui_connect_cb(), gui_link_down_cb(), gui_link_up_cb(), gui_scan_cb(), gui_start(), gui_status_up_cb(), set_wep_key_cb(), and set_wpa_key_cb().
#define MAX_KEY_LEN 64 |
Definition at line 51 of file http_server_gui.c.
static void gui_connect_cb | ( | void | ) | [static] |
Definition at line 147 of file http_server_gui.c.
References console_schedule_cmd(), equal_bssid(), gui_getstring(), gui_network_cnt, gui_network_list, gui_printk, gui_scroll_idx(), set_wep_key_cb(), set_wpa_key_cb(), and wl_cm_set_network().
Referenced by gui_start().
00148 { 00149 int index; 00150 struct wl_network_t* selected_net; 00151 struct wl_network_t* current_net = wl_get_current_network(); 00152 00153 index = gui_scroll_idx() - 1; 00154 if (index < 0 || index > gui_network_cnt) { 00155 return; 00156 } 00157 selected_net = &gui_network_list[index]; 00158 if (equal_bssid(&selected_net->bssid, ¤t_net->bssid)) { 00159 return; 00160 } 00161 00162 if (selected_net->enc_type != ENC_TYPE_NONE) /* this net needs key. */ 00163 { 00164 if (selected_net->enc_type == ENC_TYPE_WEP) { 00165 /* if key available in flash, get it, and start with that. */ 00166 gui_getstring(set_wep_key_cb, selected_net); 00167 } 00168 else { 00169 gui_getstring(set_wpa_key_cb, selected_net); 00170 00171 } 00172 } 00173 else { 00174 console_schedule_cmd("setkey none", 1); 00175 gui_printk(0, "Connecting ... "); 00176 gui_printk(1, " "); 00177 wl_cm_set_network(&selected_net->ssid, NULL); 00178 } 00179 }
void gui_link_down_cb | ( | void | ) |
Definition at line 241 of file http_server_gui.c.
References gui_printk.
00242 { 00243 gui_printk(0, "Connecting ... "); 00244 gui_printk(1, " "); 00245 }
void gui_link_up_cb | ( | void | ) |
Definition at line 226 of file http_server_gui.c.
References gui_printk, and str.
00227 { 00228 char str[WL_SSID_MAX_LENGTH + 1]; 00229 struct wl_network_t *net = wl_get_current_network(); 00230 00231 memset(str, 0, sizeof(str)); 00232 strncpy(str, net->ssid.ssid, net->ssid.len); 00233 gui_printk(0, "Connected to \"%s\"", str); 00234 gui_printk(1, "Requesting dhcp ... "); 00235 }
static void gui_scan_cb | ( | void | ) | [static] |
Definition at line 67 of file http_server_gui.c.
References enc_type2str(), gui_add_scroll_box_item(), gui_clear_scroll_box(), gui_inc_scroll_cursor(), GUI_MAX_NETWORKS, gui_network_cnt, gui_network_list, gui_printk, gui_set_bg_color(), printk(), and ssid2str().
Referenced by gui_start().
00068 { 00069 struct wl_network_t* wl_network_list; 00070 uint8_t wl_network_cnt, i; 00071 00072 gui_clear_scroll_box(); 00073 gui_set_bg_color(WHITE); 00074 gui_add_scroll_box_item("Scan Contents:", sizeof "Scan Contents:"); 00075 00076 wl_get_network_list(&wl_network_list, &wl_network_cnt); 00077 if (wl_network_cnt == 0) 00078 gui_printk(1, "No networks found"); 00079 else 00080 gui_printk(1, " "); 00081 00082 gui_network_cnt = wl_network_cnt > GUI_MAX_NETWORKS ? GUI_MAX_NETWORKS : 00083 wl_network_cnt; 00084 00085 memcpy(gui_network_list, wl_network_list, 00086 sizeof(struct wl_network_t) * gui_network_cnt); 00087 00088 for (i = 0; i < gui_network_cnt; i++) { 00089 struct wl_network_t* net = &gui_network_list[i]; 00090 char print_buf[80]; 00091 siprintf(print_buf, "%s (%ld) %s", ssid2str(&net->ssid), 00092 net->rssi, enc_type2str(net->enc_type)); 00093 printk("%s\n", print_buf); 00094 gui_add_scroll_box_item(print_buf, strlen(print_buf)); 00095 } 00096 00097 gui_inc_scroll_cursor(); /* inc cursor idx to make it >0 */ 00098 }
void gui_start | ( | void | ) |
Definition at line 252 of file http_server_gui.c.
References FCPU_HZ, FPBA_HZ, gui_add_scroll_box_item(), gui_clear_scroll_box(), gui_connect_cb(), gui_dec_scroll_cursor(), gui_draw(), gui_inc_scroll_cursor(), gui_init(), gui_printk, gui_scan_cb(), gui_set_bg_color(), and gui_set_button().
00253 { 00254 pm_freq_param_t pm_freq_param = { 00255 .cpu_f = FCPU_HZ, 00256 .pba_f = FPBA_HZ, 00257 .osc0_f = FOSC0, 00258 .osc0_startup = OSC0_STARTUP 00259 }; 00260 gui_init(&pm_freq_param); 00261 gui_draw(1); 00262 gui_printk(0, "Disconnected"); 00263 gui_set_button(0, "Scan", sizeof "Scan", gui_scan_cb); 00264 gui_set_button(1, "Connect", sizeof "Connect", gui_connect_cb); 00265 gui_set_button(2, "Up", sizeof "Up", gui_dec_scroll_cursor); 00266 gui_set_button(3, "Down", sizeof "Down", gui_inc_scroll_cursor); 00267 gui_clear_scroll_box(); 00268 gui_set_bg_color(WHITE); 00269 gui_add_scroll_box_item("Scan Contents:", sizeof "Scan Contents:"); 00270 }
void gui_status_down_cb | ( | void | ) |
void gui_status_up_cb | ( | void | ) |
Definition at line 195 of file http_server_gui.c.
References gui_add_infobox_item(), gui_clear_infobox(), gui_infobox_onoff(), gui_printk, gui_save_buttons(), gui_set_button(), ip2str(), ssid2str(), and TRUE.
00196 { 00197 struct wl_network_t *net = wl_get_current_network(); 00198 00199 gui_printk(0, "Connected to \"%s\"", ssid2str(&net->ssid)); 00200 gui_printk(1, "My ip address is %s", ip2str(netif_default->ip_addr)); 00201 #if BOARD == EVK1100 00202 gui_save_buttons(); 00203 gui_clear_infobox(0); 00204 00205 gui_add_infobox_item(ssid2str(&net->ssid), 0); 00206 00207 gui_add_infobox_item(ip2str(netif_default->ip_addr), 1); 00208 gui_infobox_onoff(TRUE); 00209 gui_set_button(0, "Back", sizeof "Back", go_back_cb); 00210 #endif 00211 }
static void set_wep_key_cb | ( | char * | ascii_key, | |
size_t | len, | |||
void * | ctx | |||
) | [static] |
Definition at line 122 of file http_server_gui.c.
References console_schedule_cmd(), gui_printk, printk(), and wl_cm_set_network().
Referenced by gui_connect_cb().
00122 { 00123 struct wl_network_t *net = ctx; 00124 char cmd[80]; 00125 00126 if (NULL == ascii_key || 0 == len || NULL == ctx) { 00127 printk("%s : Failed to add wep key\n", __func__); 00128 gui_printk(1, "Failed to add key"); 00129 return; 00130 } 00131 00132 sniprintf(cmd, sizeof cmd, "setkey 0 %s", ascii_key); 00133 printk("%s : \"%s\"\n", __func__, cmd); 00134 console_schedule_cmd(cmd, 1); 00135 00136 gui_printk(0, "Connecting ... "); 00137 gui_printk(1, " "); 00138 if ( WL_SUCCESS != wl_cm_set_network(&net->ssid, NULL) ) { 00139 printk("FAIL\n"); 00140 } 00141 }
static void set_wpa_key_cb | ( | char * | ascii_key, | |
size_t | len, | |||
void * | ctx | |||
) | [static] |
Definition at line 101 of file http_server_gui.c.
References console_schedule_cmd(), gui_printk, printk(), ssid2str(), and wl_cm_set_network().
Referenced by gui_connect_cb().
00101 { 00102 struct wl_network_t *net = ctx; 00103 char cmd[80]; 00104 00105 if (NULL == ascii_key || 0 == len || NULL == ctx) { 00106 printk("%s : Failed to add pass phrase\n", __func__); 00107 gui_printk(1, "Failed to add pass phrase"); 00108 return; 00109 } 00110 00111 sniprintf(cmd, sizeof cmd, "wpass %s %s", ssid2str(&net->ssid), ascii_key); 00112 printk("%s : \"%s\"\n", __func__, cmd); 00113 console_schedule_cmd(cmd, 1); 00114 00115 gui_printk(0, "Connecting ... "); 00116 gui_printk(1, " "); 00117 if ( WL_SUCCESS != wl_cm_set_network(&net->ssid, NULL) ) { 00118 printk("FAIL\n"); 00119 } 00120 }
char ascii_key[MAX_KEY_LEN] |
Definition at line 52 of file http_server_gui.c.
int gui_network_cnt = 0 [static] |
struct wl_network_t gui_network_list[GUI_MAX_NETWORKS] [static] |
char gui_print_buf[80] |
Definition at line 54 of file http_server_gui.c.