[ Prev ] [ Index ] [ Next ]

mobile phone

Created Thursday 28/12/2006

This document describes connecting a Sony Ericsson k608i phone to Fedore Core linux using OpenOBEX. The document is not actually distribution specific and is not even really all that specific to the k608i as the libraries and software for accessing the phone are OpenOBEX, Obexftp and Obexfs and should be applicable to most late generation mobile phones.

1. Connecting the k608i

Connect the Nokia k608i to a usb port using the usb data cable provided with the phone. Hal and hotplug should detect the phone is attached and identify it through syslog(1). The following shows example hotplug log messages when the device is connected. Consult your syslog.conf configuration for file locations, but most typically these will appear in /var/log/messages:

Dec 6 3:43:07 joslyn kernel: usb 4-4.3: new full speed USB device using ehci_hcd and address 21
Dec 6 3:43:07 joslyn kernel: usb 4-4.3: device descriptor read/64, error -32
Dec 6 3:43:07 joslyn kernel: usb 4-4.3: device descriptor read/64, error -32
Dec 6 3:43:07 joslyn kernel: usb 4-4.3: new full speed USB device using ehci_hcd and address 22
Dec 6 3:43:07 joslyn kernel: usb 4-4.3: device descriptor read/64, error -32
Dec 6 3:43:07 joslyn kernel: usb 4-4.3: configuration #1 chosen from 1 choice
Dec 6 3:43:07 joslyn kernel: cdc_acm 4-4.3:1.1: ttyACM0: USB ACM device
Dec 6 3:43:07 joslyn kernel: cdc_acm 4-4.3:1.3: ttyACM1: USB ACM device

This shows a single full speed (usb 2.0) device has been attached and is available on the ACM0 and ACM1 tty's (see section 2 for data access). The device descriptor errors can be ignored for now.

Linux treats usb-connected mobile phones like modems and so assigns a tty. The full tty access path of /dev/ttyACM0 and /dev/ttyACM1 would be required for applications using the modem/serial line internface.

Sofware like obexftp is able to use a usb identifier rather than a tty.

2. Device attribute identification

The properties of a connected mobile device can be established with a combination of lsusb(1), and udevinfo(1). First of all determine the usb bus and device id allocated to the phone:

bash # lsusb
Bus 004 Device 021: ID 0fce:d017 Sony Ericsson Mobile Communications AB K608i Phone
Bus 004 Device 012: ID 05e3:0702 Genesys Logic, Inc. USB 2.0 IDE Adapter
Bus 003 Device 003: ID 054c:0069 Sony Corp. Memorystick MSC-U03 Reader
Bus 002 Device 003: ID 045e:008a Microsoft Corp. Wireless Keyboard and Mouse
Bus 001 Device 005: ID 1110:9021 Analog Devices Canada, Ltd (Allied Telesyn)

In the previous lsusb(1) output, there is a Sony Ericsson k608i attached to usb bus 004, device 021. Next, dump the udev database with udevinfo(1) and extract out the udev class:

bash # udevinfo -e
P: /class/usb_device/usbdev4.18
N: bus/usb/004/018
P: /class/usb_device/usbdev4.21
N: bus/usb/004/021
P: /class/usb_device/usbdev4.3
N: bus/usb/004/003
P: /class/usb_device/usbdev4.6
N: bus/usb/004/006

In the above udev export, the path device path /class/usb_device/usbdev4.21 is allocated to the k608i mobile phone on bus 004/021. This path can then be used to extract the device attributes, again using udevinfo(1):

bash # udevinfo -a -p /class/usb_device/usbdev4.21

Which will print a huge list of all the devices attributes and capabilities. This information can then be used to create udev rules or indeed establish whether or not the device can be used at all.

3. Data Transfer with openOBEX

Use OpenOBEX and obexftp for data transfer. There were problems with openobex 1.1 but recompiling openobex v 1.3 (with dependent files like bluez and bluez-lib-devel) made it possiblet to compile obexftp 0.2. The obexftp test should work (see #3A and #3B)

3A. Test and identify usb interface

Test the Sony Ericsson K608i is accessible via usb by plugging the phone into a usb port (usb 2.0 port is fine) and then run the following obexftp command (if there are permission or device access problems, run the command as root or setup udev permissions):

bash # obexftp -u
    Found 1 USB OBEX interfaces
    Interface 0:
            Manufacturer: Sony Ericsson
            Product: Sony Ericsson K600
            Interface description: Sony Ericsson 600i USB WMC OBEX Interface

This shows that there is a single device on the OBEX interface identified by the OBEX usb interface id "0". Note that this interface id must be used with the -u for usb connection mode. A modem tty connection can also be specified. This can be done by specifying the tty identified in the messages log. For example, the syslog messages in #1 show that a sony ericsson mobile device is available on tty devices ACM0 and ACM1. these are accessible as /dev/ttyACM0 and /dev/tty/ACM1

A data tranfer test can then be performed by requesting a directory listing. This is done with the --list (or -l) option which should also be run as root (or setup udev permssions):

bash # obexftp -u 0 -l
    Connecting...done
    Receiving "(null)"... <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE folder-listing SYSTEM "obex-folder-listing.dtd">
    <!--
     XML Coder, Jul 20 2005, 02:57:52, (C) 2001 Sony Ericsson Mobile Communications AB
    -->
    <folder-listing version="1.0"><folder name="Pictures"/>
    <folder name="Sounds"/>
    <folder name="Themes"/>
    <folder name="Videos"/>
    <folder name="Other"/>
    </folder-listing>
    done
    Disconnecting...done

Operations for accessing and putting files on the sony ericsson k608i should then be possible. Refer to the following url for more information on data access with obexftp: http://openobex.triq.net/devices/sony-ericsson#sonyericsson_k610i

3B. List phone contents

The directories on the phone can be established using obexftp(1)'s --list (or -l) option. Without any arguments or with / as the argument, the --list option shows the contents of the root directory. Simple append directory names to show directory content. For example, in the connection test, the sony ericsson on usb device 0 showed that the root directory contained a "Pictures" directory. To list this:

bash # obexftp -u 0 -l /Pictures
    Connecting...done
    Receiving "/Pictures"... Sending ""... done
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE folder-listing SYSTEM "obex-folder-listing.dtd">
    <!--
     XML Coder, Jul 20 2005, 02:57:52, (C) 2001 Sony Ericsson Mobile Communications AB
    -->
    <folder-listing version="1.0"><parent-folder/>
    <file name="Speaker.gif" size="71560"/>
    <file name="Sony Ericsson.gif" size="55602"/>
    <folder name="Us"/>
    </folder-listing>
    done
    Disconnecting...done

and so on.

3C. Transfer from the phone

To transfer a file from the phone to the local disk, use obexftp(1)'s --get (or -g) option. Provide the fully qualified pathname. In the directory listing example of #2.A, the /Pictures directory contains a file called "Speaker.gif". To retrieve this file use the -g option with the fully qualified case sensitive pathname, like so:

bash # obexftp -u 0 -l /Pictures/Speaker.gif

Another way to transfer files from a directory is to specify the directory name with the -c option and the file with the -g option, which can take multiple files (note that wildcards do not work with obexftp):

bash # obexftp -u 0 -c /Pictures  -g Speaker.gif Sony\ Ericsson.gif

4. Gui tools

The openOBEX and obexftp tools are driven by the command line. There are gui tools like obextool and ObexFS (which integrates with nautilus for those using gnome). Start the obextool with the following, so that it is able recognise the phone,

bash $ OBEXCMD="obexftp -u 0" obextool
bash $ obextool --obexcmd "obexftp -u 0"

Urls for obextool can be found at http://www.stud.uni-karlsruhe.de/~ubq7/debian which is based on the doco at http://wiki.splitbrain.org/nokia_6630) and at http://www.tech-edv.co.at/programmierung/obextool/en/detail.html.

5. Mount/Automount Phone

The Sony Ericsson K608i phone filesystem can be mounted using a combination of fuse(1) with associated libary fuse-lib and obexfs. In fact obexfs is a thin wrapper round fuse. Installation is via a tarball at present and be sure to install obexfs 0.10 or later as 0.8 does not include usb integration. Once obexfs (>= 0.10) has been compiled and installed, the phone can be mounted using one of the #5A, #5B or #5C options below.

The obexfs tarball can be downloaded from http://openobex.triq.net/downloads

5A. mount

To be able to mount the phone maually, using mount(1), ensure that the appropriate udev permissions are set or run as privileged user. Users that are allowed to mount the phone should be added to the fuse group:

/etc/group entry:
    fuse:x:104:foo

For manual mount, create a directory to act as the mount point and ensure that it's group id is fuse and that it has write permission:

bash # mkdir -p /media/k608i
bash # chgrp fuse /media/k608i
bash # chmod g+w /media/k608i

Manually mounting the phone is now possible. The following examples are variations on the same theme and manually mount the phone on the OBEX usb device id 0 to /mnt/k608i:

bash # mount -t fuse obexautofs# /mnt/k608i
bash # mount -t fuse "obexfs#-u" /mnt/k608i
bash # obexfs -u 0 /mnt/k608i

5B. fstab

Entries for /etc/fstab follow the same style as for the manual mount examples given in #4.A. In the following there are 2 different forms. The obexautofs entry performs automatic device discovery and mounts the discovered device to the indicated location. The obexfs entry mounts the device at the specific OBEX usb device id 0. The following is an example /etc/fstab entry (choose either obexautofs# which does discovery, or obexfs is for is 0):

obexautofs#   /media/k608i    fuse    allow_other    0 0
obexfs#-u0    /media/k608i    fuse    allow_other    0 0

By default only the user mounting with fuse can see the filesystem. That is why the option allow_other is needed if you mount this as the root user. In addition, the user_allow_other entry must be set in /etc/fuse.conf for this option to used. This is a potential security flaw. To allow an unprivileged user to mount, use the following instead:

/etc/fstab entry (choose one "obexautofs" does discovery, "obexfs" is for id 0):
obexautofs    /media/k608i      fuse  user    0 0
obexfs#-u0    /media/k608i      fuse  user,fsname=obexfs#-u0    0 0
The ‘fsname’ option is needed to allow users to umount the fs. 

5C. autofs

The automounter can be used to mount a phone device as well. Again, ensure that appropriate udev permissions are set or run as privileged user. Add the following entries to add to /etc/auto.misc (again, the device is assumed to be on OBEX usb device id 0):

/etc/auto.misc entries:
    obex        -fstype=fuse,allow_other    :obexautofs#
    myobex      -fstype=fuse,allow_other    :obexfs#-u0

By default only the user mounting with fuse can see the filesystem. That is why the option allow_other is needed. It might be a security risk.

5D. Unmounting

To unmount the phone device, use fusermount(1). For example, if the phone is mounted to /media/k608i, then it can be unmounted with:

bash # fusermount -u /media/k608i

6. Motorola V3 Razr

The Motorola V3 RAZR series of mobile phones, such as the V3X, are GSM capable and identify, via lsusb(1), when connected via the usb data cable as Motorola PCS A835 GSM Phone. Connecting this particular phone is pretty much the same as for the sony ericson k608i with the difference that the phone can connect either by the ttyACM interface or as a scsi disk, much like a flash or memory stick,

6.A Connecting the V3X as ttyACM

Ensure that the usb data connection type for the phone is set to Data Connection. This setting changed from the menu path Settings-Connection-USB Settings. The two options are Memory Card and Data Connection. For ttyACM choose Data Connection from this submenu and then connect the phone with the usb data cable. Syslog should identify as per #2, above, showing something similar to:

Jun  5 22:40:42 jacquelyn kernel: usb 5-2: new full speed USB device using uhci_hcd and address 5
Jun  5 22:40:43 jacquelyn kernel: usb 5-2: configuration #1 chosen from 1 choice
Jun  5 22:40:43 jacquelyn kernel: cdc_acm 5-2:1.0: ttyACM0: USB ACM device
Jun  5 22:40:43 jacquelyn kernel: usbcore: registered new interface driver cdc_acm
Jun  5 22:40:43 jacquelyn kernel: drivers/usb/class/cdc-acm.c: v0.25:USB Abstract Control Model driver for USB modems and ISDN adapters

And lsusb(1), should identify the phone as:

bash $ lsusb 
Bus 007 Device 001: ID 0000:0000  
Bus 006 Device 001: ID 0000:0000  
Bus 005 Device 005: ID 22b8:3002 Motorola PCS A835 GSM Phone

Next, do foo

6.B Connecting the V3X as flash driver

Ensure that the connection type for the phone is set to Memory Card. This is done from the main menu, choosing Settings-Connection-USB Settings and then selecting Memory Card. After changing the usb setting, connect the phone with a usb data cable. Syslog should identify the phone similar to:

7. Openobex and Bluetooth

The obenobex library and obexftp can be used to connect via bluetooth. Ensure that the obex library and obexftp are installed. At the time of writing, the obex driver and toolsuite that are packaged as rpm's work fine and can be installed via yum with:

bash # yum install openobex-apps.x86_64 obexftp.x86_64 openobex.x86_64

At the time of writing, yum installs obenobex 1.3.5 and obexftp 0.22-02. The -b option of obexftp can be used as a discover mode. Be sure that the bluetooth device to be discovered is actually discoverable (also try as priviledged if permission problems occur during discovery):

bash # obexftp -b
Scanning ...
Using   00:12:37:D6:B8:0C       Motorola V3x
Browsing 00:12:37:D6:B8:0C ...
Channel: 9

Authenication note: The bond/pair process will ask for a pin on the phone and the bluez applet will ask for an authenication passphrase. Simply enter the same value for each. E.g., 0000 on the phone and 0000 in the bluez applet

The UUID assinged to the discovered device in the above example is 00:12:37:D6:B8:0C. This entry is put in the bluetooth hidd directory /var/lib/bluetooth. Determine what services are offered by the previously discovered device:

bash # sdptool browse 	00:12:37:D6:B8:0C
Browsing 00:19:63:53:D3:CC ...
Service Description: Sony Ericsson K750
Service RecHandle: 0x10000
Service Class ID List:
  "PnP Information" (0x1200)
Service Name: Dial-up Networking
Service RecHandle: 0x10001
Service Class ID List:
  "Dialup Networking" (0x1103)
  "Generic Networking" (0x1201)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 1
Profile Descriptor List:
  "Dialup Networking" (0x1103)
    Version: 0x0100
...[snip]...
Service Name: OBEX File Transfer
Service RecHandle: 0x10006
Service Class ID List:
  "OBEX File Transfer" (0x1106)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 9
  "OBEX" (0x0008)
Profile Descriptor List:
  "OBEX File Transfer" (0x1106)
    Version: 0x0100
...etc

A Directory listing can be done if the uuid and the OBEX File Transfer channel are known. Scan the sdptool(1) output looking for the OBEX File Transfer service section. In the previous output, this is listed as channel 9. Now that the now that the uuid and channel are known the directory listing option of obexftp can be used (note the -B option specified the channel)

bash # obexftp -b 00:12:37:D6:B8:0C -B 9 -l
Browsing 00:12:37:D6:B8:0C ...
Channel: 9
Connecting...done
Receiving "(null)"...|<?xml version="1.0" ?>
<!DOCTYPE folder-listing SYSTEM "obex-folder-listing.dtd">
<folder-listing>
<parent-folder />
<folder name="picture" size="0" type="folder" modified="20050102T000018Z" user-perm="RW" />
<folder name="video" size="0" type="folder" modified="20050102T000018Z" user-perm="RW" />
<folder name="audio" size="0" type="folder" modified="20050102T000018Z" user-perm="RW" />
</folder-listing>
done

As shown in the above listing, a "picture" subdirectory exists. Doing an ls(1) on this directory, gives something like:

bash # obexftp -b 00:12:37:D6:B8:0C -B 9 -l /picture
Browsing 00:12:37:D6:B8:0C ...
Channel: 9
Connecting...
done
Receiving "/picture"... Sending ""... done
/<?xml version="1.0" ?>
<!DOCTYPE folder-listing SYSTEM "obex-folder-listing.dtd">
<folder-listing>
<parent-folder />
	<file name="03-05-07_1753.jpg" size="170222" type="image/jpeg" modified="20070503T175134Z" user-perm="RW" />
</folder-listing>
done

To get a file, use obexftp with the -g (fetch files) option:

bash # opexftp -b  00:12:37:D6:B8:0C -B 9 -l /picture/03-05-07_1753.jpg

8.B Nautlius integration

Open nautlius and choose Open location and enter obex:/// for the url. Using a url of obex:/// within Nautilus should cause any bonded/paired devices to appear in list of discovered devices, like so:

8.C rfcomm, nfs and mounting a bluetooth device

Now bind to the device so that we can use obex push to send files to the device. Note the channel number 9, which is also identified in the initial obexftp -b device discovery operation:

bash # rfcomm bind /dev/rfcomm0 00:12:37:D6:B8:0C 9

Then check the device status:

bash # rfcomm
rfcomm0: 00:12:37:D6:B8:0C channel 9 clean 

The hcitool app can provide more information about a device. This tool operates in a similar way to sdptool in that the device uuid is feed into the tool, which then produces information on the device. The hcitool scan option is like obexftp -b discovery:

bash # hcitool scan
Scanning ...
        		00:12:37:D6:B8:0C       Motorola V3x
bah # hcitool info  00:12:37:D6:B8:0C 9
Requesting information ...
        BD Address:  00:12:37:D6:B8:0C
        LMP Version: 2.0 (0x3) LMP Subversion: 0xe1b
        Manufacturer: Texas Instruments Inc. (13)
        Features: 0xff 0xff 0x2d 0x78 0x18 0x18 0x00 0x80
                <3-slot packets> <5-slot packets> <encryption> <slot offset> 
                <timing accuracy> <role switch> <hold mode> <sniff mode> 
                <park state> <RSSI> <channel quality> <SCO link> <HV2 packets> 
                <HV3 packets> <u-law log> <A-law log> <CVSD> <power control> 
                <transparent SCO> <enhanced iscan> <interlaced iscan> 
                <interlaced pscan> <inquiry with RSSI> <AFH cap. slave> 
                <AFH class. slave> <AFH cap. master> <AFH class. master> 
                <extended features> 

To release the device: bash # rfcomm release /dev/rfcomm0

See also: http://www.des.udc.es/~mpquique/HOWTO/en-txt/Bluetooth-Howto.txt

9. Mounting devices with P3nfs

See http://www.koeniglich.de/p3nfs.html

TODO: More info on P3nfs needed here ▨

10. K750i

The Sony Ericsson K750i is an integrated phone with 2.0 megapixel digital camera, polyphonic sound and video and basic internet support. It also supports a memory stick duo. The sony erricsson site has a bunch of addons, themes and downloads, see http://www.sonyericsson.com.au/fun. The IMIE number of the phone can be determined by typing *#06# on the phone keypad.

The phone's memory stick can be mounted as a disk device by using the supplied data cable, which connects via usb. The memory stick can be written to by an external source (i.e., as a mounted filesystem) but there is a special directory structure required by the phone.

The K750I's IMIE number is 353440601679478812 http://se.md/cip3/dl/03881429

11. Urls/Doco

Documentation and tarballs for OpenOBEX, obexftp and obexfs can be found at the following:

Todo lists and further reading

Stuart Moorfoot 28 Dec 2006 foo@bund.com.au


No backlinks to this page.