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:
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!
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.