Bluetooth successful file transfer

From finninday
Jump to navigation Jump to search


Fedora 19, Droid Razr HD

Sep 7, 2013

After stumbling through the gnome interface for pairing with the phone, I eventually paired and can now do this:

[root@vorbis Camera]# hciconfig
hci0:	Type: BR/EDR  Bus: USB
	BD Address: 2C:D0:5A:8B:70:82  ACL MTU: 1021:8  SCO MTU: 64:1
	UP RUNNING PSCAN ISCAN 
	RX bytes:204469 acl:567 sco:0 events:284 errors:0
	TX bytes:6775 acl:258 sco:0 commands:82 errors:0

yum install obexfs

[root@vorbis ~]# obexfs -b E0:75:7D:57:02:EB /mnt/bluetooth
[root@vorbis ~]# cd /mnt/bluetooth/

[root@vorbis bluetooth]# ls
Alarms     aSQLiteManager  data      kindle   Messaging  MyTracks       Pictures   slacker             VMM
amazonmp3  Audible         DCIM      mailbox  Movies     NFC ReTAG      Podcasts   SmartVoiceRecorder
Android    bluetooth       Download  media    Music      Notifications  Ringtones  VaultService

# unmount
[root@vorbis obexfs-0.12]# fusermount -u /mnt/bluetooth

But I'm still trying to find out how to get signal strength of the bluetooth device.

l2ping doesn't do it:

l2ping E0:75:7D:57:02:EB
Ping: E0:75:7D:57:02:EB from 2C:D0:5A:8B:70:82 (data size 44) ...
44 bytes from E0:75:7D:57:02:EB id 0 time 27.89ms
44 bytes from E0:75:7D:57:02:EB id 1 time 18.60ms
44 bytes from E0:75:7D:57:02:EB id 2 time 21.16ms
44 bytes from E0:75:7D:57:02:EB id 3 time 10.98ms
44 bytes from E0:75:7D:57:02:EB id 4 time 74.88ms
44 bytes from E0:75:7D:57:02:EB id 5 time 41.11ms
44 bytes from E0:75:7D:57:02:EB id 6 time 38.60ms
Send failed: Connection reset by peer

Trying other commands...

[root@vorbis ryan.day]# hcitool dev
Devices:
	hci0	2C:D0:5A:8B:70:82
[root@vorbis ryan.day]# hcitool scan
Scanning ...
	E0:75:7D:57:02:EB	DROID RAZR HD
[root@vorbis ryan.day]# hcitool info E0:75:7D:57:02:EB
Requesting information ...
	BD Address:  E0:75:7D:57:02:EB
	OUI Company: Motorola Mobility LLC (E0-75-7D)
	Device Name: DROID RAZR HD
	LMP Version: 4.0 (0x6) LMP Subversion: 0x7d3
	Manufacturer: Qualcomm (29)
	Features page 0: 0xff 0xfe 0x8f 0xfe 0xd8 0x3f 0x5b 0x87
		<3-slot packets> <5-slot packets> <encryption> <slot offset> 
		<timing accuracy> <role switch> <hold mode> <sniff mode> 
		<RSSI> <channel quality> <SCO link> <HV2 packets> 
		<HV3 packets> <u-law log> <A-law log> <CVSD> <paging scheme> 
		<power control> <transparent SCO> <broadcast encrypt> 
		<EDR ACL 2 Mbps> <EDR ACL 3 Mbps> <enhanced iscan> 
		<interlaced iscan> <interlaced pscan> <inquiry with RSSI> 
		<extended SCO> <AFH cap. slave> <AFH class. slave> 
		<LE support> <3-slot EDR ACL> <5-slot EDR ACL> 
		<sniff subrating> <pause encryption> <AFH cap. master> 
		<AFH class. master> <EDR eSCO 2 Mbps> <extended inquiry> 
		<LE and BR/EDR> <simple pairing> <encapsulated PDU> 
		<non-flush flag> <LSTO> <inquiry TX power> <EPC> 
		<extended features> 
	Features page 1: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00

Ahah! Here are the commands I'm looking for, but they require an established connection. From the man page for hcitool:

       rssi <bdaddr>
              Display  received  signal strength information for the connection to the device with Bluetooth
              address bdaddr.

       lq <bdaddr>
              Display link quality for the connection to the device with Bluetooth address bdaddr.

       tpl <bdaddr> [type]
              Display transmit power level for the connection to the device with Bluetooth  address  bdaddr.
              The type can be 0 for the current transmit power level (which is default) or 1 for the maximum
              transmit power level.

[root@vorbis ~]# hcitool rssi E0:75:7D:57:02:EB
Not connected.
[root@vorbis ~]# hcitool lq E0:75:7D:57:02:EB
Not connected.
[root@vorbis ~]# hcitool tpl E0:75:7D:57:02:EB
Not connected.

And I'm having trouble establishing a connection...

[root@vorbis ~]# hcitool cc E0:75:7D:57:02:EB
[root@vorbis ~]# hcitool con
Connections:


Wednesday, May 4th, 2005

I tried applying my bluetooth knowledge so far to a Yellowdog 4.0 laptop and was able to send pictures from my phone via bluetooth to the laptop. Here is the configuration:

[rday@bobo rday]$ rpm -qa | grep blue
bluez-hcidump-1.8-1
bluez-bluefw-1.0-4
bluez-utils-2.7-3
bluez-libs-2.7-1
gnome-bluetooth-0.4.1-8
bluez-pin-0.23-1
[rday@bobo rday]$ cat /etc/yellowdog-release
Yellow Dog Linux release 4.0 (Orion)

The only local configuration I did was to change the device name that the bluetooth dongle in the laptop uses to advertise itself. Then I used bluefw to “load the firmware”, whatever that means. And then started the bluetooth service. The pin-helper said that it failed, but the phone and laptop were able to pair successfully anyway. And when I used the phone to examine the advertised services available on the laptop, it reported file transfer and synchronization. Cool.

On Yellowdog, even Nautilus was able to understand “bluetooth:///” as a file path. But it didn’t see my phone. I’ll have to poke at that more.

After the devices were paired, I could start a transfer from the phone and send pictures which magically appeared in my home directory on the laptop.

May 4th, 2005 at 1:24 pm

Trying to get gnome-bluetooth to work on RHEL 4.0WS like it does on Yellowdog has been hard. I’m stuck in dependency hell. It ought to be easy given a working system that I can copy, right?

First problem is that there isn’t a gnome-bluetooth rpm for RHEL. So I have to reach back to RHL 9.0 to get gnome-bluetooth. (I tried installing from source, which compiled and installed successfully, but somehow still doesn’t work.)

Trying to install the old gnome-bluetooth rpm yields a failed dependency:

error: Failed dependencies:
libbtctl.so.1 is needed by gnome-bluetooth-0.4.1-3.i386
libopenobex-1.0.so.0 is needed by gnome-bluetooth-0.4.1-3.i386
libsdp.so.2 is needed by gnome-bluetooth-0.4.1-3.i386
Suggested resolutions:
libbtctl-0.4.1-3.i386.rpm

Trying to install libbtctl yields a further failed dependency:

error: Failed dependencies:
libsdp.so.2 is needed by libbtctl-0.3-4.i386

libsdp.so.2 is provided by bluez-libs-2.7-1 on Yellowdog

I have bluez-libs-2.10-2 on RHEL.

The changelog for this package says that in version 2.8 the dummy SDP library was removed. Doh. I’m stuck on a dependency for a dummy library.


July 26th, 2005 at 6:11 pm

I wasn’t very explicit about the recipe for transfering files between phone and laptop. I just had to figure it out again. I took several false starts and so I’m still not sure what the right procedure is, but I think it is something like this:

  • make sure the bluetooth service is running via /etc/init.d/bluetooth status
  • start gnome-obex-server (System tools > Bluetooth file sharing)
  • use the phone to drive the transaction
  • pick a file and send it via bluetooth to the laptop

I don’t think all the business with hcitool are actually required, but it does let you see some reassuring debugging info.

Earlier attempts[edit]

Tuesday, May 3rd, 2005

The basic connections are in place for talking between my work desktop and my cell phone. Now I need to be able to do useful things like transfer files.

On the desktop, I just need to have the bluetooth service running. On the phone, if I scan for devices, it sees the desktop, but when I try to establish a connection from the phone, it fails saying that the passkey doesn’t match.

I can work around this by establishing the connection from the desktop instead.

From the desktop, I scan for devices with hcitool scan, get the address of the phone, and then use hcitool to open a connection and request authentication. Then the phone beeps and I enter the PIN. Now I have added the desktop to the device list in the phone.

hcitool scan
Scanning ...
00:0E:07:0C:0B:6D T616ryan
[rday@snapper ~]$ hcitool cc 00:0E:07:0C:0B:6D
Can't create connection: Operation not permitted
[rday@snapper ~]$ sudo bash
Password:
[root@snapper ~]# hcitool cc 00:0E:07:0C:0B:6D
[root@snapper ~]# hcitool con
Connections:
< ACL 00:0E:07:0C:0B:6D handle 6 state 1 lm MASTER
[root@snapper ~]# hcitool auth 00:0E:07:0C:0B:6D

To close the connection, I can use hcitool dc

I would like that service list to include things like synchronization and object push. To get that, I installed gnome-bluetooth from http://usefulinc.com/software/gnome-bluetooth but that hasn’t worked for me yet. This howto from a gentoo user is very helpful: http://gentoo-wiki.com/HOWTO_mobile_phone,_Bluetooth_and_GNOME

Monday, April 25th, 2005

Starting from Redhat EL4WS, I’m trying to plug in a bluetooth dongle and be able to talk to my cell phone. Here is what I have so far.

The dongle is recognized when I plug it in to a USB port:

[root@snapper ~]# lsusb
Bus 004 Device 008: ID 0a5c:2033 Broadcom Corp. BCM2033 Bluetooth
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 002: ID 413c:3010 Dell Computer Corp.
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000

This is where I start to flounder. There is a nice pile of documentation at http://www.holtmann.org/linux/bluetooth/ but it is terribly frustrating trying to find the *actual next step* that I might need to take. Random clicks on the links in that long list haven’t yielded a non-obsolete howto document so far.

What software and tools do I have at my disposal?

[root@snapper ~]# rpm -qa | grep blue
bluez-hcidump-1.11-1
bluez-libs-2.10-2
bluez-pin-0.23-3
bluez-utils-2.10-2.1

One of the things I get in bluez-utils is /etc/init.d/bluetooth. That’s promising, but simply turning it on doesn’t do much. Here is a peek inside:

UART_CONF="/etc/bluetooth/uart"

[ -e /etc/sysconfig/bluetooth ] && . /etc/sysconfig/bluetooth

start_uarts()
{
[ -f $UART_CONF ] || return
grep -v '^#' $UART_CONF | while read i; do
/usr/sbin/hciattach $i
done
}

I’ve poked around in /etc/sysconfig/bluetooth (it is a minimal file with not much in the way of clues), but I haven’t done anything with this UART stuff. This script will only try to start the UARTs if the config file exists, which it doesn’t on my system. What should I put in there? Something that hciattach will like…

Ahh, this is where it gets interesting. The man page for hciattach includes a list of supported serial devices that it can insert into the Bluez stack and my Broadcom device is not listed. It mentions support for these devices: ericsson, digi, xircom, brainboxes, silicon wave, csr. But, it also has a device type called “any”. And so this shot in the dark actually seems to work:

[root@snapper bluetooth]# hciattach /dev/ttyS1 any
[root@snapper bluetooth]# hciconfig
hci0: Type: UART
BD Address: 00:00:00:00:00:00 ACL MTU: 0:0 SCO MTU: 0:0

DOWN
RX bytes:0 acl:0 sco:0 events:0 errors:0
TX bytes:4 acl:0 sco:0 commands:1 errors:0

Wow, I wasn’t expecting to get this far. What else can I do? Using hciconfig to bring up the device doesn’t seem to work just yet, so let’s start again but first I’ll put “/dev/ttyS1 any” in /etc/bluetooth/UART and restart bluetooth.

[root@snapper bluetooth]# /etc/init.d/bluetooth stop
Stopping Bluetooth services: [ OK ]
[root@snapper bluetooth]# /etc/init.d/bluetooth start
Starting Bluetooth services: [ OK ]
[root@snapper bluetooth]#
[root@snapper dev]# hciconfig -a
hci0: Type: UART
BD Address: 00:00:00:00:00:00 ACL MTU: 0:0 SCO MTU: 0:0
DOWN
RX bytes:0 acl:0 sco:0 events:0 errors:0
TX bytes:8 acl:0 sco:0 commands:2 errors:0
Features: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Packet type: DM1 DH1 HV1
Link policy:
Link mode: SLAVE ACCEPT

It doesn’t look like it is really talking to the device. Probably this is because I’m telling it to look on the serial port /dev/ttyS1. Isn’t that the old-school serial port? How do I name a device on the USB bus? My xorg.conf is pointing to my USB mouse through the name of /dev/input/mice. That’s the only USB device I have on this system. hciattach really wants a /dev/tty to talk to. It looks like my task is to figure out how to bind a USB device to a /dev/tty* name. One quick google search later and I think the answer is in this page: http://www.linux-usb.org/USB-guide/x356.html The USB device files don’t exist on my system, so I make a directory “/dev/usb” and put ttyUSB0-3 in it. Then I tell /etc/bluetooth/uart that hciattach should use the parameters “/dev/usb/ttyUSB0 any”. Then I stop and start bluetooth. On start, I get this:

[root@snapper init.d]# /etc/init.d/bluetooth start
Can't open serial port: No such device [ OK ]
Can't initialize device: Illegal seek

Dang. Even if that would have worked, it would not explain how the mapping works between a USB device and the namespace of ttyUSB0. Maybe ttyUSB0 is pointed at my mouse. How do I find out what it is really pointed at?

For kicks, here is the relevant output of kudzu -p:

class: OTHER
bus: USB
detached: 0
driver: bcm203x
desc: "Broadcom Corp. BCM2033 Bluetooth"
usbclass: 0
usbsubclass: 1
usbprotocol: 1
usbbus: 4

usblevel: 1
usbport: 0
usbdev: 9
vendorId: 0a5c
deviceId: 2033

And here is the snipped output of lsmod:

[root@snapper ~]# lsmod
Module Size Used by
usbserial 29865 0
hci_uart 18205 0
hidp 18753 0
cmtp 22337 0
kernelcapi 49216 1 cmtp
rfcomm 38105 0
l2cap 27201 7 hidp,cmtp,rfcomm
hci_usb 16961 0
bluetooth 47429 8 hci_uart,hidp,cmtp,rfcomm,l2cap,hci_usb
bcm203x 9281 0
...
uhci_hcd 32473 0
ehci_hcd 31813 0

...

Googling for my device model number gives me this: http://www.broadcom.com/collateral/pb/2033-PB04-R.pdf

Better yet, googling for “broadcom bluetooth linux” I got this gem: http://www.twoguys.org/~gregh/nokia-6310i.html

It tells me that I really do need the bluez-bluefw rpm that I thought would be irrelevent to my setup. After installing it, here is the list of my bluetooth packages:

[root@snapper ~]# rpm -qa | grep blue
bluez-hcidump-1.11-1
bluez-libs-2.10-2
bluez-bluefw-1.0-6
bluez-pin-0.23-3
bluez-utils-2.10-2.1

Now I can plug in the bluetooth dongle and see where it shows up on the USB bus:

[root@snapper ~]# lsusb
Bus 004 Device 009: ID 0a5c:2033 Broadcom Corp. BCM2033 Bluetooth
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 002: ID 413c:3010 Dell Computer Corp.
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000

Then use that address to load the bluetooth firmware:

[root@snapper ~]# bluefw usb 004/009
bluefw[12478]: Loading firmware to usb device 0a5c:2033
bluefw[12478]: FW loaded

And then display the device configuration:

[root@snapper bluetooth]# hciconfig
hci0: Type: USB
BD Address: 00:03:C9:23:AC:B2 ACL MTU: 377:10 SCO MTU: 16:0
UP RUNNING PSCAN ISCAN
RX bytes:209 acl:0 sco:0 events:31 errors:0
TX bytes:1119 acl:0 sco:0 commands:31 errors:0

Yay!

[root@snapper bluetooth]# hcitool scan
Scanning ...
00:0E:07:0C:0B:6D T616ryan
[root@snapper bluetooth]# hcitool info 00:0E:07:0C:0B:6D
Requesting information ...
BD Address: 00:0E:07:0C:0B:6D
Device Name: T616ryan
LMP Version: 1.1 (0x1) LMP Subversion: 0x503
Manufacturer: Ericsson Technology Licensing (0)
Features: 0x04 0xca 0x31 0x00 0x00 0x00 0x00 0x00
<encryption> <rssi> <sco link> <u -law log> <a -law log> <cvsd>
[root@snapper bluetooth]# l2ping 00:0E:07:0C:0B:6D
Ping: 00:0E:07:0C:0B:6D from 00:03:C9:23:AC:B2 (data size 20) ...
0 bytes from 00:0E:07:0C:0B:6D id 200 time 32.85ms
0 bytes from 00:0E:07:0C:0B:6D id 201 time 31.16ms
0 bytes from 00:0E:07:0C:0B:6D id 202 time 22.20ms
0 bytes from 00:0E:07:0C:0B:6D id 203 time 26.15ms
0 bytes from 00:0E:07:0C:0B:6D id 204 time 28.28ms
0 bytes from 00:0E:07:0C:0B:6D id 205 time 28.31ms
0 bytes from 00:0E:07:0C:0B:6D id 206 time 26.34ms
0 bytes from 00:0E:07:0C:0B:6D id 207 time 12.31ms
0 bytes from 00:0E:07:0C:0B:6D id 208 time 13.41ms
0 bytes from 00:0E:07:0C:0B:6D id 209 time 28.42ms
10 sent, 10 received, 0% loss
[root@snapper bluetooth]#