Skip to content

Commit

Permalink
Convert signal into positive value
Browse files Browse the repository at this point in the history
The signal can be a negative dBm or a positive percentage depending of
the capabilities of the driver. We must convert the value into a
positive integer to allow to sort in all cases.
  • Loading branch information
cedk committed Apr 14, 2017
1 parent 969b97a commit 779ad69
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions wiconfig
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function scan {
# IFS=' "'
# IFS=$oIFS
echo -n > "$output"
typeset _nwids _args _nwid
typeset _nwids _args _nwid _signal

! $quiet && echo "Performing wireless scan..."
# Parse ifconfig nwid output for sorting
Expand Down Expand Up @@ -266,7 +266,10 @@ function scan {
# MAC
echo -n "|$4" >> $output
# Signal quality
printf "|%02d" ${5%dBm} >> $output
_signal=${5%dBm} # Remove dBm suffix
_signal=${_signal%\%} # Remove % suffix
_signal=${_signal#-} # Make signal always positive
printf "|%02d" ${_signal} >> $output
# Speed
echo -n "|$6" >> $output
# Options
Expand Down Expand Up @@ -379,7 +382,7 @@ function menu {
echo
for _i in ${index[@]}; do
printf "%3d) %-40s %-6s %-10s\n" \
$_i "${nwid[$_i]}" "${db[$_i]}dB" "${access[$_i]}"
$_i "${nwid[$_i]}" "${db[$_i]}" "${access[$_i]}"
done
echo
read choice?"Enter the number of the network to connect to (or r to rescan or q to quit): "
Expand Down

0 comments on commit 779ad69

Please sign in to comment.