Closed GoogleCodeExporter closed 8 years ago
Actually, I can't reproduce the error. Running the following code in an
Activity:
try {
LocalBluetoothDevice local = LocalBluetoothDevice.initLocalDevice(this);
RemoteBluetoothDevice remoteBluetoothDevice =
local.getRemoteBluetoothDevice("01:23:45:67:89:AB");
BluetoothSocket bluetoothSocket = remoteBluetoothDevice.openSocket(12);
} catch (Exception e) {
System.out.println("THERE WAS AN ERROR WITH BLUETOOTH!");
}
The exception is thrown by the openSocket() method and the string "THERE WAS AN
ERROR
WITH BLUETOOTH!" is printed.
Original comment by gerda...@gmail.com
on 12 Sep 2009 at 11:37
Here's attached test project in Eclipse cause I'm not sure if I'm missing
something.
openSocket() just doesn't throw anything. (Running FW CyanogenMod-4.0.4. on G1)
Original comment by smartmad...@gmail.com
on 13 Sep 2009 at 2:37
Attachments:
hi smartmadsoft.com:
Are you sure you also don't get any error message in logs? If you use logcat to
monitor output message, there should be something to indicate you it can not
connect
to remote device.
BTW: have you ever really connected to other device and did data communication
by
using this API? I got problem on this but am not sure if it's due to my code or
my
Hero device or something else
Original comment by likunarm...@gmail.com
on 14 Sep 2009 at 8:21
I have the same issue. No execption is thrown when I call openSocket(port) to a
device which is switched off.
I run HTC Dream and HTC Magic both with latest original T-Mobile build (1.5r3)
CRC1.
Original comment by bonifaz....@gmail.com
on 14 Sep 2009 at 8:50
I tried the test project uploaded by smartmadsoft, the error information will
be
showed in lagcat:
No route to host (113)
which means although there is no exeception thrown, the connection is still not
correct.
To bonifaz.kaufmann: can you connect to online device normally?
Original comment by likunarm...@gmail.com
on 14 Sep 2009 at 9:25
Yes everything works fine when I connect to a online device.
Original comment by bonifaz....@gmail.com
on 14 Sep 2009 at 9:54
I get this error in Logcat when I try to connect to an offline device.
09-14 18:03:14.921: ERROR/bluetooth_RfcommSocket.cpp(1889): connect error: Host
is
down (112)
but no exception which I could catch.
Original comment by bonifaz....@gmail.com
on 14 Sep 2009 at 10:04
Emmm......bonifaz.kaufmann, would you mind to share more information, like
talking
about online device, you mean another android phone, or any device supporting
SDD
profile? I am using Hero and did exact procedure as the example project, but
always
get
connect error: No route to host (113)
did you do it like this?
localDevice = LocalBluetoothDevice.initLocalDevice(this);
remoteDevice = localDevice.getRemoteBluetoothDevice(address_kkli);
RemoteBluetoothDeviceEventHandler listener = new
RemoteBluetoothDeviceEventHandler();
listener.device = remoteDevice;
remoteDevice.setListener(listener);
remoteDevice.pair();
In pair:
RemoteBluetoothDevice device
device.openSocket(port);
I would be very appreciate if you can help!
Original comment by likunarm...@gmail.com
on 15 Sep 2009 at 3:38
Well, I use basically RFCOMM and SDP and I connect an Android phone to another
Bluetooth Device with SPP. When I say online-device I mean a bluetooth device
which
is turned on and ready to receive pairing and connection requests.
I figured out that if you have paired your device once, you don't need to pair
it
again, since the localbluetooth device still remembers the last paired device.
So I just call isPaired() and I only pair again if this is false, if it is true
I
immidiately call openSocket() otherwise I pair and then call openSocket().
I tried both, openSocket(port) within the callback method paired() and
openSocket
without pairing before, but with an already paired device. In either case it
raises
no exception, but says "Host is down (112)" but this comes from the C-Library
itself
and can not be caught by a try-catch block.
The error you got (113) is only if you don't have a paired device but try to
call
openSocket I suppose.
Nevertheless, I can't say if I am connected or not, since I can't catch the
"host is
down" error. I just will try to catch an error instead of an exception next.
Hopefully this will do the trick but not very convinced about that.
Original comment by bonifaz....@gmail.com
on 15 Sep 2009 at 4:24
The reason I said it's weird is, I did pair the two device and apparently the
pairing
is successful, I can see the paired device, which is Hero, from my custom
device. But
still get this error.
The critical point is, did you ever try to communicate DATA between the device
and
your phone, and succeed in it?
Original comment by likunarm...@gmail.com
on 15 Sep 2009 at 4:31
Yes definitely. I can send and receive data over RFCOMM using inputStream and
outputStream.
Original comment by bonifaz....@gmail.com
on 15 Sep 2009 at 4:32
What if it requires the pin? Do you input it by the dialog from notification
bar or
you implement a special pin pair function?
BTW, for the port number in openSocket function, I thought it doesn't matter,
am I
correct or it does matter?
Original comment by likunarm...@gmail.com
on 15 Sep 2009 at 5:39
I see the same Error in log as bonifaz.kaufmann (but no
Error/Throwable/Exception is
thrown): ERROR/bluetooth_RfcommSocket.cpp(1889): connect error: Host is
down (112)
Here's attached stack trace if it's any help.
Original comment by smartmad...@gmail.com
on 15 Sep 2009 at 6:36
Attachments:
Port number does matter, I use port 1.
setPin(pin) does not work for me really (for some reason it just ignores it), I
have
to use the notification bar with the dialog to enter a pin when I pair the
first
time.
Original comment by bonifaz....@gmail.com
on 15 Sep 2009 at 1:11
Emmmmm, then I don't know now, I tried many times but always get
connect error: No route to host (113)
Regardless of connecting to laptop(support SPP) or my custom device
One quick question, why do you use port 1, is it the configuration in Android?
Or some
other reasons?
Original comment by likunarm...@gmail.com
on 15 Sep 2009 at 4:33
I use port 1 since my device I am connecting to uses that port.
Original comment by bonifaz....@gmail.com
on 15 Sep 2009 at 5:31
Hello everybody.
I've checked that some errors where not captured by the API. In fact, some
errors are
reported as booleans instead of exceptions by the Bluetooth service.
Next week I'll check in the new version.
Stefano.
Original comment by gerda...@gmail.com
on 1 Oct 2009 at 12:39
How to find and connect the RFCOMM service? Like j2me.
Original comment by zxpp...@gmail.com
on 5 Oct 2009 at 1:19
Hi Stefano,
I tried your new version 0.3b1, which is great. A lot of stupp seems to be
added.
However,
try {
bluetoothSocket = remoteBluetoothDevice.openSocket(port);
output = bluetoothSocket.getOutputStream();
input = bluetoothSocket.getInputStream();
}
catch (BluetoothException be) {
Log.e(TAG, "BluetoothException. Device not online!");
}
catch (Exception e) {
Log.e(TAG, "Device not found!");
}
still throws no Exception when the device is not online.
By the way, will you try to support Android 1.6? Or does this version 0.3b1
already
work with Donut?
Original comment by bonifaz....@gmail.com
on 7 Oct 2009 at 5:47
Hello Bonifaz.
Please, check the 0.3b2.
The library has been tested on HTC Dream and HTC Tatoo, both with official Donut
firmware, and it works.
Please, let me know if now it works on you stuff.
Original comment by gerda...@gmail.com
on 17 Oct 2009 at 8:38
Original comment by gerda...@gmail.com
on 17 Oct 2009 at 8:38
I will test it tomorrow when I am at the Lab.
Original comment by bonifaz....@gmail.com
on 19 Oct 2009 at 12:31
BluetoothException is thrown now, finally this gives us a way to find out if a
device
is connected or not.
Thanks a lot Stefano
p.s. tested on 1.5 and 1.6 (HTC Magic and G1)
Original comment by bonifaz....@gmail.com
on 20 Oct 2009 at 4:06
Thank you Bonifaz for your feedback, really appreciated.
Original comment by gerda...@gmail.com
on 20 Oct 2009 at 4:45
Hi guys, with HTC Hero or HTC Magic, I get
connect error: No route to host (113)
Everytime. but the device can connect to it no problem through settings.
Something wrong in the API? Or something I do wrong?
The device is paired:
try
{
LocalBluetoothDevice.initLocalDevice(this);
mLocalBluetoothDevice = LocalBluetoothDevice.getLocalDevice();
if (mLocalBluetoothDevice == null)
{
log("Device does not support Bluetooth", RED);
return;
}
mJabraDevice = mLocalBluetoothDevice.getRemoteBluetoothDevice("00:07:A4:BD:AC:51");
if (mJabraDevice == null)
{
log("Jabra device was not found", RED);
return;
}
log("Jabra device was found", GREEN);
mJabraDevice.setPin("0000");
mBluetoothSocket = mJabraDevice.openSocket(1);
}
catch (BluetoothException e)
{
log(e.getMessage(), RED);
e.printStackTrace();
return;
}
catch (Exception e)
{
log(e.getMessage(), RED);
e.printStackTrace();
return;
}
log("Connected", GREEN);
Original comment by daivuk@gmail.com
on 24 Feb 2010 at 9:14
Hi daivuk,
did you solve the problem? I also get a "No route to host (113)" on a HTC
Tattoo.
regards
Stefan
Original comment by stefanpa...@googlemail.com
on 17 Mar 2010 at 2:29
Can you tell us how it is fixed?
Original comment by smartine...@gmail.com
on 24 Feb 2012 at 10:19
Original issue reported on code.google.com by
smartmad...@gmail.com
on 7 Sep 2009 at 7:03