> Bluetooth has the following Exceptions (JSR 82 see http://java.sun.com/javame/reference/apis/jsr082/ )
> Is it possible to detect when a Bluetooth device moves out side of the range of another?
> With a device having moved outside of the range, trying to communicate with that device will result in a null pointer exception. Is it possible to know that the device has moved outside the range?
> Having moved outside the range for a few seconds the device moves back within range, can this some how be detected, and the original connection re-established?
> Is their some way to define that if a device has moved outside the range for a predetermined amount of time that the device is now no longer available?
> Also is it possible to detect if a device that you are in communication with suddenly dies, i.e. switched off by the user, interrupted by another application etc.
> If none of this is available is JSR82, can you recommend any other implementations that provide some or all of this functionality.
> Thanks in advance for any insight you may have on this.
> [Message sent by forum member 'mobilecoder' (mobilecoder)]
I'm forwarding your e-mail questions to the email@example.com
forum. They should be able to help you on that mailing list instead of
the firstname.lastname@example.org mailing list.
To unsubscribe, e-mail: email@example.com
For additional commands, e-mail: firstname.lastname@example.org
It looks like you need to control the Bluetooth signal level and catch a moment when a signal from the paired device disappear and appears again. As it is made in the Hands Free bluetooth profile. It could be possible via low level HCI protocol.
This protocol is not used by JSR82 directly and such possibility there is not in JSR82.
You could try to find some other API that have an access to the HCI protocol (BlueZ, for instance).
> email@example.com wrote:
> > Bluetooth has the following Exceptions (JSR 82 see
> http://java.sun.com/javame/reference/apis/jsr082/ )
> > BluetoothConnectionException
> > BluetoothStateException
> > ServiceRegistrationException
> > Is it possible to detect when a Bluetooth device
> moves out side of the range of another?
> > With a device having moved outside of the range,
> trying to communicate with that device will result in
> a null pointer exception. Is it possible to know that
> the device has moved outside the range?
> > Having moved outside the range for a few seconds
> the device moves back within range, can this some how
> be detected, and the original connection
> > Is their some way to define that if a device has
> moved outside the range for a predetermined amount of
> time that the device is now no longer available?
> > Also is it possible to detect if a device that you
> are in communication with suddenly dies, i.e.
> switched off by the user, interrupted by another
> application etc.
> > If none of this is available is JSR82, can you
> recommend any other implementations that provide some
> or all of this functionality.
> > Thanks in advance for any insight you may have on
> > [Message sent by forum member 'mobilecoder'
I agree with Andrey, JSR-82 instantly doesn't provide such functionality.
The only way you can be notified about something is wrong with a JSR-82 connection - getting IOException while calling send/receive methods, even in this case most probably the exception doesn't contain details about root cause of the failure.
I'm not sure there is a Java API allowing to access such low-level functionality as you are looking for. BlueZ, given as an example by Andrey, is native (C) stack.
Whether connection is re-established if remote device returns back, depends on particular JSR-82 implementation as well as underlining bluetooth stack and settings for certain local and remote devices.
There is not special event in JSR-82 that filed if remote device is switched off.
You also mentioned three JSR-82 exceptions and I would like to clarify what they are used for (the descriptions are taken from the JSR-82 specification):
1) public class BluetoothConnectionException extends java.io.IOException
This BluetoothConnectionException is thrown when a Bluetooth connection (L2CAP, RFCOMM, or OBEX over RFCOMM) cannot be established successfully. The fields in this exception class indicate the cause of the exception. For example, an L2CAP connection may fail due to a security problem. This reason is passed on to the application through this class.
2) public class BluetoothStateException extends java.io.IOException
The BluetoothStateException is thrown when a request is made to the Bluetooth system that the system cannot support in its present state. If, however, the Bluetooth system was not in this state, it could support this operation. For example, some Bluetooth systems do not allow the device to go into inquiry mode if a connection is established. This exception would be thrown if startInquiry() were called.
3) public class ServiceRegistrationException extends java.io.IOException
The ServiceRegistrationException is thrown when there is a failure to add a service record to the local Service Discovery Database (SDDB) or to modify an existing service record in the SDDB. The failure could be because the SDDB has no room for new records or because the modification being attempted to a service record violated one of the rules about service record updates. This exception will also be thrown if it was not possible to obtain an RFCOMM server channel needed for a btspp service record.
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Participation.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.