Sunday, September 11, 2011

[android-developers] Re: Got the Bluetooth blues: Service Discovery Failed

That did it!

I am going to write the authors and ask them to put this in their
errata as it may save others a LOT of wasted time (been working on
this off and on for days).

Thanks!

On Sep 11, 2:35 am, gjs <garyjamessi...@gmail.com> wrote:
> Hi,
>
> Sort of, there is a common UUID used most for 'serial devices', this
> is mentioned in the docs -
>
> 'Hint: If you are connecting to a Bluetooth serial board then try
> using the well-known SPP UUID 00001101-0000-1000-8000-00805F9B34FB.
> However if you are connecting to an Android peer then please generate
> your own unique UUID.'
>
> Seehttp://developer.android.com/reference/android/bluetooth/BluetoothDev...)
>
> Give it a try with your device. I find it works it most bluetooth GPS
> devices, laser range finder and other BT serial devices on Android. I
> only use a random UUID if I am connection to another Android device
> using BT.
>
> Regards
>
> On Sep 11, 1:44 am, darrinps <darri...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I have two text books that cover Bluetooth and have read multiple
> > articles and not one has mentioned the need to do that.
>
> > What I read in the documentation is that the UUID is random:
>
> > "A Universally Unique Identifier (UUID) is a standardized 128-bit
> > format for a string ID used to uniquely identify information. The
> > point of a UUID is that it's big enough that you can select any random
> > and it won't clash. In this case, it's used to uniquely identify your
> > application's Bluetooth service. To get a UUID to use with your
> > application, you can use one of the many random UUID generators on the
> > web, then initialize a UUID with fromString(String)."
>
> > Are you saying that there is some sort of table that exists that
> > specifies my exact device?
>
> > On Sep 8, 10:45 pm, gjs <garyjamessi...@gmail.com> wrote:
>
> > > Hi,
>
> > > Are you sure you are using the correct UUID value for your device ?
>
> > > The default UUID in bluetoothchat usually needs to be changed, see the
> > > Android bluetooth docs.
>
> > > Regards
>
> > > On Sep 8, 2:45 pm, darrinps <darri...@gmail.com> wrote:
>
> > > > I've been fighting this for a long time now and thought I'd ask the
> > > > group.
>
> > > > I have a Samsung Galaxy S running 2.2. I am trying to connect to a
> > > > Bluetooth device (Free2move dongle).
>
> > > > I can get up to the point where I do the
> > > > createRfcommSocketToServiceRecord  and then I get Service Discovery
> > > > Failed.
>
> > > > Here is what my app (VERY closely based on BluetoothChat) is telling
> > > > me:
>
> > > > 09-07 23:41:09.582: DEBUG/BluetoothChatService(11472): Paired device
> > > > found: Free2move WU
> > > > 09-07 23:41:09.582: DEBUG/BluetoothChatService(11472): Found Free2move
> > > > device: 00:0B:CE:03:35:49
> > > > 09-07 23:41:16.644: DEBUG/BluetoothChatService(11472): Will try to
> > > > connect to: 00:0B:CE:03:35:49
> > > > 09-07 23:41:28.637: DEBUG/BluetoothChatService(11472): BluetoothSocket
> > > > created for device: Free2move WU
> > > > 09-07 23:41:28.641: INFO/BluetoothChatService(11472): BEGIN
> > > > ConnectThread
> > > > 09-07 23:41:28.656: INFO/BluetoothChatService(11472): Using socket to
> > > > connect now...
> > > > 09-07 23:41:30.621: DEBUG/BluetoothChatService(11472): setState()
> > > > STATE_NONE -> STATE_CONNECTING
> > > > 09-07 23:41:34.695: ERROR/BluetoothChatService(11472): Connection
> > > > failed
> > > > 09-07 23:41:34.711: DEBUG/BluetoothChatService(11472): setState()
> > > > STATE_CONNECTING -> STATE_LISTEN
> > > > 09-07 23:41:34.730: WARN/BluetoothChatService(11472): Connection
> > > > failed with exception: Service discovery failed
> > > > 09-07 23:41:34.730: WARN/BluetoothChatService(11472): With cause:
> > > > class java.io.IOException
> > > > 09-07 23:41:34.742: WARN/BluetoothChatService(11472):
> > > > android.bluetooth.BluetoothSocket$SdpHelper.doSdp: 377
> > > > 09-07 23:41:34.742: WARN/BluetoothChatService(11472):
> > > > android.bluetooth.BluetoothSocket.connect: 201
> > > > 09-07 23:41:34.762: WARN/BluetoothChatService(11472):
> > > > com.standardandroid.speedpro.bluetooth.BluetoothChatService
> > > > $ConnectThread.run: 569
>
> > > > The code that dies looks like this:
>
> > > > private class ConnectThread extends Thread
> > > >         {
> > > >                 private final BluetoothSocket mmSocket;
> > > >                 private final BluetoothDevice mmDevice;
>
> > > >                 public ConnectThread(BluetoothDevice device)
> > > >                 {
> > > >                         mmDevice = device;
> > > >                         BluetoothSocket tmp = null;
>
> > > >                         // Get a BluetoothSocket for a connection with the
> > > >                         // given BluetoothDevice
> > > >                         try
> > > >                         {
>
> > > >                                 tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
>
> > > > I've seen some reports that this might be a bug in Android itself:http://groups.google.com/group/android-platform/browse_thread/thread/...
>
> > > > Does anyone know? Android folks?
>
> > > > Thanks.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment