Bluetooth autopairing

83 views
Skip to first unread message

Tez

unread,
Oct 19, 2010, 7:13:05 AM10/19/10
to android-platform
Hi,

I am trying to understand how the bluetooth subsystem works on
android, the ultimate aim being to modify it in such a way that I can
auto-pair in certain cases.

1. When a connection request is received, what part of the system code
is invoked?
on the Java layer, on the C layer.
2. What is the function of bluetoothd?
3. Can I implement some logic that receives RFCOMM conn requests and
first processes it before it is sent higher up thru the framework in
Java? or would it be better to implement it in C (some daemon that
must be running)

Cheers,
Earlence

Tez

unread,
Oct 19, 2010, 8:23:12 AM10/19/10
to android-platform
I have located "BluetoothEventLoop.java"

From an initial glance at the file, it seems events that are received
by the lower systems are propagated here.
Is this understanding correct?

I will place hooks in each "onXYZ" method and initiate a connection
and see what happens. (after rebuilding the platform)
If anyone can save me the trouble, it would be much obliged.

Cheers,
Earlence

Pavan Savoy

unread,
Oct 19, 2010, 10:18:56 AM10/19/10
to android-...@googlegroups.com
bluetooth on android uses the open-source bluez stack - bluez.org
also bluez kind of talks to external world via dbus so
www.kernel.org/doc/ols/2006/ols2006v1-pages-421-426.pdf ..

there are few exceptions to this IPC .. but concept pretty much
remains same as other linux flavors...

> --
> You received this message because you are subscribed to the Google Groups "android-platform" group.
> To post to this group, send email to android-...@googlegroups.com.
> To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.
>
>

--
--Pavan Savoy

Tez

unread,
Oct 20, 2010, 8:45:56 AM10/20/10
to android-platform
anyone knows about the BluetoothEventLoop class mentioned above and is
it suitable for my purposes?

Cheers,
Earlence

Ash

unread,
Oct 20, 2010, 9:43:23 AM10/20/10
to android-platform
Hey,

BluetoothEventLoop is used to handle generic bluetooth events like
device discovery, service discovery, bonding and etc. This interface
is implemented using D-Bus interface.

In case RFCOMM, it is implemented as sockets in BlueZ and the module
runs as part of kernel.

I am not sure what exactly you want to achieve. The type of changes
depend on your requirements. Either you can change the RFCOMM in
kernel or you can modify the BluetoothSocket.java and
BluetoothServerSocket.java which provides API to write RFCOMM based
application or you can modify android_bluetooth_BluetoothSocket.cpp
file which is native file for RFCOMM connection management.

Cheers,
Ash

Tez

unread,
Oct 20, 2010, 10:05:00 AM10/20/10
to android-platform
Hi Ash,

My aim is the following:

The moment an RFCOMM conn/pairing request is received, I want the
system code to branch to some logic of my own, which may optionally
auto pair and establish a connection, perform some transfer.

I was thinking that BluetoothEventLoop would be a place within the
framework where I can do this?

E

jaikumar Ganesh

unread,
Oct 20, 2010, 1:33:45 PM10/20/10
to android-...@googlegroups.com
Hi Tez:

The auto pairing code is already in BluetoothEventLoop which gets the
pairing callbacks.

So there are 2 parts here:
a) Listening and sending rfcomm data - you can use the public rfcomm APIs.
b) Auto Pairing - There is no public API for this and you will have
into the auto pairing code in BluetoothEventLoop. Also are you looking
into Bluetooth 2.0 pairing or Bluetooth 2.1 pairing ?

Tez

unread,
Oct 21, 2010, 4:39:31 AM10/21/10
to android-platform
Hi,

I do not know which version. But im working with the 2.2 sources of
the OS
And no trouble in modding the source. Whatever it takes to get the job
done :-)

So, BluetoothEventLoop is the correct place in your opinion?

Cheers,
Earlence

On Oct 20, 7:33 pm, jaikumar Ganesh <jaikum...@gmail.com> wrote:
> Hi Tez:
>
> The auto pairing code is already in BluetoothEventLoop which gets the
> pairing callbacks.
>
> So there are 2 parts here:
>    a) Listening and sending rfcomm data - you can use the public rfcomm APIs.
>    b) Auto Pairing - There is no public API for this and you will have
> into the auto pairing code in BluetoothEventLoop. Also are you looking
> into Bluetooth 2.0 pairing or Bluetooth 2.1 pairing ?
>

Arun Kumar SINGH

unread,
Oct 21, 2010, 4:46:39 AM10/21/10
to android-...@googlegroups.com, bluezdis...@zavux009.zav.st.com
Tez,

Yes. this is the file where all signals thrown upwards from bluez host via d-bus are caught in Android. As Jai suggests, you may well place your proprietary logic based on your triggers and make it loopback to Bluez again for your proprietary implementation. You may not need to touch anything above JNI i believe for your specific use-case.

Best Regards,
Arun Kumar Singh

Ash

unread,
Oct 21, 2010, 7:30:12 PM10/21/10
to android-platform
Hey Tez,

Okay, you can write a logic which waits for messages from D-Bus server
and on pairing complete it would initiate a RFCOMM connection/wait for
a connection and performs as needed (this is BlueZ specific).

Or you can use intent message sent from BluetoothEventLoop and on a
bonding complete event and modify/use existing Android Bluetooth
Socket APIs (Which i think is easier and also portable in most of the
cases since there would other proprietary Bluetooth stack running as
well).

--
Ash

On Oct 21, 1:46 pm, Arun Kumar SINGH <arunkr.si...@stericsson.com>
wrote:
Reply all
Reply to author
Forward
0 new messages