diff options
Diffstat (limited to 'src/wireless')
-rw-r--r-- | src/wireless | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/wireless b/src/wireless index 883ea0b..99c146d 100644 --- a/src/wireless +++ b/src/wireless @@ -14,24 +14,35 @@ wep_check() } # Check if a particular network is within range -# find_essid interface essid +# find_essid interface essid connection (we treat ESSID as regexp when CONNECTION=wireless-dbus) find_essid() { - local INTERFACE="$1" ESSID="$2" RETRIES=20 try=0 res scanned + local INTERFACE="$1" ESSID="$2" CONNECTION="$3" RETRIES=20 try=0 res scanned while [[ "$try" -lt "$RETRIES" ]]; do sleep 0.5 let try++ - found=$( - res=$(iwlist "$INTERFACE" scan 2>/dev/null) - [[ -z "$res" ]] && exit 1 - # if results were non-null, process them and exit 0 - echo "$res" | sed -nr 's/^\s+ESSID:"([^"]*)"$/\1/p' | fgrep -xm1 "$ESSID" - ) && { + if [[ "$CONNECTION" == wireless-dbus ]]; then + # JP: ESSID is a regexp + found=$( + res=$(iwlist "$INTERFACE" scan 2>/dev/null) + [[ -z "$res" ]] && exit 1 + # if results were non-null, process them and exit 0 + echo "$res" | sed -nr 's/^\s+ESSID:"([^"]*)"$/\1/p' | egrep -xm1 "$ESSID" + ) + else + found=$( + res=$(iwlist "$INTERFACE" scan 2>/dev/null) + [[ -z "$res" ]] && exit 1 + # if results were non-null, process them and exit 0 + echo "$res" | sed -nr 's/^\s+ESSID:"([^"]*)"$/\1/p' | fgrep -xm1 "$ESSID" + ) + fi && { scanned=1 report_debug find_essid "\"$found\"" # we only bother with at most 5 successful scans if (( try < RETRIES-4 )); then try=$((RETRIES-4)); fi } if [[ -n "$found" ]]; then + echo "$found" # JP: echo literal ESSID return 0 # network found fi done |