Juergen S.
Juergen S.

Reputation: 17

Bluetooth connection using bluetooth MAC and PIN from code only

I am doing an APP to configure/control battery powered devices using Bluetooth. The devices are not "visible" to save energy.

I have a ready list of about 50 device. The list contains the Bluetooth MAC address and the required PIN to pair.

When the APP starts up, I prompt the user to select a device from the list. So now I want to automatically bind with the device, if not already done yet, without the need for the user to enter the PIN again.

I googled a lot, but did not exactly find what I was looking for (at least what I understood). But I have to admit that I am pretty new to android programming and might simple not get the hint- I also assume I do not use the right terms to search. I found some "hacks" that simply suppress the PIN entry.

Can someone help me out here?

I already had the APP up and running if I manually bind the device, so the SPP communication is not the problem, it's mainly how to provide the PIN for connection.

Thanks a lot.

Upvotes: 0

Views: 933

Answers (1)

user1888162
user1888162

Reputation: 1735

You can create new bond with bluetooth device by calling BluetoothDevice setPin(byte[] pin) and createBond() methods. You need also set BLUETOOTH_ADMIN permission.

public boolean createBond ()

public boolean setPin (byte[] pin)

Upvotes: 0

Related Questions