Tracking down L2CAP connection problems

6 views
Skip to first unread message

Garth

unread,
Feb 13, 2008, 4:19:57 PM2/13/08
to bluecove-users
I decided to download the source to see if I could track down the
cause of my connection problems. If you remember, I've been having
problems connecting multiple Wiimotes. Usually the first 1 or 2
connect fine, but the 3rd often takes a long time to connect, or
doesn't connect at all.

I discovered that in WIDCOMMStackL2CAP.cpp that at about line 194
there is a call:

DWORD rc = WaitForSingleObject(l2c->hConnectionEvent, 500);

which I'm guessing is waiting for the connection to finish opening.
When my timeouts occur this never gets signalled.

A couple of questions:

1. Where is this signalled? I am not a Windows programmer, so wasn't
able to track down what signals this. If I know where it is signalled
I can maybe find out why it isn't happening.

2. Is there a reason for the 500ms wait time? Would it not be easier
to use the timeout value?

Thanks,
Garth

Vlad Skarzhevskyy

unread,
Feb 13, 2008, 4:39:52 PM2/13/08
to bluecov...@googlegroups.com
First:
The hConnectionEvent is set in WIDCOMMStackL2CapConn::OnConnected()

Second:
The timeout Exception are controlled in a while loop by this code
((GetTickCount() - waitStart) > (DWORD)timeout)

The 500ms wait time Allows the application to interrupt connection
thread or shutdown the application any time with 500ms delay.

Java System property "bluecove.connect.timeout" control the time
application will wait for L2CAP connection to be established before it
throw BluetoothConnectionException "Connection timeout"
BTW it defaults to 2 minutes!

Extract from: http://code.google.com/p/bluecove/wiki/Documentation
------
Configuration options

System properties: (Since v2.0.2)

* `bluecove.connect.timeout` The amount of time in
milliseconds for which the implementation will
attempt to establish connection RFCOMM or L2CAP before it throws
!BluetoothConnectionException. Defaults to 2 minutes. WIDCOMM
and OS X only.
------

--
Vlad

Reply all
Reply to author
Forward
0 new messages