Sunday, May 11, 2008

Bluetooth: Command-line

Bluetooth

Devices with Bluetooth include phones, PDAs, keyboards and mice.

Package(s)

Subsystem

  • bluez-utils / bluetooth - www.bluez.org - tools and system daemons for using Bluetooth devices. Provides ciptool, dund, hcitool, hidd, l2ping, pand, rfcomm, sdptool.
  • bluez-firmware - this firmware is required for operation of Bluetooth dongles based on the Broadcom BCM203x 'Blutonium'chipset [non-free]. This is for Linux 2.6 kernels, for Linux 2.4 kernels the package was called bluez-bcm203x [contrib].
  • bluez-cups - www.bluez.org - Bluetooth printer driver for CUPS
  • bluez-pcmcia-support - www.bluez.org - support for PCMCIA Bluetooth adapters. As it depends on both Bluetooth and pcmciautils I only recommend this if you specifically have a Bluetooth PCMCIA adapter.

GNOME

  • bluez-gnome - bluez.sourceforge.net - provides Bluetooth preferences and a GNOME applet for prompting when a Bluetooth passkey (PIN) is required. The applet pops up in the system tray when you insert a Bluetooth device and provides access to the Bluetooth preferences. Log out and back in again for this to take effect. This package is installed by the virtual package bluez-passkey-gnome.
  • gnome-bluetooth - tragically not included in Debian 4.0/Etch. It's available in Debian Testing and will be included in Debian Lenny.
    The gnome-bluetooth package includes gnome-obex-server (for receiving files) and gnome-obex-send (for sending files). gnome-bluetooth-manager (for configuring Bluetooth devices) is planned for future inclusion in gnome-bluetooth; you can see the plans for it at live.gnome.org/GnomeBluetooth.

    There's an unofficial repository where you can get gnome-bluetooth, nautilus-sendto, libgnomebt0 and libbtctl4 by adding the following repository source for Debian Testing and Unstable, not Stable (though in April 2007 I found the testing package to work with Debian 4.0/Etch) (I don't know if these people are trustworthy or not): deb http://download.tuxfamily.org/osrdebian testing gnome-bluetooth. Their key is available at download.tuxfamily.org/osrdebian/index.html.
  • nautilus-sendto - an updated version of Ubuntu's nautilus-sendto that includes Bluetooth support, as opposed to ther version already included in Debian

File Transfer

  • obexftp - command-line file transfer utility for devices that use the OBEX protocol (think-future.de/wiki/index.php?title=Bluetooth)
  • obexpushd - command-line utility for receiving files via Bluetooth or IRDA (how does this differ from obexserver?)
  • ussp-push - Client for OBEX PUSH - allows you to send objects using the OBEX PUSH protocol. The OBEX PUSH protocol is used to transfer files to a mobile device, generally via Bluetooth or IrDA. The protocol does not allow any other action than sending and generally requires less strict authentication, which is why it is sometimes preferred to the OBEX FTP protocol (which allows full filesystem access and is provided by the obexftp package).
  • I don't recommend openobex-apps because it is "the example applications ... they aren't intended for normal use..."

Miscellaneous

  • bluemon - Activate or deactivate programs based on Bluetooth link quality. BlueMon monitors the quality of the link to a Bluetooth device and can start or stop programs when the threshold drops below a certain value. This can be used to perform actions like locking the terminal when you walk away from it.
  • bluez-hcidump - www.bluez.org - allows the monitoring of Bluetooth activity using the hcidump program. Useful for troubleshooting.
  • btscanner - Bluetooth traffic scanner similar to Kismet for wireless

Configuration

The version of Bluetooth you're using can make a big difference. For a list of improvements in successive Bluetooth versions (i.e. faster speed, lower power consumption) see en.wikipedia.org/wiki/Bluetooth#Specifications_and_features. To check which version of Bluetooth you're using, look for the 'LMP version':

  • For the remote device: hcitool info . You should see something like: LMP Version: 2.0 (0x3) LMP Subversion: 0x6cc
  • For the local adapter: # hciconfig -a or hciconfig hci0 version. You should see something like: HCI Ver: 1.1 (0x1) HCI Rev: 0x175 LMP Ver: 1.1 (0x1) LMP Subver: 0x175

GNOME

bluez-gnome provides Desktop → Preferences → Bluetooth Preferences which you use to configure the mode of operation, adapter name and class of device.

Command-line

Bluetooth service manipulation: /etc/init.d/bluetooth start, /etc/init.d/bluetooth stop and /etc/init.d/bluetooth restart

Set the device name in /etc/bluetooth/hcid.conf.

Check whether the Bluetooth adapter is up and running:
hcitool dev
You should see the adapter device name and MAC address.

Troubleshooting

There is a list of supported hardware at www.bluez.org/hardware.html.

If you have trouble connecting look in /var/log/syslog.

Usage

Examine your Bluetooth adapter

Using the command-line

Examine all connected adapters:
hciconfig -a.

Using GNOME

This isn't currently possible with GNOME, it is planned for inclusion in GNOME Bluetooth Manager.

Scan for remote devices

Using the command-line

Get the MAC address and name of available devices:
hcitool scan

Using GNOME

This isn't currently possible with GNOME, it is planned for inclusion in GNOME Bluetooth Manager. However you can get something like this when sending a file where you choose the device to send to.

Ping a remote device

Using the command-line

# l2ping

Using GNOME

This isn't currently possible with GNOME, it is planned for inclusion in GNOME Bluetooth Manager which will be included in the gnome-bluetooth package.

Bond / pair with a device

You can bond with devices such as Bluetooth keyboards or phones.

Using the command-line

Connect to the device:
# hcid connect

Setting a PIN/passkey using the command-line isn't supported so use the GNOME PIN helper, bluez-gnome, whose bonding dialog should appear in the GNOME Notification Area.

Using GNOME

If you have the bluez-gnome package's Bluetooth Applet running in the Notification Area it will prompt you for a PIN when a device tries to connect. You cannot initiate a connection from the Bluetooth Applet. Initiation will be possible with the forthcoming GNOME Bluetooth Manager.

Service discovery of devices around you

Using the command-line

sdptool browse

Using GNOME

This isn't currently possible with GNOME and it doesn't look as though it's planned to be part of the forthcoming GNOME Bluetooth Manager.

Serial connections

Users must be in group 'dialout' to have privileges to use these devices.

Using the command-line

Some features require the Bluetooth device to appear as a traditional serial interface.

Create /dev/rfcomm0 bound to port 3 (the dial-up networking port) on a remote device:
# rfcomm bind 0 3

Check how the rfcomm ports are setup:
rfcomm

Release /dev/rfcomm0:
# rfcomm release 0

Using GNOME

This is planned for inclusion in the forthcoming, as yet unwritten, GNOME Bluetooth Manager.

Transfer files from a device to a computer

Using the command-line

Run obexpushd and it will sit there waiting for files to be sent from the device, which it saves to the current working directory.

Using GNOME

This requires the gnome-bluetooth package. Run Applications → Accessories → Bluetooth File Sharing. This will provide a Notification Area applet. Send a file to the computer, the file will be saved to the desktop and a dialog will appear asking whether you want to open or delete the file. You may have to set the mode of operation by right-clicking on the Bluetooth Notification Area applet and choosing 'Visible and connectable for other devices'.

Transfer files from a computer to a device

Using the command-line

ussp-push @10 (assumes the OBEX File Transfer channel is 10, which you can check with sdptool browse )

Using GNOME

This requires gnome-bluetooth and the updated nautilus-sendto not available in the stock Debian. You right-click on a file and choose 'Send To...' and are able to choose Bluetooth from the 'Send as...' list and the device from the 'Send to...' list.

Internet access through a GPRS or 3G / W-CDMA phone for a computer

See Internet access through a GPRS or 3G / W-CDMA phone from a computer over Bluetooth

Internet access through a computer for a phone

See www.howtoforge.com/bluetooth_pand_debian_etch

Linux Unwired by Roger Weeks, Edd Dumbill, Brian Jepson: www.oreilly.com/catalog/lnxunwired/

Connect a Bluetooth keyboard

Initiate the process from the computer.

Using the command-line

(the Debian documentation mentions loads of patches but i didn't need them to get it working)

# hidd --connect

Though you can provide the pin using the command-line, the documentation warns against it, so use the GNOME PIN helper bluez-gnome. The bonding dialog appears in the GNOME Notification Area, you type the key in there, then type it on the Bluetooth keyboard and press [Enter].

Using GNOME

I Don't see how it can be initiated from the computer using GNOME, without the proposed GNOME Bluetooth Manager which isn't yet available, so initiate it from the keyboard.

Connect a Bluetooth mouse

Initiate this from the computer.

Using the command-line

# hidd --connect

Using GNOME

This isn't currently possible with GNOME, it is planned for inclusion in GNOME Bluetooth Manager which will be included in the gnome-bluetooth package.

Further Information

wiki.debian.org/Bluetooth

Bluetooth accesspoint with Debian GNU/Linux

With a cheap USB bluetooth dongle, you can make your computer act as a bluetooth access point. It is best to get a class 1 device, which will give at least a range of 100 meters unobscured, and will go through 1 or 2 concrete walls or ceilings. Setting it up under Debian, or any other distro is not trivial. As this took me a while, I decided to document the process.

When you use Bluetooth for network services (as opposed to wireless microphone, wiresless mouse, etc), you are using its PAN, or Personal Area Network profile. PAN is provied by the PAN daemon, pand, from the bluez-utils package. PAN uses the BNEP protocol. BNEP stands for Bluetooth Network Encapsulation Protocol.

Kernel configuration

Get a recent 2.6.x kernel, and enable the following features, either as module or built-in:
  • CONFIG_BRIDGE_NETFILTER
  • CONFIG_BT
  • CONFIG_BT_L2CAP
  • CONFIG_BT_RFCOMM
  • CONFIG_BT_BNEP
  • CONFIG_BT_HCIUSB

Debian packages

Install the following Debian packages:
  • bridge-utils (for brctl)
  • bluez-utils (for pand)

Configuration files

  • Edit /etc/bluetooth/hcid.conf to set class to 0x020100;
  • Edit /etc/default/bluez-utils to set PAND_ENABLED=1 and PAND_OPTIONS="--listen --role NAP"
  • Create /etc/bluetooth/pan/dev-up with this contents:
               #!/bin/sh
    ifconfig $1 0.0.0.0
    brctl addif br0 $1
  • Add a bridge as a network interface to /etc/network/interfaces by using something like this (I use 192.168.192.x as my local address space).
            auto br0
    iface br0 inet manual
    up echo "Adding ethernet bridge between LAN and PAN"
    up ifconfig eth0 0.0.0.0
    up brctl addbr br0
    up brctl setfd br0 0
    up brctl stp br0 off
    up brctl addif br0 eth0
    up ifconfig br0 192.168.192.1 netmask 255.255.255.0 up
    down echo "Removing ethernet bridge between LAN and PAN"
    down ifconfig br0 down
    down brctl delif br0 eth0
    down brctl delbr br0

Operation

First check, whether your USB dongle has been detected by the kernel. You can check this by running 'hciconfig -a'. You should get information on the hci0 interface. Now, if a client bluetooth device will request network service, the PAN daemon, pand, will respond to this. Check your process list to see if pand is running. If not, '/etc/init.d/bluez-utils start' is required. Once the two bluetooth devices connect, a network device called 'bnep0' is created, and pand will execute the /etc/bluetooth/pan/dev-up script. In this script, we will bridge the newly created bnep0 to eth0, using the bridge called br0. To kill the connection at either side, run 'pand -K'.

Clients

A linux client for the bluetooth network, can connect to the server by using this command:
    pand --nodetach --role PANU --search
UPDATE: I've found that I need to have 'dbus' installed to get rid of the error "Inquiry failed. No such device" I recently experienced. Without dbus, /etc/init.d/bluetooth would fail.

Notes

Don't forget that your dhcpd server should now listen on the bridge br0, not on the LAN eth0. Edit /etc/init.d/dhcpd to change this.

The whole deal with the bridging is required, so that dhcpd can function regardless wether bnep0 exists or not. You cannot bring up dhcpd to listen on bnep0, if there is no bluetooth PAN connection. You can, however, have dhcpd listen on the br0 bridge, and attach it to bnep0 whenever a bluetooth client connects.

If you experience troubles, check the /var/log/daemon.log file for more information.

References

Bluetooth USB Dongle

Enable Bluetooth support

  • Check whether Dongle is recognized and working. We use a kernel with bluetooth support! ;)

Start debian bluetooth support:

/etc/init.d/bluez-utils start

The log:

Apr  2 20:54:04 tadpole hcid[19051]: Bluetooth HCI daemon
Apr 2 20:54:04 tadpole hcid[19051]: Starting security manager 0
Apr 2 20:54:04 tadpole sdpd[19055]: Bluetooth SDP daemon
Apr 2 21:04:24 tadpole hcid[19204]: HCI dev 0 registered
Apr 2 21:04:24 tadpole hcid[19204]: HCI dev 0 up

With bluez-utils started successfully we use hciconfig to determine the dongle status:

root@tadpole:~# hciconfig
hci0: Type: USB
BD Address: 00:09:DD:10:50:F8 ACL MTU: 192:8 SCO MTU: 64:8
UP RUNNING PSCAN ISCAN AUTH ENCRYPT
RX bytes:101 acl:0 sco:0 events:13 errors:0
TX bytes:296 acl:0 sco:0 commands:12 errors:0

This means, the USB bluetooth dongle is operational.

  • We may make the bluetooth stuff be survive reboot:
update-rc.d bluez-utils defaults

Device Detection

  • Put mobile phone in See-Me mode and scan for it:
root@tadpole:~# hcitool scan
Scanning ...
00:0F:DE:14:47:21 TF-Mobile
root@tadpole:~# hcitool inq
Inquiring ...
00:0F:DE:35:71:22 clock offset: 0x569d class: 0x520204

Yep, found the right thingy. We might want to use graphical interfaces (http://gentoo-wiki.com/HOWTO_mobile_phone,_Bluetooth_and_GNOME) to interact with our mobile phone.

Once we know our phone's bluetooth MAC we can ping the phone as we would do on a standard network to check network availability:

root@tadpole:~# l2ping 00:0F:DE:13:88:91
Ping: 00:0F:DE:13:88:91 from 00:09:DD:13:92:F8 (data size 20) ...
0 bytes from 00:0F:DE:13:88:91 id 0 time 38.70ms
0 bytes from 00:0F:DE:13:88:91 id 1 time 40.69ms
0 bytes from 00:0F:DE:13:88:91 id 2 time 43.19ms
0 bytes from 00:0F:DE:13:88:91 id 3 time 37.67ms
0 bytes from 00:0F:DE:13:88:91 id 4 time 35.21ms
5 sent, 5 received, 0% loss

Interestingly enough, the l2ping to a Nokia 6230i is a bit faster. ;)

Ping: 08:00:28:4F:1B:A6 from 00:09:DD:13:88:98 (data size 20) ...
0 bytes from 08:00:28:4F:1B:A6 id 0 time 16.53ms
0 bytes from 08:00:28:4F:1B:A6 id 1 time 29.33ms
0 bytes from 08:00:28:4F:1B:A6 id 2 time 29.63ms
0 bytes from 08:00:28:4F:1B:A6 id 3 time 34.59ms
0 bytes from 08:00:28:4F:1B:A6 id 4 time 33.41ms
0 bytes from 08:00:28:4F:1B:A6 id 5 time 27.51ms
0 bytes from 08:00:28:4F:1B:A6 id 6 time 41.03ms

Connection Establishing

  • We might change the name XYZ line in /etc/bluetooth/hcid.conf to something more personal. :) See man 5 hcid.conf for more.
  • Write a whatever PIN into /etc/bluetooth/pin. Remember it and enter it when prompted for a PIN connecting from your phone to the dongle.
  • When connecting from the phone to the dongle have a look at the logs, /var/log/syslog:
Apr  2 20:26:32 tadpole hcid[18268]: link_key_request (sba=00:09:DD:13:92:F8, dba=00:0F:DE:13:88:91)
Apr 2 20:26:32 tadpole hcid[18268]: pin_code_request (sba=00:09:DD:13:92:F8, dba=00:0F:DE:13:88:91)
Apr 2 20:26:33 tadpole hcid[18268]: link_key_notify (sba=00:09:DD:13:92:F8)
Apr 2 20:26:33 tadpole hcid[18268]: Replacing link key 00:09:DD:13:92:F8 00:0F:DE:13:88:91
Apr 2 20:26:34 tadpole hcid[18268]: link_key_request (sba=00:09:DD:13:92:F8, dba=00:0F:DE:13:88:91)
Apr 2 20:27:11 tadpole hcid[18268]: link_key_request (sba=00:09:DD:13:92:F8, dba=00:0F:DE:13:88:91)
Apr 2 20:27:16 tadpole hcid[18268]: link_key_request (sba=00:09:DD:13:92:F8, dba=00:0F:DE:13:88:91)
  • We may now push our data from the phone to the computer with the USB-dongle connected.
  • It might be necessary to grant access to our X server for the helper tool to query us for the PIN. To do so execute xhost + as user.

Device Capability Discovery

  • Query the capabilities:
sdptool browse

The T630 answer and the one the Nokia 6230i gave.

Pulling Data From Mobile

  • First query the list of available files:
obexftp -b  00:0F:DE:13:88:11 -c Bilder
Browsing 00:0F:DE:13:88:11 ...
Channel: 7
No custom transport
Connecting...bt: 1
done
Sending Bilder... Sending Bilder... done
Receiving (null).../





done
Disconnecting...done
  • Get specific file:
radtkens@tadpole:$  obexftp -b  00:0F:DE:13:88:11 -c Bilder  -g "img(27).jpg"
Browsing 00:0F:DE:13:88:11 ...
Channel: 7
No custom transport
Connecting...bt: 1
done
Sending Bilder... Sending Bilder... done
Receiving img(27).jpg...-done
Disconnecting...done

The image is now in pwd. Fire up gqview and see! :-)

  • To boldly fetch any picture in Bilder directory, use this one-liner:
for i in $(obexftp -b 00:0F:DE:13:88:11 -c Bilder -l 2>&1 | grep .jpg | \
sed 's/.*name="//g; s/" size.*//g'); do obexftp -b 00:0F:DE:13:88:11 -c Bilder -g "$i"; done;
  • We rename the files to a nicer naming scheme:
for i in $(ls *.jpg); do \
no=$(echo $i|sed 's/img(\(.*\)).jpg/\1/g');
mv -vi $i img_$(printf "%03.0f" $no).jpg;
done

Before: "img(1).jpg", after: "img_001.jpg". Have fun! :-)

Sync Tools

  • obexftp is suitable for pulling images.
  • Synchronise contacts, events and tasks using a tool such as multisync.
  • multisync has IRDA and Bluetooth plugins as well as backup, evolution and SyncML plugins.


Headset

Connection

Start bluetooth (debian way):

/etc/init.d/bluez-utils start

Check whether our bluetooth is up and running:

hcitool dev
Devices:
hci0 00:05:33:10:71:F3

This is the MAC address of our USB-bluetooth adapter.

Put your headset into pairing mode and scan for it:

hcitool scan

It should have discovered your headset, so connect to it via:

hcitool cc 

This will require us to enter the headset PIN: To prevent it from asking every time we connect we setup a small pin-helper /etc/bluetooth/pin-helper.sh script:

#!/bin/sh
echo "PIN:0000"

Modify /etc/bluetooth/hcid.conf to match this filename:

pin_helper /etc/bluetooth/pin-helper.sh;

Bluez Configuration Files

/etc/bluetooth/hcid.conf

options {
autoinit yes;
security user;
pairing multi;
pin_helper /etc/bluetooth/pin-helper.sh;
}
device {
name "My_bt%d";
class 0x3e0100;
iscan enable; pscan enable;
lm accept;
lp rswitch,hold,sniff,park;
auth enable;
encrypt enable;
}


/etc/bluetooth/rfcomm.conf

rfcomm0 {
bind yes;
device ;
channel 1;
comment "My-bt";
}

Build btsco

Requirements:

From btsco README:

  • automake-1.7
  • libbluetooth-dev
  • libasound2-dev (aka alsa-devel)
  • a recent (2.6.11.7 or newer) kernel with *integrated* alsa enabled (it won't work with the "standalone" alsa drivers that are a separate download from the kernel)

Get btsco from CVS

cvs -d:pserver:anonymous@cvs.sf.net:/cvsroot/bluetooth-alsa login
cvs -d:pserver:anonymous@cvs.sf.net:/cvsroot/bluetooth-alsa co btsco

btsco Compilation

cd btsco/
./bootstrap
./configure
make
make install

We might skip this one as we need some tools built that are otherwise wiped again:

make maintainer-clean

Kernel Module Compilation

For SCO (two-way voice quality audio) you need a kernel with the emu10k1 driver selected (this is one of the drivers that forces the inclusion of the implementation of "snd_hwdep_new").

cd kernel/
make
make install
depmod -e
make clean

Using btsco

modprobe snd_bt_sco

If running esd stop it:

esdctl stop

Do:

hciconfig hci0 voice 0x0060

Put headset into pairing mode. It should not be connected with your mobile as it would prevent pairing with our linux box. Run btsco with -v for verbose mode or with -f for daemon mode:

btsco 

This might ask for the headset PIN. Standard is with most devices 0000.

Testing

Play some WAV file (not every WAV will work, try some):

aplay -B 1000000 -D plughw:Headset my_wav_that_works.wav

The btsco seems in alpha stage. While playing a WAV may work the first time it fails on subsequent tries. Leaving this in the kernel log:

radtkens@tadpole:$ dmesg | tail
[17190778.216000] snd-bt-sco: Shift problem detected! Fixing to 1.
[17190778.216000] snd-bt-sco: Shift problem detected! Fixing to 0.
[17190779.196000] snd-bt-sco: playback_trigger 0
[17190779.196000] snd-bt-sco: setting playback to NULL
[17190779.200000] snd-bt-sco: Disposing of previous socket count 2
[17190782.504000] snd-bt-sco: playback_open
[17190782.508000] snd-bt-sco: prepare ok bps: 16000 size: 16002 count: 4000
[17190782.508000] snd-bt-sco: playback_trigger 1
[17190782.508000] snd-bt-sco: setting playback to bspcm
[17191026.524000] snd-bt-sco: Disposing of previous socket count 2
[17191026.560000] hci_scodata_packet: hci0 SCO packet for unknown connection handle 48
[17191026.560000] hci_scodata_packet: hci0 SCO packet for unknown connection handle 48
[17191026.560000] hci_scodata_packet: hci0 SCO packet for unknown connection handle 48

Unloading (rmmod sco) and reloading (modprobe sco) the sco kernel module reenables playback..

Sample output from verbose btsco:

radtkens@tadpole:$ /usr/local/btsco/bin/btsco MAC -v
btsco v0.41
Device is 2:0
Voice setting: 0x0060
RFCOMM channel 1 connected
Using interface hci0
recieved AT*ECBP=?
recieved AT+CLIP=1
recieved AT+CSCS="UTF-8"
recieved AT+CLAN?
speaker volume: 0 mic volume: 0
i/o needed: connecting sco...
connected SCO channel
Done setting sco fd
speaker volume: 0 mic volume: 0
driver is not in use
disconnected SCO channel
RFCOMM channel lost

Tipps

To use our bluetooth headset with skype we start btsco right before we start skype. skype now offers one more input method in the preferences. Have fun! :-)

We may configure the daemonized btsco using ~/.btscorc.

Links

  • btsco homepage (http://bluetooth-alsa.sourceforge.net/), alsa support for bluetooth headsets
  • btsco howto (http://www.linux.ie/articles/bluetoothheadset.php) short and good.
  • List of bluetooth devices (http://www.holtmann.org/linux/bluetooth/features.html) with features
  • Bluetooth howto collection (http://www.holtmann.org/linux/bluetooth/)
  • How to whack'n'hack bluetooth headsets (http://isospider.net/news/?a=view&id=1520), his homepage (http://www.digitalmunition.com/) and the tools (http://trifinite.org/trifinite_downloads.html)
  • Bluetooth howto (http://www.des.udc.es/~mpquique/HOWTO/en-txt/Bluetooth-Howto.txt), features some note on obex and push mechanism.
  • General bluetooth information (http://www.developertutorials.com/tutorials/wireless-technology/linux-wireless-networking-050504/page3.html) and short overview of bluez-utils (such as hci../sdpd/..).
  • Nice bluetooth tool compilation (http://tuxmobil.org/bluetooth_cell_apps.html)
  • Using IRDA (http://ale.shouldshave.org/t630_linux.html)
  • Nice page about using bluetooth (http://www.caside.lancs.ac.uk/java_bt.php) with linux including determining the notebooks OBEX DIAC.
  • Gentoo and bluetooth (http://www.gentoo.org/doc/en/bluetooth-guide.xml) presenting a bunch of gnome and kde bluetooth tools.
  • Nokia's Smartphone with Python (http://pramode.net/articles/lfy/mobile/pramode.html). There's also an interesting section called 'Parting thoughts', give it a try, that's a good thought. :)
  • Wikipedia Bluetooth (http://en.wikipedia.org/wiki/Bluetooth) page.
  • Jean Tourrilhes' bluetooth (http://www.hpl.hp.com/personal/Jean_Tourrilhes/bt/) page.
  • Running a bluetooth network (http://www.triptico.com/software/bluetooth.html)
  • Bluez (http://www.bluez.org/) homepage.

Bluetooth and GPRS

Bluetooth Installation on Debian

This howto will help you using the now well-known Bluetooth (from here simply Blu) on a distro (Debian or Debian-based) in a minute, and then using the graphical tools available on Gnome and KDE.

Let's start:

Install the basic packages, that is bluez-utils and bluz-libs.
Type this command on the console

$ apt-get install bluez-utils

to make sure all is alright it's suggested to install also packages like bluez-firmware e bluez-hcidump which can be found HERE (the same packages could be installed through apt or its graphical front-end synaptic)

Install the graphical tools accordingly to the DE used, respectively: The KDE Bluetooth Framework for KDE users.

For GnomeBluetooth's users, install the front-end by SID repository.


Now plug the Blu drive in to the PC through USB and by root execute the recognizing command

$ hciconfig

you will get an output like this:
hciconfig
hci0: Type: USB
BD Address: 00:0E:8E:00:C0:2E ACL MTU: 377:10 SCO MTU: 16:0
UP RUNNING PSCAN ISCAN
RX bytes:163 acl:0 sco:0 events:22 errors:0
TX bytes:596 acl:0 sco:0 commands:22 errors:0

where the BD address is the hardware address of your drive (or integrated card in the laptop)

Enable your mobile phone's Blu and execute this by root:
$ hcitool scan

you will get:
Scanning ...
00:12:EE:F9:15:20 Debian

this address is fundamental, write it because you will need it (of course this is my mobile's).

Open with an editor /etc/bluetooth/rfcomm.conf and modify it:
# # Bluetooth address of the device
# device 00:12:EE:F9:15:20;
# # RFCOMM channel for the connection
# channel 10;
# # Description of the connection
# comment "Sony_Ericsson V_800";

execute
$ sdptool add --channel=10 OPUSH

with a text editor create a little script named cellpin.sh and save it into /etc/bluetooth
#! /bin/bash
echo PIN: 1234

then type
$ chmod 700 /etc/bluetooth/cellpin.sh

open the hcid.conf file in /etc/bluetooth and modify it this way:
#PIN helper
pin_helper /etc/bluetooth/cellpin.sh;
#pin_helper /usr/bin/bluez-pin;


just execute:
$ hcid -f /etc/bluetooth/hcid.conf

Now when you plug the blu drive in and you enable your mobile's Blu you can exchange files :)
To the Gnome users who wants to send a file through bluetooth simply by clicking on the file with the right mouse key, select: Send to...open a text editor and write these lines

#!/bin/sh
# send file to bluetooth
filepath=$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
obexftp -b 00:12:EE:F9:15:20 -p $filepath



Save it with the name send_to_bluetooth, give it the right permissions to execute is as an user and move it into /home/vostronomeutente/.gnome2/nautilus-scripts


Some problems

If your mobile doesn't see the BT drive (so the files can't be transferred between phone and PC) execute this command on the console

$ dbus-send --system --dest=org.bluez /org/bluez/hci0 \

and then
$ org.bluez.Adapter.SetMode string:discoverable


Have fun ;)

Troubleshooting

An useful report from Gica78R: I followed this howto on Sarge but I had some problems, and the same on Etch. In particular, although in /etc/bluetooth/hcid.conf the iscan enable option was enabled, my computer kept on being invisible from the other devices. I hadn't any problem moving files from the Debian pc to the other devices, or viceversa if those devices knew in some way the PC's Bluetooth address. But if I tried to perform a device search, my pc wasn't visible.

Eventually it's a common bug so, through hcdi.conf settings, the hcin daemon enables only the PSCAN option instead of both PSCAN an ISCAN.
A sort of workaround to solve this:

1) Delete all the content of /var/lib/bluetooth/ (usually it contains a subdirectory for each Bluetooth device detected). ATTENTION: delete only the /var/lib/bluetooth/ content, NOT the directory itself!

2) add in the device section into /etc/bluetooth/hcid.conf this option: discovto 0;

3) reboot the Bluetooth service with this command as root: /etc/init.d/bluetooth restart

When is this necessary? When, although the /etc/bluetooth/hcid.conf contains the iscan enable; option, the output of hciconfig looks like this:

hci0:   Type: USB
BD Address: 00:10:60:D1:4D:C0 ACL MTU: 384:8 SCO MTU: 64:8
UP RUNNING PSCAN
RX bytes:455 acl:0 sco:0 events:27 errors:0
TX bytes:358 acl:0 sco:0 commands:24 errors:0

that is the ISCAN option isn't showed as enabled.

After have followed the istructions above, this output should look like:

hci0:   Type: USB
BD Address: 00:10:60:D1:4D:C0 ACL MTU: 384:8 SCO MTU: 64:8
UP RUNNING PSCAN ISCAN
RX bytes:455 acl:0 sco:0 events:27 errors:0
TX bytes:358 acl:0 sco:0 commands:24 errors:0
you can note ISCAN is enabled!