Re: IOBluetoothDeviceRegisterForDisconnectNotification
Re: IOBluetoothDeviceRegisterForDisconnectNotification
- Subject: Re: IOBluetoothDeviceRegisterForDisconnectNotification
- From: "Christian Martin" <email@hidden>
- Date: Mon, 23 Oct 2006 14:30:19 -0400
Hi Joe,
I appreciate you took some time to answer my question(s). I am not an
experienced programmer on OS X so I tend to go ahead with the best of my
knowledge.
I am currently able to start a java application, load a JNI which contains
the appropriate calls to triger a device search. The only way I can get a
list of all the devices is to set a separate thread (inside the JNI in C)
which has the series of calls for a device search and, at the end, I make a
call to the runloop. By doing so, the callback fctns are called and I can
get the list of devices available.
Obviously, the thread never dies since it is caught in the runloop. I can
say it works !... but can I claim it is thread safe ??? This is where I am
lost. You state : "...thread restriction I claim is indeed true for the C
apis ..." . I do not know where I can get a clear answer on this... I guess
I am pushing it a bit too much in doing something that stands out of realm
of reasonable path to follow !
Anyway...
I will try to dig in a bit more...
Thx
Christian
Christian,
It's not impossible. First I would verify that the thread restriction I
claim is indeed true for the C apis (I've been using the ObjectiveC api).
This would probably involve getting the bluetooth working first by calling
your C functions (that you're wrapping in JNI) in a purely C environment
using main and non-main threads -- query, connect, open channel,
send/receive, close channel, disconnect.
Second, if you find that it doesn't work except on the main thread, you
might investigate whether you can set up the main thread before you run
the jvm. I would be fairly certain (your mileage may vary ;-) that once
you enter the jvm that it sits in a runloop and fields window manager
events. You could add a bunch of sources to the main thread's runloop, and
your jni functions could post requests to the main thread by triggering
those sources, which would then carry out the bluetooth operation on the
main thread. Etc.
If you plan on talking to one device at a time, this should be fairly
straightforward. For simultaneous devices, you might have to implement a
command queue of some kind.
I'm CC'ing this back to the list in hopes that someone more knowledgeable
about Bluetooth, Java, threading, etc. than I will chime in...
Joe
On Oct 20, 2006, at 7:53 AM, Christian Martin wrote:
Hi Joseph,
Thx for your rapid answer.
I am currently working on a Java Application which would need some call
into the api of bluetooth. So, I did a JNI to wrap it up. Now, according
to what you are saying JAVA/JNI/Bluetooth is not possible !
Please let me know if there is an avenue that I am missing... I am
seriously stuck here.
Thx.
Christian Martin
B.Sc. Math/Computer
From: Joseph Kelly <email@hidden>
To: Christian Martin <email@hidden>
Subject: Re: IOBluetoothDeviceRegisterForDisconnectNotification
Date: Thu, 19 Oct 2006 13:57:21 -0700
The Apple Bluetooth implementation is not thread safe. In order for it
to work correctly, you must make all calls from the main thread.
Joe K.
On Oct 19, 2006, at 12:57 PM, Christian Martin wrote:
IOBluetoothDeviceRegisterForDisconnectNotification
_________________________________________________________________
Say hello to the next generation of Search. Live Search try it now.
http://www.live.com/?mkt=en-ca
_________________________________________________________________
Ready for the world's first international mobile film festival celebrating
the creative potential of today's youth? Check out Mobile Jam Fest for your
a chance to WIN $10,000! www.mobilejamfest.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden