Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 25 Aug 2019, 00:55
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
SNS wifi network display by strength order [SOLVED]
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [7 Posts]  
Author Message
greengeek


Joined: 20 Jul 2010
Posts: 5618
Location: Republic of Novo Zelande

PostPosted: Sat 21 Jan 2017, 23:24    Post subject:  SNS wifi network display by strength order [SOLVED]
Subject description: Display wifi network radio buttons according to signal strength / quality.
 

On one of my Slacko 5.6 derivatives I exclusively use Barry's SNS wizard to connect my wifi. However when it brings up the GTK (?) dialog listing the available networks that it has found they seem to be in random order - I assume in the order in which each wifi router responded.

I am wondering if there is some way to modify SNS so that it lists these networks in order of "Quality" parameter - which is recorded in the "one line" list recorded by SNS in it's files /tmp/sns_scan_raw_oneline and /tmp/sns_scan_radiobuttons.

I lack the skill to achieve this so I am keen for help to understand the coding of SNS.

As far as I can tell the SNS dialog reads the file /tmp/sns_scan_radiobuttons when it places the network info into the GTK dialog window and I suspect that it may be possible to reorder the entries in that file (based on the "quality" parameter eg; 45/70) - so that they are in order.

I suspect this change could be inserted around line 372 (just before "done" in the code below)

Code:
############WIRELESS SETUP###############
if [ "$IF_INTTYPE" == "Wireless" ];then
 #scan for networks...
 FLAGERR=
 rm -f /tmp/sns_scan_radiobuttons
 rm -f /tmp/sns_scan_rawoneline
 rm -f /tmp/sns_scan_oneline
 #xmessage -center -bg orange -buttons "" "Please wait, scanning for wireless networks..." &
 yaf-splash -placement center -bg orange -text "$(gettext 'Please wait, scanning for wireless networks...')" &
 PIDXMSG=$!
 echo "Information about this interface:
 Interface: $INTERFACE  Driver: $IF_DRIVER  Bus: $IF_BUS  MacAddress: $MACADDRESS
 Description: $IF_INFO
 " > /tmp/sns_wireless_log
 [ "`iwconfig $INTERFACE | grep "$INTERFACE" | grep "ESSID"`" != "" ] && iwconfig $INTERFACE essid off
 echo "STEP1a: ifconfig $INTERFACE up" >> /tmp/sns_wireless_log
 ifconfig $INTERFACE up >> /tmp/sns_wireless_log 2>&1
 if [ $? -ne 0 ];then
  FLAGERR=1
 else
  sleep 2 #100513 increase from 1.
  echo "STEP1b: iwlist $INTERFACE scan" >> /tmp/sns_wireless_log
  SCANRESULT="`iwlist $INTERFACE scan`" ###SCANNING### 110203
  if [ "`echo "$SCANRESULT" | grep 'Scan completed'`" = "" ];then #100513 110203
   sleep 2
   SCANRESULT="`iwlist $INTERFACE scan`" ###SCANNING### 110203
  fi
  echo "$SCANRESULT" >> /tmp/sns_wireless_log
  echo "STEP1c: ifconfig $INTERFACE down" >> /tmp/sns_wireless_log
  ifconfig $INTERFACE down #100313
  #convert each found network into a single line... 110203
  SRLINES="`echo "$SCANRESULT" | grep -v 'Scan completed' | tr '|' ' ' | tr '\n' '|' | sed -e 's%       Cell %\n%g' | tr -s ' '`"
  echo "$SRLINES" |
  while read ONELINE
  do
   [ "$ONELINE" = "" ] && continue
   [ "$ONELINE" = " " ] && continue
   [ "`echo -n "$ONELINE" | grep 'No scan results'`" != "" ] && continue #101029
   [ "`echo -n "$ONELINE" | grep ' ESSID:'`" = "" ] && continue #101029
   CELL_NUMBER="`echo -n "$ONELINE" | cut -f1 -d' '`"
   CELL_ADDRESS="`echo -n "$ONELINE" | grep -o ' Address: .*' | cut -f 3 -d ' ' | cut -f1 -d '|'`"
   CELL_CHANNEL="`echo -n "$ONELINE" | grep -o ' Channel:.*' | cut -f2 -d':' | cut -f1 -d'|'`"
   [ "$CELL_CHANNEL" == "" ] && CELL_CHANNEL="`echo -n "$ONELINE" | grep -o ' (Channel .*' | cut -f 3 -d ' ' | cut -f 1 -d')'`"
   CELL_QUALITY="`echo -n "$ONELINE" | grep -o ' Quality[:=].*' | cut -f 2 -d ' ' | cut -f 2 -d '=' | cut -f 2 -d ':'`"
   CELL_ESSID="`echo -n "$ONELINE" | grep -o ' ESSID:.*' | cut -f 2 -d '"'`" #'geany
   CELL_ENCRYPTIONKEY="`echo -n "$ONELINE" | grep -o 'Encryption key:.*' | cut -f 2 -d ':' | cut -f1 -d '|'`" #ex: off
   CELLMSG="Name: $CELL_ESSID  Encryption: $CELL_ENCRYPTIONKEY  Strength: $CELL_QUALITY"
   echo "<radiobutton><label>${CELLMSG}</label><variable>RADIO_${CELL_NUMBER}</variable></radiobutton>" >> /tmp/sns_scan_radiobuttons
   echo "$ONELINE" >> /tmp/sns_scan_rawoneline
   echo "${CELL_NUMBER}|${CELL_ADDRESS}|${CELL_CHANNEL}|${CELL_QUALITY}|${CELL_ENCRYPTIONKEY}|${CELL_ESSID}" >> /tmp/sns_scan_oneline
  done


I will be trying some options to re-order that file, but would greatly appreciate any suggestions.

cheers!

SOLUTION :
Philh has suggested that instead of trying to reorder the wifi networks listed in the /tmp "oneline" scan files it is better to modify the way these networks are sorted when they are displayed in the gui dialog. This can be achieved as follows:

Open the file /usr/local/simple_network_setup/sns and look for the following line (which is line 389 n my version):
Code:
RADIOBUTTONS="`cat /tmp/sns_scan_radiobuttons`"

and change it to:
Code:
RADIOBUTTONS="`cat /tmp/sns_scan_radiobuttons | sort -t: -k4 -n -r`"


This means that when you now use SNS to hunt for available wifi networks they will display in the connection dialog gui in order of signal "quality" (strength). This is handy because it means the default selection will now be the strongest signal and therefore the most likely to be your own home network rather than one of the neighbours networks which is what used to happen - leading to a very long wait while sns eventually determined that it could not connect.

This will be a real time saver for me.

Thanks Phil !
.

Last edited by greengeek on Sun 22 Jan 2017, 12:14; edited 2 times in total
Back to top
View user's profile Send private message 
Sailor Enceladus

Joined: 22 Feb 2016
Posts: 1561

PostPosted: Sun 22 Jan 2017, 04:03    Post subject:  

That's a nice idea. Whether trying to set up wifi in your house or looking for free wifi, higher quality first does make sense.
Back to top
View user's profile Send private message 
Philh

Joined: 17 May 2006
Posts: 147
Location: England

PostPosted: Sun 22 Jan 2017, 06:26    Post subject:  

If you change RADIOBUTTONS="`cat /tmp/sns_scan_radiobuttons `"
about line 395 to
Code:
RADIOBUTTONS="`cat /tmp/sns_scan_radiobuttons | sort -t: -k4 -n -r`"

That will just change the way its displayed I think and not change how it all works. So sns_scan_radiobuttons will still be the same and wont actually be in order of strength.
Back to top
View user's profile Send private message 
greengeek


Joined: 20 Jul 2010
Posts: 5618
Location: Republic of Novo Zelande

PostPosted: Sun 22 Jan 2017, 11:59    Post subject:  

Philh wrote:
If you change RADIOBUTTONS="`cat /tmp/sns_scan_radiobuttons `"
about line 395 to
Code:
RADIOBUTTONS="`cat /tmp/sns_scan_radiobuttons | sort -t: -k4 -n -r`"

That will just change the way its displayed I think and not change how it all works. So sns_scan_radiobuttons will still be the same and wont actually be in order of strength.
Thank you Philh ! Yes, that one change does rearrange the order of the networks displayed in the gui dialog so that they appear in order of signal strength (quality). No need to reorder the file contents after all.

Thanks, this will make it so much easier for my family to connect successfully.

I will modify my first post to reflect this solution.

cheers!
Back to top
View user's profile Send private message 
bigpup


Joined: 11 Oct 2009
Posts: 12467
Location: S.C. USA

PostPosted: Sun 22 Jan 2017, 18:32    Post subject:  

Wonder if this would be a change to submit to Woof-CE.

If you really want this to get into Puppy, the code is there in Woof-CE.
https://github.com/puppylinux-woof-CE/woof-CE
Make a pull request to submit to Woof CE.

There is also this:
woof-CE patch generator!
http://www.murga-linux.com/puppy/viewtopic.php?t=98740

_________________
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected Shocked
YaPI(any iso installer) http://www.murga-linux.com/puppy/viewtopic.php?t=107601
Back to top
View user's profile Send private message 
greengeek


Joined: 20 Jul 2010
Posts: 5618
Location: Republic of Novo Zelande

PostPosted: Mon 23 Jan 2017, 02:29    Post subject:  

bigpup wrote:
Wonder if this would be a change to submit to Woof-CE
Yes, I think it would be a worthy addition. I just looked for a git tutorial that I saw somewhere on the forum (maybe one of mavrothals posts??) but can't put my finger on it at the moment.
Back to top
View user's profile Send private message 
bigpup


Joined: 11 Oct 2009
Posts: 12467
Location: S.C. USA

PostPosted: Mon 23 Jan 2017, 05:39    Post subject:  

It is not hard.
Go to the Woof-CE Gethub page I posted the link to.
You will need to sign in.
After signing in.
Select new pull request.
Put all the info, code, etc... you want to submit in it.
Submit.

The Woof-CE team will look it over and may give feedback or not.
So check back to see what happens.
Look under issues or pull requests to find what is being done with what you submitted.

As I understand. If it is something that is accepted by the Woof-CE team, it will be added to Woof-CE.
May also get more input, from others, and modified, before adding to Woof-CE. Depends on what it is.

Example pull request:
https://github.com/puppylinux-woof-CE/woof-CE/issues/730
This one got used and put into Woof-CE.

_________________
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected Shocked
YaPI(any iso installer) http://www.murga-linux.com/puppy/viewtopic.php?t=107601
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [7 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0556s ][ Queries: 11 (0.0131s) ][ GZIP on ]