connect to it.
1) Find out what's the service UUID - run "sdptool browse" on linux
or 2) Connect directly to specific RFCOMM channel -
http://code.google.com/p/android/issues/detail?id=5427 (not official
API!)
On May 18, 11:06 pm, Chris <cbu...@gmail.com> wrote:
> Hi, I have an app that is trying to connect to another device that is
> not running Android, I have code written in C# to connect to it but I
> do not know how to get around this UUID parameter. I cannot access
> this device, nor do I know of a PIN so I cannot pair with it through
> the Bluetooth Settings. I read somewhere that Android needs to be
> paired with the device before it can connect, is this true?
>
> Currently my app discovers all Bluetooth devices and I select which to
> connect to. I've tried many different UUIDs from what I've found
> online, the most common being "00001101-0000-1000-8000-00805F9B34FB".
> So far nothing has allowed me to connect. Below is a snippet of my
> connect method. Is there anyway I can work around this UUID issue?
>
> private int connect(BluetoothDevice device)
> {
> dev = device;
>
> BluetoothSocket tmp = null;
>
> try
> {
> tmp = dev.createRfcommSocketToServiceRecord(MY_UUID);
> } // try
> catch (IOException e)
> {
> Log.e("", "create() failed" , e);
> } // catch
>
> sock = tmp;
> ba.cancelDiscovery();
> Log.d("BT", "Starting connect");
>
> try
> {
> sock.connect();
> Log.d("BT", "CONNECTED!");
>
> if(createStreams() < 0)
> return(-1);
> } // try
> catch (IOException e)
> {
> Log.e("BT", "Failed to connect");
> // make toast
> Context con = getApplicationContext();
> CharSequence text = "Bluetooth socket connect failed";
> int duration = Toast.LENGTH_SHORT;
> Toast toast = Toast.makeText(con, text, duration);
> toast.show();
>
> try
> {
> sock.close();
> } // try
> catch (IOException e2)
> {
> Log.e("BT", "Unable to close() socket during connection
> failure", e2);
> } // catch
> return(-1);
> } // catch
> ...
>
> } // connect
>
> Thanks all help is appreciated,
>
> cbudz
>
> --
> 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 athttp://groups.google.com/group/android-developers?hl=en
--
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