This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new!


CLI Magic: Access your Bluetooth phone via the command line

By Duane Odom on February 26, 2007 (8:00:00 AM)

Share    Print    Comments   

Recently, I upgraded my cell phone to a Motorola RAZR v3 from T-Mobile, a Bluetooth-enabled device. I wanted to copy files to this device using my Laptop running Debian testing (Etch) using command line tools. I found what I needed in a package of Bluetooth tools and daemons called BlueZ.

After I installed bluez-utils with apt-get, I found a utility installed with the package named sdptool that speaks the Bluetooth Service Discovery Protocol. SDP provides for the discovery of services available on Bluetooth devices. Some common services available on cell phones are Dial-Up Networking for PPP connections, LAN for network connections, and OPUSH (Object PUSH) for sending files to a phone. The OPUSH service seemed to best fit my needs.

My phone does not broadcast its available services unless prompted to (for security reasons), so in the menu options of the phone, I enabled broadcast mode and ran sdptool search OPUSH to see if my phone provided Object PUSH and on which channel it was provided. My results were as follows:

Inquiring ...
Searching for OPUSH on 00:11:22:33:44:55 ...
Service Name: OBEX Object Push
Service Description: OBEX Object Push
Service Provider: /a/mobile/system/cl.gif
Service RecHandle: 0x10008
Service Class ID List:
 "OBEX Object Push" (0x1105)
Protocol Descriptor List:
 "L2CAP" (0x0100)
 "RFCOMM" (0x0003)
   Channel: 8
 "OBEX" (0x0008)
Language Base Attr List:
 code_ISO639: 0x656e
 encoding:    0x6a
 base_offset: 0x100
 code_ISO639: 0x6672
 encoding:    0x6a
 base_offset: 0xc800
 code_ISO639: 0x6573
 encoding:    0x6a
 base_offset: 0xc803
 code_ISO639: 0x7074
 encoding:    0x6a
 base_offset: 0xc806
Profile Descriptor List:
 "OBEX Object Push" (0x1105)
   Version: 0x0100

The line "Searching for OPUSH on 00:11:22:33:44:55 ..." told me that the command found my phone and that its network address was "00:11:22:33:44:55". The next line of interest was "Channel: 8" which told me that the OPUSH service was available on my phone on channel 8 via the RFCOMM protocol.

Now I was ready to copy a test file over to the phone. I used an application called obex_test from the bluez-utils package to push the test file to the phone. I provided the obex_test application with the address of my phone and the channel on which the OPUSH service was available with the command obex_test -b 00:11:22:33:44:55 8. After running the command, I was provided with a prompt. I typed the command c to connect to the phone, then issued the command p to give a put request and typed the path to the file to be uploaded -- /pics/tux.jpg -- and the name of the file as I wanted it to appear on the phone -- tux.jpg. The phone then prompted me to accept the incoming transfer. When it finished, I issued the command q to quit the session. The output of the session is shown below.

duane@thinkpod:~> obex_test -b 00:11:22:33:44:55 8
Using Bluetooth RFCOMM transport
OBEX Interactive test client/server.
> c
Connect OK!
Version: 0x10. Flags: 0x00
> p
PUT file (local, remote)> /pics/tux.jpg tux.jpg
name=/pics/tux.jpg, size=15811
Going to send 15811 bytes
Made some progress...
Made some progress...
Made some progress...
PUT successful!
> q

Using the obex_test application to start a new interactive session every time I wanted to copy a new file to my phone would be too tedious. After a quick search, I found a script called that serves as wrapper for the obex_test application, thus simplifying the process of moving files to the phone. The script takes the network address of the phone, the channel of the OPUSH service, and the path of the file to be pushed as its parameters. The command 00:11:22:33:44:55 8 /pics/tux.jpg accomplishes the same task as the interactive obex_test session above but makes executing and scripting this task much easier.

Users who are interested in transferring files from their phone to their computer using the command line may be out of luck. I had no problem telling my phone to send a file to my computer, but I was unsuccessful in finding a way to accept the file except by using a GUI -- specifically the gnome-bluetooth package. Once that package is installed, you can click on Applications -> Accessories -> Bluetooth File Sharing in the GNOME menu. You should see a Bluetooth icon appear in your system tray. When you tell your phone to transfer to your computer, a window should appear on your desktop asking you to accept the file. Tip: The accept window did not appear on top of the other windows on my desktop and it wasn't listed in the window list. I suggest minimizing all windows on your desktop before you perform the transfer so that the transfer accept window is easily visible.

If you find BlueZ useful, another interesting tool you might want to consider is btscanner, which scans for Bluetooth devices in range and extracts as much information as possible from a device without the requirement to pair with it. Also check out hcitool, which is included in the bluez-utils package. It provides information about the connection to a phone, such as link quality and signal strength, and allows you to configure things like connection encryption and authorization. As always, you should read the man page for each command.

Duane Odom is a computer programmer for the US Department of Defense and a freelance writer. He has been a Linux user since 2001.

Share    Print    Comments   


on CLI Magic: Access your Bluetooth phone via the command line

Note: Comments are owned by the poster. We are not responsible for their content.

Network share

Posted by: Anonymous Coward on February 26, 2007 07:09 PM
Cool, but a little bit complex.

I think it would be sweet if you could mount it as a network share.


Re: Network share

Posted by: Anonymous [ip:] on January 02, 2008 06:50 PM
oh yeah well screw you ~ by andre



Posted by: Anonymous Coward on February 26, 2007 07:10 PM
Wonder, if someone could use FUSE to make a virtual filesystem or something?



Posted by: Anonymous Coward on February 26, 2007 08:02 PM
<a href="" title="">obexfs</a>


sync, sync, sync

Posted by: Anonymous Coward on February 26, 2007 09:08 PM
In my day to day, this is probably the largest shortfall. Admittidly, it's probably more me than a limitation of Linux distros. Under Windows, my T5 was a duplication of outlook, my music and office documents. Motorola's software (why wouldn't they publish for non-win32? also?) makes my phone a second duplication of outlook. To keep both devices syncronized, I'm still limited to booting back to windows.

Anyone out there have some good websites on Linux/PalmOS or more Linux/Phone syncronization? Ideally, my PalmOS should sync calendar, tasks, contacts, documents, images, music, video.. those last three are not so bad with the Palm in flashdrivemode but the tasks/calendar/contacts sync still illudes me.


Are You Servious?

Posted by: Anonymous Coward on February 26, 2007 11:06 PM
(why wouldn't they publish for non-win32? also?)
Because they don't feel that the expenditure on development and support is worth the return for 5% or less of the market.

There is plenty of Palm OS sync support for Linux desktops out there. <a href="" title="">published an article last year</a> about it. Evolution, the Linux Outlook has Palm support built in. Google has page after page about Linux and Palm synchronization. For PalmOS support, choices abound!


Re:sync, sync, sync

Posted by: Administrator on March 02, 2007 10:02 PM
<a href="" title="">Jpilot</a> is possibly the best standalone Palm desktop app available for Linux. Definitely worth looking into.


Experiences with USB Bluetooth dongles on Linux

Posted by: Anonymous Coward on February 28, 2007 01:51 AM
I am using a super cheapo cellphone. I wanted to transfer my own graphics, mp3s, videos, and my own Java midlets for execution on the phone. I can put these on my Apache webserver, but my cell carrier charges me for bandwidth.

I knew Bluetooth would be zero cost. But what hardware to use? I researched, and found out that the official Bluetooth SIG does not allow anyone to designate anything as bluetooth compatible unless it has been certified by them for major bucks. Therefore, there is no official hardware compatibility list for Linux.

Here is my personal experience. I'm using a very ancient SuSE 9.1 (yeah, I know, I'm planning to upgrade to a shiny new Ubuntu in a few weeks). I thought that with such ancient software, there was little hope. I borrowed a friends USB Bluetooth dongle, and then tried the KDE Bluetooth Sync program. To my astonishment(!) it just worked! It found my phone. I could drag-drop files into it and click Send, then the phone would vibrate to tell me there was an incomming file.

Later, I bought my own different brand (Zoom) USB Dongle for about $20 at Microcenter. It also just worked. Furthermore, both dongles just worked on my partner's out of date Mac OS X system. No additional software needed. The stock OS just recognized it. I took my Zoom dongle in to work with me and tried it on Windows XP. It also just worked. This is stock Windows XP. I did not use any of the software that was included on the CD that came with the dongle.

Hope that experience helps. I expect that if you get a $20 Zoom usb bluetooth dongle, it will just work on Linux. YMMV. Hope that helps.



Copying files from cellphone to computer

Posted by: Anonymous Coward on February 28, 2007 02:26 AM
sdptool add --channel=10 OPUSH


Linux and Cell Phones Compatibility Overview

Posted by: Administrator on February 28, 2007 09:12 PM
TuxMobil provides a <a href="" title="">Linux and mobile cellular phones compatibility database</a>, which lists almost 500 different phones.


Send files from mobile to pc

Posted by: Anonymous [ip:] on August 17, 2007 10:22 AM
I managed to send files from my mobile to the pc with obexftpd -b -c /tmp, but for some reason this don't work anymore, my mobile disconnects immediately.
[Modified by: Anonymous on August 17, 2007 10:24 AM]


Re: Send files from mobile to pc

Posted by: princ3 on August 17, 2007 12:42 PM
Ok, found it out, you have to delete this directory:

rm -r /var/lib/bluetooth


CLI Magic: Access your Bluetooth phone via the command line

Posted by: Anonymous [ip:] on September 10, 2007 12:14 AM
this work! great article


CLI Magic: Access your Bluetooth phone via the command line

Posted by: Anonymous [ip:] on January 02, 2008 06:49 PM
hi im andre and im famous cause i just posted my name now people worldwide know my name


linux drivers for RAZOR V3 AS DIAL UP MODEM

Posted by: Anonymous [ip:] on February 19, 2008 01:52 AM
I am interested in trying ubuntu 6.10 as os in an old pc i try it and work excellent but i live in a rurak area and depend on my razr v3 as a modem . Do you know if there is drivers already written for this purpose . Actually i am using win xp an there is drivers for this os using the cel as a dial-up connection , fortune it is a flat rate by month .

thanks for any help


This story has been archived. Comments can no longer be posted.

Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya