void print_network_list(void) { struct wl_network_list_t* wl_network_list; uint8_t i; wl_get_network_list(&wl_network_list); if (wl_network_list->cnt == 0) printk("no nets found\n"); for (i = 0; i < wl_network_list->cnt; i++) print_network(wl_network_list->net[i]); }
/** * This function can be modified to pick a network based on * application specific criteria. * * If the SSID can not be found in the scan list it will be * assumed to be a hidden SSID and the wl_connect() command * will be called to attempt to probe for the network and * connect to it. */ static struct wl_network_t* find_best_candidate(struct cm* cm) { struct wl_network_list_t* netlist; struct wl_network_t *best_net = NULL; uint8_t i; if (wl_get_network_list(&netlist) != WL_SUCCESS) return NULL; if (netlist->cnt == 0) return NULL; for (i = 0; i < netlist->cnt; i++) { /* match on ssid */ if (cm->candidate.ssid.len) if (!equal_ssid(&cm->candidate.ssid, &netlist->net[i]->ssid)) continue; /* match bssid */ if (strncmp((char*) cm->candidate.bssid.octet, "\xff\xff\xff\xff\xff\xff", 6)) if (!equal_bssid(&cm->candidate.bssid, &netlist->net[i]->bssid)) continue; /* check for best rssi. */ if ( best_net && ( best_net->rssi > netlist->net[i]->rssi) ) { continue; } best_net = netlist->net[i]; } return best_net; }