Bluetooth for Your Mobile Phone
How to connect your computer with your mobile phone under Linux; how to exchange phone numbers, SMS-messages, phone call entries and your calendar; how to synchronize time with your cellphone.
|external links:||develop programs for Nokia cellphones under Linux|
|environmentally friendly electronics producers|
Before we can start to exchange data with our mobile phone we need to activate the wireless interface of our computer in order to enable Bluetooth first which can usually be done by a switch or handle at the side of the notebook. You will have to activate Bluteooth or your IR-interface on your cellphone as well. When using the infrared interface it is important that both devices are within eye-contact that means that no obstacle must be between the cellphone and the computer and that both devices are adjusted within a straight line like at a light barrier.
On a Nokia 6230 f.i. infrared can be activated via favourites → infrared and Bluetooth via menu → settings → connections → Bluetooth → Bluetooth on. Therupon the IR or Bluetooth symbol will appear at the upper left edge of the display. After finishing with your data transfer and synchronization it will be better to deactivate Bluetooth again because it consumes power and so that no unauthorized people can try to crack your cellular phone. We will prefer to treat the usage of Bluetooth over infrared in the following because it is the newer interface and more easy to handle (no 'eye-contact' necessary).
Now we will go on with pairing Bluetooth devices. In order to make two Bluetooth devices exchange data, they need to establish a mutually authenticated connection first. This can be achieved by entering an arbitrarily agreed upon password (i.e. one that is the same) on both devices. The coupling will persist even after turning the power off and on again until one of the users deltes the pairing explicitly. Exactly this issue can lead to problems on trying to re-establish the connection. Whenever the pairing was deleted on one device the other device still believes the pairing to be in good order yet. Before re-establishing a Bluetooth pairing the coupling has to be deleted on both devices before explicitly.
If everything goes well the pairing will even be initiated by your desktop surface and the user just needs to enter the same code two times. Whenever this should not work automatically or whenever the user wants to exclude another source of errors it will be necessary to care about Bluetooth pairing manually:
The program blueman-applet from the blueman package enters the system tray of your task bar. It can be used to delete old couplings (devices → right click on the device → delete). If you click on the search button under devices then it should discover your mobile phone as long as the bluetooth settings of your phone make it discoverable. A right click on the newly discovered device and selecting ‘couple’ will initiate a new pairing. Do not forget to delete the pairing on your cellular before initiating a new Bluetooth pairing (Nokia 6230: menu → settings → connections → Bluetooth → paired devices → »device« → options → delete authentication). If this does not work try to initiate the pairing from your cellular phone by setting ‘discoverable’ in the blueman system tray applet to on ( paired devices → »device« → options → pair a new device).
For console freaks the discoverability of the computer can be switched on by a hciconfig hci0 piscan and switched off again by a hciconfig hci0 noscan. The program simple-agent (formerly passkey-agent) from the bluez-test-scripts package can be used to manage entering the PIN on your computer if the desktop environment (blueman) should not manage to do so (gunzip simple-agent.gz; chmod +x simple-agent; cp examples/bluezutils.py .). Alternatively you can use bluetoothctl:> bluetoothctl [bluetooth]# agent DisplayYesNo/KeyboardOnly Agent registered [bluetooth]# scan on Discovery started [CHG] Controller 00:22:5F:5C:BB:15 Discovering: yes [CHG] Device BC:B1:F3:F5:C9:D7 RSSI: -65 [bluetooth]# info BC:B1:F3:F5:C9:D7 Device BC:B1:F3:F5:C9:D7 Name: GT-I9100 … [bluetooth]# pair BC:B1:F3:F5:C9:D7 [CHG] Device BC:B1:F3:F5:C9:D7 Connected: yes [agent] Enter passkey (number in 0-999999): 488002 [bluetooth]# paired-devices Device BC:B1:F3:F5:C9:D7 GT-I9100 [bluetooth]# remove BC:B1:F3:F5:C9:D7 [DEL] Device BC:B1:F3:F5:C9:D7 GT-I9100 Device has been removed [bluetooth]# paired-devices [bluetooth]# help …
The following has proven to be practical for putting Bluetooth in operation: "hciconfig -a" provides information about your Bluetooth interface as soon as the hardware switch for enabling Bluetooth has been turned on or at least as soon as you plug in your Bluetooth-USB stick. Then, if your mobile phone is up and running "hcitool scan " needs to view your cellular. At last you can retrieve information about supported protocols and services via sdptool search FTP/DUN/... (DUN: Dial Up Network - dial in with your cellular).> hciconfig -a hci0: Type: USB BD Address: 00:10:60:D1:00:D3 ACL MTU: 310:10 SCO MTU: 64:8 UP RUNNING RX bytes:8532 acl:62 sco:0 events:181 errors:0 TX bytes:1463 acl:33 sco:0 commands:71 errors:0 Features: 0xff 0xff 0x8f 0xfe 0x9b 0xf9 0x00 0x80 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH HOLD SNIFF PARK Link mode: SLAVE ACCEPT Name: 'linux-k7n1-0' Class: 0x4a010c Service Classes: Networking, Capturing, Telephony Device Class: Computer, Laptop HCI Ver: 2.0 (0x3) HCI Rev: 0xc5c LMP Ver: 2.0 (0x3) LMP Subver: 0xc5c Manufacturer: Cambridge Silicon Radio (10) > hcitool scan Scanning ... 00:0E:ED:52:74:5C Nokia elm > sdptool search FTP Inquiring ... Searching for FTP on 00:0E:ED:52:74:5C ... Service Name: OBEX File Transfer Service RecHandle: 0x10001 Service Class ID List: "OBEX File Transfer" (0x1106) Protocol Descriptor List: "L2CAP" (0x0100) "RFCOMM" (0x0003) Channel: 10 "OBEX" (0x0008) Language Base Attr List: code_ISO639: 0x656e encoding: 0x6a base_offset: 0x100 Profile Descriptor List: "OBEX File Transfer" (0x1106) Version: 0x0100
Wammu is a comfortable and widely used GUI-frontend for Gammu. Get yourself started after clicking through the customization dialogues specifying the Bluetooth address of your cellular which you have retrieved by a hcitool scan before. It is very simple to download your phone number list, your SMS-messages and calls realized or slipped away. "Synchronize Time" may also be practical if you do not want to enter time and date every time you have run out of batteries. There are various facilities for sending SMS like for making your text bold or italic. In deed there has to be enough space on your cellular to store the SMS-message you wanna send. This is a difference towards XGnooki and KMobiletools which can send messages directly. The only way to export SMS-messages is to convert them into E-mail or XML-format. Otherwise you can only save all of your data in binary format.
Unfortunately I have run out of time in testing alternative Gammu-frontends like GammUI, Kammu, GnomeGammu und QtPhoneSync (all of them for Linux) or the GAMMU graphical user interface for Windows.
If it is all about downloading and storing data as plain text from your mobile phone then you may better directly use Gammu without any frontend.> gammu getallsms >all.sms # backupsms(/restoresms) add. deletes SMS from phone > gammu backupsms all-backup.sms # -all & -yes um alles mit ja zu beantworten Delete each sms after backup? (ja/nein/IMMER/EINMAL/NIE) nein Backup sms from folder "Eingang" (SIM)? (ja/nein/IMMER/EINMAL/NIE) ja Backup sms from folder "Gesendete Obj." (SIM)? (ja/nein/IMMER/EINMAL/NIE) ja Backup sms from folder "Eingang"? (ja/nein/IMMER/EINMAL/NIE) ja Backup sms from folder "Gesendete Obj."? (ja/nein/IMMER/EINMAL/NIE) ja Backup sms from folder "Gespeicherte"? (ja/nein/IMMER/EINMAL/NIE) ja Backup sms from folder "Vorlagen"? (ja/nein/IMMER/EINMAL/NIE) ja > gammu backup contacts.vcf Strg+C drücken, um zu unterbrechen... Überprüfe das Telefonbuch des Telefons Backup phone phonebook? (ja/nein/IMMER/EINMAL/NIE) ja Reading: 100 Prozent > gammu backup calender+todo.vcs Strg+C drücken, um zu unterbrechen... Überprüfe Telefon-Kalender Checking phone todos
The data will be stored as directly readable text which can also simply be parsed. "vcf" & "vcs" are standardized file formats which can be read by any application. However direct import into Thunderbird or KAddressBook has not yielded working results. When downloading SMS-messages getallsms produces a textually better readable format while the backup format corresponds to a format designed for Gammu which has been thought to recover your messages at a later time.
XGnokii constitues another alternative towards Wammu/Gammu. In order to make it run under openSUSE 11.2 I had to configure the /var/lock-directory with "user"-rights and I had to edit the gnokiirc. By principle you could adapt the /etc/gnokiirc to your needs. Nonetheless it is more simple to create your own ~/.gnokiirc alike.~/.gnokiirc [global] port = 00:0E:ED:52:74:5C model = 6230 connection = bluetooth
For 'port' you have to insert the Bluetooth address of your mobile phone detected by hcitool scan. 'Model' is the make of your cellular; in this case a Nokia 6230. By principle you could edit /etc/gnokiirc for this purpose. However I wanna discourage you from doing so because this file is very hard to comprehend due to the many comments so that you may quickly enter port and model in the wrong place. "~/.gnokiirc" on the other hand only knows one global configuration section. This needs to be followed by furnishing /var/lock with user rights as XGnokii did not start without this provision when being tested.> ls -ld /var/lock/ drwxrwxr-t 6 root root 4096 19. Jan 12:36 /var/lock/ > chgrp users /var/lock/ > ls -ld /var/lock/ drwxrwxr-t 6 root users 4096 20. Jan 19:46 /var/lock/
If things should not work with a direct Bluetooth connection Gnooki can also be configured to operate with the /dev/rfcomm0-interface like shown in the next section.port = /dev/rfcomm0 model = AT connection = serial rfcomm_channel = 1
XGnokii features SMS, calendar and contact support. Address book entries can be added and re-transmitted onto your cellular. SMS-messages from your cellular can be downloaded with "Messages → Activate SMS reading". Even more you can send SMS-messages with your cellular fromout of your computer.
The export of phone numbers is done in CSV (comma separated value) format which can be read more easily than the .vcf format of Gammu. Unfortunately SMS-messages can only be exported one by one.
Many programs like KMobileTools require that you establish a special Bluetooth connection in advance. This is among other things especially necessary for modem dial-up. The tool "rfcomm" (Radio Frequency Communication) fits this purpose. It emulates a serial line interface. That way you have to specify the Bluetooth address of our cellular determinded via hcitool scan first.> rfcomm release 00:0E:ED:52:74:5C; Can't release device: No such device > ls /dev/rfcomm* ls: Zugriff auf /dev/rfcomm* nicht möglich: Datei oder Verzeichnis nicht gefunden > rfcomm bind 0 00:0E:ED:52:74:5C 1 > ls /dev/rfcomm* /dev/rfcomm0 > rfcomm show 00:0E:ED:52:74:5C rfcomm0: 00:0E:ED:52:74:5C channel 1 clean
In order to leverage the usage of our rfcomm-connection by user programs like KMobileTools, Wammu (Gammu frontend) and XGnokii (Gnokii frontend) we will have to make the device file write- and readable for the user. This can be achieved by adding the rfcomm* device file to the dialout group. You will have to log out and in again to get the change in group access privileges honored by applications (You may try to run them from a new bash instance as well.).> ls -l /dev/rfcomm0 ls: Zugriff auf /dev/rfcomm1 nicht möglich: Datei oder Verzeichnis nicht gefunden > ls -l /dev/rfcomm0 crw-rw---- 1 root dialout 216, 0 19. Jan 12:07 /dev/rfcomm0 > groupmod -A elm dialout > groups # als User ohne Root-Recht users www audio at video vboxusers # logout & login; oder: su $USER als root > groups users www dialout audio at video vboxusers
As you can see the device is now part of the group dialout. However it means that user programs like KMobileTools can not access it unless you have successfully joined the dialout group (groupmod).
KMobileTools is another very convenient GUI-application. It relies that the emulation for a serial line interface has already been established (see: rfcomm - Create and Approve rfcomm Device Files). SMS-messages can be conveniently edited and sent by your mobile phone. Very interesting is the »Browse SMS« function which enables you to browse a list of all SMS on your cellular in order to select and download singleton SMS-messages of interest. The download of all SMS is done by storing them directly as plain text (in complement to the tagged storage of Gammu) which is only separated by hyphenated lines. The function to browse the telephone book has unfortunately not worked with the Nokia 6230 by a former test.
Many desktop environments do automatically offer bluetooth:/, obex:/ or obexftp:/ protocol support to be entered in the address bar for browsing Bluetooth devices. Under the KDE version distributed with openSUSE 11.2 this mode of communication was unfortunately not availabel. It can also happen that by using a browser with the specified protocol not all folders which are available via direct obexftp will be shown. ObexFTP is absolutely necessary to be used for downloading photos from your cellular phone because all the frontends discussed and reviewed up to now can only synchronize addresses, calendar entries and SMS-messages.
ObexFTP is a small and neat command line tool to easily transmit data like photos between cellular phone and computer. If the infrared interface (-i) should not be used by default the -b or the -t /dev/rfcomm0 option has to be given (see: Create and Approve an rfcomm Device). No matter whether you connect directly or via the rfcomm interface a new connection will be established for every invocation of the obexftp command. In order to avoid having to confirm the new connection every time you can select menu → settings → connections → Bluetooth → paired devices → »your device» → options → acknowledge connection → No with a Nokia 6230.
Because of the fact that re-establishing a new connection on every invocation is slow or even cumbersome you will get used to issueing several obexftp commands at once: -c »dir« changes the current directory and -l corresponds to ls while -g »file« makes up a GET (download) and -p »file« a PUT (upload). Hence you must not exchange the order of options given. The following example shows how to extract the file names out of an XML-directory listing in order to download all the files at once.> obexftp -b -l -c / Scanning for (null) ... Found: 00:0E:ED:52:74:5C Browsing 00:0E:ED:52:74:5C ... Connecting...done Receiving "(null)"...\ <!DOCTYPE folder-listing SYSTEM "obex-folder-listing.dtd" [ <!ATTLIST folder mem-type CDATA #IMPLIED> ]> <folder-listing version="1.0"> <folder name="Galerie" created="20030101T000000" user-perm="R" mem-type="DEV "/> </folder-listing> done Sending ""... done Disconnecting...done > obexftp -b -c /Galerie -l 2>&1 | egrep "<(folder|file) name" <folder name="" user-perm="RW" mem-type="MMC"/> <folder name="Fotos" created="20030101T000000" user-perm="R" mem-type="DEV"/> <folder name="Videoclips" created="20030101T000000" user-perm="R" mem-type="DEV"/> <folder name="Musikdat." created="20030101T000000" user-perm="R" mem-type="DEV"/> <folder name="Grafiken" created="20030101T000000" user-perm="R" mem-type="DEV"/> <folder name="Töne" created="20030101T000000" user-perm="R" mem-type="DEV"/> <folder name="Aufnahmen" created="20030101T000000" user-perm="R" mem-type="DEV"/> > obexftp -b -c /Galerie/Fotos | sed -n 's#.*file name="\([^"]*\)".*#\1#p' >files.lis > obexftp -b -c /Galerie/Fotos $(sed -s "s#^#-g #" <files.lis) Scanning for (null) ... Found: 00:0E:ED:52:74:5C Browsing 00:0E:ED:52:74:5C ... Connecting...done Sending ""... Sending "Galerie"... Sending "Fotos"... done Receiving "Bild000.jpg"...\done Receiving "Bild001.jpg"...\done Receiving "Bild002.jpg"...|done Receiving "Bild003.jpg"...\done Receiving "Bild004.jpg"...\done ... > obexftp -b -c /Galerie/Grafiken $(obexftp -b -c /Galerie/Grafiken -l | sed -n 's#.*file name="\([^"]*\)".*#-g \1#p') ... Receiving "Dots4.jpg"...-done Receiving "Flower.jpg"...|done ... > modprobe ircomm-tty > ls /dev/ircomm ircomm0 ircomm11 ircomm14 ircomm17 ircomm2 ircomm22 ircomm25 ircomm28 ircomm30 ircomm5 ircomm8 ircomm1 ircomm12 ircomm15 ircomm18 ircomm20 ircomm23 ircomm26 ircomm29 ircomm31 ircomm6 ircomm9 ircomm10 ircomm13 ircomm16 ircomm19 ircomm21 ircomm24 ircomm27 ircomm3 ircomm4 ircomm7 > irattach /dev/ttyS1 -s
Sich über das Handy mit dem Computer ins Internet einwähen zu können ist sicherlich eine der nützlichsten Funktionen eines guten Mobiltelephons. Um zu testen ob ihr Mobiletelephon DialUpNetworks unterstützt geben sie wie in Abschnitt "Informationen vom Mobiltelephon abfragen" »sdptool serch DUN« ein. Hierfür ist es zuerst notwendig eine Serielle Schnittstelle /dev/rfcomm0 zu emulieren. Das Programm, das wir zur Einwahl verwenden werden ist wvdial. Hier eine Beispielkonfiguration von /etc/wvdial.conf für GPRS unter Orange:
Internet dial-in with your cellular is for sure one of the most useful features of your mobile phone. In order to find out whether your mobile phone supports DialUpNetworks just enter »sdptool serch DUN« like described in the chapter about "Querying Information from Your Mobile Phone" . At first you will have to establish a serial line interface emulation like described at 'Create and Approve a /dev/rfcomm0 Device'. The program you will use for dial-up is wvdial. Here is a sample configuration for /etc/wvdial.conf for GPRS under Orange:[Dialer GSM] Init1 = ATZ Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 Init3 = AT+CGDCONT=1,”IP”,”wap.orange.at”,"",0,0 Modem = /dev/rfcomm0 Phone = *99# Username = wap Password = wap New PPPD = yes ISDN = no BAUD = 115200 Stupid Mode = yes Carrier Check = no [Dialer GPRS] Phone = *99# Stupid Mode = 1 Inherits = BluetoothMobile Username = orange Password = wap
By now you can already dial in with wvdial GPRS. In order to obtain a working internet connection you will usually still have to configure routing with ip route change/add default via »myip« and you will have to configure a proxy server. You can get the IP-address for ppp by a simple ip route. Proxy servers are to be configured at /etc/sysconfig/proxy with openSUSE. The right configuration options for proxies can be found on your cellular (services → settings → connection settings → show active service settings → primary/secondary proxy). It may be useful to write an on short script to accomplish these tasks (wvdial; wait for ppp + routing & proxy configuration). In order to dial-up via modem it may be necessary to verify that the smpppd process is running.
While Bluetooth will work out of the box with a traditional Nokia, Alcatel, Motorola, BenQ/Siemens or a cellular of one of the many other producers you will have to retrofit Bluetooth support for the Apple iPhones and Android Phones via the Appstore. Bluetooth is officially just supported for the headset of the iPhone.
Nonetheless there are different possibilities for internet dial-up via the Android platform by so called tethering apps; may it be via Bluetooth, USB or WLAN. Even though Android smartphones are said to support contact synchronization via Google mail accounts the function does however need to remain bounded to Google mail accounts. The disadvantage about Google mail accounts is that you can not contact support in case of problems which is a severe disadvantage for professional and security affine users. Moreover not everyone wants Google to posess his personal contact data. Without a GMail registration you will however even be excluded from the Appstore.
The fact that Android is a Linux based platform is of little help in here because there are proprietary device drivers, goodies and a development environment, which can not be translated offhand with free software. Someone who does really estimate the freedom of Linux may buy an Ubuntu, Mozilla, or a Meego/Maemo smartphone.