Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Posts: 11
Registered: ‎09-20-2008
My Device: Not Specified

Bluetooth runs out of connections when device moves out of range.

Hi,

 

I have a bluetooth device which I am in communication with. The device goes out of range. Connector.open fails with a java.io.IOException (Unable to Connect). I keep trying to connect with Connector.open and after 10 retries I get the exception java.io.IOException (All connections in use). Once this exception is thrown no further connection can be made until the application is closed.

 

Ideally on this failure I would like to close the connection before trying again but the exception prevents the StreamConnection from being returned.

 

The debug from the blackberry is as follows.

 

I call

 

if (connection != null)

{
     connection.close();

     connection = null;

 

}

connection = Connector.open("
btspp://000937600042:1;authenticate=false;encrypt=false;master=false" ) ;

 

and the following occurs

 

 

BT: SPP_EVENT_DISCONNECTED

BT: freeSerialPort a05b86b0
BT: BTEVENT_LINK_DISCONNECT
net.rim.bluetooth: DD16
CMM: ZerodIn-2(5085) no sig from 0x33
BT: allocSerialPort a05b86b0
BT: SPP_EVENT_CONNECTED

BT: BTEVENT_LINK_CONNECT
net.rim.bluetooth: DC04
IOException java.io.IOException: Unable to connect.


 

After a few more failed attempts...

 

I get this...

 


JVM: bklt @169854: timer
JVM: bklt @169855: idle 15
JVM: bklt @169856: setTimer 15
CMM: ZerodIn-2(5085) no sig from 0x33
BT: openClientPort: All connections in use
Tag[bluetooth] : IOException java.io.IOException: All connections in use

 

 

 

Is there a prefered way to handle a client device going out of range and then back into range again ?

 

All the best,

 

Dave

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Bluetooth runs out of connections when device moves out of range.

Please ensure that you are closing connections based on the example here:

 

How To - Close connections 
Article Number: DB-00530

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/How_To_...

 

What BlackBerry model and handheld software version are you testing with?  You can see this under Options, About on the BlackBerry.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Bluetooth runs out of connections when device moves out of range.

If I understand the OP, he is claiming that the debug output shows that a connection was established but the IOException

was thrown before the assignment completed leaving an orphan connection.

 

True?

New Developer
Posts: 11
Registered: ‎09-20-2008
My Device: Not Specified

Re: Bluetooth runs out of connections when device moves out of range.

Hi,

 

Yes, the connection is orphaned when that exception is thrown. 

 

We have several different handsets which are exhibiting the same issue.

 

The phone I have here is a blackberry 8700 (EDGE)

v4.2.1.101 (Platform 2.3.0.81)

 

All the best,

 

Dave.

 

New Developer
Posts: 11
Registered: ‎09-20-2008
My Device: Not Specified

Re: Bluetooth runs out of connections when device moves out of range.

When I exit the application I get the following...

 

MN: unload 1
BT: freeSerialPort a03751e0
BT: freeSerialPort a0375884
BT: freeSerialPort a0375730
BT: freeSerialPort a03755dc
BT: freeSerialPort a0375488
BT: freeSerialPort a0375334
BT: freeSerialPort a0374f38
BT: freeSerialPort a0375b2c
BT: freeSerialPort a03759d8
Foreground net_rim_bb_ribbon_app(53)

 

Is there any way to manually free these serial ports when the error is detected ?

 

Dave.

Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Bluetooth runs out of connections when device moves out of range.

I've never used this but I'm always interested in IO problems with resource usage.

From what I can determine, the support is mostly in javax and so is probably also discussed

at Sun,

 

http://www.google.com/search?hl=en&q=site%3Asun.com+Bluetooth+Connection&btnG=Search

 

But there is also a RIM class that offers a close() method on the SerialPort,

 

http://www.blackberry.com/developers/docs/4.0.2api/net/rim/device/api/bluetooth/BluetoothSerialPort....

 

You might try calling close or disconnect on one of these as they claim to close the hardware resources,

not the "profile" that the ctor is supposed to make.

 

 

 

Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Bluetooth runs out of connections when device moves out of range.

To make a religious point, I would also mention that you could grep rendered javadocs for terms like bluetooth to see what things

might be avialable, LOL ( see other thread from Linux guy that almost started a flame war),

$ grep -l Bluetooth *
blackberry.api.invoke.Invoke.txt
device.api.bluetooth.BluetoothSerialPort.txt
device.api.bluetooth.BluetoothSerialPortInfo.txt
device.api.bluetooth.BluetoothSerialPortListener.txt
device.api.bluetooth.package-frame.txt
device.api.bluetooth.package-summary.txt
device.api.bluetooth.package-tree.txt
device.api.media.control.AudioPathControl.txt
device.api.servicebook.ServiceRouting.txt
device.api.servicebook.package-summary.txt
device.api.system.CoverageInfo.txt
device.api.system.CoverageStatusListener.txt
device.api.system.IOPort.txt
device.api.system.package-summary.txt

New Developer
Posts: 11
Registered: ‎09-20-2008
My Device: Not Specified

Re: Bluetooth runs out of connections when device moves out of range.

I've already stumbled across that implementation. There is no associated serial port manager, that I could find, which would allow iteration of the allocated serial ports.

 

I have been searching for days now and have so far not come up with a workaround.

 

Has anyone else experienced this bug ?

 

Do you use a different method to communicate across bluetooth ?

 

Dave.

Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Bluetooth runs out of connections when device moves out of range.

It doesn't seem to be abstract, can you use this instead of a connection?

AFAIK from the API it probably tries to connect in the ctor, not sure what could go wrong there.

 

No, I haven't used BT but am curious about it and IO flukes more generally. Asynchronous events

are always hard to process in a robust consistent way. I guess you could tell users not to move while

you are connected, LOL.

 

I think I had looked at this briefly and was mostly interested in discovery and IIRC the RIM classes

or at least the older ones didn't support server discovery so I stopped.

 

New Developer
Posts: 7
Registered: ‎05-17-2009
My Device: Not Specified

Re: Bluetooth runs out of connections when device moves out of range.

I recently came across the same issue as the OP, has anyone found a solution to this?