Skip to main content

Bluetooth Driver

2 replies [Last post]
Anonymous

I am writing a Bluetooth driver and am trying to implement auto reconnect, I
can sucessfully connect and disconnect. I want to have the application auto
connect if the connection is dropped. I have listeners that raise events for
open

streamConn = (StreamConnection)Connector.open("btspp://" + address);

but once the connection is open how can I detect if the connection is
dropped? I could add a exception handler on read() but there could be a
valid exception and I can not assume that an exception is a dropped
connection. Is there a way to detect if the StreamConnection is closed?

Thanks

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Roger

Just split up your exception handling (what do you mean by "valid
exception"?). Once you catch a SocketException (or similar), you
shouldn't have any problems with categorizing the problem.

Another tipp: let em ping frequently. Bluetooth connections aren't as
stable as usual socket connections for some particular reasons, that are
plain to see. So the exception might be thrown before the trouble raises
and you even might reconnect in time.

I highly appreciate writing a very sophisticated Connection (-Pool)
Manager since Bluetooth surprises in several cases. Keep in mind, that
there are lots of different BT stacks. E.g. a Widcomm stack works
completely different from BlueZ asf..

Best,

Roger

Chris Rotberg schrieb:
> I am writing a Bluetooth driver and am trying to implement auto
> reconnect, I can sucessfully connect and disconnect. I want to have
> the application auto connect if the connection is dropped. I have
> listeners that raise events for open
>
> streamConn = (StreamConnection)Connector.open("btspp://" + address);
>
> but once the connection is open how can I detect if the connection is
> dropped? I could add a exception handler on read() but there could be
> a valid exception and I can not assume that an exception is a dropped
> connection. Is there a way to detect if the StreamConnection is closed?
>
> Thanks
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the
> body of the message "signoff KVM-INTEREST". For general help, send
> email to listserv@java.sun.com and include in the body of the message
> "help".

--
/**************************
* Roger F. Hösl
* Engelthaler Str. 5
* 60435 Frankfurt
* Fon: (069) 79202638
* Mobil: 0172 1409984
* Fax: (069) 79202978
* Mail: roger@crazything.de
**************************/

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Chris Rotberg

I am using the javax.Bluetooth classes

What are the stack events that are thrown, is seems I am having trouble
catching the SocketException, it is showing a phone generated disconnect
notice that I am trying to catch

Thanks

_____

From: A mailing list for KVM discussion [mailto:KVM-INTEREST@JAVA.SUN.COM]
On Behalf Of Roger
Sent: Saturday, May 17, 2008 10:22 AM
To: KVM-INTEREST@JAVA.SUN.COM
Subject: Re: Bluetooth Driver

Just split up your exception handling (what do you mean by "valid
exception"?). Once you catch a SocketException (or similar), you shouldn't
have any problems with categorizing the problem.

Another tipp: let em ping frequently. Bluetooth connections aren't as stable
as usual socket connections for some particular reasons, that are plain to
see. So the exception might be thrown before the trouble raises and you even
might reconnect in time.

I highly appreciate writing a very sophisticated Connection (-Pool) Manager
since Bluetooth surprises in several cases. Keep in mind, that there are
lots of different BT stacks. E.g. a Widcomm stack works completely different
from BlueZ asf..

Best,

Roger

Chris Rotberg schrieb:

I am writing a Bluetooth driver and am trying to implement auto reconnect, I
can sucessfully connect and disconnect. I want to have the application auto
connect if the connection is dropped. I have listeners that raise events for
open

streamConn = (StreamConnection)Connector.open("btspp://" + address);

but once the connection is open how can I detect if the connection is
dropped? I could add a exception handler on read() but there could be a
valid exception and I can not assume that an exception is a dropped
connection. Is there a way to detect if the StreamConnection is closed?

Thanks
===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

--

/**************************

* Roger F. Hösl

* Engelthaler Str. 5

* 60435 Frankfurt

* Fon: (069) 79202638

* Mobil: 0172 1409984

* Fax: (069) 79202978

* Mail: roger@crazything.de

**************************/
===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]