Here is another question. I would like to make automatic pairing. Let me explain: i want my application to discover a device offering the service i want, once it finds the correct device i want the application to connect automatically without any user input, thus the phone sends automatically the link key (which is stored in the application)
The link key exchange is at layer HCI (LMP), is there an api to connect to a bluetooth device without having the standard bluetooth prompt. I just want to handle all the connection at application level, i don't want the user to choose for a device and to enter a link key.
You can't simply send the link key to another device. It is calculated by both the local device and the remote device
using various variables including the PIN you enter on
both device during pairing procedure. On successful pairing,
the devices get linkkey and now they are bonded.
You can automate device discovery, service discovery and the
connection establishment. And, you can automate the PIN prompt
on the local (your) device. But, you can't automate it on the
remote device yourself.
If you are interested in reading more about BT security, search
I'm working on it and I'd like to disable the Security Manager. Is it possible?
kmkumar you are right, you can't send the link key, because is the master who fix it, but if the slave knows the PIN the master is waiting for you can send this PIN using HCI. So both devices will be paired.
If you run your application on the server side (listening) device you can determine on the server side whether authentication is needed or not. This applies to both C++ and Java MIDP applications.
PointToPoint example (C++), and BtsppEcho/Btl2capEcho (Java) examples describe how to do it.
If your application is connecting to a device without any specific application, it is up to that device's settings whether the authentication is needed or not. You cannot bypass authentication programmatically. That would in fact be the eldorado for virus developers :-(