You are not logged in.

#1 2012-12-29 17:57:30

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,422
Website

Swifer: simple wifi connector tool with auto-connect features

I've just got the newest incarnation of my wifi tool ready for testing.

It is available on github.  As there have been a few nibbles, I've added swifer-git to the AUR.

I readily admit this may be partially reinventing the wheel of tools like netcfg.  I've never used netcfg, but there seems to be a lot to it.  There is very little to swifer.

Swifer, ran without parameters, will present a ncurses list of available networks (manual mode) and connect you to the one you select.  If you select an unsecure/open network wifi will do this silently.  If you select a secure and unknown (see "add" below) swifer will prompt you for a passphrase to pass to wpa_supplicant.  If you select a secure and known network swifer will also handle this silently requiring no further input.

Parameters: (each can be invoked with the first two letters):
auto
Automatic connect mode will not present the ncurses menu.  Instead wifi will automatically detect the strongest signal available among known (see "add") networks and connect to it.
any
Any is like auto (and implies auto), except that it will select the strongest connection from among any known networks and any unsecure/open unknown networks.  Effectively this gets you the best available connection without requiring any further input.
add
Add will add the network selected (either from the menu or from the auto-detect) to the list of known networks so it can be automaticaly connected to in the future.

Other options in various states of usability:
reconnect (INCOMPLETE)
Reconnect will keep wifi alive and monitor the network connection.  If it disconnects or drops below a signal threshold, wifi will reconnect to the best available network.
verbose
Verbose is not particularly useful yet as it only disinhibits dhcpcd output for troubleshooting purposes.  Verbose is disabled in any automatic mode.

Limitations:
- Wifi is only a wifi tool and does not manage any wired connections.
- Wifi is for automating simple but repetitive manual connection steps.  Wifi will *break* complex setups with mutliple connections.  For example, wifi kills any active dhcpcd or wpa_supplicant process before it starts a new one.  If you want dhcpcd active on eth0 AND you try to use wifi for wlan0, you will lose your eth0 connection.  I do not consider this a problem as I define the scope of use of wifi as a tool for more "common use" to just get a wireless connection.  Those with more advanced needs should not use this tool.
- With the above, wifi's management of WPA networks is very "vanilla".  It simply calls wpa_passphrase and wpa_supplicant.  If you have advanced security needs you may need to customize these (just once) in your wpa_supplicant.conf.  After that wifi should connect to your network well.

Optional configuration:
/etc/swifer.conf will be created when you "add" the first network.  You can also create this manually and add either of the following options to the top (above "[NETWORKS]") of the file to change the defaults to use an alternate interface or a drop-in replacement for dhcpcd (such as dhclient).
INTERFACE
INTERFACE = wlan0
DHCP
DHCP = dhcpcd

Potential advantages: (over other connection tools)
- Wifi is simple.  The code is (I hope) simple.  The configuration is simple (all automated).  Use is simple.
- Unless invoked in "reconnect" mode, wifi does not run as a daemon.  It just sets up your connection then gets out of your way.

Future directions:
- A systemd service file for auto modes is coming soon.  With this you will be able to have wifi automatically connect to the best available network at boot (if you enable the service). (done)
- Finish the reconnect modes.
- Put together a man page.  For now see the README, or just ask here.

Bugs:
- There most certainly are many.  Let me know when you find them.

(edit: formatted for easier reading)

NAME CHANGED AS REQUESTED: Swifer is a Simple WIFi ConnectoR.

Last edited by Trilby (2012-12-31 00:23:05)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#2 2012-12-29 18:36:05

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: Swifer: simple wifi connector tool with auto-connect features

Please, if it's not too late, consider changing the name. Using a completely generic name for something like this will cause immense frustration when searching for issues, even more so with a name that refers to something that is likely to be sought in conjunction with the application (cf. "maxima" for a computer algebra system that does calculus).


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#3 2012-12-29 19:09:12

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,422
Website

Re: Swifer: simple wifi connector tool with auto-connect features

Definitely not to late.  I'm open to suggestions for a name that will avoid confusion but will still be descriptive/meaningful.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#4 2012-12-29 19:20:43

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: Swifer: simple wifi connector tool with auto-connect features

Sounds interesting, I'll give it a shot!

About the name, Xyne is definitely right. How about "swinct" (simple wireless network connection tool)? wink Or "cnwt" (chuck norris wifi tool)? I'm just fooling around, but maybe I'll come up with a better idea, who knows smile

Offline

#5 2012-12-29 19:29:31

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,422
Website

Re: Swifer: simple wifi connector tool with auto-connect features

EDIT: This post can now be ignored - this issue is solved.

If anyone more familiar with systemd than I am can point me in the right direction as to why the service file fails, I'd appreciate it.

I have a couple known networks set up, so if I run `wifi auto` wifi connects to a known network and launches dhcpcd and I am connected.  If the same command is executed from a service file it did not seem to do anything.  By some exploring I found that it did, in fact, execute just as it should, but the dhcpcd process was killed after wifi finished.

There is some difference in how systemd executes commands in a service file and how they are run from the command line.  So I even tried a service file with an exec line of "/bin/bash -c 'wifi auto'" and it failed in the same way: it ran, but dhcpcd was killed afterwards.

Last edited by Trilby (2012-12-29 20:12:36)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2012-12-29 19:48:32

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: Swifer: simple wifi connector tool with auto-connect features

Without knowing a lot about systemd, I looked at how netcfg does it. Interesting lines for you could be

RemainAfterExit=yes
Type=forking

in the [Service] section and

Before=network.target
Wants=network.target

in the [Unit] section seems to make sense too.

Offline

#7 2012-12-29 19:51:51

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,422
Website

Re: Swifer: simple wifi connector tool with auto-connect features

I tried the different types, and the remain after is only for systemd's record keeping.  But I think I have a solution.  I was using simple "system(...)" calls in the code instead of forking, and using execvp.  I'm testing the new set up now.

These changes seemed to do it.  Though it could be the service file to as "Type=forking" is not the same as "Type=Forking" ... what's the forking difference! wink


EDIT: Name change is complete.  Wifi is now Swifer.

Last edited by Trilby (2012-12-29 20:32:07)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2013-01-15 14:59:19

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,422
Website

Re: Swifer: simple wifi connector tool with auto-connect features

Last week I was contacted about a problem in swifer.  Aparently I forgot to implement part of the configurable dhcpcd/dhclient option.  Swifer would read the config, but then (try to) launch dhcpcd regardless of the setting.

This was quickly fixed on git and should be working now.  But all my replies to that email have been returned as undeliverable even after I looked up that users website, double checked the email address, and tried again.

So, please report all bugs and or requests here or in the AUR comments.  This way we will have a functioning line of communication, I wont have to hunt for email addresses, and everyone can benefit from any progress made.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#9 2013-01-18 01:04:16

hellomynameisphil
Member
From: /home/phil/Vancouver
Registered: 2009-10-02
Posts: 257
Website

Re: Swifer: simple wifi connector tool with auto-connect features

Am I the user in question? At any rate, thanks for the update; I'll give it a shot. Will also report bugs & kudos here from now on.

Offline

#10 2013-01-18 01:07:04

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,422
Website

Re: Swifer: simple wifi connector tool with auto-connect features

Yup.  I wasn't going to name names.  I got your email and replied that day and it bounced back immediately as undeliverable.  So I came here, and got your email link, and that looked like it went through ... but several days later I got the undeliverable notice.

I am interested if this works as intended with dhclient as I have not tested it myself, so do keep me posted.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#11 2013-01-18 02:26:00

hellomynameisphil
Member
From: /home/phil/Vancouver
Registered: 2009-10-02
Posts: 257
Website

Re: Swifer: simple wifi connector tool with auto-connect features

I just did a git clone and ran make && sudo make install clean. I enabled swifer.service via systemctl. I then rebooted. swifer did not connect to my network. It used to at least get the name of the right network, and I would then manually use dhclient to actually connect to the network, but this no longer seems to work.

Here is my /etc/swifer.conf:

DHCP = dhclient

[NETWORKS]
70E36D

Am I missing anything obvious?

Offline

#12 2013-01-18 03:13:30

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,422
Website

Re: Swifer: simple wifi connector tool with auto-connect features

That is an odd problem, the dchp option shouldn't affect how it initially connects to networks.

Could you run swifer manually and see if it connects?

Tomorrow I'll get dhclient myself and start experimenting on my end.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#13 2013-01-18 09:49:07

hellomynameisphil
Member
From: /home/phil/Vancouver
Registered: 2009-10-02
Posts: 257
Website

Re: Swifer: simple wifi connector tool with auto-connect features

Interesting. Running swifer manually has no effect at all. This makes me think I'm about to have egg on my face because I am missing something horribly obvious, but I can't think of what it is.

None of 'swifer auto', 'swifer any', 'swifer autoconnect' or 'swifer verbose' produce much in the way of output and nothing in the way of results. 'any' and 'verbose' ask me to choose a network from the ncurses menu, but they don't seem to be doing anything at all to connect to networks; 'ip addr' shows no ip address, and conky doesn't show either the network name or an ip address. 'ping google.ca' of course outputs 'ping: unknown host google.ca'.

EDIT: I'm on Fedora, btw.

Last edited by hellomynameisphil (2013-01-18 09:49:42)

Offline

#14 2013-03-02 20:05:28

chickenPie4tea
Member
Registered: 2012-08-21
Posts: 309

Re: Swifer: simple wifi connector tool with auto-connect features

Sorry If I missed it but does it allow you to connect to WEP - I know WEP is a bit old but my wifi at home has to use it as my friends computer is still on WIN98 ! and that cant use WPA


You can like linux without becoming a fanatic!

Offline

#15 2013-03-02 21:09:30

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,422
Website

Re: Swifer: simple wifi connector tool with auto-connect features

As is, no it probably doesn't.  I have virtually no experience with WEP so I wouldn't know where to start.  But if you make it easy for me by outlining the steps you would take to manually connect to WEP networks, I'd be happy to implement options for those steps in swifer.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#16 2013-03-02 22:31:01

progandy
Member
Registered: 2012-05-17
Posts: 5,180

Re: Swifer: simple wifi connector tool with auto-connect features

Trilby wrote:

As is, no it probably doesn't.  I have virtually no experience with WEP so I wouldn't know where to start.  But if you make it easy for me by outlining the steps you would take to manually connect to WEP networks, I'd be happy to implement options for those steps in swifer.

This is an official example:
http://hostap.epitest.fi/gitweb/gitweb. … s/wep.conf


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#17 2013-03-02 22:59:50

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,422
Website

Re: Swifer: simple wifi connector tool with auto-connect features

I'm not really sure what to make of that example - how was it generated, where do those values come from?  The only documentation I can find for WEP are lines that say not to use it.  I'm sure I could search harder, but I don't have any need for it myself.

Again, I would be happy to build it in to swifer, but I'd need the actual steps one would take to connect manually.  Using wpa_supplicant with an existing configuration entry such as that one would only be the last step.  Swifier will already do that step quite well: just use `swifer add` then select the network, then manually edit the network config file for that network in /usr/share/swifer/.  From then on swifer would connect properly.

But to automate the generation of such a config file I'd need to know how it should be generated.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#18 2013-03-22 04:50:41

hiller_jim
Member
Registered: 2013-03-22
Posts: 3

Re: Swifer: simple wifi connector tool with auto-connect features

I'm not sure if I have ncurses issues or what, but the text is invisible when I run 'swifer any'.  I've tried this with both a ssh terminal from another Linux host (Fedora) and an ssh terminal from Putty (Windows).  I can do a copy/paste and pull the text into a text editor and it is there, but I see nothing on the ssh window.

For the record, I compiled and am running this on a pogoplug (ARM) and had no indication that there was a problem during the compile.  Obviously I have no organic video available so the only way I can see anything is via ssh.  I use other tools like lynx all the time over ssh and they all appear to display fine.

Should I try changing colors or something and recompile?

Thanks.

Offline

#19 2013-03-22 05:30:27

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,422
Website

Re: Swifer: simple wifi connector tool with auto-connect features

There should not be any output with `swifer any`.  The "any" parameter implies "auto" so the menu should not be displayed.

Do you get the menu if you just run `swifer` with no parameters?  What text are you able to copy and paste when you do `swifer any`?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#20 2013-03-24 04:10:33

hiller_jim
Member
Registered: 2013-03-22
Posts: 3

Re: Swifer: simple wifi connector tool with auto-connect features

Interesting.  I went in again just now to do a copy/paste and it pulls up the list of access points in glorious color.  Everything appears to be working fine now.  I'm trying to remember if I did a reboot after I installed it last time....

Anyway, 'swifer' and 'swifer any' appear to do the same thing:  pulls up a list of access points with the percentages next to them.  'swifer auto' returns: [swifer] no suitable networks found.  This is what I'd expect as I have saved no SSID/password pairs.

CTRL-C does not appear to work.  The only way I can bail out is to select one of the APs and then hit CTRL-C when it asks for the password.

I'll post more results as I play around with it.

Thanks.

Offline

#21 2013-03-24 04:46:00

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,422
Website

Re: Swifer: simple wifi connector tool with auto-connect features

Ah, there was a typo that made the "any" mode not work.  I don't use that option much, so I never caught it.  I just pushed the fix for that.

To quit, hit 'q'.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#22 2013-03-24 18:13:56

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: Swifer: simple wifi connector tool with auto-connect features

Question - is the 'reconnect' mode working yet? I noticed that in the service file the 'reconnect' lines are all commented out. That's the one thing netcfg never was able to do...automatically reconnect to a different network when I put the laptop to sleep then wake it up in a different location.

Thanks!
Scott

Offline

#23 2013-03-24 18:20:58

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,422
Website

Re: Swifer: simple wifi connector tool with auto-connect features

No.  Not quite. (edit: not in a way that has been tested).

All that's missing is an efficent way of checking whether the connection is still good.  I could do a popen("ping ...") and read the results - but this would just be ugly.  I've meant to look into a way of doing this - if anyone knows, let me know.

I can have it trigger a reconnect based on signal strength pretty easily.  But signal strength and connectivity are not the same.  One could have a strong signal from the router, but the router's network connection could be down.

EDIT: I just grabbed a bit of code from one of my other projects that should do the job well.  I just pushed the changes to git - but be warned, until I wander around with my netbook, I can't make any promises that this will work - nor can I promise it will not break in really ugly ways.

Reconnect only works in auto modes - it doesn't make much sense to reconnect in manual modes ... it'd have to open a terminal, display the menu, etc.  That will never happen.

Last edited by Trilby (2013-03-24 19:00:57)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#24 2013-03-24 20:19:45

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: Swifer: simple wifi connector tool with auto-connect features

Tested your changes...not working as of yet.
I used this line in  /usr/lib/systemd/system/swifer.service:

ExecStart=/usr/bin/swifer auto reconnect

enable and started swifer.service:

sudo systemctl status swifer
swifer.service - Simpler wifi connector tool
          Loaded: loaded (/usr/lib/systemd/system/swifer.service; enabled)
          Active: active (exited) since Sun 2013-03-24 12:59:24 PDT; 11min ago
         Process: 1040 ExecStart=/usr/bin/swifer auto reconnect (code=exited, status=0/SUCCESS)
        Main PID: 1855 (code=exited, status=0/SUCCESS)
          CGroup: name=systemd:/system/swifer.service
Mar 24 12:59:25 scotty dhcpcd[1855]: wlan0: acknowledged xxx.xx.4.152 from xxx.xx.5.1
Mar 24 12:59:25 scotty dhcpcd[1855]: wlan0: checking for xxx.xx.4.152
Mar 24 12:59:29 scotty dhcpcd[1855]: wlan0: sending IPv6 Router Solicitation
Mar 24 12:59:30 scotty dhcpcd[1855]: wlan0: leased xxx.xx.4.152 for 7200 seconds

Attached to normal wifi network (added to swifer), then attached to hotspot on phone (added to swifer), then suspended, shutdown the hotspot on my phone, then resumed (no connection achieved).

It doesn't look like there's any swifer process that stays running when the swifer.service is activated. Could that be the issue?

Scott

Last edited by firecat53 (2013-03-24 20:20:19)

Offline

#25 2013-03-24 21:35:40

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,422
Website

Re: Swifer: simple wifi connector tool with auto-connect features

I'm at home with a wired connection - so I can't do any of my own testing until tomorrow - but if you wish to do some testing, I'd suggest taking the service out of the equation - first see if swifer will reconnect.

Just do "swifer auto reconnect" from a terminal (as root or w/ sudo).  Then see if there is a swifer process after it is connected.  If there is turn off one of the networks and see if it switches.

As is, the problem could be service-file related, suspend-resume related, or process forking related.  My first goal would be to pinpoint which of the three is the problem.

EDIT: one likely issue is that swifer may currently exit if there are no suitable networks found during a rescan.  To check whether this is the issue, you could look in the stderr output.  Does stderr from service-file-launched programs go to journalctl?

EDIT: as an only partly related aside "reconnect auto" is no longer needed, the reconnect keyword implies auto, as it makes no sense to have a manual reconnect mode.

EDIT: I just pushed a change that fixed a foolish mistake in the execvp call.  I'd be surprised if this was the only problem preventing reconnect from currently working, but it was certainly one of them.  As a bonus (mistake in hindsight) I replaced two system() calls with execvp - I feel much better not opening a root shell just to stop current dhcp or wpa_supplicant processes.

Last edited by Trilby (2013-03-24 22:06:24)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB