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.

Thursday, April 14, 2011

Plasma NM: bugs fixed after 4.6.2

Update: I am going to work more on nm09 branch from now on. The number of people complaining about poor NM-0.9 support is increasing. Unfortunately I am also very busy on other things now so I will have to slow down on Plasma NM bugfixing.

Following my last post about bugs fixed in Plasma NM, here is the list of bugs fixed after 4.6.2 release date (April 6th) and before 4.6.3 release date (May 6th):

209673: Improve 802.1x certificate handling for WPA PEAP connections.
253362: Try to limit the auto-expanding width code used to accomodate the traffic plotter in interface details widget.
258246: dont't show hiddenWirelessNetworItem by default, show it only if showMore is checked or wireless interface details are activated.
257920: Enable setting of custom routes.
270827: Add IPv6 support.
272140: Set timestamp for system connections.
272135: Hover all connections associated to a network interface instead of just the first one found.
272138: Fix problems when changing connection's scope from user to system and vice-versa. Be warned that changing connection's scope is not well tested yet.
272174: Disables connection's hover state when entering interface details tab.
209624: Add Bluetooth Network Access Point (NAP) tethering support for Gsm phones. Thanks Rajeesh K. Nambiar for implementing the patch and testing it with his iPhone 3GS.
264083: Try to unlock (PIN/PUK) and enable modem before connecting to Gsm connections. Also PIN is now one-time only.
194899: Add button in wireless connection editor to copy the current access point's MAC address to BSSID field.
268021: Add notifications for VPN connections.
. Uses KAuth (KDE's Policy Kit wrapper) to authorize users to create/delete/modify system connections.
. Load networkmanagement kded's module on plasmoid startup to make sure it is loaded.
271768: Show notification to warn user if he/she tries to connect when networking or wireless is disabled.
271767: Automatically show other connections in main window if there is no preferred network available.
271765: Add button to configure notifications directly from networkmanager settings.
259351: Avoid dangling pointer when setting signal strength for an access point C++ object that has just been destroyed
253584: Avoid dangling pointer when deleting RemoteInterfaceConnection.
203584. Bluetooth tethering support for Dial-up Network (DUN), tested with my phone (Samsung i8910). CDMA will take more time since I do not have a compatible cell phone to do tests.
. Show essid and MAC address of the active accesspoint in wireless interface details.
249016: Enable additional addresses even on DHCP.
271353: Try harder not to resize the "show more" button. Also all connection widgets do not change its height when toggling "show more" button.
. Fix crash when stopping NetworkManager-0.8.2.
. Various fixes for adhoc support.
204340: Add systemwide connection support for NM 0.8. Many thanks to Gökçen Eraslan and Andrey Borzenkov for working in this patch. There are still some glitches to fix but it mostly works. One problem I noticed happens if NetworkManager is using the ifnet plugin, then one system connection is changed to user connection and back to system connection. The final connection will not be listed until NetworkManager is restarted. This problem does not happen with the keyfile plugin.
270901: Do not show notification for appearing/disappearing access points if already connected to one.
. Monolithic knetworkmanager is unmaintained. Its code is not compiled by default. Please use the plasmoid instead.
. Fix autoconnect sometimes being disabled without user request when connection is explicitly disconnected by the user.
. Fix autoconnect setting not saved after editing connection settings.


We also have a proposal patch for adding IPv6 support to Plasma NM, which would close bug 270827. Well, not everybody have a real IPv6 network (no IPv4 tunneling, IPv6 DHCP server) available to test this patch, so if anybody with such network could test it the patch's author (Ilia Kats) and me would appreciate. Update: patch commited, now we need more real world testing.

Update: last week I confirmed Ilia Kats' KDE developer account and now he is a Plasma NM developer, congratulations :-)  That is the least I could do after all the important work he is doing for Plasma NM, such as the ad-hoc fix and IPv6 support among others.

Tuesday, April 5, 2011

Plasma NM: connection sharing

Now that the ad-hoc wireless bug has been fixed it is possible to share wired or 3G connection through wireless. To create a shared connection:

  1. Create an ad-hoc connection:
  2. Click on the connection in Plasma NM window and wait.
  3. This dialog will appear, just fill in the passphrase and click Ok:
  4. Wait some seconds and the ad-hoc AP will be started:

I was able to browse the web using my cell phone. The WirelessSharing connection did not appear when I scanned the neighborhood, I had to write the essid manually. Using my current notebook as gateway I was able to connect my old notebook to the Internet too.