Linux

Bluetooth (ObexFTP) file transfer timeout on Linux

Dear Reader,

Lately i have been experiencing a weird issue on my Linux box of Zenwalk 7.8. I am using blueman app here to transfer the files.

Strange part was, i was able to send files to my linux box (Laptop) from my mobile device, but not the other way around. This always irked me a bit but did not bother much as i hardly use the bluetooth. But today, i decided to do a bit of research (logs and google) on this and i happen to run some diagnosis.

First, via blueman i paired the devices. Trying to send the file from box to mobile device, it reported time out error. Looking at the dmesg logs, it turned out nothing much useful.

Next, i went on to see if the device has been properly recognized by the bluetooth service. So ran few commands as root (sudo) user listed below:

bash-4.3# hcitool dev
Devices:
hci0    3C:XX:XX:XX:XX:XX

The MAC address printed from the above command is the bluetooth chip on my laptop/desktop.

To know HCI0 bus info, you can run command:

bash-4.3# hciconfig dev
hci0:    Type: BR/EDR  Bus: USB
BD Address: 3C:XX:XX:XX:XX:XX  ACL MTU: 1021:8  SCO MTU: 64:1
UP RUNNING PSCAN
RX bytes:15273 acl:156 sco:0 events:648 errors:0
TX bytes:109775 acl:248 sco:0 commands:419 errors:0

Once the device is detected, next i ran another command to make the device (BUS) up, in case it hasn’t.

bash-4.3# hciconfig hci0 up

The above command doesn’t print out any return lines. All is well so far.

Next i wanted to know if the mobile device is in the radar, i need to scan it:

bash-4.3# hcitool scan
Scanning …
7C:XX:XX:XX:XX:XX    zenwalker

Note the MAC address printed above is of the mobile device.

Then i wanted to connect the hcitool to mobile device:

bash-4.3# hcitool cc 7C:XX:XX:XX:XX:XX

Everything seems to be on track. Now, since the blueman is unable to transfer the file to my mobile device (Hint: Make sure your firewall isn’t blocking connection), its of no use using it further. So i tried via obexftp tool, since the blueman app uses the same tool underneath.

bash-4.3# obexftp -b 7C:XX:XX:XX:XX:XX -p /home/zenwalker/Pictures/abc.jpg

I tried sending a pic to my mobile device via above command, but it returned me some errors:

Connecting…failed: connect
Tried to connect for 3ms
error on connect(): Invalid argument

Further investigation revealed that, i need to explicitly mentioned the channel to which it should communicate. Usually this shall be figured by itself, but some times some mobile devices act crazy or the tool here itself is not bullet proof.

So what the heck is this channel or where do i get it? 😮

Run this command:

bash-4.3# sdptool browse 7C:XX:XX:XX:XX:XX

This command outputs following result:

Service RecHandle: 0x10000
Service Class ID List:
“Generic Attribute” (0x1801)
Protocol Descriptor List:
“L2CAP” (0x0100)
PSM: 31
“ATT” (0x0007)
uint16: 0x1
uint16: 0x5

 

Service RecHandle: 0x10001
Service Class ID List:
“” (0x1800)
Protocol Descriptor List:
“L2CAP” (0x0100)
PSM: 31
“ATT” (0x0007)
uint16: 0x14
uint16: 0x1e

 

Service Name: Headset Gateway
Service RecHandle: 0x10002
Service Class ID List:
“Headset Audio Gateway” (0x1112)
“Generic Audio” (0x1203)
Protocol Descriptor List:
“L2CAP” (0x0100)
“RFCOMM” (0x0003)
Channel: 2
Profile Descriptor List:
“Headset” (0x1108)
Version: 0x0102

 

Service Name: Handsfree Gateway
Service RecHandle: 0x10003
Service Class ID List:
“Handsfree Audio Gateway” (0x111f)
“Generic Audio” (0x1203)
Protocol Descriptor List:
“L2CAP” (0x0100)
“RFCOMM” (0x0003)
Channel: 3
Profile Descriptor List:
“Handsfree” (0x111e)
Version: 0x0106

 

Service Name: AV Remote Control Target
Service RecHandle: 0x10004
Service Class ID List:
“AV Remote Target” (0x110c)
Protocol Descriptor List:
“L2CAP” (0x0100)
PSM: 23
“AVCTP” (0x0017)
uint16: 0x102
Profile Descriptor List:
“AV Remote” (0x110e)
Version: 0x0103

 

Service Name: Advanced Audio
Service RecHandle: 0x10005
Service Class ID List:
“Audio Source” (0x110a)
Protocol Descriptor List:
“L2CAP” (0x0100)
PSM: 25
“AVDTP” (0x0019)
uint16: 0x102
Profile Descriptor List:
“Advanced Audio” (0x110d)
Version: 0x0102

 

Service Name: Android Network Access Point
Service Description: NAP
Service RecHandle: 0x10006
Service Class ID List:
“Network Access Point” (0x1116)
Protocol Descriptor List:
“L2CAP” (0x0100)
PSM: 15
“BNEP” (0x000f)
Version: 0x0100
SEQ8: 0 6
Language Base Attr List:
code_ISO639: 0x656e
encoding:    0x6a
base_offset: 0x100
Profile Descriptor List:
“Network Access Point” (0x1116)
Version: 0x0100

 

Service Name: OBEX Phonebook Access Server
Service RecHandle: 0x10008
Service Class ID List:
“Phonebook Access – PSE” (0x112f)
Protocol Descriptor List:
“L2CAP” (0x0100)
“RFCOMM” (0x0003)
Channel: 19
“OBEX” (0x0008)
Profile Descriptor List:
“Phonebook Access” (0x1130)
Version: 0x0101

 

Service Name: OBEX Object Push
Service RecHandle: 0x10009
Service Class ID List:
  “OBEX Object Push” (0x1105)
Protocol Descriptor List:
  “L2CAP” (0x0100)
  “RFCOMM” (0x0003)
    Channel: 12
  “OBEX” (0x0008)
Profile Descriptor List:
  “OBEX Object Push” (0x1105)
    Version: 0x0100

Above is a series of channels available in my mobile for many types of communications. Search in your output for “OBEX file transfer” or “OBEX object push” or similar text under service name section (highlighted in RED), the rest all is gibberish related to this subject. Take a note of the Channel value. In my case its 12, for Nokia phones it could be 11 and for some other phones it could be something else.

Lets try again to transfer the file by explicitly stating the channel:

bash-4.3# obexftp -b 7C:XX:XX:XX:XX:XX  -B 12 -p /home/zenwalker/Pictures/abc.jpg

But again dead-end with errors:

Connecting..\failed: send UUID
Tried to connect for 120ms
error on connect(): Success
Still trying to connect

Back to drawing board :(. Further investigation revealed that i should force the obexftp tool to ignore UUID (hint taken from error message 😀 )

So now, lets use options “-U NONE” for the above command:

bash-4.3# obexftp -b 7C:XX:XX:XX:XX:XX  -B 12  -U NONE -p /home/zenwalker/Pictures/abc.jpg
Suppressing FBS.
Connecting..\done
Tried to connect for 112ms
Sending “/home/zenwalker/Pictures/abc.jpg”…-done
Disconnecting..\done

Yuppie, at last success 😀

Next step is to add these options into the bluetooth config files to make blueman work successfully. That’s for another blog post 😉

Thanks, hope it helps
Zen 🙂

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s