Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an Android RFCOMM socket without any input from the user?

Here's the scenario:

I need to write an application for Android to create a RFCOMM socket to a PC with a Bluetooth dongle (I'm going to write the server too).

My requirement is that the user doesn't have to pair device manually.

Actually, with a big hack, I'm using the createInsecureRfcommSocket.

A little scenario: I've an Android application which exchanges information with a Linux box with a RFCOMM socket opened. I can manually set the PIN on the devices (hard coding it IS an option)

I'm looking for different roads:

Write a JNI wrapper

As has been done here by Max Kellermann, I can write a JNI layer to make all the pairing phase. This should be a good option, but there's a problem:

The NDK 4b does not provide libbluetooth libraries, so -lbluetooth fails, as well as the NDK v.3.

Options:

  1. Find the NDK 1.5 (which includes lib bluetooth). After days of web search I've been not able to find out. Anyone has or knows where I can find it?
  2. Compile libbluetooth for Android by myself and use them for -lbluetooth. No lucky there, I'm not able to build them. Any hint?

Use something exposed by the APIs

Any one know how can I use createRfcommSocketToServiceRecord and have the user not to manually pair the device? Is it possible? How should I write the server?

Something I do not know

Maybe (sure!) there is something I do not know. Maybe I can use something else? Not RFCOMM? SDP?

Maybe I can manually pair with the Android API?

I hope to have been clear enough, if not just ask. And again, as it's not the first time, I'm in your hands :)

Thanks for all the support guys!

like image 456
Enrico Carlesso Avatar asked Nov 17 '10 14:11

Enrico Carlesso


1 Answers

At the end, I can say that you can't.

Even if you find a way, using wrappers, writing C modules and so on, android evolution will probably change the thing you're using.

And so, there's no option. Sadly.

Let's see how Android Bluetooth API will change in the future.

like image 127
Enrico Carlesso Avatar answered Sep 20 '22 20:09

Enrico Carlesso