# Bluetooth - opd, obex and me

## the_enigma

Ok, I've got Bluez Bluetooth running.  I can connect to virtual serial ports fine, so my next step is setting up obex.  I managed to get opd to compile by linking /usr/lib/libbluetooth.so to /usr/lib/libsdp.so for the compile.  It compiles cleanly, but I'm still hesitant as to whether that is the right idea.  Either way though, opd does link against libsdp.so so without it it won't compile.  I'm guessing it's just because bluez-sdp got merged into bluez-libs.

So anyway, it runs now.  But it errors out

```
delta opd # opd --mode OBEX --path /tmp --channel 10 --sdp

opd[24661]: OBEX Push Daemon - version 0.2 started

opd[24661]: OBEX Object Push service registered with sdpd

opd[24661]: Failed to register BtOBEX server on RFCOMM channel 10. (-94 / 0)

delta opd # 
```

I'm not sure what that code means, but I tried testing with obex_test

```
enigma@delta ~/downloads/openobex-apps-1.0.0/src $ ./obex_test -b 00:0e:07:5d:1c:e4

Using Bluetooth RFCOMM transport

OBEX Interactive test client/server.

> p /home/enigma/me.jpg me.jpg

PUT file (local, remote)> name=/home/enigma/me.jpg, size=5089

Going to send 5089 bytes

Link broken!

Error while doing OBEX_HandleInput()

> 
```

Don't know if that's relevant, but that's another error message.

I've started the bluetooth service, so hcid, rfcomm and sdpd are all running.

Any ideas/

----------

## the_enigma

More info for people to read about.

I found obexftp somewhere, so I decided to see how it functioned.

```
enigma@delta ~/downloads/openobex-apps-1.0.0/src $ obexftp -b 00:0e:07:5d:1c:e4  -l

Browsing 00:0E:07:5D:1C:E4 ...

Channel: 7

No custom transport

Connecting...bt: -94

failed: connect

Still trying to connect

Connecting...bt: -94

failed: connect

Still trying to connect

Connecting...bt: -94

failed: connect

Still trying to connect
```

Not well.  The exact same error is coming from both obexftp and opd (-94).  Anyone know where this comes from, or what it could mean?  I've tried rummaging around the source code, but I can't seem to trace where it's coming from.

Any ideas?

Edit: More tests

So I now actually try to connect when using obex_test.  Seems I forgot to read the documentation last time?

```
enigma@delta ~/downloads/openobex-apps-1.0.0/src $ ./obex_test -b 00:0e:07:5d:1c:e4

Using Bluetooth RFCOMM transport

OBEX Interactive test client/server.

> c

Transport connect error! (Bluetooth)
```

So, still no good.  But I'm pretty sure it's something in openobex which has gone funny.  

lsmod (cropped)

```
Module                  Size  Used by

rfcomm                 35932  0 

l2cap                  23364  5 rfcomm

hci_usb                10824  2 

bluetooth              45188  7 rfcomm,l2cap,hci_usb

```

And yes, bluetooth the service is started, hcid and spd are running, and I can use Bluetooth fine via rfcomm, and I can even sync my phone (SE T610) and Evolution2.  Just obex, and I'll have a fully functional Bluetooth whizbang thing.

----------

## the_enigma

I'm getting somewhere ..

Reading http://www.koders.com/c/fid62D887B6D5092B71D032CA3D231510CB00DA2E47.aspx?s=BtOBEX_ServerRegister

after a bit of tracing, seems I get -ESOCKTNOSUPPORT returned.  So that's my problem

Now I just have to work out why it was compiled without bluetooth support.

Now I'm not silly, I have tried many times to recompile both openobex and opd, and nothing seemed to fix anything.

One thing that has me confused is the fact that neither use the bluetooth USE flag.  They both seem to check during 'configure'.  So I'm guessing that when I was compiling them, I didn't have the Bluetooth service started, so it didn't find any bluetooth devices and didn't compile with bluetooth support.

So yeah, now it works  :Very Happy: 

----------

## the_enigma

I'm back and I broke something.

Somehow, since May, somethings been broken.  All my bluetooth services start fine.  I can pair my phone many times (deleting the pairing inbetween) with no problems.  'opd' starts up no problems, and registers with sdp with no problems.  However, when I try to send a file (picture) from my phone (T610) to my laptop, opd and hcid both report nothing happening at all.  And of course my phone eventually says "Bluetooth connection failed".  If I try to send when the phone is unpaired, I still get nothing.  

Anyone have any ideas on what I broke this time?

----------

## the_enigma

Just playing around some more with this.  For some reason, opd fails to register with SDP when using channel 10.  

```
Sep 24 11:15:39 [opd] Failed to register BtOBEX server on RFCOMM channel 10. (-1 / 98)_
```

I've no idea what the underscore is for, but it's there for all other channels.  And opd starts fine for all other channels.  But still, I can't get opd or hcid to even do anything when I try to send a file from my T610 to my laptop.  The lights on the bluetooth module light up, so the module is definately recieving some form of communication.

Edit:  Just noticed, opd sometimes says 

```

opd[13268]: Terminating .. 

*** glibc detected *** free(): invalid pointer: 0x0804dcfc ***

```

on exiting.  So I'm gonna try to recompile it, or go back to an older version.

Edit again:  v0.2 does the same, and recompiling 0.2-r1 doesn't help either.  No surprise, as the only difference between the two is linking against libbluetooth.so as opposed to libsdp.so as mentioned in my first post.

Anyway, played a bit with hcidump, but all I can get is this:

http://www.strudel-hound.com/hcidump.filesend.txt

Possibly not much help unless someone really understands Bluetooth however.

----------

## the_enigma

Ok, more fixed.

Somehow, rebooting fixed my channel 10 problems.  So now I can send files again.  Beats me why, though.

I've edited /etc/hotplug/usb/hci_usb to start the bluetooth and opd services.  But how can I stop those services when removing the module?  Or I suppose the services should be stopped prior to removing the module.  Might do that instead.

----------

## kira09

Hello,

I have the same problem but I still can't solve it:

```
#opd --mode OBEX --channel 10 --path /root/bluetooh-inbox/ --sdp --metadata

opd[246]: OBEX Push Daemon - version 0.2 started

opd[246]: OBEX Object Push service registered with sdpd

opd[246]: Failed to register BtOBEX server on RFCOMM channel 10. (-121 / 0)

```

Have you an idea on the subject, or some information which lead to resolve this Problem?

I do some researches on the subject but the web sites and forums which mention this problem are rare.

Thanks in advance for any help,

----------

## kira09

Please I really need help, I have to solve this problem.

I've done many researches on the subject but I still have the same problem.

Please help me,

----------

