From 9aa66b3940f64f829b201fb5ffb6cc97e36734fe Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer <reinhold@kainhofer.com> Date: Thu, 15 Dec 2011 16:57:19 +0100 Subject: [PATCH] hp2101nw_setup.pl: Allow rescanning for wireless access points --- hp2101nw_setup.pl | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/hp2101nw_setup.pl b/hp2101nw_setup.pl index 3728f64..0975929 100755 --- a/hp2101nw_setup.pl +++ b/hp2101nw_setup.pl @@ -15,6 +15,14 @@ ## For the device protocol see: ## http://wiki.kainhofer.com/hardware/hp2101nw_wlan_printserver +## Supported devices: +## -) HP 2101nw wireless G USB print server (USB-id 03f0:cd02) +## +## Devices that seem to use a similar config format (but might not use USB at all): +## -) Linksys WPS54G-DE Wireless-G printserver 802.11g USB +## -) NetHawk RF-200A +## -) SMC2621W-U EZ Connect Wireless Print Server + use Device::USB; use Data::Dumper; @@ -598,18 +606,20 @@ sub print_wireless_networks ($) { sub wifi_ask_ssid ($) { - my $aps = shift; + my $dev = shift; + my $aps = scan_for_aps ($dev); print_wireless_networks ($aps); my @ssids = (sort {lc $a cmp lc $b} keys (%$aps)); my $newssid; print "Please enter the number or the SSID of the desired wireless network.\n"; - print "Enter '0', 'hidden' or 'h' to connect to a hidden network.\n"; + print "\tEnter '0', 'hidden' or 'h' to connect to a hidden network.\n"; + print "\tEnter 'r' or 'rescan' to rescan for wireless networks.\n"; do { print "Desired wireless network: "; $newssid = input (); return $newssid if (exists $aps->{$newssid}); if ($newssid =~ /^[1-9]\d*$/ && ($newssid <= scalar(@ssids))) { - return $ssids[$newssid-1]; + return ($aps,$ssids[$newssid-1]); } if ($newssid eq "0" || $newssid eq "h" || $newssid eq "hidden") { $newssid = ""; @@ -617,7 +627,10 @@ sub wifi_ask_ssid ($) { print "Please enter the SSID: "; $newssid = input (); } - return $newssid; + return ($aps,$newssid); + } + if ($newssid eq "r" || $newssid eq "rescan") { + return wifi_ask_ssid ($dev); } } while 1; # We'll jump out of the loop via return! } @@ -856,8 +869,7 @@ sub main () { debug ("\tSelected operation: %s\n", $operation); if ($operation eq "wifi_infrastructure") { # Infrastructure, scan for APs - my $aps = scan_for_aps ($dev); - my $newap = wifi_ask_ssid ($aps); + my ($aps,$newap) = wifi_ask_ssid ($dev); my %newconfig = ('SSID' => $newap); debug ("\tSelected wireless network: %s\n", $newap); my %security = wifi_ask_security ($newap, $aps); -- GitLab