Search This Blog

Sunday, April 24, 2011

Plasma NM: Bluetooth tethering

Two weeks ago Alex Fiestas contacted me for us to fix one of the often requested features in Bluedevil: tethering (use of a bluetooth device, usually a cell phone, to access the Internet wirelessly). Last year during Solid Sprint in Madrid he and Will Stephenson worked on that (I also helped) but we still did not figure out how to make it work as easily as possible. Well, we are getting close...

Tethering needs support from both Bluedevil and Plasma NM, and they must cooperate to a certain degree to register the connection in NetworkManager. After some research and some answers from the NetworkManager's guys we finally got the information we needed. Most of the needed code went to Plasma NM and Solid, the Bluedevil part was already almost done.

To keep the story short here is the screenshot of a tethering connection in Plasma NM:



Things to notice:

  1. I am using a bluetooth icon for the network interface, which is logical since NetworkManager identifies it as bluetooth. The only problem is that it can get mixed up with the Bluedevil icon in systray. Maybe someone can create a different icon, volunteers? ;-)
  2. The "Unknown" word in connection name refers to the unknown access technology used. It seems ModemManager is not able to get that information, I will try to figure out if there is another way to get that. Update: ModemManager works with bluetooth devices, the problem is that Plasma NM assumed that ModemManager's objects always existed when there was a NetworkManager object associated to it, which is not true for bluetooth devices. Bluetooth devices always have a NetworkManager object associated to them but the ModemManager object only exists if the org.bluez.Serial.Connect method has been called. The consequence is that Plasma NM is not notified (via Qt's signals) when there is a change in the bluetooth's ModemManager object properties. I will try to fix that in the future. Update2: problem fixed :-)




Here some other things to notice:
  1. System Name works for a serial (ppp) connection! :-) This was an old bug in Plasma NM, the usual NM method to get the interface name returns the serial device (/dev/ttyACM0, /dev/ttyUSB0, etc). The traffic graph also did not work for the same reason. I added a hack to force Plasma NM to always use ppp0 as interface name for all serial devices (Dial-up modem, Gsm/Cdma phones, Bluetooth). Well, now I do not need the hack because NM-0.8.2 can give me that information. Unfortunately the support for that is going to be available only in KDE SC 4.7.0.
  2. For the same reason access technology is not reported, neither are the operator's name and the signal quality. The "Enable" status also comes from ModemManager, if there is no way to get those information I will remove them from interface details in the future. Update: problem source detected, just need some time to fix it.  Update2: problem fixed :-)
  3. Yes, mobile broadband in Brazil can be very slow in some places, actually in most cities, even in some neighborhoods in big cities. There are places where it is indeed fast, usually in big cities and some fortunate cities, that is not my case :-/ Here where I live I can get a little above 260 kbps in 3G (220 kbps in 2G) at best for a 300 kbps plan. I do not even bother to get get a faster plan because most operator's networks cannot keep up to the speed and the ones which do are expensive enough to make them not viable :-/

What is still missing:

  1. Cdma phones's bluetooth support (in both Solid and Plasma NM).
  2. PAN (bluetooth's Personal Area Network) support for both Gsm and Cdma phones. Those two is going to take time since my phone is not compatible with Cdma nor PAN. Update: PAN implemented for Gsm phones :-) Actually the service that the phone must support is NAP (Network Access Point) and not PAN. Or PAN always comes with NAP, I am not sure.
  3. Without the bluetooth patch to Solid's NetworkManager backend that is going to be in 4.7.0 Plasma NM will recognise bluetooth interfaces as gsm. The consequence is that Plasma NM mixes Gsm and Bluetooth connections but NM refuses to use pure Gsm connections with Bluetooth interfaces. With the patch in place Plasma NM can distinguish between Gsm and Bluetooth connections. For instance, I have registered one Bluetooth and one Gsm connection in Plasma NM, but only the Bluetooth one is shown in the screenshots above.
  4. Update: Another consequence is that no gsm connection detail (operator's name, signal quality, access technology) is available without the Solid's patch.
  5. No, for now there is no way to use the same registered connection with the same phone connected through USB and Bluetooth. You have to create one connection to be used when the phone is connected through USB and another connection when the phone is connected through Bluetooth.
  6. When the bluetooth controller is active and there is a bluetooth connection registered the bluetooth interface is always shown, even when phone's bluetooth is disabled. That is the way NM works.
  7. Some lines of code in Bluedevil to call Plasma NM to register a bluetooth connection when a bluetooth device has just been paired.
  8. More testing.

For the braves who wants to try the Solid patch:
  1. Get the patch against 4.6.2 here: http://git.reviewboard.kde.org/r/101172
  2. Recompile kdelibs and kde-workspace. Recompiling kdelibs is needed because of the ABI changes in Solid. I had some crashes in kded4 until I recompile kdelibs.
  3. Recompile Plasma NM:
  4. git clone git://anongit.kde.org/netwokmanagement
  5. mkdir networkmanagement/build
  6. cd networkmanagement/build
  7. cmake -DCMAKE_INSTALL_PREFIX=/usr ..
  8. make
  9. make install
Update: Bluedevil 1.2 is going to support launching networkmanagement_configshell to create the bluetooth connection, so you will not need to use any command line. All Plasma NM released since 0.9.0 support bluetooth tethering:



If you still wants to lauch it yourself follow these instructions:
  1. Execute: $(kde4-config --path exe --locate networkmanagement_configshell) create --type bluetooth --specific-args "00:11:22:33:44:55 dun" . Pay attention to the quotes (") in "00:11:22:33:44:55 dun", they are required.
  2. Change 00:11:22:33:44:55 to your phone's bluetooth hardware address. You can get it in Bluedevil. Update: Change dun for nap if you want that service.
  3. In a few seconds Plasma NM's Mobile Connection Wizard window should appear and you can finish registering the connection.
  4. After that you can go the Plasma NM window and the connection should be there. Just click on it to connect to the Internet.
You can edit/delete the bluetooth connection in Plasma NM even without the Solid's patch.

30 comments:

bulldog98 said...

I would suggest an mobilephone with an bluetooth icon as an overlay for the Plasma NM icon.

IAnjo said...

Thanks for all your work on NM.

I have a small suggestion: maybe when ModemManager cannot find out the technology, just hide the (Unknown) display on the connections list and display only the phone name.

If a user wants to check, he/she can always go into the details and see that it is unknown.

Lamarque said...

@bulldog98, the mobile phone used in gsm connections does not work goot with overlays, there would be too much details to distinguish the overlay if the icon is small, like the ones in system tray.

@IAnjo, that is a good idea. The access technology is very important for mobile connections. 2G connections can go only about 200 kbps, 3G can go above 1 mpbs, if its a big difference and most users wanted to know if they are in 3G mode.

Magnus Lundborg said...

For a long time I have looked forward to an easy way to do this. Thank you very much for the hard work you have put into improving NM.

Anonymous said...

great work but I have interface issue - traffic graph is something out of the blue, it doesn't fit to good to the other NM GUI

Anonymous said...

Great work you are doing with Network Manager integration into KDE! Thanks for all the time you put into this project.

Are there any plans to get VPN support rolling with non-saved passwords? It is really annoying to edit the configuration, enter my onetime password, save the configuration and only afterwards connect;-) Maybe I am doing something wrong though... are there additional pieces needed to get the password prompts?

Lamarque said...

@Magnus Lundborg, thanks.

The traffic graph is something I like in Plasma NM.

VPN one-time password works with Cisco VPN (VPNC), which is the only I test myself. I do not have access to other types of VPN networks to do tests.

Nikos Platis said...

Hello, thanks for all the work on plasma-nm.

Unfortunately I am having several problems with recent git versions of plasma-nm. Before I ask more specific questions, two general ones:

1) How do I erase all settings/info used by plasma-nm and NM (system and user settings)? I would like to try a fresh start.

2) It would probably be a good idea to setup a forum topic somewhere to provide support for plasma-nm, provided that you (and other developers) would like to devote some time to it.

Lamarque said...

@nplatis, 1) For Plasma NM:
1. Remove the plasmoid from panel
2. Disable the kded daemon: qdbus org.kde.kded /kded /unloadModule networkmanagement
3. rm -irf \
~/.kde/share/config/networkmanagement* \
~/.kde/share/apps/networkmanagement
4. Open kwalletmanager, open the default wallet and delete the "Network Management" directory in there. Warning: this will delete all wireless network encryption keys if you are using kwallet. If you are not using kwallet deleting the files in ~/.kde/share/config will delete the encryption keys.

For NM I think it suffices to delete the system connections's directory, in my system it is /etc/NetworkManager/system-connections . Keep in mind that you wil also delete the "Auto eth0" system connection, so wired connections will not work until you recreate one wired connection.

About the forum I rather prefer that you fill entries in bugs.kde.org.

Chris said...

can you please make it so easy as in windows ?

(click teather on the cellphone, windows automatically finds the connection , installs drivers and connects...)

:/

Lamarque said...

@Chris, that part should be done in Bluedevil. Plasma NM deals with network only. Detecting and configuring the bluetooth devices/services is Bluedevil's responsability.

What I did is create a way for anyone (Bluedevil included here) to register bluetooth connections. Now we need to change Bluedevil to detect if the phone is capable of NAP, DUN or both and ask the user which one of them he/she wants to configure. The rest is executing networkmanagement_configshell.

The bug entry for that is http://bugs.kde.org/261191

procuste said...

on my suse 11.4 and kde 4.6.3 I tried your $(kde4-config --path exe --locate networkmanagement_configshell) create --type bluetooth --specific-args "00:1D:FD:2A:BD:14 dun"
it starts the wizard, register the connection, but plasma networkmanager don't show me any possibility to connect with broadband, Thanks for everything you are doing :-))

procuste said...

Broadband connections could be made by bluetooth and usb, what do you think about this two icons to indicate them??
http://www.4shared.com/photo/53eftO47/phone_and_usb.html
http://www.4shared.com/photo/5PaOvBrS/phone_and_BT.html
bye and thanks for everything you are doing :-)

Lamarque said...

@Procuste, I think you need to apply the patch I mentioned in the post. I thought it would work without it but it seems the patch is needed. The icons are interesting, when I have more time I will try them.

Tomasz Dudzik said...

The plasmoid UI still sucks! really. What da hell do we need the interfaces stuff here? This isin't nice. The plasmoid should only show the list of the wifi networks or the current connection. And what is the 'show more' button doing there. Same thing for the 'enable' and 'wireless' checkboxes. This should go to the KCM. Sorry for those hard words, but i can't stand it anymore. This UI is crap! Hope you get that for your heart and make it simple for home users. Advanced users should take a look at the KCM :)

Lamarque said...

@Tomasz Dudzik said, I am the wrong guy to complaint about Plasma NM's GUI. I did not create it and I do not intent to change it anytime soon. Besides:

1. Be more polite with someone who is working for free;

2. The interfaces are there to access interface details info (name, IP address, traffic graph, etc);

3. Plasma NM is not a wifi only application;

4. The "Show More" button is there to help wifi users, if you only care about wifi access you should have figured out that by now;

5. The same for the "Wireless" checkbox, it is pretty obvious to understand why all the "Enable" checkboxes are there;

6. "This should go to the KCM": do not talk like a "I am the usability guy" to a hacky guy like me, that argument do not work with people like me;

7. I am an advanced user! I work with computers because I like it and have studied for that (M.Sc in Computer Science). I hack KDE source code, the kernel or any program when something do not work for me (well, when I have time actually). Personally I do not care if any GUI is crowed with buttons, checkboxes, combobox, etc as long as they do what they are proposing to do without bugs. I try to create my programs as easy to operate as possible too, but that takes time and a lot of testing, so give some credit for who created Plasma NM's GUI.

Please do not use words like "Advanced users should take a look at the KCM" with me. You do not need to talk about people like me like we were insignificant. It is also possible to create good programs taking usability into account without sacrificing advanced users.

I also do not see Plasma NM's GUI as bad as you are trying show. However, since I am not going to change it any time soon there is no point in talking about it with me. Anybody can change Plasma NM's GUI as long as he/she do not break what is already working.

scroogie said...

Tomasz Dudzik: Come one, why don't you just go and create a minimalistic "WiFi Manager" widget? Attacking a volunteer is really bad style, even more so if you don't have a clue what you're talking about. Such comments always remind of the "poisonous people" talk by Google:

http://video.google.com/videoplay?docid=-4216011961522818645

grawcho said...

great work ... i was waiting for this feature for sisx months. however i have an issue with one of my machines i installed KDE 4.7 after released (bluedevil 1.1 dosn't support this automaticly) and using the command line you suggested dose not prompt plasmaNM connection wizard nor dose it add a bluetooth option to the applet. suggestions? and may i say again ... great work (i have been working around this with rfcomm and vwdial manually) so BIG THANKS from israel

Lamarque said...

What phone do you use? In the command

$(kde4-config --path exe --locate networkmanagement_configshell) create --type bluetooth --specific-args "00:11:22:33:44:55 dun"

The quotes (") in "00:11:22:33:44:55 dun" are required, did you type them? You have only one bluetooth controller, right? networkmanagement_configshell searchs for the device only at the default bluetooth controller, if you have only one controller then it is the default one too.

Anonymous said...

I want this functions
http://www.connectify.me/
sorry for link but my english is bad
for you is possible in kdenetwork?

Lamarque said...

You can already do something very similar to that, read: Plasma NM: connection sharing.

gldickens3 said...

Hi Lamarque,

The KDE 4.7 announcment stated that bluetooth tethering is now available with KDE 4.7 as follows from the announcement:

"The Plasma Workspaces now also offer much improved network management, including experimental support for NetworkManager 0.9 as well as Bluetooth tethering, 3G, VPN, MAC spoofing and other advanced networking options."

However, I don't see any options for Bluetooth tethering in the bluedevil or network manager applets. So, could you explain how to do bluetooth tethering in KDE 4.7. One would think that bluetooth tethering would be straight forward since it was included prominently in the KDE 4.7 announcement.

I am running OpenSUSE 11.4, KDE 4.7, plasmoid-networkmanagment 0.9.svn1192577-7.2 and bluedevil 1.0.2-3.8.1.

Thanks,

Gordon

Lamarque said...

@gldickens3, you need Bluedevil 1.2 for it to work out of the box, otherwise you need to launch networkmanagement_configshell at the command line. All of this is stated in my and afiestas' posts.

gldickens3 said...

Hi Lamarque,

I have run networkmanagement_configshell from the command line several times but the connection never shows up in the NM. I am running plasmoid-networkmanagment 0.9.svn1192577-7.2. Should this version of NM support bluetooth DUN? Also, where do I get a copy of Bluedevil 1.2? I don't see it in any repo including unstable:Playground or Distro:Factory.

Thanks,

Gordon

Lamarque said...

@gldickens3, no, 0.9.svn1192577-7.2 uses a snapshot from November of last year, that's too old. You need to use OpenSuse's unstable packages:

http://lists.opensuse.org/opensuse-kde/2011-05/msg00035.html

Version 0.9.1git20110722 is also available, so you can use it version instead of 0.9.1git20110503.

Bluedevil 1.2 has not been released yet, the package bluedevil-1.1.git.1312126724-11.1.i586.rpm is a snapshot that seems to include the support. You can search for it with http://software.opensuse.org/search?q=bluedevil+1.1&baseproject=openSUSE%3AFactory&lang=en&exclude_debug=true

You need to choose one of the package that fits better for you configuration: i586 (32-bits) or x86_64 (64-bits).

gldickens3 said...

Hi Lamarque,

Thanks for the detailed info! I will be trying out the NM and bluedevil versions that you recommended and I will let you know how it goes. Unfortunately, due to other commitments, it may be a few days before I can report back.

Gordon

gldickens3 said...

Hi Lamarque,

I installed both versions of the plasmoid-networkmanagement applets that you recommended, however, after rebooting or logging out/in neither plasmoid-networkmanagement applet will appear in the system tray. When I open System Tray Settings > Entries then Network Management does not appear. However, when I open System Tray Settings > Display then the Network Manager does appear under "Extra Items" but it is unchecked and when I check it then it will not save it as checked. In otherwords, the other applets do not work since I cannot get them to appear in the system tray.

Any recommmendations?

Thanks,

Gordon

Roberto said...

It's very "interesting" that on a Kubuntu 12.04 I still need to manually issue the networkmanagement_configshell create --type bluetooth --specific-args "00:11:22:33:44:55 nap" to have NM create the connection...

Did they break something during an upgrade as usual (I'm running 4.9) or...?

Lamarque said...

@gldickens3, if the checkbox does not keep checked then probably the Plasma NM's kded module is failing to load, look in the ~/.xsession-errors for any possible error message.

@Roberto, I do not know. I, for one, do not use Kubuntu. If they ship an old version of Plasma NM then that can explain this problem since there is a race condition in older versions. The current version is 0.9.0.6.

Oleksandr Lemberg said...

Hello
Wizard do not starting after adding DUN device via Bluedevil, and even manualy.
Only pop up notice appearing: "Setting…"
KDE 4.11 Bluedevil 1.3~ NM 0.9.8 NM kde libs 0.9.0.8